TikTok Content Moderation Team is working to help creators manage their video comments effectively, ensuring a positive environment by identifying spammy behavior in the comments section.
You have a total of n videos and k keywords that you want to monitor for spammy behavior in the comments. The comments are collected in an array called comments, while the keywords that indicate spammy behavior are stored in another array called spam_keywords.
A comment is flagged as spam if it contains at least two instances of the keywords in the spam_keywords array.
Your task is to analyze the comments for each video and return an array of n strings, labeling each comment as either "spam" or "not_spam" based on the presence of the keywords.
Note: If a keyword appears multiple times in a comment, each occurrence counts toward the spam threshold. Also note that, keyword matching should be case-insensitive.
Complete the function getSpamComments in the editor.
getSpamComments takes the following arguments:
- 1.
string comments[n]: an array of strings representing comments on TikTok videos - 2.
string spam_keywords[n]: an array of strings containing keywords that signify spammy behavior
Returns
string[n]: the results of spam detection
comments = ["viral tricks to boost", "Great viral tips", "boost views and go viral"] spam_keywords = ["viral", "boost"] return = ["spam", "not_spam", "spam"]

comments = ["The sun is bright", "Blockbuster bonanza"] spam_keywords = ["bright", "bonanza", "paid"] return = ["not_spam", "not_spam"]
- 1 ≤ n ≤ 10^3
- 1 ≤ k ≤ 10^5
- 1 ≤ |comments[i]| ≤ 10^5
- 1 ≤ |spam_keywords[i]| ≤ 10^5
- It is guaranteed that the sentences and search words consist of lowercase and uppercase English letters and spaces only.
- Count Cyclic Digit PairsOA · Seen Jun 2026
- Count Skipped Numbers After SubtractionsOA · Seen Jun 2026
- Event ID Check Completion TimesOA · Seen Jun 2026
- Check Even-Position MonotonicityOA · Seen Jun 2026
- Count Alternating Tile GroupsOA · Seen Jun 2026
- Count Even-Digit NumbersOA · Seen Jun 2026
- Inventory Discount TrackerOA · Seen Jun 2026
- Construct WDL StringOA · Seen Jun 2026
public String[] getSpamComments(String[] comments, String[] spam_keywords) {
// write your code here
}