Skip to content

Commit 4a213d2

Browse files
feat: implemented LeetCode 1929, 2942
1 parent 3e8f77b commit 4a213d2

File tree

1 file changed

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

1 file changed

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

3+
import java.util.ArrayList;
34
import java.util.List;
45

6+
57
public class Lesson11 {
68

79
/**
810
* Provide the solution to LeetCode 1929 here:
911
* https://leetcode.com/problems/concatenation-of-array
1012
*/
1113
public int[] getConcatenation(int[] nums) {
12-
return null;
14+
int [] ans = new int[nums.length * 2];
15+
System.arraycopy(nums, 0, ans, 0, nums.length);
16+
System.arraycopy(nums, 0, ans, nums.length, nums.length);
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+
ArrayList<Integer> out = new ArrayList<>();
26+
for(int i = 0; i<words.length; i++){
27+
if (words[i].indexOf(x) != -1){
28+
out.add(i);
29+
}
30+
}
31+
32+
return out;
2133
}
2234
}

0 commit comments

Comments
 (0)