Skip to content

Commit a2067f1

Browse files
committed
feat: implement array concatenation and word search functions
1 parent 7b3bd25 commit a2067f1

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

lesson_11/arrays_ts/src/lesson11.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,27 @@
33
* https://leetcode.com/problems/concatenation-of-array
44
*/
55
export function getConcatenation(nums: number[]): number[] {
6-
return [];
7-
}
6+
const answer: number[] = new Array(nums.length * 2);
7+
8+
for (let i = 0; i < nums.length; i++) {
9+
answer[i] = nums[i];
10+
answer[i + nums.length] = nums[i];
11+
}
812

13+
return answer;
14+
}
915
/**
1016
* Provide the solution to LeetCode 2942 here:
1117
* https://leetcode.com/problems/find-words-containing-character/
1218
*/
1319
export function findWordsContaining(words: string[], x: string): number[] {
14-
return [];
20+
const result: number[] = [];
21+
22+
for (let i = 0; i < words.length; i++) {
23+
if (words[i].includes(x)) {
24+
result.push(i);
25+
}
26+
}
27+
28+
return result;
1529
}

0 commit comments

Comments
 (0)