used max heap , still getting TLE, PLZ HELP
Getting TLE,, PLZ HELP
hi @Akshay123
for geting kth nearest element you are poping k element and then pushing k-1 elements
this thing you have done n times
and also you need only k elements so why to store or maintain n elements not only k elemnts?
so worst case time complexity of your code will be O(n^2)
this will give TLE
in this question you have to use multiset
reference code: if needed
Thanks man, really helpful!!
1 Like