Skip to content

Commit 506dd0e

Browse files
author
Yafiaha
committed
Feat: Yafiah added Java Leetcode problems Lesson-11
1 parent 8ee965f commit 506dd0e

File tree

1 file changed

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

1 file changed

+19
-2
lines changed
Lines changed: 19 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,30 @@ public class Lesson11 {
910
* https://leetcode.com/problems/concatenation-of-array
1011
*/
1112
public int[] getConcatenation(int[] nums) {
12-
return null;
13+
int n = nums.length;
14+
int ans[] = new int[2*n];
15+
for (int i = 0; i<n; i++){
16+
ans[i] = nums[i];
17+
ans[n+i] = nums[i];
18+
}
19+
return ans;
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+
List<Integer> list = new ArrayList<>();
28+
for (int i = 0; i < words.length; i++) {
29+
String str = words[i];
30+
for (int j = 0; j < str.length(); j++) {
31+
if (str.charAt(j) == x) {
32+
list.add(i);
33+
break;
34+
}
35+
}
36+
}
37+
return list;
2138
}
2239
}

0 commit comments

Comments
 (0)