Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
abcbdc8
Add IntelliJ IDEA run configurations to gitignore and JUnit launcher …
yamcodes Feb 10, 2026
5d18af7
Merge branch 'main' into 18-improve-minimum-deletions-space-complexit…
yamcodes Feb 10, 2026
1fe4740
Add solution progression to package-info and stub O(1) DP solution
yamcodes Feb 12, 2026
0ef02a2
Refactor solution links to use code tags for clarity
yamcodes Feb 12, 2026
87750a9
Update solution progression to reflect new implementations
yamcodes Feb 12, 2026
d6a3ef0
Refactor solution progression documentation and add naive and prefix/…
yamcodes Feb 12, 2026
e00ba3d
Refactor: Rename solution classes and update references
yamcodes Feb 13, 2026
c874624
Refactor solution file naming and test structure
yamcodes Feb 13, 2026
0ebe23f
Refactor Test run configuration encoding
yamcodes Feb 13, 2026
bebf22e
Rename test run configuration to "Test All"
yamcodes Feb 13, 2026
808d20e
Implement space-optimized DP solution for minimum deletions
yamcodes Feb 14, 2026
dccc212
Refactor minimumDeletions to simplify logic and improve clarity
yamcodes Feb 14, 2026
3022aaf
Refactor variable initialization for clarity
yamcodes Feb 14, 2026
357059e
Disable unused test classes and reorder variables in Solution.java
yamcodes Feb 14, 2026
4d737f4
Add TODO to refactor Solution with cleaner DP formulation
yamcodes Feb 14, 2026
ae5de78
Update TODO comment for DP implementation in minimum deletions
yamcodes Feb 14, 2026
9916c30
Add climbing stairs solution and test cases
yamcodes Feb 14, 2026
d825814
Merge branch 'main' into climbing-stairs
yamcodes Feb 14, 2026
6a031ed
Clarify `@ValueSource` and `@MethodSource` usage in README.md
yamcodes Feb 14, 2026
7d0add9
Disable climbing stairs tests until implementation is complete
yamcodes Feb 14, 2026
9ff2fde
Implement recursive solution for climbing stairs problem
yamcodes Feb 14, 2026
d910277
Implement memoized solution for climbing stairs problem
yamcodes Feb 14, 2026
bfb216e
Add base cases for n=1 and n=2 to memoized solution
yamcodes Feb 14, 2026
9fc6b12
Initialize memoization array as a class member
yamcodes Feb 14, 2026
ab1871c
Implement dynamic programming solution for climbing stairs
yamcodes Feb 14, 2026
5de63dd
Make Solution class public and adjust loop start index
yamcodes Feb 14, 2026
2a6cb8a
Add Climbing Stairs to README
yamcodes Feb 14, 2026
f747d7e
Refactor Solution to O(1) space complexity
yamcodes Feb 14, 2026
de7a949
Add base classes and tests for Min Cost Climbing Stairs solutions
yamcodes Feb 14, 2026
d6ae1e4
Update README with solution file paths and LC links
yamcodes Feb 14, 2026
05324ca
Improve README formatting and enhance LeetCode/solution links
yamcodes Feb 14, 2026
03745f7
Merge branch 'main' into min-cost-climbing-stairs
yamcodes Feb 14, 2026
77a76a3
Implement dynamic programming solutions for Min Cost Climbing Stairs …
yamcodes Feb 14, 2026
78bda2f
Refactor Min Cost Climbing Stairs solution to reduce space complexity…
yamcodes Feb 14, 2026
4670a15
Add Min Cost Climbing Stairs to README with solution details and LC link
yamcodes Feb 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,25 @@ My LeetCode solutions in Java, focused on clean code and optimal algorithms.

## Solutions

