Skip to content

Latest commit

 

History

History
 
 

EqualizingBitStrings

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

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.