Insert all characters of string S1 in the set
HashSet < Character > bset = new HashSet < Character > ( ) ; char [ ] S1arr = S1 . toCharArray ( ) ; char [ ] S2arr = S2 . toCharArray ( ) ; for ( char x : S1arr ) bset . add ( x ) ; int count = 0 ;