Is my logic to solve the problem using recursion correct?

Here is my code-


is this code correct to solve problem using recursion

Hi @pragyachoudhary1111
Your code is correct. But there is a slight error that in the if case condition should be i== -1 then only return because the value can exist on the 0th index also.
Here is your corrected code :