why mask is taken as 1 << n ?
Why mask is taken as 1 << n?
Hi @sahazeer123,
we take mask as 1<<n. Let n==3, mask=(1<<n)-1 ==> mask=7(bit representation 111). Since we have n=3, we want to store which all places have the salesman has visited, hence we take mask as 7. when mask == 7 , it means the salesman has travelled all the places otherwise it hasn’t.
hope dis resolves ur doubt.
If u still have any queries u can post it here.
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.