Skip to content
← Back to the archive

18 August 2026

Longest Word

Easy Strings

Find the single longest word in a sentence.

Given a sentence of lowercase words separated by single spaces, return the longest word. If more than one word shares the longest length, return whichever of them appears first in the sentence.

Constraints

  • 1 <= number of words <= 1000
  • Each word contains only lowercase English letters
  • 1 <= length of each word <= 100

Function signature

def longest_word(sentence):

Sign in to solve this bracket

Reading the problem is free for everyone. Opening the editor and solving it requires an account with Open Bracket+.