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 44* https://leetcode.com/problems/concatenation-of-array
55*/
66export 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 ) ;
911
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 ;
1517}
1618
17-
1819/**
1920* Provide the solution to LeetCode 2942 here:
2021* https://leetcode.com/problems/find-words-containing-character/
2122*/
2223export function findWordsContaining ( words : string [ ] , x : string ) : number [ ] {
2324 //creates a new array list names arrList
24- const arrList : number [ ] = [ ]
25+ const arrList : number [ ] = [ ] ;
2526
2627 //Runs a loop that will iterate through each character in the String.
2728 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 ) ;
3033 }
31- } return arrList ; //Will return the Array elListo
34+ //Will return the Array list arrList
35+ } return arrList ;
3236}
3337
You can’t perform that action at this time.
0 commit comments