Minimum number of Identical even Subsegments of a Binary String in minimum bit flips.

Revision en1, by thetwoface, 2025-07-10 17:42:27

Given a binary string s, the objective is to divide it into subsegments such that all bits into that segment is identical(i.e. either '0' or '1') and the subsegments should be of even length. Mathematically for any subsegment Bi ∈ s ⇒ len(Bi)%2==0 and ∀ j either Bij='0' or '1' . The criteria to achieve this: 1. This should be done in minimum number of flips required to form an Identical even subsegments. 2. And Minimize the total number of subsegments. Outpur the minimum number of subsegments.

NOTE: First you have to minimize the number of flips before minimizing subsegments.

Constraints are: 2<= s.size() <=10^5

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English thetwoface 2025-07-10 17:42:27 727 Initial revision (published)