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