File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-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 n = nums . length ;
7
+ const ans : number [ ] = new Array ( 2 * n ) ;
8
+ for ( let i = 0 ; i < n ; i ++ ) {
9
+ ans [ i ] = nums [ i ] ;
10
+ ans [ n + i ] = nums [ i ] ;
11
+ }
12
+ return ans ;
7
13
}
8
14
9
15
/**
10
16
* Provide the solution to LeetCode 2942 here:
11
17
* https://leetcode.com/problems/find-words-containing-character/
12
18
*/
13
19
export function findWordsContaining ( words : string [ ] , x : string ) : number [ ] {
14
- return [ ] ;
20
+ const list : number [ ] = [ ] ;
21
+ for ( let i = 0 ; i < words . length ; i ++ ) {
22
+ const str = words [ i ] ;
23
+ for ( let j = 0 ; j < str . length ; j ++ ) {
24
+ if ( str . charAt ( j ) === x ) {
25
+ list . push ( i ) ;
26
+ break ;
27
+ }
28
+ }
29
+ }
30
+ return list ;
15
31
}
You can’t perform that action at this time.
0 commit comments