Skip to content

Commit 3458800

Browse files
author
Ezra Nyabuti
committed
feat: implement getConcatenation and findWordsContaining functions
1 parent a6ce0c9 commit 3458800

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lesson_11/arrays_ts/src/lesson11.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,25 @@
33
* https://leetcode.com/problems/concatenation-of-array
44
*/
55
export function getConcatenation(nums: number[]): number[] {
6-
return [];
6+
if (nums.length === 0) return [];
7+
const result = [...nums];
8+
for (const num of nums) {
9+
result.push(num);
10+
}
11+
return result;
712
}
813

914
/**
1015
* Provide the solution to LeetCode 2942 here:
1116
* https://leetcode.com/problems/find-words-containing-character/
1217
*/
1318
export function findWordsContaining(words: string[], x: string): number[] {
14-
return [];
19+
if (words.length === 0) return [];
20+
const result = [];
21+
for (let i = 0; i < words.length; i++) {
22+
if (words[i].includes(x)) {
23+
result.push(i);
24+
}
25+
}
26+
return result;
1527
}

0 commit comments

Comments
 (0)