https://www.hackerrank.com/contests/101sep14/challenges/jim-and-the-skyscrapers
Firstly I know the solution that is mentioned in the editorial. I thought whether this problem can be solved without using any such data structure or can i used simple set and finally i clicked to a solution.
Solution is very simple i can sort these element using vector pair and then i can use a set to find out the element which is greater than me using upper_bound and bigger than me but this solution giving this verdict TLE for some files. what is the reason for this. I think my solution's complexity is O(nlog(n)). Can anyone help me in verifying the complexity of my solution. Thanx in advance.
here is my code link here .
Please do have a look.
I haven't looked at your code, but maybe all solutions are intended to fail. There is cool O(n) solution
no author has O(nlog(n)) solution and most importantly i check that file on which my code is producing TLE that file contain only 50,000 numbers.
Try changing line 111 to:
std::set has it's own lower_bound and upper_bound implementations
aww i forget that post shit happens.
@rasinhas Yes you are right .It was the reason for TLE.
Btw, there is an easy stack-based linear solution.
Thanx Winger i understood this solution.