Tap here to switch tabs
Problem
Submissions

Problem: Count Binary Palindromic Numbers

Count Binary Palindromic Numbers asks you to count integers from zero through n whose binary representation, written without leading zeros, reads the same forward and backward.

Statement

Given an integer n, return the total number of integers kk in the range [0,[0, n]] such that the binary representation of kk without leading zeros is a palindrome.

Note: The binary representation of 00 is $ ext{“}0 ext{”}$.

Constraints:

  • 0≤0 \leq n ≤1015\leq 10^{15}

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Binary Palindromic Numbers

Count Binary Palindromic Numbers asks you to count integers from zero through n whose binary representation, written without leading zeros, reads the same forward and backward.

Statement

Given an integer n, return the total number of integers kk in the range [0,[0, n]] such that the binary representation of kk without leading zeros is a palindrome.

Note: The binary representation of 00 is $ ext{“}0 ext{”}$.

Constraints:

  • 0≤0 \leq n ≤1015\leq 10^{15}