Skip to content

Commit 9cc1821

Browse files
committed
Feat: Modified lesson 11 java by Hummad Tanweer
1 parent 8ee965f commit 9cc1821

File tree

1 file changed

+24
-5
lines changed
  • lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11

1 file changed

+24
-5
lines changed
Lines changed: 24 additions & 5 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 {
@@ -8,15 +9,33 @@ public class Lesson11 {
89
* Provide the solution to LeetCode 1929 here:
910
* https://leetcode.com/problems/concatenation-of-array
1011
*/
11-
public int[] getConcatenation(int[] nums) {
12-
return null;
13-
}
12+
public
13+
int[] getConcatenation(int[] nums) {
14+
// int len = nums.size();
15+
//return null;
16+
int n = nums.length;
17+
int ans[] = new int[2 * n];
18+
for (int i = 0; i < n; i++) {
19+
ans[i] = nums[i];
20+
ans[i+n]= nums[i];
21+
} return ans;
22+
}
23+
1424

1525
/**
1626
* Provide the solution to LeetCode 2942 here:
1727
* https://leetcode.com/problems/find-words-containing-character/
1828
*/
1929
public List<Integer> findWordsContaining(String[] words, char x) {
20-
return null;
21-
}
30+
31+
List result = new ArrayList();
32+
for (int i = 0; i < words.length; i++) {
33+
if (words[i].indexOf(x) != -1) {
34+
result.add(i);
35+
}
36+
}
37+
return result;
38+
}
2239
}
40+
41+

0 commit comments

Comments
 (0)