[Python] DP and Quick Select - Why TLE?
43 / 49 test cases passed. Not sure what caused the TLE. Any help is welcomed.\n\nPython\nclass Solution:\n    def kthLargestValue(self, matrix: List[List[int]]
43 / 49 test cases passed. Not sure what caused the TLE. Any help is welcomed.\n\n```Python\nclass Solution:\n    def kthLargestValue(self, matrix: List[List[int]], k: int) -> int:\n        rows = len(matrix)\n        cols = len(matrix[0])\n        xor = [[0] * (cols + 1) for _ in range(rows + 1)]\n        values = []\n        for row in range(1, rows + 1):\n            for col in range(1, cols + 1):\n                xor[row][col] = xor[row][col - 1] ^ xor[row - 1][col] ^ xor[row - 1][col - 1] ^ matrix[row - 1][col - 1]\n                values.append(xor[row][col])\n                \n        # find the kth largest value from values\n        \n        def partition(arr, left, right):\n            pivot = arr[right]\n            for i in range(left, right):\n                if arr[i] < pivot:\n                    arr[left], arr[i] = arr[i], arr[left]\n                    left += 1\n            arr[left], arr[right] = arr[right], arr[left]\n            return left\n        \n        left = 0\n        right = len(values) - 1\n        k = len(values) - k\n        while True:\n            mid = partition(values, left, right)\n            if mid == k:\n                return values[mid]\n            if mid < k:\n                left = mid + 1\n            else:\n                right = mid - 1\n```\n
[]