Pref-test 1 2 3 4 5 are failing

Already tried every test case in milestones, But still, my pref-test 1,2,3,4,5 are failing, Can someone give me any hint what I am missing

check whether your code is optimized or not.

i use 2 pointer concept to solve so their is no TLE.
But the Answer is Wrong

Hey @tanujsharma1412 Your approach is flawless and your code is beautiful. However, the issue is with compareInterval and compareInterval_2 comparator functions.

This is because we know that, any comparison based sorting algorithm must make at least nLog2n comparisons to sort the input array, and you are converting your string for every comparison which is why your program is failing for larger input cases.

Suggestion : You can call default sort(broken.begin(), broken.end()) without comparator in your code and the results would be same.

If still confused feel free to reopen the post and discuss

1 Like

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.