Time complexity: O(n)
Space complexity: O(1)
Runtime 0 ms Beats 100.00% of users with Java Memory 45.25 MB Beats 34.48% of users with Java