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.
funcmakeAnagram(a:String,b:String)->Int{// Write your code hereletaSort=a.sorted()letbSort=b.sorted()varcount=0varaIndex=0varbIndex=0whileaIndex<aSort.count&&bIndex<bSort.count{letval=aSort[aIndex]letval2=bSort[bIndex]ifval<val2{count+=1aIndex+=1}elseifval>val2{count+=1bIndex+=1}else{aIndex+=1bIndex+=1}}ifaIndex<aSort.count{count+=(aSort.count-aIndex)}ifbIndex<bSort.count{count+=(bSort.count-bIndex)}returncount}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
swift solution