Largest Palindromic Substring

Advanced

A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. For this fun challenge, we'll focus on finding the largest palindromic substring within a given string.

Task

You need to write a function largest_palindromic_substring that takes a single string as an input and returns the largest palindromic substring within that string. If there are multiple solutions, return the first one found.

Example

Let's say you have the string "babad", the largest palindromic substring would be either "bab" or "aba", and you can choose to return either since both are correct.

Here's another example:

largest_palindromic_substring("cbbd")

This should return "bb" as it is the largest palindrome within the string.

Have fun exploring palindromes and enhancing your pattern recognition skills!

Geek
Inputs

Arg 1:

"babad"
Expected Output
"bab"
Actual Output
Largest Palindromic Substring [advanced] | Coding for Kids