Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

If the word that you just found is longer than the current longest word, replace the current longest word with the new word. When your

If the word that you just found is longer than the current "longest word", replace the current "longest word" with the new word.

When your loop ends, the remainder of the input string should contain a single "word". Perform one final comparison to see whether this last word is the longest of them all.

Finally, print the longest word that you found.

Remember that your output should ONLY contain the longest word (and nothing else).

Examples:

Input: This is a very long sentence

Output: sentence

Input: the rain in spain falls mainly on the plain

Output: mainly

Input: the cat in the hat

Output: the

Explanation: the maximum word length for this string is 3. As a result, the final output is just the first 3-character word (the initial "the").

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Combinatorial Testing In Cloud Computing

Authors: Wei-Tek Tsai ,Guanqiu Qi

1st Edition

9811044805, 978-9811044809

More Books

Students also viewed these Programming questions

Question

Find m1 and m2. Explain your reasoning. 150 1 2

Answered: 1 week ago

Question

What is the mode?

Answered: 1 week ago