Skip to content

Commit a45ece0

Browse files
solves number of strings that appear as substrings in word
1 parent 780d460 commit a45ece0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@
470470
| 1945 | [Sum of Digits of String After Convert](https://leetcode.com/problems/sum-of-digits-of-string-after-convert) | [![Java](assets/java.png)](src/SumOfDigitsOfStringAfterConvert.java) | |
471471
| 1952 | [Three Divisors](https://leetcode.com/problems/three-divisors) | [![Java](assets/java.png)](src/ThreeDivisors.java) | |
472472
| 1957 | [Delete Characters to Make Fancy String](https://leetcode.com/problems/delete-characters-to-make-fancy-string) | [![Java](assets/java.png)](src/CheckIfStringIsAPrefixOfArray.java) | |
473-
| 1961 | [Check If String Is a Prefix of Array](https://leetcode.com/problems/check-if-string-is-a-prefix-of-array) | | |
473+
| 1961 | [Check If String Is a Prefix of Array](https://leetcode.com/problems/check-if-string-is-a-prefix-of-array) | [![Java](assets/java.png)](src/NumberOfStringsThatAppearAsSubstringsInWord.java) | |
474474
| 1967 | [Number of Strings That Appear as Substrings in Word](https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word) | | |
475475
| 1971 | [Find if Path Exists in Graph](https://leetcode.com/problems/find-if-path-exists-in-graph) | | |
476476
| 1974 | [Minimum Time to Type Word Using Special Typewriter](https://leetcode.com/problems/minimum-time-to-type-word-using-special-typewriter) | | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class NumberOfStringsThatAppearAsSubstringsInWord {
2+
public int numOfStrings(String[] patterns, String word) {
3+
int substrings = 0;
4+
for (String pattern : patterns) {
5+
if (word.contains(pattern)) {
6+
substrings++;
7+
}
8+
}
9+
return substrings;
10+
}
11+
}

0 commit comments

Comments
 (0)