Given a list of tokens and a list of stopwords, remove all tokens that appear in the stopword list.
Input: tokens = ["this", "is", "a", "test"], stopwords = ["is", "a"]
Output: ["this", "test"]
Input: tokens = ["hello", "world"], stopwords = ["the", "and"]
Output: ["hello", "world"]
Input: tokens = ["a", "an", "the"], stopwords = ["a", "an", "the"]
Output: []
Convert stopwords to a set for O(1) lookup, then filter tokens using list comprehension.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Given a list of tokens and a list of stopwords, remove all tokens that appear in the stopword list.
Input: tokens = ["this", "is", "a", "test"], stopwords = ["is", "a"]
Output: ["this", "test"]
Input: tokens = ["hello", "world"], stopwords = ["the", "and"]
Output: ["hello", "world"]
Input: tokens = ["a", "an", "the"], stopwords = ["a", "an", "the"]
Output: []
Convert stopwords to a set for O(1) lookup, then filter tokens using list comprehension.
Sign in to take notes on this problem
Accepts: array
Accepts: array