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