Last Updated: 18 Sep, 2025

First Longest Even Word

Easy
Asked in company
FactSet

Problem statement

You are given a string s containing words separated by spaces. Your task is to find and return the first word in the string that satisfies two conditions:


1) The word must have an even length.
2) The word's length must be the maximum among all other even-length words in the string.


If multiple words of the same maximum even length exist, you must return the one that appears first in the original string.


Input Format:
A single line containing the string s.


Output Format:
Print a single string which is the first longest even-length word.

If no even-length words are found in the string, print "00".


Note:
A word is a sequence of non-space characters.

Multiple spaces between words, as well as leading/trailing spaces, should be handled correctly.