Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Binary Palindrome

Try to solve the Minimum Operations to Make Binary Palindrome problem.

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

Try to solve the Minimum Operations to Make Binary Palindrome problem.

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