Skip to content

Commit 71dd5aa

Browse files
committed
Refactor: Fixed code formatting and the comments for lesson11.ts
1 parent 6c5e88b commit 71dd5aa

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

lesson_11/arrays_ts/src/lesson11.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,34 @@
44
* https://leetcode.com/problems/concatenation-of-array
55
*/
66
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);
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
*/
2223
export 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

0 commit comments

Comments
 (0)