My questions is specific to the problem posed here: Interview puzzle: Jump Game
The top answer claims that it runs in O(n)
time. It says that it can do this
because each element need be considered only once (elements that would be considered a second time can be skipped)
However, just checking if we have already considered an element takes a constant time per element, so it ought to take O(n^2)
, right? O(n)
to consider each new element, and O(n)
to exclude elements we've already considered. Why is this not the case?