Time complexity: O(n)
Space complexity: O(1)
Runtime 2 ms Beats 84.74% of users with Java Memory 45.76 MB Beats 77.56% of users with Java