File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed
lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11 Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change 11package com .codedifferently .lesson11 ;
22
3+ import java .util .ArrayList ;
34import java .util .List ;
45
56public class Lesson11 {
67
7- /**
8- * Provide the solution to LeetCode 1929 here:
9- * https://leetcode.com/problems/concatenation-of-array
10- */
118 public int [] getConcatenation (int [] nums ) {
12- return null ;
9+ int n = nums .length ;
10+ int [] results = new int [2 * n ];
11+ for (int i = 0 ; i < n ; i ++) {
12+ results [i ] = nums [i ];
13+ results [i + n ] = nums [i ];
14+ }
15+ return results ;
1316 }
1417
18+ // lookiing for an integer array that has a concatenation method Im going to given the paramters
19+ // of integer array of variable named nums
20+ // We are declaring one of the variable which is n which equals num.length.
21+
1522 /**
1623 * Provide the solution to LeetCode 2942 here:
1724 * https://leetcode.com/problems/find-words-containing-character/
1825 */
1926 public List <Integer > findWordsContaining (String [] words , char x ) {
20- return null ;
27+ List <Integer > indices = new ArrayList <>();
28+ // The new array lists is the result of the place of the indices
29+ for (int i = 0 ; i < words .length ; i ++) {
30+ if (words [i ].indexOf (x ) != -1 ) {
31+ indices .add (i );
32+ }
33+ }
34+ return indices ;
2135 }
2236}
You can’t perform that action at this time.
0 commit comments