#K33717. Largest Palindromic Substring

    ID: 25150 Type: Default 1000ms 256MiB

Largest Palindromic Substring

Largest Palindromic Substring

Given a string s, find and return the largest palindromic substring in s. A palindrome is a sequence of characters that reads the same forward and backward. In case there are multiple substrings of maximum length, return the one that appears first in s.

The solution should use an efficient algorithm (e.g. expanding around the center) and handle edge cases such as an empty string or a string of length one.

inputFormat

The input consists of a single line containing the string s. Read the input from standard input (stdin).

outputFormat

Output the largest palindromic substring found in s to standard output (stdout).

## sample
babad
bab