- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNo925.java
23 lines (22 loc) · 512 Bytes
/
No925.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
packageAlgorithm.leetcode.String;
/**
*
* Created by tujietg on Oct 23, 2019
*/
publicclassNo925 {
publicbooleanisLongPressedName(Stringname, Stringtyped) {
char[] nameChar = name.toCharArray();
char[] typedChar = typed.toCharArray();
inti = 0;
for (intk = 0; k < typed.length(); k++) {
if (i < name.length() && nameChar[i] == typedChar[k]) {
i++;
} else {
if (k == 0 || typedChar[k] != typedChar[k - 1]) {
returnfalse;
}
}
}
returni == name.length();
}
}