Method to find an equal index
static int findIndex ( string str ) { int len = str . Length ; int [ ] open = new int [ len + 1 ] ; int [ ] close = new int [ len + 1 ] ; int index = - 1 ; open [ 0 ] = 0 ; close [ len ] = 0 ; if ( str [ 0 ] == ' ( ' ) open [ 1 ] = 1 ; if ( str [ len - 1 ] == ' ) ' ) close [ len - 1 ] = 1 ;