77. Longest Word
Core1000 ms256 MBSolved by 0%
Read one line and print the longest word in it.
A word is any run of non-space characters. If several words tie for longest, print the
first one. If the line contains no words at all, print None.
Constraints - The line has between 1 and 100000 characters. - Printable ASCII only.
Input
A single line of text.
Output
Print the longest word. On a tie print the first one. Print None if the line contains no words.
Inputthe quick brown fox
Outputquick
Notehas the longest word in the middle
Inputa bb ccc
Outputccc
Notehas the longest word at the very end, which a loop that only checks on a space would miss
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.