Problem
Spam Text Classification
Learn this problemProblem statement
A classification system evaluates whether each text is spam using a list of spam words.
A text is labeled "spam" if it contains at least two spam-word occurrences. Each occurrence of a spam word counts toward the total, and matching is case-sensitive.
Given an array texts and an array spamWords, return an array where each element is either "spam" or "not_spam" for the corresponding text.
Function
classifyTexts(texts: String[], spamWords: String[]) → String[]Examples
Example 1
texts = ["This is a limited offer just for you","Win cash now! Click here to claim your prize","Hello friend, just checking in","Congratulations! You have won a free gift"]spamWords = ["offer","cash","Click","prize","Congratulations","free"]return = ["not_spam","spam","not_spam","spam"]The first and third texts contain fewer than two spam-word occurrences. The second and fourth texts contain at least two.
Constraints
1 <= texts.length <= 10^31 <= spamWords.length <= 10^51 <= text.length <= 10^51 <= spamWord.length <= 10^5- The combined length of all spam words is at most
10^7.