You are viewing a single comment's thread. Return to all comments →
While elegant, the worst case complexity is still O(N^2).
e.g.
n = 1e5-1 h[i] = 1, i = range(n)
will make your program timeout.
And in the case you would check for that special case, I would use:
h[0] = h[n-1] = rand()
Seems like cookies are disabled on this browser, please enable them to open this website
Largest Rectangle
You are viewing a single comment's thread. Return to all comments →
While elegant, the worst case complexity is still O(N^2).
e.g.
will make your program timeout.
And in the case you would check for that special case, I would use: