#K83187. Longest Palindrome Word Length
Longest Palindrome Word Length
Longest Palindrome Word Length
You are given a string containing words separated by spaces. Your task is to determine the length of the longest word that is a palindrome. A palindrome is a word that reads the same forwards and backwards.
If no palindrome exists in the string, output 0.
The problem can be mathematically expressed as follows:
Let \(W = \{w_1, w_2, \dots, w_n\}\) be the set of words in the input string. Find \(m = \max\{ |w_i| : w_i = reverse(w_i) \}\). If no such word exists, then \(m = 0\).
inputFormat
A single line containing a string composed of words separated by spaces.
outputFormat
A single integer representing the length of the longest palindrome word in the input string. If there is no palindrome word, output 0.## sample
racecar
7