Problem Brief
Spam Classification
FULLTIMEOA
For MTS role.
You are given a list of texts and a list of spam words. Classify each text as "spam" if it contains at least 2 spam words, and "not spam" otherwise. Spam words and texts are case-insensitive.
Approach "I" used: Converted spamWords to lowercase and stored in a HashSet. Iterated through each text, split it into words, normalized them to lowercase, and counted how many match spam words. Marked it as "spam" if the count was 2 or more.
Edge Case: Spam words can repeat, and each occurrence must be counted.
1Example 1
Input
texts = ["Free prize worth millions", "Ten tips for a carefree lifestyle"], spamWords = ["free", "money", "win", "millions"]
Output
["spam", "not_spam"]
Explanation
:)