Skip to content

1problem completed#1523

Open
BharathVuppala96 wants to merge 1 commit into
super30admin:masterfrom
BharathVuppala96:master
Open

1problem completed#1523
BharathVuppala96 wants to merge 1 commit into
super30admin:masterfrom
BharathVuppala96:master

Conversation

@BharathVuppala96

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

It seems there has been a misunderstanding. The problem you were asked to solve is "Least Falling Path Sum", which involves a matrix and finding a falling path with the minimum sum. However, your solution is for "Delete and Earn", which is a different problem entirely.

For the "Least Falling Path Sum" problem, you need to work with a 2D matrix and consider paths from the top row to the bottom row, moving only to adjacent columns in the next row.

A common approach to solve "Least Falling Path Sum" is to use dynamic programming. You can modify the matrix in place or use a separate DP array to store the minimum falling path sum up to each cell. For each cell in the next row, you can compute the minimum path sum by considering the three possible cells above it (from the previous row) that can lead to it.

Here is a suggested approach in Python:

  1. If the matrix is empty, return 0.
  2. For each row starting from the second row (index 1), update each cell by adding the minimum value from the three adjacent cells in the row above (if they exist).
  3. After processing all rows, the answer will be the minimum value in the last row.

Alternatively, you can use a recursive approach with memoization to avoid recalculating the same subproblems.

Please review the problem statement again and implement the solution for the correct problem. Your current solution, while correct for "Delete and Earn", does not address the requirements of the falling path problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants