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. Data Structures
  3. Arrays
  4. Sparse Arrays
  5. Discussions

Sparse Arrays

Problem
Submissions
Leaderboard
Discussions
Editorial

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

  • h351680058
    2 years ago+ 0 comments

    python 3 solution using hash map, pass all cases

    def matchingStrings(strings, queries):
            d = {}
            for s in queries:
                    d[s] = 0
            for ss in strings:
                    if ss in d:
                            d[ss]+=1
            ans = [d[num] for num in queries]
            return ans
    
    8|
    Permalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature