Skip to content

Commit 6e34e92

Browse files
committed
"Feat lesson 11 leet code"
1 parent ac458a6 commit 6e34e92

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed
Lines changed: 26 additions & 6 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,34 @@ 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+
class Solution {
13+
public int[] getConcatenation(int[] nums) {
14+
int n = nums.length;
15+
int [] ans = new int[n * 2];
16+
17+
for (int i =0; i< n; i++){
18+
ans[i] = nums [i];
19+
ans [i + n] = nums[i];
20+
}
21+
return ans;
22+
}
23+
}
24+
1425

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

lesson_11/arrays_ts/src/lesson11.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
* Provide the solution to LeetCode 1929 here:
33
* https://leetcode.com/problems/concatenation-of-array
44
*/
5-
export function getConcatenation(nums: number[]): number[] {
6-
return [];
7-
}
5+
86

97
/**
108
* Provide the solution to LeetCode 2942 here:
119
* https://leetcode.com/problems/find-words-containing-character/
1210
*/
13-
export function findWordsContaining(words: string[], x: string): number[] {
14-
return [];
15-
}
11+
12+
13+
14+

0 commit comments

Comments
 (0)