This is a verified interview question from Hackerrank. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Spam Detection" covers key patterns like Strings.
"You are given : - A list of spam words - A list of email subjects An email is classified as spam if: - Repeated spam words count individually (e.g., 'free free' counts as 2) - Its subject contains at least two spam words - Matching is not case-sensitive For each subject, return: - 'not_spam' otherwise - 'spam' if it contains 2 or more spam words ### Example Suppose subjects = ['free prize worth millions', 'ten tips for a carefree lifestyle'], and spamWords = ['free', 'money', 'win', 'millions']. Output: ['spam', 'not_spam'] ### Explanation: - 'free prize worth millions' contains 'free' and 'millions' (2 spam words) -> 'spam' - 'ten tips for a carefree lifestyle' contains no spam words -> 'not_spam'"
Join thousands of developers practicing for Hackerrank.