Skip to content

Commit 4e1d657

Browse files
committed
feat: adds David Smith Leetcode for lesson 11
1 parent 8ee965f commit 4e1d657

File tree

1 file changed

+14
-3
lines changed
  • lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11

1 file changed

+14
-3
lines changed

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

Lines changed: 14 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,24 @@ public class Lesson11 {
910
* https://leetcode.com/problems/concatenation-of-array
1011
*/
1112
public int[] getConcatenation(int[] nums) {
12-
return null;
13+
int n = nums.length;
14+
int[] ans = new int[2 * n];
15+
System.arraycopy(nums, 0, ans, 0, n);
16+
System.arraycopy(nums, 0, ans, n, n);
17+
return ans;
1318
}
1419

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

0 commit comments

Comments
 (0)