#3766

Minimum Operations to Make Binary Palindrome

specialist · 860 · lc medium +31 · 51.7% accepted · 51 likes · top 41%

Description

Given an integer array nums, for each element nums[i] compute the minimum number of +1 or -1 operations needed to transform it into a binary palindrome (a number whose binary representation without leading zeros reads identically forward and backward), and return these counts as an array ans.

Code

1
2
3