Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita486fcc

Browse files
committed
Add solution #2942
1 parent8e036a2 commita486fcc

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

‎README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#1,965 LeetCode solutions in JavaScript
1+
#1,966 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1932,6 +1932,7 @@
19321932
2900|[Longest Unequal Adjacent Groups Subsequence I](./solutions/2900-longest-unequal-adjacent-groups-subsequence-i.js)|Easy|
19331933
2901|[Longest Unequal Adjacent Groups Subsequence II](./solutions/2901-longest-unequal-adjacent-groups-subsequence-ii.js)|Medium|
19341934
2918|[Minimum Equal Sum of Two Arrays After Replacing Zeros](./solutions/2918-minimum-equal-sum-of-two-arrays-after-replacing-zeros.js)|Medium|
1935+
2942|[Find Words Containing Character](./solutions/2942-find-words-containing-character.js)|Easy|
19351936
2948|[Make Lexicographically Smallest Array by Swapping Elements](./solutions/2948-make-lexicographically-smallest-array-by-swapping-elements.js)|Medium|
19361937
2962|[Count Subarrays Where Max Element Appears at Least K Times](./solutions/2962-count-subarrays-where-max-element-appears-at-least-k-times.js)|Medium|
19371938
2965|[Find Missing and Repeated Values](./solutions/2965-find-missing-and-repeated-values.js)|Easy|
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* 2942. Find Words Containing Character
3+
* https://leetcode.com/problems/find-words-containing-character/
4+
* Difficulty: Easy
5+
*
6+
* You are given a 0-indexed array of strings words and a character x.
7+
*
8+
* Return an array of indices representing the words that contain the character x.
9+
*
10+
* Note that the returned array may be in any order.
11+
*/
12+
13+
/**
14+
*@param {string[]} words
15+
*@param {character} x
16+
*@return {number[]}
17+
*/
18+
varfindWordsContaining=function(words,x){
19+
constresult=[];
20+
21+
for(leti=0;i<words.length;i++){
22+
if(words[i].includes(x)){
23+
result.push(i);
24+
}
25+
}
26+
27+
returnresult;
28+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp