3 ms·
OP meant O(1) in time and space (forgot the space but it’s in the linked article). That solution is O(N) in space.
by d--b 5y ago
OP meant O(1) in time and space (forgot the space but it’s in the linked article). That solution is O(N) in space.