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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Strings
  4. Gemstones
  5. Discussions

Gemstones

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics

    You are viewing a single comment's thread. Return to all comments →

  • nikhilar98
    4 months ago+ 0 comments

    javaScript:

    function gemstones(arr) {
        // Write your code here
        let count=0;
        let minerals=""
        let str=arr.join("");
        
        for(let i of str){
            if(!minerals.includes(i)){
                 minerals+=i
            }
        }
        
        for (let i of minerals){
            let skip=false
            for(let j of arr){
                if(!j.includes(i)){
                    skip=true
                    break;
                }  
            }
            if(skip==false){
                count++  
            }
        }
        return count
    }
    
    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy