Need help to find the Time Complexity

Revision en1, by Yath, 2022-11-19 21:21:23

For this problem : I submitted this solution: . This solution is giving TLE i.e. why I want to know the time complexity(with explanation).
My logic was to store all the K pairs in a map<int , vector> such that the first element of each pair acts as key , its value being a vector of all the values the key is making a pair with. Now I iterate from 1 till N(stack) and for each stack , I iterate through the keys which are less than or equal to the position of that stack . For each key , I binary search to find out In how many pairs my current stack is falling into. Finally I sort the array and the find the median.


  Rev. Lang. By When Δ Comment
en1 English Yath 2022-11-19 21:21:23 737 Initial revision (published)