Hi, I wanted to solve this question in O(N) but couldn't think of it. I did it in O(N logN ) using priority queue but can somebody provide me O(N) solution.
https://postimg.org/image/c31iexg13/
The link of question is not opening now, so I have shared the pic of question.
no comments
I guess it can be solved in O(N) as some of my friends did it in O(N).
Not possible. Ur friends do not know how to estimate the TC. And I seriously doubt this can be solved using a PQ. Can u post a link to your solution?