File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11 Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
1
package com .codedifferently .lesson11 ;
2
2
3
+ import java .util .ArrayList ;
3
4
import java .util .List ;
4
5
5
6
public class Lesson11 {
@@ -9,14 +10,26 @@ public class Lesson11 {
9
10
* https://leetcode.com/problems/concatenation-of-array
10
11
*/
11
12
public int [] getConcatenation (int [] nums ) {
12
- return null ;
13
+ int answer [] = new int [nums .length * 2 ];
14
+ for (int i = 0 ; i < nums .length ; i ++) {
15
+ answer [i ] = nums [i ];
16
+ answer [i + nums .length ] = nums [i ];
17
+ }
18
+ return answer ;
13
19
}
14
20
15
21
/**
16
22
* Provide the solution to LeetCode 2942 here:
17
23
* https://leetcode.com/problems/find-words-containing-character/
18
24
*/
19
25
public List <Integer > findWordsContaining (String [] words , char x ) {
20
- return null ;
26
+ List <Integer > result = new ArrayList <>();
27
+ for (int i = 0 ; i < words .length ; i ++) {
28
+ if (words [i ].indexOf (x ) != -1 ) {
29
+ result .add (i );
30
+ }
31
+ }
32
+
33
+ return result ;
21
34
}
22
35
}
You can’t perform that action at this time.
0 commit comments