---
# System prepended metadata

title: Competitive Programming Tools

---

# Competitive Programming Tools

1. ## Vector   
###        Vectors are the same as the dynamic arrays but it is speacial type of arrays because `it has the ability to resize it self automatically when an element is inserted or deleted.`


## :+1: **Example**: 
#### `A simple way to insert data and output data in vector.`
```python=1
 vector<int> v; // vector initializing;
  // vector<data_type>data_name;

  for (int i = 0; i < 10; i++)
    v.push_back(i); // push_back(input);
  for (int i = 0; i < 10; i++)
    cout << v[i] << " "; // showing output;

```

:::success
### **Output:** `0 1 2 3 4 5 6 7 8 9`
:::


## :+1: **Example**: 
#### `We can insert data and show output in this way also.`
```python=1
vector<int> v(10); // vector initializing;
  // vector<data_type>data_name(size);
  for (auto &i : v)
  {
    cin >> i; // it will take input from the input field in the vector what we declared in the loop//
  }
  for (auto i : v)
  {
    cout << i << " "; // it will show the output from begin() to end() of the vector what we declared in the loop//
  }

```
:::success
### **Input:** `0 1 2 3 4 5 6 7 8 9`
### **Output:** `0 1 2 3 4 5 6 7 8 9`
:::
## **`Some important functions of vector`**
:::warning
1. font();-> Returns a reference to the first element in the vector
2. back();-> Returns a reference to the last element in the vector
3. rbegin();->  Returns a reverse iterator pointing to the last element in the vector (reverse beginning). It moves from last to first element
4. rend();-> Returns a reverse iterator pointing to the theoretical element preceding the first element in the vector (considered as reverse end)
5. empty();-> Returns whether the container is empty.
6. erase();->  It is used to remove elements from a container from the specified position or range.
7. clear();-> It is used to remove all the elements of the vector container
:::

