Tap here to switch tabs
Problem
Submissions

Problem: Count Prefixes of a Given String

med
30 min
Try to solve the Count Prefixes of a Given String problem.

Statement

You are given an array of strings words and a string s.

A prefix of a string is a leading contiguous substring.

Return the number of strings in words that are a prefix of s. If the same string appears multiple times in words, count each occurrence independently.

Constraints:

  • 1≤1 \leq words.length ≤1000\leq 1000

  • 1≤1 \leq words[i].length, s.length ≤10\leq 10

  • words[i] and s consist only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Prefixes of a Given String

med
30 min
Try to solve the Count Prefixes of a Given String problem.

Statement

You are given an array of strings words and a string s.

A prefix of a string is a leading contiguous substring.

Return the number of strings in words that are a prefix of s. If the same string appears multiple times in words, count each occurrence independently.

Constraints:

  • 1≤1 \leq words.length ≤1000\leq 1000

  • 1≤1 \leq words[i].length, s.length ≤10\leq 10

  • words[i] and s consist only of lowercase English letters.