We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Draw out the truth table for N inputs and you will see that there is one input where all the values are 0. The rest of the inputs has at least one set bit. that means the answer is (2 ^ N) - 1 and then take the modulus of it.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Diwali Lights
You are viewing a single comment's thread. Return to all comments →
Draw out the truth table for N inputs and you will see that there is one input where all the values are 0. The rest of the inputs has at least one set bit. that means the answer is (2 ^ N) - 1 and then take the modulus of it.