Skip to content

Commit cd61a61

Browse files
committed
feat:add solutions on leetcode.
1 parent 8ee965f commit cd61a61

File tree

1 file changed

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

1 file changed

+18
-3
lines changed
Lines changed: 18 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,28 @@ 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[2 * nums.length];
14+
15+
System.arraycopy(nums, 0, ans, 0, nums.length);
16+
System.arraycopy(nums, 0, ans, nums.length, nums.length);
17+
return ans;
1318
}
1419

20+
// worked on the solutions with Pablo, Joseph, & Nile via jitsi. //
1521
/**
1622
* Provide the solution to LeetCode 2942 here:
1723
* https://leetcode.com/problems/find-words-containing-character/
1824
*/
19-
public List<Integer> findWordsContaining(String[] words, char x) {
20-
return null;
25+
class Solution {
26+
public List<Integer> findWordsContaining(String[] words, char x) {
27+
List<Integer> indices = new ArrayList<>();
28+
for (int i = 0; i < words.length; i++) {
29+
String str = String.valueOf(x);
30+
if (words[i].contains(str)) {
31+
indices.add(i);
32+
}
33+
}
34+
return indices;
35+
}
2136
}
2237
}

0 commit comments

Comments
 (0)