Skip to content

Commit e80baf4

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

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed
Lines changed: 14 additions & 2 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,25 @@ public class Lesson11 {
910
* https://leetcode.com/problems/concatenation-of-array
1011
*/
1112
public int[] getConcatenation(int[] nums) {
12-
return null;
13+
int answer[] = new int[nums.length * 2];
14+
for (int i = 0; i < nums.length; i++) {
15+
answer[i] = nums[i];
16+
answer[i + nums.length] = nums[i];
17+
}
18+
return answer;
1319
}
1420

1521
/**
1622
* Provide the solution to LeetCode 2942 here:
1723
* https://leetcode.com/problems/find-words-containing-character/
1824
*/
1925
public List<Integer> findWordsContaining(String[] words, char x) {
20-
return null;
26+
List<Integer> result = new ArrayList<>();
27+
for (int i = 0; i < words.length; i++) {
28+
if (words[i].indexOf(x) != -1) {
29+
result.add(i);
30+
}
31+
}
32+
return result;
2133
}
2234
}

lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lesson_11/arrays_java/package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lesson_11/package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)