Skip to content

Commit d712d7b

Browse files
committed
Add solution #1023
1 parent 349714e commit d712d7b

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
@@ -299,6 +299,7 @@
299299
1009|[Complement of Base 10 Integer](./1009-complement-of-base-10-integer.js)|Easy|
300300
1010|[Pairs of Songs With Total Durations Divisible by 60](./1010-pairs-of-songs-with-total-durations-divisible-by-60.js)|Medium|
301301
1022|[Sum of Root To Leaf Binary Numbers](./1022-sum-of-root-to-leaf-binary-numbers.js)|Easy|
302+
1023|[Camelcase Matching](./1023-camelcase-matching.js)|Medium|
302303
1037|[Valid Boomerang](./1037-valid-boomerang.js)|Easy|
303304
1041|[Robot Bounded In Circle](./1041-robot-bounded-in-circle.js)|Medium|
304305
1047|[Remove All Adjacent Duplicates In String](./1047-remove-all-adjacent-duplicates-in-string.js)|Easy|

solutions/1023-camelcase-matching.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* 1023. Camelcase Matching
3+
* https://leetcode.com/problems/camelcase-matching/
4+
* Difficulty: Medium
5+
*
6+
* Given an array of strings queries and a string pattern, return a boolean array answer
7+
* where answer[i] is true if queries[i] matches pattern, and false otherwise.
8+
*
9+
* A query word queries[i] matches pattern if you can insert lowercase English letters
10+
* pattern so that it equals the query. You may insert each character at any position
11+
* and you may not insert any characters.
12+
*/
13+
14+
/**
15+
* @param {string[]} queries
16+
* @param {string} pattern
17+
* @return {boolean[]}
18+
*/
19+
var camelMatch = function(queries, pattern) {
20+
return queries.map(s => s.match(pattern.split(/(.)/).join('[a-z]*'))?.at(0) === s);
21+
};

0 commit comments

Comments
 (0)