Return min(q1,min(q2,q3)

please explain why are we returing the this statement return min(q1,min(q2,q3)

Hi Ayush, q1 q2 and q3 represent the answers for 3 different ways of reducing N to 1. we need to choose the minimum of these three ways.

so if N = 30 and if you divide it by 3 let us say q1 steps will be needed for 10, if you divide it by 2 then q2 steps will be needed for 15 and if you subtract 1 from it q3 steps will be needed for 29. you will choose the way in which the steps needed to reach 1 are minimum. that is what the statement min(q1,min(q2,q3) helps you to do.

Hope that helps :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.