question: private boolean checkPattern ( ) { if ( pattern == null ) { return false ; } char leftSeparator = getLeftSeparator ( ) ; char rightSeparator = getRightSeparator ( ) ; Stack < Character > separatorStack = new Stack < Character > ( ) ; for ( int i = 0 ; i < pattern . length ( ) ; i ++ ) { char cur = pattern . charAt ( i ) ; if ( cur == leftSeparator ) { separatorStack . push ( cur ) ; } else if ( cur == rightSeparator ) { if ( ! separatorStack . isEmpty ( ) && ( separatorStack . pop ( ) == leftSeparator ) ) { continue ; } else { return false ; } } } return separatorStack . isEmpty ( ) ; }
target:  check if the pattern has legal separators