Periodic Binary String With Minimum Period and a Given Binary String as Subsequence . | C # implementation to find the periodic string with minimum period ; Function to find the periodic string with minimum period ; Print the string S if it consists of similar elements ; Find the required periodic string with period 2 ; Driver code
using System ; class GFG { static void findPeriodicString ( string S ) { int l = 2 * S . Length ; int count = 0 ; for ( int i = 0 ; i < S . Length ; i ++ ) { if ( S [ i ] == '1' ) count ++ ; } if ( count == S . Length count == 0 ) Console . WriteLine ( S ) ; else { char [ ] arr = new char [ l ] ; for ( int i = 0 ; i < l ; i += 2 ) { arr [ i ] = '1' ; arr [ i + 1 ] = '0' ; } for ( int i = 0 ; i < l ; i ++ ) Console . Write ( arr [ i ] ) ; Console . WriteLine ( ) ; } } public static void Main ( ) { string S = "1111001" ; findPeriodicString ( S ) ; } }