Please tell me the approach to resolve my TLE.
TLE in one case
start the question with a greedy approach, keep positions of all the elements stored and then try to swap the biggest element with the element at first position , now update their posiitons , again try to swap the secoond biggest element to the second place
1 Like
is there any other approach other than selection sort(that works in worst case nlogn when k = n and array already sorted)