Code not compiling

hello @Amishi

check now->

why do we have to initialize ans with -1 and not zero(0)

becuase then we dont have to handle -1 case seprately.

if element will not be there in the array then ans will never be updated .
and becuase of that when we print ans we will get -1 in output

1 Like

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.