Commit a2c19bc
committed
feat: Count strings in 2D array that contain the letter 'a'
🧠 Logic:
- Define a static method `count` that accepts a 2D array of strings.
- Use nested loops to iterate through all elements in the array.
- For each string, use `indexOf("a")` to check if it contains the character 'a'.
- If found, increment the `count`.
- In `main`, define a 2D string array `items`, call `count`, and print the total number of strings that contain 'a'.
Signed-off-by: Somesh diwan <[email protected]>1 parent 1f56cfa commit a2c19bc
1 file changed
+26
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
3 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
12 | 19 | | |
13 | 20 | | |
14 | 21 | | |
15 | 22 | | |
16 | 23 | | |
17 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
18 | 35 | | |
0 commit comments