Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package g3601_3700.s3693_climbing_stairs_ii;

// #Medium #Array #Dynamic_Programming #Biweekly_Contest_166
// #2025_10_07_Time_3_ms_(99.74%)_Space_58.06_MB_(96.52%)
// #2026_11_10_Time_3_ms_(97.54%)_Space_110.15_MB_(92.77%)

@SuppressWarnings({"unused", "java:S1172"})
public class Solution {
Expand Down
49 changes: 9 additions & 40 deletions src/main/java/g3601_3700/s3693_climbing_stairs_ii/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,11 @@ Return the **minimum** total cost to reach step `n`.

One optimal path is `0 → 1 → 2 → 4`

Jump

Cost Calculation

Cost

0 → 1

<code>costs[1] + (1 - 0)<sup>2</sup> = 1 + 1</code>

2

1 → 2

<code>costs[2] + (2 - 1)<sup>2</sup> = 2 + 1</code>

3

2 → 4

<code>costs[4] + (4 - 2)<sup>2</sup> = 4 + 4</code>

8
| Jump | Cost Calculation | Cost |
| --- | --- | --- |
| 0 → 1 | <code>costs[1] + (1 - 0)<sup>2</sup> = 1 + 1</code> | 2 |
| 1 → 2 | <code>costs[2] + (2 - 1)<sup>2</sup> = 2 + 1</code> | 3 |
| 2 → 4 | <code>costs[4] + (4 - 2)<sup>2</sup> = 4 + 4</code> | 8 |

Thus, the minimum total cost is `2 + 3 + 8 = 13`

Expand All @@ -58,23 +40,10 @@ Thus, the minimum total cost is `2 + 3 + 8 = 13`

One optimal path is `0 → 2 → 4`

Jump

Cost Calculation

Cost

0 → 2

<code>costs[2] + (2 - 0)<sup>2</sup> = 1 + 4</code>

5

2 → 4

<code>costs[4] + (4 - 2)<sup>2</sup> = 2 + 4</code>

6
| Jump | Cost Calculation | Cost |
| --- | --- | --- |
| 0 → 2 | <code>costs[2] + (2 - 0)<sup>2</sup> = 1 + 4</code> | 5 |
| 2 → 4 | <code>costs[4] + (4 - 2)<sup>2</sup> = 2 + 4</code> | 6 |

Thus, the minimum total cost is `5 + 6 = 11`

Expand Down
Loading