Python Solution: Time Complexity: O(NlogN) Space Complexity: O(N)
Python Solution: Time Complexity: O(n) Space Complexity: O(n)