text: Count of strings that does not contain Arc intersection | C # program for the above approach ; Function to check if there is arc intersection or not ; Traverse the String S ; Insert all the elements in the stack one by one ; Extract the top element ; Pop out the top element ; Check if the top element is same as the popped element ; Otherwise ; If the stack is empty ; Function to check if there is arc intersection or not for the given array of Strings ; Stores count of String not having arc intersection ; Iterate through array ; Length of every String ; Function Call ; Print the desired count ; Driver Code ; Function Call
code: using System ; using System . Collections . Generic ; class GFG { static int arcIntersection ( String S , int len ) { Stack < char > stk = new Stack < char > ( ) ; for ( int i = 0 ; i < len ; i ++ ) { stk . Push ( S [ i ] ) ; if ( stk . Count >= 2 ) { char temp = stk . Peek ( ) ; stk . Pop ( ) ; if ( stk . Peek ( ) == temp ) { stk . Pop ( ) ; } else { stk . Push ( temp ) ; } } } if ( stk . Count == 0 ) return 1 ; return 0 ; } static void countString ( String [ ] arr , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int len = arr [ i ] . Length ; count += arcIntersection ( arr [ i ] , len ) ; } Console . Write ( count + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String [ ] arr = { "0101" , "0011" , "0110" } ; int N = arr . Length ; countString ( arr , N ) ; } }