1961. Check If String Is a Prefix of Array Easy

@problem@discussion
#Array#String



1/**
2 * [1961] Check If String Is a Prefix of Array
3 *
4 * Given a string s and an array of strings words, determine whether s is a prefix string of words.
5 * A string s is a prefix string of words if s can be made by concatenating the first k strings in words for some positive k no larger than words.length.
6 * Return true if s is a prefix string of words, or false otherwise.
7 *  
8 * Example 1:
9 * 
10 * Input: s = "iloveleetcode", words = ["i","love","leetcode","apples"]
11 * Output: true
12 * Explanation:
13 * s can be made by concatenating "i", "love", and "leetcode" together.
14 * 
15 * Example 2:
16 * 
17 * Input: s = "iloveleetcode", words = ["apples","i","love","leetcode"]
18 * Output: false
19 * Explanation:
20 * It is impossible to make s using a prefix of arr.
21 *  
22 * Constraints:
23 * 
24 * 	1 <= words.length <= 100
25 * 	1 <= words[i].length <= 20
26 * 	1 <= s.length <= 1000
27 * 	words[i] and s consist of only lowercase English letters.
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/check-if-string-is-a-prefix-of-array/
33// discuss: https://leetcode.com/problems/check-if-string-is-a-prefix-of-array/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn is_prefix_string(s: String, words: Vec<String>) -> bool {
39        false
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_1961() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.