Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Ignore List Word Frequency

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Ignore List Word Frequency. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Fiverr Search may need to identify repeated words in a list of analyzed search terms while excluding common words from an ignore list. Given a list of words and a list of ignored words, return each word that appears more than once and is not ignored.

The result must contain each qualifying word exactly once, ordered by its first appearance in words. Matching is case-sensitive, so "Logo" and "logo" are different words.

Formal Specification

Implement find_repeated_words(words, ignore).

  • Input: words, a list of strings, and ignore, a list of strings.
  • Output: a list of strings containing every distinct word whose frequency in words is greater than one and whose value is not in ignore.
  • Preserve the order in which qualifying words first occur in words.

Constraints

  • 1 <= len(words) <= 10^5
  • 0 <= len(ignore) <= 10^5
  • Each word contains 1 to 50 case-sensitive characters
  • The output contains each qualifying word exactly once

Function Signature

def find_repeated_words(words, ignore):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output