/* Description: Given an vector v containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the vector. Approach: Using for loop from 0 to n and searching if the value is present in the vector or not using find() function. If a certain value is not present, the function will return it. */ #include #include #include using namespace std; //function starts int missingNumber(vector &v){ int num; for(int i=0;i<=v.size();i++){ //checking if i is present or not in the vector //if not present,it will store the value of i in the num variable and breaking it if(find(v.begin(),v.end(),i)==v.end()){ num=i; break; } } return num; } //main starts int main() { cout << "Enter number of elements:\n"; int n; cin>>n; vector v(n); cout<<"Enter any "<>v[i]; } cout<<"\nMissing number is: "<