Class Solution
- java.lang.Object
-
- g1901_2000.s1961_check_if_string_is_a_prefix_of_array.Solution
-
public class Solution extends Object
1961 - Check If String Is a Prefix of Array.Easy
Given a string
sand an array of stringswords, determine whethersis a prefix string ofwords.A string
sis a prefix string ofwordsifscan be made by concatenating the firstkstrings inwordsfor some positivekno larger thanwords.length.Return
trueifsis a prefix string ofwords, orfalseotherwise.Example 1:
Input: s = “iloveleetcode”, words = [“i”,“love”,“leetcode”,“apples”]
Output: true
Explanation: s can be made by concatenating “i”, “love”, and “leetcode” together.
Example 2:
Input: s = “iloveleetcode”, words = [“apples”,“i”,“love”,“leetcode”]
Output: false
Explanation: It is impossible to make s using a prefix of arr.
Constraints:
1 <= words.length <= 1001 <= words[i].length <= 201 <= s.length <= 1000words[i]andsconsist of only lowercase English letters.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-