Double-Base Palindromes
Updated
Problem statement
Given an integer upperBound, return every integer x such that 1 <= x <= upperBound and the ordinary representations of x in both base 10 and base 2 read the same forward and backward.
Binary representations must not contain leading zeroes. Return the qualifying integers in increasing order.
Function
doubleBasePalindromes(upperBound: int) → int[]Examples
Example 1
upperBound = 20return = [1,3,5,7,9]For example, 9 is 9 in decimal and 1001 in binary, so it qualifies. No integer from 10 through 20 is palindromic in both bases.
Example 2
upperBound = 100return = [1,3,5,7,9,33,99]33 is 100001 in binary, and 99 is 1100011; both representations are palindromes.
Constraints
1 <= upperBound <= 100000.- Use each number's standard decimal and binary form, without leading zeroes.
More xAI interview questions
- Resumable List IteratorPHONE SCREEN · Seen Apr 2026
- Earliest Dataset Readiness in a PipelinePHONE SCREEN · Seen Mar 2026
- Most Common N-GramsPHONE SCREEN · Seen Mar 2025
- Live Top-K Spaces by Active UsersONSITE INTERVIEW · Seen Jan 2026
- Total Active Time by SpaceONSITE INTERVIEW · Seen Jan 2026
- Dynamic Batch Decode TraceONSITE INTERVIEW · Seen Dec 2025
- Nested Transaction Key-Value StoreONSITE INTERVIEW · Seen Oct 2025
- Weighted LRU CacheONSITE INTERVIEW · Seen Oct 2025
- LFU CacheONSITE INTERVIEW · Seen Sep 2025
- Cached Lazy Token BucketsONSITE INTERVIEW · Seen Sep 2025
Similar questions at other companies
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Add Two Integers Given as StringsJane Street · PHONE SCREENJane Street interview questions
- Fizz and Buzz Words From 1 to nDocuSign · PHONE SCREENDocuSign interview questions
- Fizz BuzzBloomberg LP · PHONE SCREENBloomberg LP interview questions
- FizzBuzz With Bubble and ScreamZillow · PHONE SCREENZillow interview questions
- Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
- Per-Segment SpeedingOnePay · PHONE SCREENOnePay interview questions
- Add Decimal Strings ExactlyMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Format a Centered Pagination BarMixpanel · PHONE SCREENMixpanel interview questions