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.
Since we're looking at powers of 2 just use bitshift, that is faster since it doesn't have the overhead of a function call. Also there is no need for calculating 10**9+7 every time, since it's a constant. Just write 1000000007 instead.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Shashank and List
You are viewing a single comment's thread. Return to all comments →
Since we're looking at powers of 2 just use bitshift, that is faster since it doesn't have the overhead of a function call. Also there is no need for calculating 10**9+7 every time, since it's a constant. Just write 1000000007 instead.