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
4 changes: 2 additions & 2 deletions automation/state.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"catalogIndex": 4,
"lastRunDate": "2026-10-24"
"catalogIndex": 5,
"lastRunDate": "2026-10-25"
}
25 changes: 25 additions & 0 deletions problems/2026-10-25-climb-stairs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Climbing Stairs

## Problem

You are climbing a staircase. It takes `n` steps to reach the top.

Each time you can climb `1` or `2` steps. In how many distinct ways can you climb to the top?

## Examples

```
Input: n = 2
Output: 2

Input: n = 3
Output: 3
```

## Constraints

- `1 <= n <= 45`

## Notes

Implement `climbStairs` in `solution.js`.
17 changes: 17 additions & 0 deletions problems/2026-10-25-climb-stairs/climb-stairs.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { climbStairs } from "./solution.js";

describe("climbStairs", () => {
it("two steps", () => {
assert.equal(climbStairs(2), 2);
});

it("three steps", () => {
assert.equal(climbStairs(3), 3);
});

it("one step", () => {
assert.equal(climbStairs(1), 1);
});
});
15 changes: 15 additions & 0 deletions problems/2026-10-25-climb-stairs/solution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @param {number} n
* @returns {number}
*/
export function climbStairs(n) {
if (n <= 2) return n;
let a = 1;
let b = 2;
for (let i = 3; i <= n; i++) {
const next = a + b;
a = b;
b = next;
}
return b;
}
Loading