Skip to content

Solved Problem 1 - Delete and earn and Problem 2 - Minimum falling path sum#1540

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

Solved Problem 1 - Delete and earn and Problem 2 - Minimum falling path sum#1540
anirudhv98 wants to merge 1 commit into
super30admin:masterfrom
anirudhv98:master

Conversation

@anirudhv98

Copy link
Copy Markdown

Completed DP - 3, please review.

@super30admin

Copy link
Copy Markdown
Owner

Least Falling Path Sum (Problem1.cs)

**
The code itself is excellent for "Delete and Earn" - well-commented, efficient, and follows best practices. However, you've submitted the wrong solution entirely. This appears to be a copy-paste error or confusion about which problem you're solving. The "Least Falling Path Sum" problem requires:

  • A 2D matrix input
  • Dynamic programming from top to bottom
  • Considering three possible moves (down, down-left, down-right)

**

VERDICT: NEEDS_IMPROVEMENT


Delete and Earn (Problem2.cs)

Strengths:

  • The solution is well-written and follows good coding practices
  • Space complexity is excellent (O(1)) - modifying input matrix in-place
  • Clear handling of boundary conditions (first and last columns)
  • The final minimum finding logic is correct

Areas for Improvement:

  • Critical Issue: This solution solves the wrong problem. The assignment was "Delete and Earn" but the submitted code solves "Minimum Falling Path Sum"
  • For the Delete and Earn problem, you would need to:
    1. Count frequencies of each number
    2. Apply a House Robber DP pattern where taking number i means you cannot take i-1 or i+1
    3. The DP recurrence would be: dp[i] = max(dp[i-1], count[i]*i + dp[i-2])

Recommendation: Please ensure you read the problem statement carefully and implement the correct algorithm. The Delete and Earn problem requires understanding the relationship between adjacent numbers and using a transformed array where each index represents the total points from that number.

VERDICT: NEEDS_IMPROVEMENT

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