File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11 Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,14 @@ public int[] getConcatenation(int[] nums) {
24
24
* https://leetcode.com/problems/find-words-containing-character/
25
25
*/
26
26
public List <Integer > findWordsContaining (String [] words , char x ) {
27
- List <Integer > arrayOfIndices = new ArrayList <>(); // Use a List to dynamically store indices
28
27
29
- for (int i = 0 ; i < words .length ; i ++) {
30
- if (words [i ].indexOf (x ) != -1 ) { // Check if the character is present in the word
31
- arrayOfIndices .add (i ); // Add the index to the list
32
- }
28
+ List <Integer > arrayOfIndices = new ArrayList <>(); // Use a List to dynamically store indices
29
+
30
+ for (int i = 0 ; i < words .length ; i ++) {
31
+ if (words [i ].contains (x )){ // Check if the character is present in the word
32
+ arrayOfIndices .add (i ); // Add the index to the list
33
33
}
34
- return arrayOfIndices ;
34
+ }
35
+ return arrayOfIndices ; // Return list
35
36
}
36
- }
37
+
You can’t perform that action at this time.
0 commit comments