Min Steps to 1 using DP — Coding Question

Problem Statement:

Input format :

Output format :

4
2
For n = 4
Step 1 : n = 4 / 2 = 2
Step 2 : n = 2 / 2 = 1
7
3
For n = 7
Step 1 : n = 7 ­- 1 = 6
Step 2 : n = 6 / 3 = 2
Step 3 : n = 2 / 2 = 1

Code:

Thanks for Reading

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store