Phone Spam Report Counter
Updated
Problem statement
Process a finite ordered sequence of operations for a phone spam-report counter.
REPORT phoneNumberrecords one new spam report forphoneNumber. Repeated reports are distinct events, so each operation increments that number's count by one.COUNT phoneNumberreturns the current number of reports forphoneNumber. A number that has not been reported returns0.
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 phoneNumberorCOUNT phoneNumber. - Every
phoneNumbercontains between1and32decimal 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