What is the problem with this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the problem with this code?

vector<int> permutationEquation(vector<int> p) { vector<int> s; for(int i=0;i<p.size();i++) { vector<int>::iterator it = find(p.begin(),p.end(),i); int z = p.at(it); s[i]= find(p.begin(),p.end(),z); } return s; } error : "no instance of overloaded function \"std::vector<_Ty, _Alloc>::at [with _Ty=int, _Alloc=std::allocator<int>]\" matches the argument list -- argument types are: (std::_Vector_iterator<std::_Vector_val<std::conditional_t<true, std::_Simple_types<int>, std::_Vec_iter_types<int, size_t, ptrdiff_t, int *, const int *, int &, const int &>>>>) -- object type is: std::vector<int, std::allocator<int>>", "startLineNumber": 15, error 2 : "no suitable conversion function from \"std::_Vector_iterator<std::_Vector_val<std::conditional_t<true, std::_Simple_types<int>, std::_Vec_iter_types<int, size_t, ptrdiff_t, int *, const int *, int &, const int &>>>>\" to \"int\" exists", "startLineNumber": 16, "startColumn": 10, "endLineNumber": 16, "endColumn": 14 } "startColumn": 15, "endLineNumber": 15, "endColumn": 17 }

7th Jun 2020, 3:42 PM
Abhishek Dimri
Abhishek Dimri - avatar
0 Answers