Skip to content

Commit 343a757

Browse files
committed
feat: added work into lesson 11
1 parent 5c28980 commit 343a757

File tree

2 files changed

+39
-18
lines changed

2 files changed

+39
-18
lines changed
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
package com.codedifferently.lesson11;
22

3+
import java.util.ArrayList;
34
import java.util.List;
45

56
public class Lesson11 {
67

7-
/**
8-
* Provide the solution to LeetCode 1929 here:
9-
* https://leetcode.com/problems/concatenation-of-array
10-
*/
118
public int[] getConcatenation(int[] nums) {
12-
return null;
9+
int answer[] = new int[nums.length * 2];
10+
for (int i = 0; i < nums.length; i++) {
11+
answer[i] = nums[i];
12+
answer[i + nums.length] = nums[i];
13+
}
14+
return answer;
1315
}
1416

15-
/**
16-
* Provide the solution to LeetCode 2942 here:
17-
* https://leetcode.com/problems/find-words-containing-character/
18-
*/
1917
public List<Integer> findWordsContaining(String[] words, char x) {
20-
return null;
18+
var result = new ArrayList<Integer>();
19+
for (int i = 0; i < words.length; i++) {
20+
if (words[i].contains(String.valueOf(x))) {
21+
result.add(i);
22+
}
23+
}
24+
return result;
2125
}
2226
}

lesson_11/arrays_ts/src/lesson11.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
1-
/**
2-
* Provide the solution to LeetCode 1929 here:
3-
* https://leetcode.com/problems/concatenation-of-array
4-
*/
1+
52
export function getConcatenation(nums: number[]): number[] {
6-
return [];
7-
}
3+
if (nums.length === 0) {
4+
return [];
5+
}
6+
const result = [...nums];
7+
for (const num of nums) {
8+
result.push(num);
9+
}
10+
return result;
11+
}
12+
13+
14+
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 [];
15-
}
21+
if (words.length === 0) {
22+
return [];
23+
}
24+
const result = [];
25+
for (let i = 0; i < words.length; i++) {
26+
if (words[i].includes(x)) {
27+
result.push(i);
28+
}
29+
}
30+
return result;
31+
}
32+
//Received help from copiliot and Meiko and Bryana.

0 commit comments

Comments
 (0)