Skip to content

Latest commit

 

History

History
9 lines (5 loc) · 576 Bytes

File metadata and controls

9 lines (5 loc) · 576 Bytes

EqualizeBitStrings

You are given two binary strings a and b of the same length. You can perform the following two operations on the string a:

  • Swap any two bits at indices i and j respectively (1 ≤ i, jn), the cost of this operation is |i−j|, that is, the absolute difference between i and j.
  • Select any arbitrary index i (1 ≤ in) and flip (change 0 to 1 or 1 to 0) the bit at this index. The cost of this operation is 1.

Find the minimum cost to make the string a equal to b. It is not allowed to modify string b.