Minimum count of perfect squares, required to represent a number

I was trying to solve this question:

I was trying to write a simple recursive solution to this question (not memoization or dynammic programming, plain recursion), the code is here:

My code is always giving 1 as the output.
I request the TA to kindly edit my code so that it can give the desired output.

https://ide.codingblocks.com/s/589630 i have implemented the same using bottom up down… its very easy to understand

Sir many thanks for the bottom down approach, but could you please show it once using brute force approach of recursion (which has exponential time complexity). I am right now building my concepts.

https://ide.codingblocks.com/s/589635 here’s the recursive solution

do u still have any doubt??

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.

No sir, thanks a lot!