A Journey Towards One

Given N. You can perform 3 types of operations: Increase N by 1. Decrease N by 1. Divide N by 2, av…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

In the test case the minimum number of making 23 into 1 is 7 in my sense.

  1. decrease 23 by 1.it becomes 22
  2. divide 22 by 2. it becomes 11
  3. decrease 11 by 1. it becomes 10
  4. divide 10 by 2. it becomes 5
  5. decrease 5 by 1. it becomes 4
  6. divide 4 by 2. it becomes 2
  7. divide 2 by 2. it becomes 1

why 6? can anyone explain it?

How about this?

23 -> 24 -> 12 -> 6 -> 3 -> 2 -> 1
1 Like