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.
decibinaryNumbers(long x) generates all decibinary reps for n=0,1, 2, etc. It sums the counts of these reps until the xth decibinary number is in the current list, and it returns it.
the generateAllDbReps() method calculates 'place', the leftmost position that could hold a non-zero digit in the decibinary representation of 'n'.
internalGenerateAllDbReps tries every possible digit in position 'place' for number 'n'. It recurses to the next lower place by adding the digit to the decibinary number 'dbNum' and subtracting the digit from 'n'.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Decibinary Numbers
You are viewing a single comment's thread. Return to all comments →
decibinaryNumbers(long x) generates all decibinary reps for n=0,1, 2, etc. It sums the counts of these reps until the xth decibinary number is in the current list, and it returns it.
the generateAllDbReps() method calculates 'place', the leftmost position that could hold a non-zero digit in the decibinary representation of 'n'.
internalGenerateAllDbReps tries every possible digit in position 'place' for number 'n'. It recurses to the next lower place by adding the digit to the decibinary number 'dbNum' and subtracting the digit from 'n'.