Time: O(longN), Space: O(1)