Skip to content

Commit 4e7a156

Browse files
merge: add test case and description (TheAlgorithms#842)
1 parent 02a4cee commit 4e7a156

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

Dynamic-Programming/ClimbingStairs.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
/*
2-
* You are climbing a stair case. It takes n steps to reach to the top.
3-
* Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
4-
*/
1+
/**
2+
* @function ClimbStairs
3+
* @description You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
4+
* @param {Integer} n - The input integer
5+
* @return {Integer} distinct ways can you climb to the top.
6+
* @see [Climb_Stairs](https://www.geeksforgeeks.org/count-ways-reach-nth-stair/)
7+
*/
58

69
const climbStairs = (n) => {
710
let prev = 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { climbStairs } from '../ClimbingStairs'
2+
3+
describe('ClimbingStairs', () => {
4+
it('climbStairs of 0', () => {
5+
expect(climbStairs(0)).toBe(1)
6+
})
7+
8+
it('climbStairs of 1', () => {
9+
expect(climbStairs(1)).toBe(1)
10+
})
11+
12+
it('climbStairs of 10', () => {
13+
expect(climbStairs(10)).toBe(89)
14+
})
15+
16+
it('climbStairs of 15', () => {
17+
expect(climbStairs(15)).toBe(987)
18+
})
19+
})

0 commit comments

Comments
 (0)