Skip to content

Commit 09defcc

Browse files
authored
Create 925-long-pressed-name.js
1 parent 07bd618 commit 09defcc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

925-long-pressed-name.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {string} name
3+
* @param {string} typed
4+
* @return {boolean}
5+
*/
6+
const isLongPressedName = function(name, typed) {
7+
let i = 0, m = name.length, n = typed.length
8+
for(let j = 0; j < n; j++) {
9+
if(i < m && name[i] === typed[j]) i++
10+
else if(j === 0 || typed[j] !== typed[j - 1]) return false
11+
}
12+
return i === m
13+
};

0 commit comments

Comments
 (0)