Skip to content

Commit 39f9d8e

Browse files
committed
feat: completes leet code lesson
1 parent 7b3bd25 commit 39f9d8e

File tree

1 file changed

+20
-6
lines changed
  • lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11

1 file changed

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

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

56
public class Lesson11 {
67

7-
/**
8-
* Provide the solution to LeetCode 1929 here:
9-
* https://leetcode.com/problems/concatenation-of-array
10-
*/
118
public int[] getConcatenation(int[] nums) {
12-
return null;
9+
int n = nums.length;
10+
int[] results = new int[2 * n];
11+
for (int i = 0; i < n; i++) {
12+
results[i] = nums[i];
13+
results[i + n] = nums[i];
14+
}
15+
return results;
1316
}
1417

18+
// lookiing for an integer array that has a concatenation method Im going to given the paramters
19+
// of integer array of variable named nums
20+
// We are declaring one of the variable which is n which equals num.length.
21+
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+
List<Integer> indices = new ArrayList<>();
28+
// The new array lists is the result of the place of the indices
29+
for (int i = 0; i < words.length; i++) {
30+
if (words[i].indexOf(x) != -1) {
31+
indices.add(i);
32+
}
33+
}
34+
return indices;
2135
}
2236
}

0 commit comments

Comments
 (0)