Given a string, check if it contains the word “not” as a complete word. (Not as a part of another word, like nothing)
SUPER QUICK EXPLANATION
- The quote is Real Fancy, if the quote is “not”, quote begin with “not*”, quote ends with “not" or quote contains “not” where "” represents space character.
Consider the special case where quote itself is “not” separately.
After this, the word “not” can either appear as the prefix, as the suffix or in between the quote. So, check separately if the first word is “not”, the last word is “not” or the quote contains the word “not”. (Make sure to check that the word “not” is surrounded by space character on both sides.)
Those not interested in splitting the string into words can solve this by inputting the quote as a string, add space character at both ends of strings. Now, the quote will be “Real Fancy” if it contains “not” where “*” represents space character.
As a side fact, @vijju123 actually have a thing about fancy quotes. He has another fancy quote, shared during the contest, “You made my non-fancy quote a fancy one”.
Time complexity is O(|S|) per test case where |S| is the length of the quote.
AUTHOR’S AND TESTER’S SOLUTIONS:
Feel free to Share your approach, If it differs. Suggestions are always welcomed.