New answers tagged

3 votes

Creating an O(n) algorithm for an array of integers

This can be solved in O(n) by maintaining a monotonic stack of heights of previous buildings. For each new building, remove all elements from the stack with height not greater than the current element....
Unmitigated's user avatar
2 votes

Creating an O(n) algorithm for an array of integers

My approach, n log n: ...
RippedGeek's user avatar
5 votes

Creating an O(n) algorithm for an array of integers

lint def valid_jumps(N: ... Pep-8 asks that you spell the parameter name in this way: n The problem statement suggested ...
J_H's user avatar
  • 25.4k
4 votes

Creating an O(n) algorithm for an array of integers

The code layout is good. It is clear from the code that the function accepts a list of integers and returns a list of integers. However, you should add a docstring describing more details about the ...
toolic's user avatar
  • 3,253

Top 50 recent answers are included