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.
functiongemstones(arr){// remove duplictions in each string letstrs=[];for(constiofarr){strs.push(i.split('').filter((a,index)=>i.indexOf(a)===index).join(''));}console.log(strs);letcounts={};for(constiofstrs){for(constjofi){if(i.split('').includes(j))counts[j]=(counts[j]||0)+1;}}letcounter=0;for(constiincounts){if(counts[i]===arr.length){counter++;}}return(counter);}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Gemstones
You are viewing a single comment's thread. Return to all comments →
JS solution