Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Dynamic Programming but also build up problem-solving skills.
In this problem, there are N points on the road, you can step ahead by 1 or 2. If you start from point 0, and can only move from point i to point i+1 after taking a step of length one, find the number of ways you can reach point N.
Example :
Input:
N = 4
Output:
5
Explanation: Three ways to reach at 4thpoint. They are {1, 1, 1, 1}, {1, 1, 2}, {1, 2, 1} {2, 1, 1}, {2, 2}.
Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/reach-the-nth-point5433/1