Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Binary Palindrome

Minimum Operations to Make Binary Palindrome asks you to adjust each positive integer by increments or decrements until it has a palindromic binary representation and returns the minimum for each.

Statement

You are given an array of positive integers nums.

In one operation, you can increment or decrement any integer by 11.

An integer is considered a binary palindrome if its binary representation without leading zeros reads the same forward and backward.

Return an integer array ans of the same length as nums, where ans[i] represents the minimum number of operations needed to transform nums[i] into a binary palindrome.

Constraints:

  • 1≤1 \leq nums.length ≤5000\leq 5000

  • 1≤1 \leq nums[i] ≤5000\leq 5000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Binary Palindrome

Minimum Operations to Make Binary Palindrome asks you to adjust each positive integer by increments or decrements until it has a palindromic binary representation and returns the minimum for each.

Statement

You are given an array of positive integers nums.

In one operation, you can increment or decrement any integer by 11.

An integer is considered a binary palindrome if its binary representation without leading zeros reads the same forward and backward.

Return an integer array ans of the same length as nums, where ans[i] represents the minimum number of operations needed to transform nums[i] into a binary palindrome.

Constraints:

  • 1≤1 \leq nums.length ≤5000\leq 5000

  • 1≤1 \leq nums[i] ≤5000\leq 5000