Skip to content

Commit 81cd5b6

Browse files
author
“A1-4U2T1NN”
committed
feat: completed lesson11.java assignment;
1 parent a51c852 commit 81cd5b6

File tree

1 file changed

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

1 file changed

+20
-2
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,32 @@ public class Lesson11 {
99
* https://leetcode.com/problems/concatenation-of-array
1010
*/
1111
public int[] getConcatenation(int[] nums) {
12-
return null;
12+
int[] ans = new int[nums.length + nums.length];
13+
for(int i = 0; i < nums.length; i++) {
14+
ans[i] = nums[i];
15+
ans[i + nums.length] = nums[i];
16+
}
17+
return ans;
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+
int[] indices = new int[words.length];
26+
int count = 0;
27+
28+
for (int i = 0; i < words.length ; i++) {
29+
if(words[i].contains(Character.toString(x))) {
30+
indices[count] = i;
31+
count = count + 1;
32+
}
33+
}
34+
int[] arrayOfIndices = new int[count];
35+
for (int i = 0; i < count; i++) {
36+
arrayOfIndices.length;
37+
}
38+
return arrayOfIndices.length;
2139
}
2240
}

0 commit comments

Comments
 (0)