• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
October 27, 2023 |1.7K Views
PROBLEM OF THE DAY: 26/10/2023 | Minimum Operations
Description
Discussion

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:

  • Double the number
    Add one to the number  

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