Skip to content

Commit 4e5a1e1

Browse files
committed
feat: modifies lesson11.ts to write code for leetcode coding prompt for extra credit -Joseph Caballero
1 parent 10d76bc commit 4e5a1e1

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

lesson_11/arrays_ts/src/lesson11.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,28 @@
33
* https://leetcode.com/problems/concatenation-of-array
44
*/
55
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;
714
}
815

916
/**
1017
* Provide the solution to LeetCode 2942 here:
1118
* https://leetcode.com/problems/find-words-containing-character/
1219
*/
1320
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;
1530
}

0 commit comments

Comments
 (0)