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.
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.
Sites all over the internet are filled with basic level tree problems like