If the letter is available in String str3 , decrement it 's  frequency & increment the ptr2
if ( freq . containsKey ( str3 . charAt ( ptr2 ) ) ) if ( freq . get ( str3 . charAt ( ptr2 ) ) > 0 ) { freq . put ( str3 . charAt ( ptr2 ) , freq . get ( str3 . charAt ( ptr2 ) ) - 1 ) ; ptr2 ++ ; }