TensorTonicTensorTonic
Problems
Study PlansProjectsNewInterviewPricingFeedback
Problems
Loading...
1 / 1

Remove Stopwords

Data ProcessingNLP
Easy

Remove every token that appears in stopwords. Comparisons are case-sensitive, and retained tokens must remain in their original order. Return a new list without modifying either input.

Loading visualization...

Examples

Input: tokens = ["this", "is", "a", "test"], stopwords = ["is", "a"]

Output: ["this", "test"]

Explanation: The two matching stopwords are removed while the remaining order is preserved.

Input: tokens = ["hello", "world"], stopwords = ["the", "and"]

Output: ["hello", "world"]

Input: tokens = ["a", "an", "the"], stopwords = ["a", "an", "the"]

Output: []

Hint 1

Build blocked = set(stopwords) before scanning the tokens.

Hint 2

Filter with [token for token in tokens if token not in blocked].

Requirements

  • Convert stopwords to a set for membership checks
  • Preserve the order and duplicates of retained tokens
  • Treat uppercase and lowercase tokens as different
  • Return a new list

Constraints

  • tokens and stopwords are lists of strings
  • Use Python only
Try Similar Problems
Text ChunkingWord Count DictBag Of WordsEdit DistancePad Sequences

Sign in to take notes on this problem

Case 1
Case 2
Case 3

Accepts: array

Accepts: array

You must run your code first.
PrevNext

Remove Stopwords

Data ProcessingNLP
Easy

Remove every token that appears in stopwords. Comparisons are case-sensitive, and retained tokens must remain in their original order. Return a new list without modifying either input.

Loading visualization...

Examples

Input: tokens = ["this", "is", "a", "test"], stopwords = ["is", "a"]

Output: ["this", "test"]

Explanation: The two matching stopwords are removed while the remaining order is preserved.

Input: tokens = ["hello", "world"], stopwords = ["the", "and"]

Output: ["hello", "world"]

Input: tokens = ["a", "an", "the"], stopwords = ["a", "an", "the"]

Output: []

Hint 1

Build blocked = set(stopwords) before scanning the tokens.

Hint 2

Filter with [token for token in tokens if token not in blocked].

Requirements

  • Convert stopwords to a set for membership checks
  • Preserve the order and duplicates of retained tokens
  • Treat uppercase and lowercase tokens as different
  • Return a new list

Constraints

  • tokens and stopwords are lists of strings
  • Use Python only
Try Similar Problems
Text ChunkingWord Count DictBag Of WordsEdit DistancePad Sequences

Sign in to take notes on this problem

Case 1
Case 2
Case 3

Accepts: array

Accepts: array

You must run your code first.