Skip to content

712 leetcode solved#1

Merged
mstepan merged 2 commits into
masterfrom
NO-REF-7127-solved
May 11, 2026
Merged

712 leetcode solved#1
mstepan merged 2 commits into
masterfrom
NO-REF-7127-solved

Conversation

@mstepan
Copy link
Copy Markdown
Owner

@mstepan mstepan commented May 11, 2026

712 leetcode solved

Summary by CodeRabbit

  • New Features

    • Added solution to LeetCode problem 712 (Minimum ASCII Delete Sum for Two Strings).
  • Tests

    • Added test cases to validate the solution with multiple input scenarios.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c4522a0f-8621-4182-b0df-bf88b604c3d7

📥 Commits

Reviewing files that changed from the base of the PR and between a24f395 and 4d22fc9.

📒 Files selected for processing (1)
  • src/main/java/com/github/mstepan/leetcode/medium/MinimumAsciiDeleteSumForTwoStrings.java
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/com/github/mstepan/leetcode/medium/MinimumAsciiDeleteSumForTwoStrings.java

📝 Walkthrough

Walkthrough

Introduces a new LeetCode 712 solution that uses dynamic programming to compute the minimum ASCII deletion sum from two strings. The implementation validates inputs, builds a DP table with base cases, and fills it using character-match or deletion-cost minimization. Two JUnit tests validate the algorithm against known outputs.

Changes

Minimum ASCII Delete Sum Solution

Layer / File(s) Summary
DP Algorithm Implementation
src/main/java/com/github/mstepan/leetcode/medium/MinimumAsciiDeleteSumForTwoStrings.java
Class declaration and minimumDeleteSum(String s1, String s2) method implementing a bottom-up DP solution: non-null input validation, 2D DP table initialization with cumulative ASCII sums for deletions, table filling via character-match (diagonal) or deletion-cost minimization, and return of the final DP value.
Unit Tests
src/test/java/com/github/mstepan/leetcode/medium/MinimumAsciiDeleteSumForTwoStringsTest.java
JUnit 5 test class with two test cases: case1 verifies minimumDeleteSum("sea", "eat") and case2 verifies minimumDeleteSum("delete", "leet") with expected numeric assertions.

🎯 1 (Trivial) | ⏱️ ~3 minutes

🐰 A DP table, neat and fair,
Two strings find balance with care,
Delete this, delete that,
Till ASCII sums are combat,
LeetCode 712 solved without a hair! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title '712 leetcode solved' is vague and uses generic phrasing that doesn't clearly describe what was implemented, making it difficult for teammates to understand the specific change from the title alone. Use a more descriptive title that specifies the problem or solution, e.g., 'Implement LeetCode 712: Minimum ASCII Delete Sum For Two Strings' or 'Add solution for minimum ASCII delete sum dynamic programming problem'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch NO-REF-7127-solved

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/test/java/com/github/mstepan/leetcode/medium/MinimumAsciiDeleteSumForTwoStringsTest.java (1)

11-19: ⚡ Quick win

Add boundary tests for empty/equal inputs.

Current tests cover canonical examples, but not base-path behavior (empty strings and already-equal strings), which are important for the DP border conditions.

Suggested additional tests
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.junit.jupiter.api.Test;
@@
     `@Test`
     void case2() {
         assertEquals(403, minimumDeleteSum("delete", "leet"));
     }
