Skip to content

Commit 4605473

Browse files
committed
Add solution #925
1 parent 95f3439 commit 4605473

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
867|[Transpose Matrix](./0867-transpose-matrix.js)|Easy|
4040
890|[Find and Replace Pattern](./0890-find-and-replace-pattern.js)|Medium|
4141
916|[Word Subsets](./0916-word-subsets.js)|Medium|
42+
925|[Long Pressed Name](./0925-long-pressed-name.js)|Easy|
4243
929|[Unique Email Addresses](./0929-unique-email-addresses.js)|Easy|
4344
966|[Vowel Spellchecker](./0966-vowel-spellchecker.js)|Medium|
4445
970|[Powerful Integers](./0970-powerful-integers.js)|Easy|

solutions/0925-long-pressed-name.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* 925. Long Pressed Name
3+
* https://leetcode.com/problems/long-pressed-name/
4+
* Difficulty: Easy
5+
*
6+
* Your friend is typing his name into a keyboard. Sometimes, when typing a character c,
7+
* the key might get long pressed, and the character will be typed 1 or more times.
8+
*
9+
* You examine the typed characters of the keyboard. Return True if it is possible that
10+
* it was your friends name, with some characters (possibly none) being long pressed.
11+
*/
12+
13+
/**
14+
* @param {string} name
15+
* @param {string} typed
16+
* @return {boolean}
17+
*/
18+
var isLongPressedName = function(name, typed) {
19+
let i = 0;
20+
return typed.split('').filter(l => name[i] === l ? ++i : false).length === name.length;
21+
};

0 commit comments

Comments
 (0)