• + 1 comment

    to remove duplicacy... e.g. in let s1='abbc' and s2='fabc'. Since count of b isn't same in s1 and s2, not using s2 = s2.substring(0,index)+s2.substring(index+1); would consider b to be present ignoring the count. Expl: s2.substring(0,index) would calc the substring from beginning to pos index-1(including) and s2.substring(index+1) means starting from index+1 position thereby omitting the character at pos index.