Time complexity: O(n)
Space complexity: O(1)
Runtime 1 ms Beats 99.90% of users with Java Memory 45.92 MB Beats 51.99% of users with Java