Time complexity: O(n log(n))
Space complexity: O(n)
Runtime 12 ms Beats 13.08% Memory 46.48 MB Beats 46.09%