Skip to content

Commit a70a91a

Browse files
committed
feat: java solution for finding word's index that contains the given character
1 parent 8c38aa0 commit a70a91a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

find word containing char.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public List<Integer> findWordsContaining(String[] words, char x) {
3+
List<Integer> char_index = new ArrayList<>();
4+
for (int i = 0 ; i< words.length ; i++) {
5+
if ( words[i].indexOf(x) != -1){
6+
char_index.add(i);
7+
}
8+
}
9+
return char_index;
10+
}
11+
}

0 commit comments

Comments
 (0)