+
+    `@Test`
+    void emptyStrings() {
+        assertEquals(0, minimumDeleteSum("", ""));
+        assertEquals((int) 'a', minimumDeleteSum("a", ""));
+        assertEquals((int) 'a', minimumDeleteSum("", "a"));
+    }
+
+    `@Test`
+    void alreadyEqualStrings() {
+        assertEquals(0, minimumDeleteSum("abc", "abc"));
+    }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/com/github/mstepan/leetcode/medium/MinimumAsciiDeleteSumForTwoStringsTest.java`
around lines 11 - 19, Add boundary tests to
MinimumAsciiDeleteSumForTwoStringsTest to cover empty and already-equal inputs:
add test methods that assert minimumDeleteSum("", "") == 0,
minimumDeleteSum("abc", "") == sum of ascii of "abc" and minimumDeleteSum("",
"abc") == same sum, and minimumDeleteSum("same","same") == 0 so DP border
conditions are validated; locate tests in the class alongside existing
case1/case2 and use the same assertEquals style with the minimumDeleteSum
function name.
src/main/java/com/github/mstepan/leetcode/medium/MinimumAsciiDeleteSumForTwoStrings.java (1)

13-15: ⚡ Quick win

Fix the DP approach/space complexity wording in Javadoc.

Line 13 describes the method as top-down, but the implementation is bottom-up tabulation (Lines 27–50).
Line 14 also implies O(min(N, K)) space, while current code allocates rows * cols.

Suggested doc-only patch
-    /**
-     * Solved using top-down dynamic programming approach.
-     * time: O(N*K), space: O(N*K) ~ O(min(N, K))
+    /**
+     * Solved using bottom-up dynamic programming (tabulation).
+     * time: O(N*K), space: O(N*K)
+     * (Space can be optimized to O(min(N, K)) with a rolling 1D DP array.)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/github/mstepan/leetcode/medium/MinimumAsciiDeleteSumForTwoStrings.java`
around lines 13 - 15, The Javadoc is incorrect: the implementation in
MinimumAsciiDeleteSumForTwoStrings uses a bottom-up tabulation (not top-down) as
implemented in the DP loop around lines 27–50, and the space complexity is not
O(min(N,K)) because the code allocates a full rows x cols table. Update the
Javadoc to say "bottom-up tabulation" (or "iterative DP/tabulation") and set
time complexity to O(N*K) and space complexity to O(N*K) (or mention O(min(N,K))
only if you also change the implementation to use a rolling 1D array
optimization); keep the method/class name MinimumAsciiDeleteSumForTwoStrings as
the reference when updating the comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@src/main/java/com/github/mstepan/leetcode/medium/MinimumAsciiDeleteSumForTwoStrings.java`:
- Around line 13-15: The Javadoc is incorrect: the implementation in
MinimumAsciiDeleteSumForTwoStrings uses a bottom-up tabulation (not top-down) as
implemented in the DP loop around lines 27–50, and the space complexity is not
O(min(N,K)) because the code allocates a full rows x cols table. Update the
Javadoc to say "bottom-up tabulation" (or "iterative DP/tabulation") and set
time complexity to O(N*K) and space complexity to O(N*K) (or mention O(min(N,K))
only if you also change the implementation to use a rolling 1D array
optimization); keep the method/class name MinimumAsciiDeleteSumForTwoStrings as
the reference when updating the comment.

In
`@src/test/java/com/github/mstepan/leetcode/medium/MinimumAsciiDeleteSumForTwoStringsTest.java`:
- Around line 11-19: Add boundary tests to
MinimumAsciiDeleteSumForTwoStringsTest to cover empty and already-equal inputs:
add test methods that assert minimumDeleteSum("", "") == 0,
minimumDeleteSum("abc", "") == sum of ascii of "abc" and minimumDeleteSum("",
"abc") == same sum, and minimumDeleteSum("same","same") == 0 so DP border
conditions are validated; locate tests in the class alongside existing
case1/case2 and use the same assertEquals style with the minimumDeleteSum
function name.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7dfdabc5-b438-480e-91fa-ea6c6d42d9ac

📥 Commits

Reviewing files that changed from the base of the PR and between 3375292 and a24f395.

📒 Files selected for processing (2)
  • src/main/java/com/github/mstepan/leetcode/medium/MinimumAsciiDeleteSumForTwoStrings.java
  • src/test/java/com/github/mstepan/leetcode/medium/MinimumAsciiDeleteSumForTwoStringsTest.java

@mstepan mstepan merged commit ece606d into master May 11, 2026
2 checks passed
@mstepan mstepan deleted the NO-REF-7127-solved branch May 11, 2026 09:47
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.

1 participant