Stuck Keyboard
You are given two strings typed
and target
. You want to write target
, but the keyboard is stuck so some characters may be written 1
or more times. Return whether it’s possible that typed
was meant to write target
.
Constraints
n ≤ 100,000
wheren
is the length oftyped
m ≤ 100,000
wheren
is the length ofs
https://binarysearch.com/problems/Stuck-Keyboard
Examples
Example 1
Input
- typed =
aaabcccc
- target =
abc
Output
- answer =
True
Explanation
Each of the "a"
, "b"
, and "c"
were typed
Example 2
Input
- typed =
abc
- target =
ab
Output
- answer =
False
Explanation
"c"
was not typed
Leave a comment