Help me out

codechef

#1

How to print whether a word is in a sentence or not???
Like “I am a boy” and I have to check whether word “I” is there or not.


#2

A simple approach could be:

  • Take the sentence as input in a string
  • Break the sentence at all places where ’ ’ [space character] appears, and store them in a vector or array of strings.
  • Iterate through the vector of strings and compare each string, using STL you can also directly call find() function on the vector to search for the string.

Doing this in python is quite easy though.

sentence = "I am a boy"
words = sentence.split(' ') # split() the sentence
if "I" in words:
    print("I is present in the sentence.")



#3

Please delete your question. This question is from an ongoing contest and discussion of questions from ongoing contest is not allowed. Just wait for another 26 hours and you will come to know how to do it.


#4

This Question is similar to the 1st question in Jan19B Contest. Plz Delete or your would be penalinzed for plagarism.


#5

Hey, this is the 1st qestion of JAN LONG “FANCY QUOTES”. Just delete your question man, you will get banned.