mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
merge: add test case and description (#842)
This commit is contained in:
@ -1,7 +1,10 @@
|
|||||||
/*
|
/**
|
||||||
* You are climbing a stair case. It takes n steps to reach to the top.
|
* @function ClimbStairs
|
||||||
* Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
|
* @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?
|
||||||
*/
|
* @param {Integer} n - The input integer
|
||||||
|
* @return {Integer} distinct ways can you climb to the top.
|
||||||
|
* @see [Climb_Stairs](https://www.geeksforgeeks.org/count-ways-reach-nth-stair/)
|
||||||
|
*/
|
||||||
|
|
||||||
const climbStairs = (n) => {
|
const climbStairs = (n) => {
|
||||||
let prev = 0
|
let prev = 0
|
||||||
|
19
Dynamic-Programming/tests/ClimbingStairs.test.js
Normal file
19
Dynamic-Programming/tests/ClimbingStairs.test.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { climbStairs } from '../ClimbingStairs'
|
||||||
|
|
||||||
|
describe('ClimbingStairs', () => {
|
||||||
|
it('climbStairs of 0', () => {
|
||||||
|
expect(climbStairs(0)).toBe(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('climbStairs of 1', () => {
|
||||||
|
expect(climbStairs(1)).toBe(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('climbStairs of 10', () => {
|
||||||
|
expect(climbStairs(10)).toBe(89)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('climbStairs of 15', () => {
|
||||||
|
expect(climbStairs(15)).toBe(987)
|
||||||
|
})
|
||||||
|
})
|
Reference in New Issue
Block a user