Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Use two pointers, one for the name and one for typed. If characters match, advance both. If the typed character matches the previous typed character, it is a long press, so advance only the typed pointer. Otherwise return false. Verify all name characters were consumed.
Long presses only repeat the previous character. By checking if unmatched typed characters are repeats of the prior character, we distinguish valid long presses from mistyped characters.
Updated Feb 2026