Skip to content

Commit 0bc66b6

Browse files
committed
Feat: adds Shawn Dunsmore Lesson11 java.
1 parent 3e8f77b commit 0bc66b6

File tree

1 file changed

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

1 file changed

+24
-6
lines changed
Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.codedifferently.lesson11;
2-
2+
import java.util.ArrayList;
33
import java.util.List;
44

55
public class Lesson11 {
@@ -9,14 +9,32 @@ public class Lesson11 {
99
* https://leetcode.com/problems/concatenation-of-array
1010
*/
1111
public int[] getConcatenation(int[] nums) {
12-
return null;
13-
}
12+
int n = nums.length;
13+
int[] ans = new int[2 * n];
14+
15+
16+
for (int i = 0; i < n; i++) {
17+
ans[i] = nums[i];
18+
ans[i + n] = nums[i];
19+
}
20+
21+
return ans;
22+
}
23+
1424

1525
/**
1626
* Provide the solution to LeetCode 2942 here:
1727
* https://leetcode.com/problems/find-words-containing-character/
1828
*/
19-
public List<Integer> findWordsContaining(String[] words, char x) {
20-
return null;
21-
}
29+
public List<Integer> findWordsContaining(String[] words, char x) {
30+
List<Integer> indices = new ArrayList<>();
31+
32+
for (int i = 0; i < words.length; i++) {
33+
if (words[i].indexOf(x) != -1) {
34+
indices.add(i);
35+
}
36+
}
37+
38+
return indices;
39+
}
2240
}

0 commit comments

Comments
 (0)