| # | Problem | Difficulty | Time | Space |
|------|-----------------------------------------------------------------------------------------------------------------------|------------|-------------------|--------|
| 1 | [Two Sum](https://leetcode.com/problems/two-sum/) | Easy | `O(n log n)` | `O(n)` |
| 9 | [Palindrome Number](https://leetcode.com/problems/palindrome-number/) | Easy | `O(log10(n) / 2)` | `O(1)` |
| 70 | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs/) | Easy | `O(n)` | `O(1)` |
| 1653 | [Minimum Deletions to Make String Balanced](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced/) | Medium | `O(n)` | `O(1)` |
| #* | Problem | Difficulty | Time | Space |
|-----------------|----------------------------------------------------------------------------------------------------------------------------------|------------|-------------------|--------|
| [1][lc-1] | [Two Sum](src/main/java/codes/yam/leetcode/twosum/Solution.java) | Easy | `O(n log n)` | `O(n)` |
| [9][lc-9] | [Palindrome Number](src/main/java/codes/yam/leetcode/palindromenumber/Solution.java) | Easy | `O(log10(n) / 2)` | `O(1)` |
| [70][lc-70] | [Climbing Stairs](src/main/java/codes/yam/leetcode/climbingstairs/Solution.java) | Easy | `O(n)` | `O(1)` |
| [746][lc-746] | [Min Cost Climbing Stairs](src/main/java/codes/yam/leetcode/mincostclimbingstairs/Solution.java) | Easy | `O(n)` | `O(1)` |
| [1653][lc-1653] | [Minimum Deletions to Make String Balanced](src/main/java/codes/yam/leetcode/minimumdeletionstomakestringbalanced/Solution.java) | Medium | `O(n)` | `O(1)` |

<sup>*Problem numbers link to LeetCode; problem names link to solution source.</sup>

[lc-1]: https://leetcode.com/problems/two-sum/

[lc-9]: https://leetcode.com/problems/palindrome-number/

[lc-70]: https://leetcode.com/problems/climbing-stairs/

[lc-746]: https://leetcode.com/problems/min-cost-climbing-stairs/

[lc-1653]: https://leetcode.com/problems/minimum-deletions-to-make-string-balanced/

## Project Structure

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package codes.yam.leetcode.mincostclimbingstairs;

/**
* Solution for the <b>Min Cost Climbing Stairs</b> problem.
*
* <p>Optimizes {@code SolutionDp} by replacing the DP array with two rolling variables.
*
* <ul>
* <li><b>Time Complexity:</b> <code>O(n)</code>
* <li><b>Space Complexity:</b> <code>O(1)</code>
* </ul>
*/
class Solution {
int minCostClimbingStairs(int[] cost) {
int a = 0;
int b = 0;
for (int i = 2; i <= cost.length; i++) {
int c = Math.min(a + cost[i - 2], b + cost[i - 1]);
a = b;
b = c;
}
return b;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package codes.yam.leetcode.mincostclimbingstairs;

/**
* Solution for the <b>Min Cost Climbing Stairs</b> problem.
*
* <ul>
* <li><b>Time Complexity:</b> <code>O(n)</code>
* <li><b>Space Complexity:</b> <code>O(n)</code>
* </ul>
*/
class SolutionDp {
int minCostClimbingStairs(int[] cost) {
int n = cost.length;
int[] dp = new int[n + 1];
dp[0] = 0;
dp[1] = 0;
for (int i = 2; i <= n; i++) {
dp[i] = Math.min(dp[i - 2] + cost[i - 2], dp[i - 1] + cost[i - 1]);
}
return dp[n];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Solutions for the "Min Cost Climbing Stairs" problem on LeetCode.
*
* <ul>
* <li><b>Slug:</b> <code>min-cost-climbing-stairs</code>
* <li><b>Difficulty:</b> Easy
* </ul>
*
* <p><b>Solution progression:</b>
*
* <ol>
* <li>{@code SolutionDp} — Bottom-up DP, <code>O(n)</code> time, <code>O(n)</code> space
* <li>{@code Solution} — Space-optimized DP, <code>O(n)</code> time, <code>O(1)</code> space
* </ol>
*
* @see <a href="https://leetcode.com/problems/min-cost-climbing-stairs/">Problem Link</a>
*/
package codes.yam.leetcode.mincostclimbingstairs;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package codes.yam.leetcode.mincostclimbingstairs;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

class SolutionDpTest {
@ParameterizedTest
@MethodSource("codes.yam.leetcode.mincostclimbingstairs.TestCases#cases")
void minCostClimbingStairs(int[] cost, int expected) {
assertEquals(expected, new SolutionDp().minCostClimbingStairs(cost));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package codes.yam.leetcode.mincostclimbingstairs;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

class SolutionTest {
@ParameterizedTest
@MethodSource("codes.yam.leetcode.mincostclimbingstairs.TestCases#cases")
void minCostClimbingStairs(int[] cost, int expected) {
assertEquals(expected, new Solution().minCostClimbingStairs(cost));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package codes.yam.leetcode.mincostclimbingstairs;

import java.util.stream.Stream;
import org.junit.jupiter.params.provider.Arguments;

@SuppressWarnings("unused")
class TestCases {
static Stream<Arguments> cases() {
return Stream.of(
Arguments.of(new int[] {10, 15, 20}, 15),
Arguments.of(new int[] {1, 100, 1, 1, 1, 100, 1, 1, 100, 1}, 6));
}
}