Skip to content

Commit 5931fe9

Browse files
committed
feat: solved leet code problems for Zion Buchanan lesson 11 hw
1 parent 439780a commit 5931fe9

File tree

1 file changed

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

1 file changed

+16
-4
lines changed
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
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 n = nums.length;
13+
int[] ans = new int[2 * n];
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+
var results = new ArrayList<Integer>();
27+
for (int i = 0; i < words.length; i++) {
28+
if (words[i].indexOf(x) > -1) {
29+
results.add(i);
30+
}
31+
}
32+
return results;
2133
}
22-
}
34+
}

0 commit comments

Comments
 (0)