Minimum steps to one

in this min we have not written then how this program give correct answer

Didn’'t get you. Share the code please.