Skip to content

Commit 925fadf

Browse files
author
jjcapparell
committed
feat: Edited lesson11.ts Lesson11.java to complete functions/methods
1 parent 8ee965f commit 925fadf

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed
Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
package com.codedifferently.lesson11;
22

3+
import java.util.ArrayList;
34
import java.util.List;
45

56
public class Lesson11 {
67

7-
/**
8-
* Provide the solution to LeetCode 1929 here:
9-
* https://leetcode.com/problems/concatenation-of-array
10-
*/
8+
119
public int[] getConcatenation(int[] nums) {
12-
return null;
13-
}
10+
int[] answer = new int[2*nums.length];
1411

15-
/**
16-
* Provide the solution to LeetCode 2942 here:
17-
* https://leetcode.com/problems/find-words-containing-character/
18-
*/
12+
for(int i=0;i<nums.length;i++) {
13+
answer[i] = nums[i];
14+
answer[i+nums.length] = nums[i];
15+
}
16+
return answer;
17+
}
18+
1919
public List<Integer> findWordsContaining(String[] words, char x) {
20-
return null;
20+
List answer = new ArrayList();
21+
for(int i=0;i<words.length;i++){
22+
if (words[i].indexOf(x)!=-1){
23+
answer.add(i);
24+
}
25+
}
26+
return answer;
2127
}
2228
}
29+

lesson_11/arrays_ts/src/lesson11.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
/**
2-
* Provide the solution to LeetCode 1929 here:
3-
* https://leetcode.com/problems/concatenation-of-array
4-
*/
1+
52
export function getConcatenation(nums: number[]): number[] {
6-
return [];
3+
const answer = [2*nums.length];
4+
5+
for (let i=0;i<nums.length;i++){
6+
answer[i]=nums[i];
7+
answer[i+nums.length]=nums[i];
8+
}
9+
return answer;
710
}
811

9-
/**
10-
* Provide the solution to LeetCode 2942 here:
11-
* https://leetcode.com/problems/find-words-containing-character/
12-
*/
1312
export function findWordsContaining(words: string[], x: string): number[] {
14-
return [];
13+
let answer = [];
14+
for(let i=0;i<words.length;i++){
15+
if (words[i].indexOf(x)!=-1){
16+
answer.push(i);
17+
}
18+
}
19+
return answer;
1520
}

0 commit comments

Comments
 (0)