[Pyhon 🐍] Sorted List - Binary Search -  O (N log N)
\nfrom sortedcontainers import SortedList\n\nclass Solution:\n    def resultArray(self, nums: List[int]) -> List[int]:\n        \n        arr1 = SortedList([num
```\nfrom sortedcontainers import SortedList\n\nclass Solution:\n    def resultArray(self, nums: List[int]) -> List[int]:\n        \n        arr1 = SortedList([nums[0]])\n        \n        arr2 = SortedList([nums[1]])\n        \n        a1 = [nums[0]]\n        a2 = [nums[1]]\n        \n        \n        N = len(nums)\n        for i in range(2,N):\n            \n            cur = nums[i]\n            \n            c1 = len(arr1)- bisect.bisect(arr1,cur)\n            c2 = len(arr2)- bisect.bisect(arr2,cur)\n\n            if c1 > c2:\n                arr1.add(cur)\n                a1.append(cur)\n            elif c2 > c1:\n                arr2.add(cur)\n                a2.append(cur)\n            elif len(arr1) < len(arr2):\n                arr1.add(cur)\n                a1.append(cur)\n            elif len(arr2) < len(arr1):\n                arr2.add(cur)\n                a2.append(cur)\n            else:\n                arr1.add(cur)\n                a1.append(cur)\n        \n\n        return a1+a2\n```
['Binary Tree', 'Python3']