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