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.
- LRU Cache with TTL ExpirationONSITE INTERVIEW · Seen May 2026
- Maximum Candies with At Most Two Types in a LineONSITE INTERVIEW · Seen May 2026
- Top-K KOLs by Total LikesONSITE INTERVIEW · Seen May 2026
- Compute Walking DistanceSeen Mar 2026
- Count Sawtooth SubarraysSeen Mar 2026
- Format TextSeen Mar 2026
- Memory AllocatorSeen Mar 2026
- TikTok Shopping SpreeSeen Mar 2025
public String[] getSpamComments(String[] comments, String[] spam_keywords) {
// write your code here
}