Question on Hackerearth- Remove Friends
My solution- http://ideone.com/VzT4Gy
Please help me to improve my algorithm. I’m getting TLE at the time of final submission for all the test cases.
Question on Hackerearth- Remove Friends
My solution- http://ideone.com/VzT4Gy
Please help me to improve my algorithm. I’m getting TLE at the time of final submission for all the test cases.
Bro … your arrange function makes the time complexity worse . you’re iterating over n for every arrange function call . Instead , just use vector.erase function for this purpose …