#925
Long Pressed Name
pupil · 515 · lc easy +28 · verified · 32.8% accepted · 2,588 likes · top 10%
Description
A friend types name on a keyboard, but some keys are held too long and emit extra repeated characters. Given the resulting string typed, return true if typed could have been produced by typing name with some characters accidentally long-pressed, or false otherwise.
Example 1:
Input: name = "alex", typed = "aaleex"
Output: true
Explanation: 'a' and 'e' in 'alex' were long pressed.
Example 2:
Input: name = "saeed", typed = "ssaaedd"
Output: false
Explanation: 'e' must have been pressed twice, but it was not in the typed output.
Code
1
2
3