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.
constgemstones=(stoneArray)=>{try{letgemStoneCount=0;letreferenceString="";lettempCount=1;if(stoneArrayinstanceofArray&&stoneArray.length>0){// REMOVING DUPLICATES FROM THE STRINGreferenceString=[...newSet(stoneArray[0].split(""))].join("");for(leti=0;i<referenceString.length;i++){tempCount=1;for(letj=1;j<stoneArray.length;j++){if(stoneArray[j].indexOf(referenceString[i])>-1){tempCount++;}}if(tempCount===stoneArray.length){gemStoneCount++;}}}returngemStoneCount;}catch(error){console.log(error.message);}}
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 →
JAVASCRIPT :