Reported February 2025
TikTokhash table

Change Username

Reported by candidates from TikTok's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live TikTok OA. Under 2s to a working solution.
Founder's read

TikTok's 'Change Username' problem hits different when you're live on the OA. It sounds simple on the surface, but there's almost always a constraint twist that catches candidates off guard. You're not just validating or swapping strings here. The real test is handling the state change correctly, managing what's already taken, and avoiding race conditions or duplicate logic. StealthCoder sits in the background as your safety net if the edge cases blank your mind during the actual assessment.

Pattern and pitfall

This problem typically boils down to three things: validation (is the new username legal?), availability (is it already claimed?), and persistence (does the old name become free again?). The trick most candidates miss is the order of operations. You can't check availability and then update without atomicity concerns, and you can't just swap pointers without considering what happens to the old username in the system's namespace. The pattern is usually a hash-table lookup paired with careful state management. Common pitfall: assuming usernames are unique globally without checking if the same user already owns it, or forgetting that a successful change must free the old name back into the pool. StealthCoder can surface the exact validation rules and state-change sequence in real time if you freeze up.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Change Username 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass TikTok's OA.

TikTok reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Change Username FAQ

Is this a string manipulation problem or a system design one?+

It's mostly validation and state management. You'll need a hash-table (or map) to track username ownership, but the heavy lifting is ensuring the old username is properly released and the new one is locked atomically. Not a pure string problem.

What's the catch with TikTok's version?+

TikTok likely cares about whether a user can reserve their old name again immediately after changing, or if there's a cooldown. Also watch for whether multiple users in the test can collide on the same desired new username. The OA usually bakes in one scenario like this.

Can I just overwrite the username in the user object?+

Not safely. You need to first validate the new name isn't taken, then atomically remove the old mapping and add the new one. If you overwrite first, another request could sneak in and claim the old name, breaking consistency.

How do I spot the edge case in 30 seconds?+

Ask yourself: what if two users try to change to the same new username simultaneously? What if a user tries to change to a name they already have? What if the new name is taken by an admin or reserved? One of these is probably tested.

Should I write a full user database schema or just the username logic?+

Check the problem text carefully. If it's marked as a system design or backend question, you may need a User class or storage layer. If it's algorithmic, focus on the validation and state-change logic with a mock namespace.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with TikTok.

OA at TikTok?
Invisible during screen share
Get it