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