Skip to content

Commit f1ff464

Browse files
committed
feat: adds Lesson11 arrays homework
1 parent ac458a6 commit f1ff464

File tree

1 file changed

+24
-7
lines changed
  • lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11

1 file changed

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

33
import java.util.List;
4+
import java.util.ArrayList;
45

56
public class Lesson11 {
67

78
/**
89
* Provide the solution to LeetCode 1929 here:
910
* https://leetcode.com/problems/concatenation-of-array
1011
*/
11-
public int[] getConcatenation(int[] nums) {
12-
return null;
13-
}
12+
public class Solution {
13+
public int[] getConcatenation(int[] nums) {
14+
int n = nums.length;
15+
int[] ans = new int[2 * n];
1416

17+
for (int i = 0; i < n; i++) {
18+
ans[i] = nums[i];
19+
ans [i + n] = nums[i];
20+
}
21+
return ans;
22+
}
23+
}
1524
/**
1625
* Provide the solution to LeetCode 2942 here:
1726
* https://leetcode.com/problems/find-words-containing-character/
1827
*/
19-
public List<Integer> findWordsContaining(String[] words, char x) {
20-
return null;
21-
}
22-
}
28+
public class WorldFilter {
29+
public List<Integer> findWordsContaining(String[] words, char x) {
30+
List<Integer> result = new ArrayList<>();
31+
32+
for (int i = 0; i < words.length; i++) {
33+
if (words[i].indexOf(x) != -1) {
34+
result.add(i);
35+
}
36+
}
37+
38+
return result;
39+
}

0 commit comments

Comments
 (0)