LeetCode --- 1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence 解题报告

Posted 杨鑫newlfe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence 解题报告相关的知识,希望对你有一定的参考价值。

Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.

Return the index of the word in sentence (1-indexed) where searchWord is a prefix of this word. If searchWord is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return -1.

prefix of a string s is any leading contiguous substring of s.

Example 1:

Input: sentence = "i love eating burger", searchWord = "burg"
Output: 4
Explanation: "burg" is prefix of "burger" which is the 4th word in the sentence.

以上是关于LeetCode --- 1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence 解题报告的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode 1455. 检查单词是否为句中其他单词的前缀

LeetCode 1455. 检查单词是否为句中其他单词的前缀 双指针

LeetCode 1455. 检查单词是否为句中其他单词的前缀 双指针

LeetCode 958. Check Completeness of a Binary Tree

ipad后壳 fccid:bcga1455 ic:579c-a1455 serial:DLXKX1N2F19N 帮我看一下 谢谢

BZOJ 1455 1455: 罗马游戏 (可并堆-左偏树+并查集)