FastPrepPhone Spam Report Counter
Problems/Phone Spam Report Counter

Phone Spam Report Counter

Pinterest logoPinterest● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Pinterest onsite interview. The report asks for a class that stores the spam-report state of phone numbers and answers count queries. It does not give the exact methods, what counts as the same event, the rules for how reports age, or a portable way to run it. This exercise uses a fixed list of report and count operations that keeps that state and the main ability.

Process a finite ordered sequence of operations for a phone spam-report counter.

  • REPORT phoneNumber records one new spam report for phoneNumber. Repeated reports are distinct events, so each operation increments that number's count by one.
  • COUNT phoneNumber returns the current number of reports for phoneNumber. A number that has not been reported returns 0.

Return the integer results of all COUNT operations in encounter order. A REPORT operation produces no result. There is no deletion or time window.

Function

countSpamReports(operations: String[]) → int[]

Examples

Example 1

operations = ["REPORT 4155550100","REPORT 4155550100","COUNT 4155550100","COUNT 2125550199"]return = [2,0]

The first number receives two reports. The second number has never been reported.

Example 2

operations = ["COUNT 7","REPORT 7","COUNT 7","REPORT 8","REPORT 7","COUNT 8","COUNT 7"]return = [0,1,1,2]

Counts are independent per phone number and reflect only preceding REPORT operations.

Example 3

operations = ["REPORT 999","COUNT 999","COUNT 999"]return = [1,1]

A count query does not mutate the stored count.

Constraints

  • 1 <= operations.length <= 100000.
  • Every operation is exactly REPORT phoneNumber or COUNT phoneNumber.
  • Every phoneNumber contains between 1 and 32 decimal digits.
  • The count for every phone number fits in a signed 32-bit integer.

More Pinterest Onsite Interview questions

  • Minimum Bus Routes to a DestinationPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Delete and Compact a Forest SubtreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Filter Pins by Excluded IDsONSITE INTERVIEW · Seen Oct 2026
  • Top-Scoring Items in a Time WindowONSITE INTERVIEW · Seen Oct 2026
  • Optimal Account BalancingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Escape Room LeaderboardPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Policy Violation Set ChecksONSITE INTERVIEW · Seen Sep 2026
  • Shortest Sequence of Source SubsequencesONSITE INTERVIEW · Seen Sep 2026
  • Insert Addition and Multiplication OperatorsONSITE INTERVIEW · Seen Sep 2026
  • Unique Active Pins by Time SegmentONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Basic In-Memory SpreadsheetGoogle · ONSITE INTERVIEWGoogle interview questions
  • Mutable Record Store with Error ResultsSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
  • Task Row ModificationsNotion · ONSITE INTERVIEWNotion interview questions
  • Card Transaction StreamCapital One · ONSITE INTERVIEWCapital One interview questions
  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions
  • Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • In-Memory Vault File SystemHarvey · ONSITE INTERVIEWHarvey interview questions

Pinterest interview experiences

  • Pinterest Experienced MLE Phone Screen: 1 Experience
All Pinterest interview questionsSee Pinterest hiring insights
Saved
class Solution {
    public int[] countSpamReports(String[] operations) {
        // Write your code here.
    }
}
Checking account…