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.
Honestly, some puzzles just aren't worth the time / points. This one looks like it's just bookkeeping.
Running the range and doing pop-counts takes too long. Instead, given the range, determine how often each of the 32-bits possible will be a 1. The range may contain some number of full cycles, with half 1s and half 0s, and then some off-cycle handling on either end. Might have to handle a case for the positive portion of the range and a case for the negatives -- TBD.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
2's complement
You are viewing a single comment's thread. Return to all comments →
Honestly, some puzzles just aren't worth the time / points. This one looks like it's just bookkeeping.
Running the range and doing pop-counts takes too long. Instead, given the range, determine how often each of the 32-bits possible will be a 1. The range may contain some number of full cycles, with half 1s and half 0s, and then some off-cycle handling on either end. Might have to handle a case for the positive portion of the range and a case for the negatives -- TBD.