Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

FANCY - EDITORIAL

$
0
0

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2

Setter:Shivam Gupta
Tester:Xiuhan Wang
Editorialist:Taranpreet Singh

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

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.

EXPLANATION

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.)

Trick

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

Time complexity is $O(|S|)$ per test case where $|S|$ is the length of the quote.

AUTHOR'S AND TESTER'S SOLUTIONS:

Setter's solution
Tester's solution
Editorialist's solution

Feel free to Share your approach, If it differs. Suggestions are always welcomed. :)


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>