Spam Classification

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.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: