Practice Count Prefixes of a Given String
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a string array words and a string s, where words[i] and s comprise only of lowercase English letters. Return the number of strings in words that are a prefix of s. A prefix of a string is a substring that occurs at the beginning of the string. A substring is a contiguous sequence of characters within a string.
Source: Count Prefixes of a Given String on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
words = ["a","b","c","ab","bc","abc"], s = "abc"
3
# Example 2
words = ["a","a"], s = "aa"
2
Constraints
Related LeetCode Problems
Practice more problems similar to Count Prefixes of a Given String.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.