working solution#1539
Conversation
Least Falling Path Sum (problem1.py)It seems there was a misunderstanding: you solved the wrong problem. The problem you were given is "Least Falling Path Sum", but your code is for "Delete and Earn". Please make sure to read the problem statement carefully and verify that your solution matches the problem. For the "Least Falling Path Sum" problem, you need to work with a matrix and find a falling path with minimum sum. A common approach is to use dynamic programming where you start from the bottom row and work upwards, or from the top row downwards with memoization. Here's a hint:
Example of a correct solution for "Least Falling Path Sum" in Python: class Solution:
def minFallingPathSum(self, matrix: List[List[int]]) -> int:
n = len(matrix)
for i in range(1, n):
for j in range(n):
min_val = matrix[i-1][j]
if j > 0:
min_val = min(min_val, matrix[i-1][j-1])
if j < n-1:
min_val = min(min_val, matrix[i-1][j+1])
matrix[i][j] += min_val
return min(matrix[-1])This solution has O(n^2) time complexity and O(1) space if modified in place (or O(n^2) if not). VERDICT: NEEDS_IMPROVEMENT Delete and Earn (problem2.py)It seems there has been a mix-up in the code submission. The code you provided is for "Minimum Falling Path Sum", but the problem you need to solve is "Delete and Earn". Please ensure you are working on the correct problem and submit the appropriate solution. For the "Delete and Earn" problem, you need to consider the following approach:
Please implement the correct solution for "Delete and Earn". If you need help, refer to the reference solution provided. VERDICT: NEEDS_IMPROVEMENT |
No description provided.