Hackerearth- Remove Friends

Question on Hackerearth- Remove Friends

My solution- VzT4Gy - Online C++ Compiler & Debugging Tool - Ideone.com

Please help me to improve my algorithm. I’m getting TLE at the time of final submission for all the test cases.

1 Like

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 …

1 Like