Skip to content

Commit c50f263

Browse files
committed
feat: add Dasias leet code answers to lesson11 in java
1 parent 8ee965f commit c50f263

File tree

1 file changed

+16
-3
lines changed
  • lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11

1 file changed

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

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

56
public class Lesson11 {
6-
77
/**
88
* Provide the solution to LeetCode 1929 here:
99
* https://leetcode.com/problems/concatenation-of-array
1010
*/
1111
public int[] getConcatenation(int[] nums) {
12-
return null;
12+
int[] answer = new int[2 * nums.length];
13+
for (int i = 0; i < nums.length; i++) {
14+
answer[i] = nums[i];
15+
answer[i + nums.length] = nums[i];
16+
}
17+
return answer;
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+
List<Integer> answer = new ArrayList<>();
26+
for (int i = 0; i < words.length; i++) {
27+
if (words[i].contains(Character.toString(x))) {
28+
answer.add(i);
29+
}
30+
}
31+
return answer;
2132
}
2233
}
34+
// I got help from Joesphs to talk things out and explain what this code is doing and how to go
35+
// about applying code and what does it mean

0 commit comments

Comments
 (0)