FastPrepSpam Classification
Problems/Spam Classification

Spam Classification

Salesforce logoSalesforce● EasyFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamples

Problem statement

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.

Function

classifyTexts(texts: String[], spamWords: String[]) → String[]

Examples

Example 1

texts = ["Free prize worth millions", "Ten tips for a carefree lifestyle"]spamWords = ["free", "money", "win", "millions"]return = ["spam", "not_spam"]

:)

More Salesforce interview questions

  • Count Subarrays With Product Equal to KOA · Seen Dec 2026
  • Get Minimum TimeOA · Seen Nov 2026
  • Count Increasing TripletsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Reverse a Sublist of a Linked ListONSITE INTERVIEW · Seen Nov 2026
  • Rotting OrangesONSITE INTERVIEW · Seen Nov 2026
  • 3Sum SmallerONSITE INTERVIEW · Seen Nov 2026
  • Count Zero Request ServersONSITE INTERVIEW · Seen Nov 2026
  • Minimum No-Repeat Segments After One Character RemovalOA · Seen Nov 2026
  • Get Message StatusOA · Seen Nov 2026

Similar questions at other companies

  • Branch with the Most FilesCapital One · OACapital One interview questions
  • Count User Mentions in Chat MessagesRamp · OARamp interview questions
  • First Non-Repeating CharacterAmazon · OA · ONSITE INTERVIEW
  • Total Each Letter's Count in an Encoded StringIBM · OAIBM interview questions
  • Find Words That Can Be Formed by CharactersTabaPay · OA
  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • Count Palindrome Addition ChoicesThe D.E. Shaw Group · OAThe D.E. Shaw Group interview questions
  • Count Palindrome Addition ChoicesHudson River Trading · OAHudson River Trading interview questions
  • Count Phrases Formed by Anagram ReplacementWells Fargo · OAWells Fargo interview questions
  • Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions

Salesforce interview experiences

  • Salesforce Infrastructure SWE OA and Onsite: 1 Experience
  • Salesforce Experienced Backend SWE First Round: 1 Experience
All Salesforce interview questionsSee Salesforce hiring insights
Saved
class Solution {
    public String[] classifyTexts(String[] texts, String[] spamWords) {
      // write your code here
    }

}
Checking account…