Skip to content

Commit 993570c

Browse files
committed
adds implementation for getConcatenation & findWordsContaining methods
1 parent 50680f2 commit 993570c

File tree

1 file changed

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

1 file changed

+21
-2
lines changed
Lines changed: 21 additions & 2 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,32 @@ public class Lesson11 {
910
* https://leetcode.com/problems/concatenation-of-array
1011
*/
1112
public int[] getConcatenation(int[] nums) {
12-
return null;
13+
// final int n = nums.length;
14+
int ans[] = new int[nums.length * 2];
15+
for (int i = 0; i < nums.length; i++) {
16+
ans[i] = nums[i];
17+
}
18+
int index = nums.length;
19+
for (int i = 0; i < nums.length; i++) {
20+
ans[index] = nums[i];
21+
index++;
22+
}
23+
return ans;
1324
}
1425

1526
/**
1627
* Provide the solution to LeetCode 2942 here:
1728
* https://leetcode.com/problems/find-words-containing-character/
1829
*/
1930
public List<Integer> findWordsContaining(String[] words, char x) {
20-
return null;
31+
32+
// return null;
33+
List<Integer> result = new ArrayList<>();
34+
for (int i = 0; i < words.length; i++) {
35+
if (words[i].indexOf(x) != -1) {
36+
result.add(i);
37+
}
38+
}
39+
return result;
2140
}
2241
}

0 commit comments

Comments
 (0)