Given . You can perform 3 types of operations:
You have to find the minimum number of operations needed to reach 1.
The first line of the input will contain an integer (), the number of test cases. Each of the next T lines will contain an integer (), as described in the problem statement.
For each test case, you have to find the minimum number of operations needed to reach 1.
5 2 3 4 5 23
1 2 2 3 6
Login to submit
If you analyze, you’ll find it is better to divide NNN by 2 when available. So, dp[n] = 1 + dp[n / 2...