diff --git a/climbing-stairs/Zioq.js b/climbing-stairs/Zioq.js new file mode 100644 index 000000000..e199bb1b7 --- /dev/null +++ b/climbing-stairs/Zioq.js @@ -0,0 +1,30 @@ +/** + * @param {number} n + * @return {number} + */ +var climbStairs = function(n) { + // 1 -> 1 + // 2 -> (1+1) | 2 + // 3 -> (1+1+1) | (1+2) | (2+1) + // 4 -> (1+1+1+1) | (2+1+1) | (1+2+1) | (1+1+2) | (1+2+2) + // 5 -> (1+1+1+1+1) | (2+1+1+1) | (1+2+1+1) | (1+1+2+1) | (1+1+1+2) | (1+2+2) | (2+1+2) | (2+2+1) + if(n <=3) return n + + let a = 0; + let b = 1; + let c = 0; + + for(let i=0; i