• 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

C Program for TAIL command of UNIX

Cisco Hiring Event 21st – 22nd Feb 2015

Microsoft BING Interview Experience

Find Pythagorean Triplets in an array in O(N)

Coin Collection Dynamic Programming

The greedy coins game Dynamic Programming

Adobe Interview Questions 8 month Exp

Find the smallest window in a string containing all characters of another string

In Given LinkedList Divide LL in N Sub parts and delete first K nodes of each part

Find the kth number with prime factors 3, 5 and 7

Skiing on Mountains Matrix

LeetCode : Word Search

Find two non repeating elements in an array of repeating elements

write a c program that given a set a of n numbers and another number x determines whether or not there exist two elements in s whose sum is exactly x

Walmart Labs Interview Experience

Test Cases for Round Function

Serialise Deserialise N-ary Tree

VMWare Openings

Leetcode: Edit Distance

simple sql injection

Find an index i such that Arr [i] = i in array of n distinct integers sorted in ascending order.

Check Binary Tree is Binary Search Tree or not

C++ OOPs Part2

SAP Off Campus Hiring_ March 2015 Verbal Skills

1014 Practice Question of New GRE – Princeton

Longest Increasing Subsequence

Number of Islands BFS/DFS

Binary Tree in Java

Rectangular chocolate bar Create at least one piece which consists of exactly nTiles tiles

Templates in C++

Copyright © 2026 · Genesis Framework · WordPress · Log in