Skip to content

Commit ce3633a

Browse files
committed
Feat: lesson 11 LeetCode answers
1 parent 5c28980 commit ce3633a

File tree

1 file changed

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

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,27 @@ 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 [n * 2];
14+
for (int i=0; i < n; i++){
15+
ans [i] = nums[i];
16+
ans [i + n] = nums[i];
17+
}
18+
return ans;
1319
}
1420

1521
/**
1622
* Provide the solution to LeetCode 2942 here:
1723
* https://leetcode.com/problems/find-words-containing-character/
1824
*/
1925
public List<Integer> findWordsContaining(String[] words, char x) {
20-
return null;
26+
ArrayList <Integer> result = new ArrayList <>();
27+
28+
for(int i=0; i< words.length: i++) {
29+
if(words [i].indexOf(x) != -1) {
30+
result.add(i);
31+
}
32+
}
33+
return result;
2134
}
2235
}

0 commit comments

Comments
 (0)