Time complexity: O(n)
Space complexity: O(1)
Runtime 2 ms Beats 90.27% of users with Java Memory 55.17 MB Beats 70.63% of users with Java