Loading Now

longestSubstr

A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" are not.

If there is such a substring in s that is not a palindrome, output the maximum length of such a substring. Otherwise output 0.

Example

  • For s = "qqqq" the output should be longestSubstr(s) = 0
  • For s = "aba" the output should be longestSubstr(s) = 2

Input/Output

  • [Execution time limit] 0.5 seconds
  • [Input] string s
    Guaranteed constraints:
    1 <= |s| <= 50
  • [Output] integer

Post Comment

Contact