Time complexity: O(n^2)
Space complexity: O(1)
Runtime 13 ms Beats 85.93% of users with Java Memory 42.73 MB Beats 86.36% of users with Java