This article is in continuation of this one.

In the previous article, I had tried to emphasize how
nᵗʰ Fibonacci Number = Number of ways to climb n step staircase, where you have only two possible options to move, either by climbing 1 step or 2 steps at a time.

Climbing Staircase Problem

The Story begins with a Problem
Yesterday, I was solving a very famous DP problem, the climbing stairs.
The problem is quite simple. You are climbing a staircase. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

The solution is also pretty straight forward.
Suppose we have climbed up some steps and we are left with some i steps to reach the top. …

Counting problems have been irritating people for ages. They are generally long and weird with additions — substractions going on in different parts with meanings difficult to understand.
Out of all the popular counting problems, one can be solved using some chocolates and boxes, which I am going to discuss in this article.

The Problem

Balanced Binary Tree

Tree problems are quite popular among competitive programming questions. All the fame is because of the complexity of thought they deliver to the mind of a beginner and sometimes they even scare the intermediate programmers, who have been programming for a while.

Here in this blog, I will discuss a general problem that has similar complexity issues and share a thought to break the solution.

Some Prerequisites
Sites all over the internet are filled with basic level tree problems like

  • Finding the depth of a node in a tree
  • Finding the height of a tree
  • Sum of a subtree rooted…

Anshul Garg

Programmer | In love with Maths and Problem Solving | github@garganshul108 | linkedin@anshulgargofficial

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store