menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Data Science News

>

1455. Chec...
source image

Dev

4w

read

389

img
dot

Image Credit: Dev

1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence

  • Given a sentence and a searchWord, check if searchWord is a prefix of any word in the sentence.
  • Return the index of the first word where searchWord is a prefix, or -1 if there is no such word.
  • The solution involves splitting the sentence into words and iterating through each word to check for a prefix match.
  • If a match is found, return the 1-indexed position of the word, otherwise return -1.

Read Full Article

like

23 Likes

For uninterrupted reading, download the app