1 min readJun 28, 2020
Hi!
That's a good solution if you do not consider the space complexity constraints on this problem(mentioned in condition #2). Notice that this problem requires a constant space complexity O(1) meaning space required by the algorithm does not grow with the size of the data on which the algorithm is operating.