Problem Type : BFS , math , greedy , shortest path
Problem link: Two Buttons
this was a very interesting for me.
This problem asks us what is the minimum steps we need to reach from one given number to another given number by multiplying by 2 or subtracting 1
i have found 2 ways to solve this problem
1) using bfs (hard way)
2) simple mathematics
The hard way:
let us try to analyze 2 given test cases
1) 4 ->6 minimum steps: 2
2) 10 ->1 minimum steps: 9
let us make a graph using the 2 test cases
Problem link: Two Buttons
this was a very interesting for me.
This problem asks us what is the minimum steps we need to reach from one given number to another given number by multiplying by 2 or subtracting 1
i have found 2 ways to solve this problem
1) using bfs (hard way)
2) simple mathematics
The hard way:
let us try to analyze 2 given test cases
1) 4 ->6 minimum steps: 2
2) 10 ->1 minimum steps: 9
let us make a graph using the 2 test cases