python | prefix sum _ heap |
\nclass Solution:\n    def kthLargestValue(self, matrix: List[List[int]], k: int) -> int:\n        temp=0\n        pq= []\n        n = len(matrix)\n        m = 
```\nclass Solution:\n    def kthLargestValue(self, matrix: List[List[int]], k: int) -> int:\n        temp=0\n        pq= []\n        n = len(matrix)\n        m = len(matrix[0])\n        \n        prefix= [  [0]*m for i in range(n) ]\n        \n        \n        for i in range(n):\n            for j in range(m):\n                if i==0 or j==0:\n                    if i==0 and j==0:\n                        prefix[i][j] = matrix[i][j]\n                    elif i==0 and j!=0:\n                        prefix[i][j] ^= prefix[i][j-1]^ matrix[i][j]\n                    else:\n                        prefix[i][j]^=prefix[i-1][j]^ matrix[i][j]\n                else:\n                    \n                    prefix[i][j] ^= prefix[i-1][j] ^ prefix[i][j-1]^matrix[i][j]^prefix[i-1][j-1]\n                if len(pq)<k:\n                    heappush(pq,prefix[i][j])    \n                else:\n                    heappush(pq, prefix[i][j])\n                    heappop(pq)\n                \n\n                  \n        return heappop(pq)\n                    \n```
['Python', 'Python3']