File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 372
372
2114|[ Maximum Number of Words Found in Sentences] ( ./2114-maximum-number-of-words-found-in-sentences.js ) |Easy|
373
373
2129|[ Capitalize the Title] ( ./2129-capitalize-the-title.js ) |Easy|
374
374
2154|[ Keep Multiplying Found Values by Two] ( ./2154-keep-multiplying-found-values-by-two.js ) |Easy|
375
+ 2185|[ Counting Words With a Given Prefix] ( ./2185-counting-words-with-a-given-prefix.js ) |Easy|
375
376
2215|[ Find the Difference of Two Arrays] ( ./2215-find-the-difference-of-two-arrays.js ) |Easy|
376
377
2235|[ Add Two Integers] ( ./2235-add-two-integers.js ) |Easy|
377
378
2244|[ Minimum Rounds to Complete All Tasks] ( ./2244-minimum-rounds-to-complete-all-tasks.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 2185. Counting Words With a Given Prefix
3
+ * https://leetcode.com/problems/counting-words-with-a-given-prefix/
4
+ * Difficulty: Easy
5
+ *
6
+ * You are given an array of strings words and a string pref.
7
+ *
8
+ * Return the number of strings in words that contain pref as a prefix.
9
+ *
10
+ * A prefix of a string s is any leading contiguous substring of s.
11
+ */
12
+
13
+ /**
14
+ * @param {string[] } words
15
+ * @param {string } pref
16
+ * @return {number }
17
+ */
18
+ var prefixCount = function ( words , pref ) {
19
+ return words . filter ( word => word . startsWith ( pref ) ) . length ;
20
+ } ;
You can’t perform that action at this time.
0 commit comments