• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to secondary sidebar

GoHired

Interview Questions asked in Google, Microsoft, Amazon

Join WeekEnd Online Batch from 4-April-2020 on How to Crack Coding Interview in Just 10 Weeks : Fees just 20,000 INR

  • Home
  • Best Java Books
  • Algorithm
  • Internship
  • Certificates
  • About Us
  • Contact Us
  • Privacy Policy
  • Array
  • Stack
  • Queue
  • LinkedList
  • DP
  • Strings
  • Tree
  • Mathametical
  • Puzzles
  • Graph

building with N steps, we can take 1,2,3 steps calculate number of ways to reach at top of building

March 24, 2014 by Dhaval Dave

Given n stairs, how many number of ways can you climb if u use either 1, 2 or 3 at a time?

When you find any difficult problem first step is to reduce it to very small problem with example
Consider 3 steps. you can take only one at a time. Then number of ways are 1: ie {(1,1,1)}
Consider 2 steps. you can take 1 or 2 at a time. Then number of ways are 2: ie {(1,1), (2)}

Consider 3 steps. you can take 1 or 2 at a time Number of ways : 3 ie : {(1,2),(2,1),(1,1,1)}
Consider 4 steps. you can take 1 or 2 at a time Number of ways : 5
ie {(1,1,1,1), (1,2,1),(1,1,2),(2,1,1),(2,2)}
See carefully 2,3,5……
This makes Fibonacci series

because If we are at Nth step then to reach at bottom (same as climbing) at each step we can decide whether to take N-1 or N-2 step and at each decision further option keeps open.

so Function if we can take 1 or 2 is

F(n) = F(n-1) + F(n-2) ;
Similarly if we can take three steps 1,2 or 3
F(n) = F(n-1) + F(n-2) + F(n-3) ;

Similar Articles

Filed Under: Adobe Interview Questions, problem, Puzzle Tagged With: Mathematical

Reader Interactions

Primary Sidebar

Join WeekEnd Online/Offline Batch from 4-April-2020 on How to Crack Coding Interview in Just 10 Weeks : Fees just 20,000 INR

Join WeekEnd Online/Offline Batch from 4-April-2020

WhatsApp us

Secondary Sidebar

Custom Search

  • How I cracked AMAZON
  • LeetCode
  • Adobe
  • Amazon
  • Facebook
  • Microsoft
  • Hacker Earth
  • CSE Interview

Top Rated Questions

Coin Collection Dynamic Programming

Given array of 0’s and 1’s. All 0’s are coming first followed by 1’s. find the position of first 1

Given a float number convert it into the string WITHOUT using any inbuilt Function

Serialise Deserialise N-ary Tree

Introduction To Number Theory ( Part 1 )

Max Sum in circularly situated Values

TicTacToe Game As Asked in Flipkart

Get Minimum element in O(1) from input numbers or Stack

Add Sub Multiply very large number stored as string

robot standing at first cell of an M*N matrix. It can move only in two directions, right and down. In how many ways, it can reach to the last cell i.e. (M, N) Code it

Convert number to words java

Regular Expression Matching

Check if an array has duplicate numbers in O(n) time and O(1) space

Code Chef PRGIFT Solution

Reversal of LinkedList

Naurki.com Security Breach

Connect n ropes with minimum cost

N Petrol bunks or City arranged in circle. You have Fuel and distance between petrol bunks. Is it possible to find starting point so that we can travel all Petrol Bunks

Check a String is SUBSEQUENCE of another String Find Minimum length for that ( DNA Matching )

Find Nearest Minimum number in left side in O(n)

Count Possible Decodings of a given Digit Sequence

The Magic HackerEarth Nirvana solutions Hiring Challenge

Find Pythagorean Triplets in an array in O(N)

Difference between a LinkedList and a Binary Search Tree BST

Amazon Interview Experience – SDE Chennai

Spanning Tree

Urban Ladder Written Test.

Memory Efficient LinkedList

Puzzle : 100 doors in a row Visit and Toggle the door. What state the door will be after nth pass ?

The greedy coins game Dynamic Programming

Copyright © 2025 · Genesis Framework · WordPress · Log in