You are viewing a single comment's thread. Return to all comments →
if there is 2 "a" in str1, but only 1 "a" in str2, diff will not increase
can you please explain this further
take second string into stringbuilder and if char from first string is present in second string remove char at that position from stringbuilder if char is not present in second string then increment count final answer is count.... thanks DanLuo
I did something similar.Converted String to StringBuffers sb1 and sb2.
Upon iterating characters through sb1:
if the character is found in sb2,then change that character value in sb2 to some other value(say '/') so that it couldn't be found in further iterations.
This is essential as sb1 may have repeating characters.