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.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  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 →

  • a2_darwazeh
    4 years ago+ 0 comments

    Wow i really went the hard route ay, forgot about dictionaries.

    import re
    
    no_strings = int(input())
    strings = []
    no_q = 0
    queries = []
    
    for _ in range(no_strings):
        strings.append(input())
    
    no_q = int(input())
    for _ in range(no_q):
        queries.append(re.compile(r'^'+input()+'$'))
    
    for pattern in queries:
        found = 0
        for s in strings:
            found += len(pattern.findall(s))
        print(found)
    
    -3|
    ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature