FastPrepCount Palindromic Base Representations

Count Palindromic Base Representations

SEDEMAC logoSEDEMAC● EasyNEW GRADOA
Learn

Problem statement

For each integer base from 2 through 16, convert the positive integer value to that base. Return how many of those digit sequences read the same from left to right and right to left. Digits are compared by numeric value, so bases above ten need no special text encoding.

Function

countPalindromicBases(value: int) → int

Examples

Example 1

value = 9return = 9

The binary and base-eight forms are palindromes, and every base above nine uses one digit.

Example 2

value = 5return = 13

Each base is checked independently using its digit sequence.

Constraints

  • 1 <= value <= 1000000000
  • bases 2 through 16 are inclusive

More SEDEMAC problems

See SEDEMAC hiring insights
public int countPalindromicBases(int value) {
    // Write your code here.
}
value9
expected9
Checking account…