Count Palindromic Base Representations
Updated
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) → intExamples
Example 1
value = 9return = 9The binary and base-eight forms are palindromes, and every base above nine uses one digit.
Example 2
value = 5return = 13Each base is checked independently using its digit sequence.
Constraints
1 <= value <= 1000000000bases 2 through 16 are inclusive
More SEDEMAC interview questions
Similar questions at other companies
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
- Costliest ChocolateRippling · OARippling interview questions
- Distinct Chapters Missed During a Cyclic AbsenceVisa · OAVisa interview questions
- Reduce a Number to One DigitAccenture · OAAccenture interview questions
- Online No-Intercept Linear RegressionTwo Sigma · OATwo Sigma interview questions
- Calculate the Half SpreadMillennium · OAMillennium interview questions
- Plus Mult ArrayIBM · OAIBM interview questions
- Product Minus Sum of DigitsTikTok · OATikTok interview questions
- Progressive Tax CalculatorInteractive Brokers · OA