SOLVED IT JUST AFTER THE CONTEST 😭😭
Code\npython3 []\nclass Solution:\n    def maxRemoval(self, nums: List[int], queries: List[List[int]]) -> int:\n        ans = 0\n        q = sorted(queries)\n  
# Code\n```python3 []\nclass Solution:\n    def maxRemoval(self, nums: List[int], queries: List[List[int]]) -> int:\n        ans = 0\n        q = sorted(queries)\n        e = defaultdict(int)\n        curr = 0\n        for i, num in enumerate(nums):\n            if num<=curr:\n                curr -= e[i]\n                continue\n            p = []\n            for j, pq in enumerate(q):\n                if pq[0]>i:\n                    break\n                if pq[1]>=i:\n                    p.append((pq[1],j))\n            p.sort(key = lambda x:-x[0])\n            index = set()\n            while p and q and num > curr:\n                ind = p.pop(0)[1]\n                x,y = q[ind]\n                index.add(ind)\n                if x>i:\n                    break\n                if y<i:\n                    continue\n                ans += 1\n                curr += 1\n                e[y] += 1\n            q = [q[i] for i in range(len(q)) if i not in index]\n            if num>curr:\n                return -1\n            curr -= e[i]\n        return len(queries)-ans\n        \n```
['Hash Table', 'Sorting', 'Python3']