File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11 Expand file tree Collapse file tree 1 file changed +20
-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,31 @@ 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
+
14
+ int answer [] = new int [2 * nums .length ];
15
+ for (int i = 0 ; i < nums .length ; i ++) {
16
+ answer [i ] = nums [i ];
17
+ answer [i + nums .length ] = nums [i ];
18
+ }
19
+
20
+ return answer ;
13
21
}
14
22
15
23
/**
16
24
* Provide the solution to LeetCode 2942 here:
17
25
* https://leetcode.com/problems/find-words-containing-character/
18
26
*/
19
27
public List <Integer > findWordsContaining (String [] words , char x ) {
20
- return null ;
28
+
29
+ List <Integer > result = new ArrayList <>();
30
+
31
+ for (int i = 0 ; i < words .length ; i ++) {
32
+
33
+ if (words [i ].indexOf (x ) != -1 ) {
34
+ result .add (i );
35
+ }
36
+ }
37
+
38
+ return result ;
21
39
}
22
40
}
You can’t perform that action at this time.
0 commit comments