Skip to content

Commit 67d6e0d

Browse files
chore: implemented leetCode functions in Lesson11 file
1 parent 7b3bd25 commit 67d6e0d

File tree

1 file changed

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

1 file changed

+17
-2
lines changed
Lines changed: 17 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,28 @@ public class Lesson11 {
910
* https://leetcode.com/problems/concatenation-of-array
1011
*/
1112
public int[] getConcatenation(int[] nums) {
12-
return null;
13+
int[] finalArr = new int[nums.length * 2];
14+
for (int i = 0; i < nums.length; i++) {
15+
finalArr[i] = nums[i];
16+
finalArr[i + nums.length] = nums[i];
17+
}
18+
19+
return finalArr;
1320
}
1421

1522
/**
1623
* Provide the solution to LeetCode 2942 here:
1724
* https://leetcode.com/problems/find-words-containing-character/
1825
*/
1926
public List<Integer> findWordsContaining(String[] words, char x) {
20-
return null;
27+
var results = new ArrayList<Integer>();
28+
var ch = String.valueOf(x);
29+
for (int i = 0; i < words.length; i++) {
30+
if (words[i].contains(ch)) {
31+
results.add(i);
32+
}
33+
}
34+
35+
return results;
2136
}
2237
}

0 commit comments

Comments
 (0)