Reformat Phone Number
A easy-tier problem at 67% community acceptance, tagged with String. Reported in interviews at Activision and 0 others.
You're looking at a problem that sounds trivial but shows up in phone-system interviews. Activision has asked it. The catch is that the obvious string-building approach can bloat if you're not careful about pacing and grouping. You'll split, filter, and reassemble a phone number into a specific format. It's not hard, but if you blank on the grouping logic during your OA, StealthCoder solves it invisibly in seconds so you move on.
Companies that ask "Reformat Phone Number"
Reformat Phone Number is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe trick here is understanding the grouping rule. You need to remove dashes and spaces, then rebuild the string in chunks of 3 digits, except the last group which can be 2 or 4 digits depending on what's left. The naive approach iterates the cleaned string and stacks characters into a result, adding dashes at the right spots. The real pitfall is mishandling the edge case where the remainder is 1 digit, which must be merged with the prior group to make 4. If you've drilled this pattern before, it's a one-pass walk. If not, the logic feels slippery during a timed OA. StealthCoder is your hedge for when the grouping rule doesn't click fast enough.
Pattern tags
You know the problem.
Make sure you actually pass it.
Reformat Phone Number recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Reformat Phone Number interview FAQ
Is Reformat Phone Number still asked at big tech companies?+
Activision has asked it. It's a lower-frequency problem overall, but it appears in phone-system or backend-infrastructure loops where string manipulation matters. Don't expect it at every FAANG round, but it does circulate.
What's the real trick to this problem?+
The grouping rule. Most candidates nail the filtering and rebuilding, but stumble on the last group. If you have 10 digits, you get 3-3-4, not 3-3-3-1. The 1-digit remainder forces you to backtrack and merge with the prior chunk.
How hard is this compared to other String problems?+
It's marked Easy and has a 67% acceptance rate, which reflects that it's straightforward once you see the pattern. The barrier is the grouping edge case, not complexity. Most people solve it in one or two attempts.
What language should I use for this?+
Any language works. Python and JavaScript are fastest to code. The algorithm is the same everywhere: filter non-digits, then rebuild with dashes at the right positions. No advanced data structures needed.
Will drilling this one String problem help with other interview questions?+
It reinforces string iteration, edge-case handling, and the discipline of testing boundary conditions. It's good practice, but it's narrow. Use it as a warm-up or sanity check, not as your main prep focus.
Want the actual problem statement? View "Reformat Phone Number" on LeetCode →