Skip to content

Commit c7459cc

Browse files
committed
feat: implements getConcatenation and findWordsContaining methods in Lesson11
1 parent 7b3bd25 commit c7459cc

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,33 @@ public class Lesson11 {
99
* https://leetcode.com/problems/concatenation-of-array
1010
*/
1111
public int[] getConcatenation(int[] nums) {
12-
return null;
12+
int n = nums.length;
13+
int[] ans = new int[2 * n];
14+
15+
for (int i = 0; i < n; i++) {
16+
ans[i] = nums[i];
17+
ans[i + n] = nums[i];
18+
}
19+
20+
return ans;
1321
}
1422

1523
/**
1624
* Provide the solution to LeetCode 2942 here:
1725
* https://leetcode.com/problems/find-words-containing-character/
1826
*/
1927
public List<Integer> findWordsContaining(String[] words, char x) {
20-
return null;
21-
}
28+
List<Integer> result = new ArrayList<>();
29+
30+
for (int i = 0; i < words.length; i++) {
31+
if (words[i].indexOf(x) != -1) {
32+
result.add(i);
33+
}
34+
}
35+
36+
return result;
37+
}
2238
}
39+
40+
41+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)