We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Anagram
You are viewing a single comment's thread. Return to all comments →
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.