Regarding recursion last two lines

in the last two lines why are we using int res=funtion…
why are we initializing this as int

Hi @Adhyayan,
See you have to initialize res because if current index is not equal to the number then the number must exist in somewhere from the next index to the end index so to call the next index you do int res = function call so that function can return if the number is available somewhere after the current index ;

Kindly make recursive stack using paper pencil for a better clarity

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.