IMHO the Editorial Solution is running in `O(N^2)`. Do you agree?


#1

The editorial solution has a while inside the for that could iterate over the whole array if numbers were ordered ascendently. To me, that makes it an O(N^2) solution.


#2

No. In that loop, every node is visited at most twice: once by the outer loop as it traverses through A, and once in the inner loop because it will only traverse that inner loop for nodes that start a sequence.