Implementation needed with time complexity O(n log n)
Implementation needed with time complexity O(n log n)