#P879. Hidden Palindrome

    ID: 879 Type: Default 1000ms 64MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>2016BASICDPDivide & Conquer回文字串巢狀迴圈矩陣累加遞迴CCC

Hidden Palindrome

題目描述

A palindrome is a word which is the same when read forwards as it is when read backwards. For example, "mom" and "anna" are two palindromes. A word which has just one letter, such as "a", is also a palindrome. Given a word, what is the longest palindrome that is contained in the word? That is, what is the longest palindrome that we can obtain, if we are allowed to delete characters from the beginning and/or the end of the string?

輸入格式

The input will consist of one line, containing a sequence of at least 1 and at most 40 lowercase letters.

輸出格式

Output the total number of letters of the longest palindrome contained in the input word.

Samples

["banana","abracadabra","abba"]
["5","3","4"]

提示

自定義一個函數去找一個字串是不是palindrome

原始資料

  • Zero1 題號:a879
  • Hydro 題號:Z0879
  • Locale:zh_TW
  • Display:open