Longest Word in a Sentence
Words in sentence are separated by single spaces. Return the longest word. If several words share the longest length, return the first of them.
Example 1
sentence "I love coding in python"
returns "coding"
python has 6 letters.
Example 2
sentence "one two six"
returns "one"
All have 3 letters, so the first.
Constraints
1 <= len(sentence) <= 100- Letters and single spaces, no space at the start or end
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Strings problems
- Maximum Nesting Depth of ParenthesesBeginner
- Mirror CipherBeginner
- One Segment of OnesBeginner
- Percentage of Letter in StringBeginner
- Prefix of Any Word in a SentenceBeginner
- Remove Vowels from a StringBeginner
- Reverse Each WordBeginner
- Reverse Prefix of WordBeginner