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 Programming Logic but will also help you build up problem-solving skills.
In this problem, we are given, a number N. Find the minimum number of operations required to reach N starting from 0. You have 2 operations available:
Example :
Input:
N = 8
Output: 4
Explanation:
0 + 1 = 1 --> 1 + 1 = 2 --> 2 * 2 = 4 --> 4 * 2 = 8.
Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/find-optimum-operation4504/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp-compiler/06910224-2dec-41c9-9004-36fceb8b60d3