Check if a unique character is present in both string S and P
int check = 0 ; for ( char i = ' a ' ; i <= ' z ' ; i ++ ) { if ( mapS . getOrDefault ( i , 0 ) > 0 && mapP . getOrDefault ( i , 0 ) > 0 ) { mapT . put ( i , mapT . getOrDefault ( i , 0 ) + 2 ) ; check = 1 ; break ; } }