[Python 3] Sweep Line - Simple
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n1. 1-D sweep line\n```\nclass Solution:\n    def rangeAddQueries(self, n: int, queries: List[List[int]]) -> List[List[int]]:\n        ans = [[0] * n for _ in range(n)]\n        for r1, c1, r2, c2 in queries:\n            for r in range(r1, r2 + 1):\n                ans[r][c1] += 1\n                if c2 + 1 < n: ans[r][c2 + 1] -= 1\n        for r in range(n):\n            for c in range(1, n):\n                ans[r][c] += ans[r][c - 1]\n        return ans\n```\n- TC: $$O(N^2 + NQ)$$\n- SC: $$O(1)$$ if not including space for answer\n\n2. 2-D Sweep line\n```\nclass Solution:\n    def rangeAddQueries(self, n: int, queries: List[List[int]]) -> List[List[int]]:\n    ans = [[0] * n for _ in range(n)]\n    for r1, c1, r2, c2 in queries:\n        ans[r1][c1] += 1\n        if r2 + 1 < n: ans[r2 + 1][c1] -= 1\n        if c2 + 1 < n: ans[r1][c2 + 1] -= 1\n        if r2 + 1 < n and c2 + 1 < n: ans[r2 + 1][c2 + 1] += 1\n    for r in range(1, n):\n        for c in range(n):\n            ans[r][c] += ans[r - 1][c]\n    for r in range(n):\n        for c in range(1, n):\n            ans[r][c] += ans[r][c - 1]\n    return ans\n```\n- TC: $$O(N^2 + Q)$$\n- SC: $$O(1)$$ if not including space for answer
['Line Sweep', 'Matrix', 'Python3']