Monthly Archive: March 2016


Find the first common ancestor of two nodes in a binary tree

Algorithm Create two arrays with in-order and post-order traversal for the given binary tree and call them in-order and post-order traversal respectively. Find the number of nodes in-between the given two nodes in the...


Distinct ways to reach the n’th stair

Problem: Given stair case with n stairs, count the number of ways in which you can climb the stairs. Each time you can either take 1 step or 2 steps. Solution: — Number of...