in my code i am getting an error please tell me which concept is wrong here.
Sorting game problem
@Eshika
There are several mistake in your code
- See compare function, line 17 should be return it2.second<it1.second; and line 19 should be else return it1.first<it2.first; (you have to sort in lexographical order)
- Don’t creating your vector b of size n. It contain less number of values since for few c<val. Instead push_back when c>=val.
- use compare function while sorting . Write sort(b.begin(), b.end(),compare);
- while printing final output array. Iterate till i<b.size() not n.
- Change line 45 to cout<<b[i].first<<" ";
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.