• 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

Right view of Binary tree

Top 10 Interviews Techniqes for Campus Interview in IIT NIT BITS for MTech

The greedy coins game Dynamic Programming

Hackerearth : Counting Subarrays

There are N nuts and N bolts, u have to find all the pairs of nuts and bolts in minimum no. of iteration

Given Set of words or A String find whether chain is possible from these words or not

Generate largest number arranging a no. of given non negative integer numbers

Skiing on Mountains Matrix

HackeEarth Flipkart’s Drone

Get K Max and Delete K Max in stream of incoming integers

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

SAP Off Campus Hiring_ March 2015 Verbal Skills

Sort Stack in place

Python String and numbers

Serialise Deserialise N-ary Tree

Maximum path sum between two leaves

Knight Tour Problem (Graph – Breadth First Search)

Print Power Set of a Set

ADOBE Aptitude C Language Test

Find position of the only set bit

Level order traversal in Spiral form

Find shortest distances between every pair of vertices ( Dynamic Programming Floyd Warshall Algorithm)

Stickler thief

Find if two rectangles overlap

Printing Longest Common Subsequence

Best Java Book | Top Java Programming Book for Beginners

BlueStone E-commerce Interview Experience

Fibonacci Hashing & Fastest Hashtable

Find loop in Singly linked list

Urban Ladder Written Test.

Copyright © 2025 · Genesis Framework · WordPress · Log in