Priority que and line sweep
Intuition\n Describe your first thoughts on how to solve this problem. \nGredily use the longest range to meet the nums[i] requirement.\n\n# Approach\n Describe
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nGredily use the longest range to meet the nums[i] requirement.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe trick how u want to create a priority heap that takes into account when you are moving through length of nums. E.G if you are at i == 2 you h have two available queries [1,3] and [2,3] both has the applicable length of 2. This can be obtained by the end value which has the value of 3. It doenst matter the length is not 2 you just want to use the same base.\n\n\n# Complexity\n- Time complexity: nlog(n) time, limited by the priority heap \n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n), linear space\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```python3 []\nclass Solution:\n    def maxRemoval(self, nums: List[int], queries: List[List[int]]) -> int:\n\n\n        lit = []\n        queries.sort()\n        heapq.heapify(lit)\n\n        sweeper = [0]*(len(nums)+1)\n        cur = 0\n        idx = 0\n        ans = 0\n\n\n        for i in range(len(nums)):\n            cur += sweeper[i]\n            while  idx<len(queries) and queries[idx][0] <=i:\n                start, end = queries[idx]\n                idx +=1\n                dif = end + 1\n                heapq.heappush(lit, [-dif, start, end])\n            \n            while len(lit) > 0 and cur<nums[i]:\n                diff, start, end  = heapq.heappop(lit)\n                if i>=start and i<=end:\n                    ans+=1\n                    cur+=1\n                    sweeper[end+1] -=1\n            if cur<nums[i]:\n                return -1\n        return len(queries) - ans\n\n                \n\n\n\n\n                \n\n\n\n\n        \n```
['Python3']