Phone Spam Report Counter
Reported by candidates from Pinterest's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Pinterest reported this one in August 2026, and the trap is smaller than you'd think. It looks like a freebie: a hash map, REPORT increments, COUNT reads. But the edge case that breaks a naive solution is hiding in the input, and it costs people the clean pass. If you've got an OA invite for the next couple of days, read this first. The pattern is hash-table counting. The work is in the details, not the algorithm. And if you blank mid-assessment, StealthCoder runs invisibly on your desktop as a safety net and hands you the solution in real time.
The problem
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.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is a map from phone number string to integer count. REPORT does count[num] += 1. COUNT appends count.get(num, 0) to the result list and changes nothing. That's the whole algorithm, O(n) over up to 100000 operations. The pitfall is the key type. Phone numbers can be up to 32 digits, so parsing them into a 32-bit or even 64-bit integer will overflow or collide. Leading zeros matter too, so "007" and "7" are different numbers. Keep the key as a string. Split each operation on the first space only. Second pitfall: a COUNT on an unseen number must return 0 without inserting a key, or at least must not crash on a missing key. Third, don't emit anything for REPORT. If you freeze on the parsing details during the live OA, StealthCoder is the hedge that shows you the clean version.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Phone Spam Report Counter cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Pinterest's OA.
Pinterest reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Phone Spam Report Counter FAQ
How hard is the Phone Spam Report Counter really?+
Easy. It's a hash map counter with string parsing. The difficulty is carefulness, not insight. Most failures come from treating phone numbers as integers or from emitting output for REPORT operations. If you write it cleanly the first time, you're done in minutes.
What's the trick to this Pinterest OA question?+
Use the phone number as a string key, never an integer. Numbers can have 32 digits, so they overflow native integer types, and leading zeros would be lost. Then increment on REPORT and read with a default of 0 on COUNT.
Does COUNT change the stored count?+
No. Example 3 shows two COUNT calls on 999 both returning 1. COUNT is a pure read. Use a get with a default of 0 so unreported numbers return 0 and don't need an entry created.
What's the time complexity and will it pass 100000 operations?+
Each operation is one hash lookup or update, so total time is O(n) with O(k) space for k distinct numbers. That's well within limits for 100000 operations. Splitting each string is cheap since numbers are at most 32 characters.
How do I prepare for this in 48 hours?+
Practice the hash map counter pattern in your language of choice until the default-value lookup is automatic. Then write a quick parser for command strings and test with leading zeros, an empty result list, and only COUNT operations.