Problem · Math
Minimum Operations to Make Binary Palindromic
Learn this problemProblem statement
You are given a number N (0<=N<=2*1e9) and you can do the following operation any number of times including zero.
In one operation you can increase or decrease the number by 1.
Your task is to find the minimum number of operations to make the binary form of the N palindromic.
Function
minOperationsToMakeBinaryPalindromic(N: int) → intExamples
Example 1
N = 6return = 1
You need to decrease N by 1 to make it 5 as binary representation of 5 is Palindromic (101) or you can increase N by 1 to make it 7 as its binary is also palindromic (111).
Constraints
0 <= N <= 2 * 109More Google problems
- Deduplicate Logs: Keep FirstONSITE INTERVIEW · Seen Jul 2026
- Deduplicate Logs: Keep LatestONSITE INTERVIEW · Seen Jul 2026
- Find a Template Across Binary-Tree LeavesONSITE INTERVIEW · Seen Jul 2026
- Maximum Programmer-Problem MatchingONSITE INTERVIEW · Seen Jul 2026
- Minimum Direction ViolationsONSITE INTERVIEW · Seen Jul 2026
- Stream Latest Log VersionsONSITE INTERVIEW · Seen Jul 2026
- Stream Unique Logs in Timestamp OrderONSITE INTERVIEW · Seen Jul 2026
- Top-K IP Addresses from File RecordsONSITE INTERVIEW · Seen Jul 2026