Time complexity: O(n)
Space complexity: O(1)
Runtime 0 ms Beats 100.00% Memory 41.26 MB Beats 28.88%
Space complexity: O(n)