FastPrepClassify Reviews by Sentiment Word Occurrences
Problems/Classify Reviews by Sentiment Word Occurrences

Classify Reviews by Sentiment Word Occurrences

ZipRecruiter logoZipRecruiter● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes review strings, positive and negative word lists, whole-word matching split on spaces, repeated occurrences, and a positive, negative or neutral comparison. We supplied case, punctuation, overlap, and the casing of the output. Our version is about 92% the same as the reported question.

For every review, split on whitespace and count all token occurrences found in positiveWords and negativeWords. Repeated tokens count repeatedly. Matching is case-sensitive and punctuation remains part of a token.

Return positive when the positive count is greater, negative when it is smaller, and neutral when the counts are equal. A token present in both lexicons contributes to both counts.

Function

classifyReviews(reviews: String[], positiveWords: String[], negativeWords: String[]) → String[]

Examples

Example 1

reviews = ["good good bad","bad","plain"]positiveWords = ["good"]negativeWords = ["bad"]return = ["positive","negative","neutral"]

The batch contains positive, negative, and neutral reviews.

Example 2

reviews = ["great great poor"]positiveWords = ["great"]negativeWords = ["poor"]return = ["positive"]

Every matching occurrence contributes.

Constraints

  • 0 <= reviews.length <= 10000
  • The total input text length is at most 200000.

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

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

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public String[] classifyReviews(String[] reviews, String[] positiveWords, String[] negativeWords) {
        // Write your code here.
    }

}
Checking account…