Description
Solutions
Minimum Operations to Make Binary Palindromic
🤘 INTERN

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.

Example 1:

Input:  N = 6
Output: 1
Explanation:

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 * 109
Thumbnail 0
Testcase

Result
Case 1

input:

output: