text: Count of strings that does not contain Arc intersection | 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: function arcIntersection ( S , len ) { var stk = [ ] ; for ( var i = 0 ; i < len ; i ++ ) { stk . push ( S [ i ] ) ; if ( stk . length >= 2 ) { var temp = stk [ stk . length - 1 ] ; stk . pop ( ) ; if ( stk [ stk . length - 1 ] == temp ) { stk . pop ( ) ; } else { stk . push ( temp ) ; } } } if ( stk . length == 0 ) return 1 ; return 0 ; } function countString ( arr , N ) { var count = 0 ; for ( var i = 0 ; i < N ; i ++ ) { var len = arr [ i ] . length ; count += arcIntersection ( arr [ i ] , len ) ; } document . write ( count + " " ) ; } var arr = [ " " , " " , " " ] ; var N = arr . length ; countString ( arr , N ) ;