Leonardo’s Leaps (Stair Case Puzzle)
1,422.0K Views
This is a classic interview puzzle asked in many interviews.
Puzzle :Given N step stair, how many number of ways can you climb if you use either 1 or 2 at a time?
For example for a stair case with 3 steps there are total 3 ways to climb it :
Way 1: 1 single step then a double step
Way 2: 1 double step and then a single step
Way 3: 3 single steps
The problem is ismply calculating nth fibonacci number .
Let’s write a simple function numWays(x)
int numWays(int n){
if(n<=0)return 0; if(n=1)return 1; if(n==2)return 2; else return numWays(n-1)+numWays(n-2); }
Your Answer
More puzzles to try-
Decode the Rebus
Below rebus represent famous DiCaprio movie. Can you name it?Read More »Around the equator
Two identical trains, at the equator start travelling round the world in opposite directions. They start to-gether, run at the ...Read More »Aeroplane around the world – hardest puzzle
On Bagshot Island, there is an airport. The airport is the homebase of an unlimited number of identical airplanes. Each ...Read More »Moving right to left riddle
What are moving right to left, right now?Read More »How can this be?
A woman shoots her husband. Then she holds him under water for over 5 minutes. Finally, she hangs him. But ...Read More »Colour of the Bear
A Bear has fallen from a height of 10m from ground. It reached ground in sqrt(2) seconds. Luckily it didn’t ...Read More »Traveling puzzle
John recently traveled from his home town to a distant Conference, on a pedal tricycle of all things! his wonderful, ...Read More »Mistake
123456789123456789123456789. Can you find the the mistake?Read More »Chess Board Queens
What is the minimum number of Queens with which you can cover every square of chess board? Read More »Puzzle fry Derby
After the local Puzzle fry Derby, some friends were telling everyone who had won. Unfortunately, the friends were having problems ...Read More »How Come ??
Take 9 from 6, 10 from 9, 50 from 40 and leave 6. How Come ??Read More »How is this situation possible?
A horse travels a certain distance each day. Strangely enough, two of its legs travel 30 miles each day and ...Read More »Distance Traveled Puzzle
Two friends decide to get together; so they start riding bikes towards each other. They plan to meet halfway. Each ...Read More »I can make polar bears white funny riddle
I can make polar bears white. I can make joker cry. I can make the toughest guy in the world ...Read More »Bright and yellow
It is bright and yellow and turn on and off everyday, some say they need me but others wish that ...Read More »Can you crack the code to reveal a saying?
The Greek philosopher Pythagoras described three as the perfect number – it has a beginning, a middle and en end. ...Read More »Describe your way of measuring the 45 minutes.
Your job is to measure 45 minutes, if you have only two cords and matches to light the cords. 1. ...Read More »Have Some Combination!
Nabila got some digits: 1,2,4,5,6,8,0 She made some numbers from them! In those numbers digits might be repeated! But all ...Read More »Man is found dead in a phone booth in a pool of blood riddle
A man is found dead in a phone booth in a pool of blood. The glass on either end of ...Read More »Find the missing part
Can you find the missing piece of the Porsche?Read More »
Accenture Interview PuzzlesAdobe Interview PuzzlesAge RiddleAkbar Birbal PuzzlesAlgorithm PuzzlesAlphabet riddleAmazon Interview PuzzlesAnalytical MathematicsAptitude PuzzleBank PuzzlesBetting PuzzlesBrain TeasersCalendar PuzzlesCards PuzzlesChess Board PuzzleChess PuzzlesChristmas Puzzlecipher PuzzleCivil Services PuzzleClock time puzzleCognizant Interview PuzzlesCoins PuzzleComputational PuzzleconundrumCoronavirus PuzzleCoupondunia Interview PuzzleCritical Thinking Puzzledata analyticsData Structure Interview QuestionsDecode PuzzleDetective PuzzlesDice PuzzleDictionary Riddlesdifficult riddleEasy Math puzzlesEasy puzzlesEinstein puzzleEnglish RiddleFamily Tree Puzzlefamous puzzleFill in the blanks riddlesFinding Killer RiddlesFlipkart interview puzzlesFunny RiddlesGeneral KnowledgeGeographical PuzzleGoogle Code Jam 2014Google Interview PuzzlesGRE PuzzleHard Puzzle