We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My solution is a bit different compared to one in editorial. I don't use tree. Simply sorted array. So the first part is O(N*logN). The second part - finding the min is O(N) - straightforward finding minimum with two iterators. In editorial we have O(N*logC), where C = max(Ai). But, according to my view, it is not correct, since in editorial sorting done first as well! Check this out:
sort(a,a+n);
So it shall be O(N*logN) as well!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Yet Another Minimax Problem
You are viewing a single comment's thread. Return to all comments →
My solution is a bit different compared to one in editorial. I don't use tree. Simply sorted array. So the first part is O(N*logN). The second part - finding the min is O(N) - straightforward finding minimum with two iterators. In editorial we have O(N*logC), where C = max(Ai). But, according to my view, it is not correct, since in editorial sorting done first as well! Check this out:
So it shall be O(N*logN) as well!