File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 3
3
* https://leetcode.com/problems/concatenation-of-array
4
4
*/
5
5
export function getConcatenation ( nums : number [ ] ) : number [ ] {
6
- return [ ] ;
6
+ const ans : number [ ] = [ ] ;
7
+ for ( const num of nums ) {
8
+ ans . push ( num ) ;
9
+ }
10
+ for ( const num of nums ) {
11
+ ans . push ( num ) ;
12
+ }
13
+ return ans ;
7
14
}
8
15
9
16
/**
10
17
* Provide the solution to LeetCode 2942 here:
11
18
* https://leetcode.com/problems/find-words-containing-character/
12
19
*/
13
20
export function findWordsContaining ( words : string [ ] , x : string ) : number [ ] {
14
- return [ ] ;
21
+ const num : number [ ] = [ ] ;
22
+ for ( const word of words ) {
23
+ const wordArr = word . split ( '' ) ;
24
+ const containsX = wordArr . some ( ( char ) => x . includes ( char ) ) ;
25
+ if ( containsX ) {
26
+ num . push ( words . indexOf ( word ) ) ;
27
+ }
28
+ }
29
+ return num ;
15
30
}
You can’t perform that action at this time.
0 commit comments