Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Flips to Reverse Binary String

Minimum Number of Flips to Reverse Binary String asks you to take an integer's binary representation and return the fewest bit changes needed to make it read backward.

Statement

Given a positive integer n, consider its binary representation without leading zeros.

Return the minimum number of bit flips required to transform this binary representation into its reversed string. A bit flip involves changing a bit from 00 to 11 or from 11 to 00.

Constraints:

  • 1≤1 \leq n ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Flips to Reverse Binary String

Minimum Number of Flips to Reverse Binary String asks you to take an integer's binary representation and return the fewest bit changes needed to make it read backward.

Statement

Given a positive integer n, consider its binary representation without leading zeros.

Return the minimum number of bit flips required to transform this binary representation into its reversed string. A bit flip involves changing a bit from 00 to 11 or from 11 to 00.

Constraints:

  • 1≤1 \leq n ≤109\leq 10^9