Removing parenthesis from str and pushing into queue , if not visited already
temp = str . substring ( 0 , i ) + str . substring ( i + 1 ) ; if ( ! visit . has ( temp ) ) { q . push ( temp ) ; visit . add ( temp ) ; } } } }