Store string that are initially have formed lexicographically smallest 2 k length substring
string temp_str = " " ; for ( int i = 0 ; i < ( zeroes_in_2k ) / 2 ; i ++ ) { temp_str . push_back ( '0' ) ; } for ( int i = 0 ; i < ones_in_2k ; i ++ ) { temp_str . push_back ( '1' ) ; } for ( int i = 0 ; i < ( zeroes_in_2k ) / 2 ; i ++ ) { temp_str . push_back ( '0' ) ; }