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