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
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Implementation
  4. Between Two Sets
  5. Discussions

Between Two Sets

Problem
Submissions
Leaderboard
Discussions
Editorial

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

  • Gloud
    4 years ago+ 25 comments

    My javascript solution:

    function getTotalX(a, b) {
        let validCount = 0;
        
        for (let x = 1; x <= 100; x++) {
            if (a.every(int => (x % int == 0))) {
                if (b.every(int => (int % x == 0))) {
                    validCount++;
                }
            }
        }
    
        return validCount;
    }
    
    88|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature