Skip to content

Commit 20b1302

Browse files
committed
feat: generated Java and TS solutions for lesson 11 Leet Code Problems
1 parent 8ee965f commit 20b1302

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.codedifferently.lesson11;
22

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

56
public class Lesson11 {
@@ -9,14 +10,22 @@ public class Lesson11 {
910
* https://leetcode.com/problems/concatenation-of-array
1011
*/
1112
public int[] getConcatenation(int[] nums) {
12-
return null;
13+
int[] ans = new int[nums.length * 2];
14+
System.arraycopy(nums, 0, ans, 0, nums.length);
15+
System.arraycopy(nums, 0, ans, nums.length, nums.length);
16+
return ans;
1317
}
1418

1519
/**
1620
* Provide the solution to LeetCode 2942 here:
1721
* https://leetcode.com/problems/find-words-containing-character/
1822
*/
1923
public List<Integer> findWordsContaining(String[] words, char x) {
20-
return null;
24+
List<Integer> output = new ArrayList();
25+
for (int i = 0; i < words.length; i++) {
26+
if (words[i].contains(String.valueOf(x))) {
27+
output.add(i);
28+
}
29+
} return output;
30+
}
2131
}
22-
}

lesson_11/arrays_ts/src/lesson11.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33
* https://leetcode.com/problems/concatenation-of-array
44
*/
55
export function getConcatenation(nums: number[]): number[] {
6-
return [];
6+
let ans: number[] = [...nums, ...nums];
7+
return ans;
78
}
89

910
/**
1011
* Provide the solution to LeetCode 2942 here:
1112
* https://leetcode.com/problems/find-words-containing-character/
1213
*/
1314
export function findWordsContaining(words: string[], x: string): number[] {
14-
return [];
15+
let output: number[] = [];
16+
for (let i = 0; i < words.length; i++) {
17+
if (words[i].includes(x)) {
18+
output.push(i);
19+
}
20+
}
21+
return output;
1522
}

0 commit comments

Comments
 (0)