Not understanding line of code

in this code please explain me the line number 45 that is ans|=sum<<i; with an example. I am very confused with this line

hello @shivamgoel150

it basically sets ith bit of ans.
becuase sum is 1.
sum<<i will give a number whose ith bit will be set .
ans|=sum<<i ; will set the ith bit of ans by taking or with it.

btw ur logic seems incorrect to me

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.