https://ide.codingblocks.com/s/71373
I am getting TLE in my second test case if you can give me some hint
https://ide.codingblocks.com/s/71373
I am getting TLE in my second test case if you can give me some hint
here for updation, you traverse through complete list.
SO your complexity is O(qn)
You need to solve it in O(q log(n))
Hint - use MaxPriority Queue of Size K
Thank you… Got the answer