#C14929. Longest Word Finder
Longest Word Finder
Longest Word Finder
You are given a sentence containing words separated by spaces. Your task is to find the longest word in the sentence and output the word along with its length. In case there are multiple words of the same maximum length, output the one that appears first in the sentence.
If the input string is empty or contains no words, output an empty string followed by 0.
You can use the following examples to understand the problem:
- Input: "The quick brown fox jumped over the lazy dog" → Output: "jumped 6"
- Input: "supercalifragilisticexpialidocious" → Output: "supercalifragilisticexpialidocious 34"
- Input: "a bb ccc ddd" → Output: "ccc 3"
inputFormat
The input consists of a single line containing a sentence. The sentence may include spaces, and the words are separated by one or more spaces.
outputFormat
Output a single line containing the longest word and its corresponding length, separated by a space. If the input is empty, output an empty string followed by 0.
## sampleThe quick brown fox jumped over the lazy dog
jumped 6