File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change 4
4
* https://leetcode.com/problems/concatenation-of-array
5
5
*/
6
6
export function getConcatenation ( nums : number [ ] ) : number [ ] {
7
- const n = nums . length ; //Creates a variable named n that is the length of nums
8
- const ans = new Array ( 2 * n ) ; //Creates a new array that is double the size of n
7
+ //Creates a variable named n that is the length of nums
8
+ const n = nums . length ;
9
+ //Creates a new array that is double the size of n
10
+ const ans = new Array ( 2 * n ) ;
9
11
10
- for ( let i = 0 ; i < n ; ++ i ) {
11
- ans [ i ] = nums [ i ] ;
12
- ans [ i + n ] = nums [ i ] ;
13
- }
14
- return ans ;
12
+ for ( let i = 0 ; i < n ; ++ i ) {
13
+ ans [ i ] = nums [ i ] ;
14
+ ans [ i + n ] = nums [ i ] ;
15
+ }
16
+ return ans ;
15
17
}
16
18
17
-
18
19
/**
19
20
* Provide the solution to LeetCode 2942 here:
20
21
* https://leetcode.com/problems/find-words-containing-character/
21
22
*/
22
23
export function findWordsContaining ( words : string [ ] , x : string ) : number [ ] {
23
24
//creates a new array list names arrList
24
- const arrList : number [ ] = [ ]
25
+ const arrList : number [ ] = [ ] ;
25
26
26
27
//Runs a loop that will iterate through each character in the String.
27
28
for ( let i = 0 ; i < words . length ; ++ i ) {
28
- if ( words [ i ] . includes ( x ) ) { //Checks to see if the word inclues the char 'x'
29
- arrList . push ( i ) ; //Pushes the index of i if it is true that the word contains that character
29
+ //Checks to see if the word inclues the char 'x'
30
+ if ( words [ i ] . includes ( x ) ) {
31
+ //Pushes the index of i if it is true that the word contains that character
32
+ arrList . push ( i ) ;
30
33
}
31
- } return arrList ; //Will return the Array elListo
34
+ //Will return the Array list arrList
35
+ } return arrList ;
32
36
}
33
37
You can’t perform that action at this time.
0 commit comments