<gh_stars>0


class Solution:
    @staticmethod
    def longest_palindromic(s: str) -> str:

        # variable to put a palindrome in it
        output = ''

        # search about a palindrome
        for i in range(len(s)):
            for j in range(len(s) + 1):
                if len(output) >= j - i:
                    continue
                elif s[i:j] == s[i:j][::-1]:
                    output = s[i:j]
                    continue
        return output

#  i repeated the function to give output of example as a comment
#  we can use loop to do this shortly
print(Solution.longest_palindromic("babad")) # Output: "bab"
print(Solution.longest_palindromic("cbbd")) # Output: "bb"
print(Solution.longest_palindromic("a")) # Output: "a"
print(Solution.longest_palindromic("ac")) # Output: "a"
class Solution:
    @staticmethod
    def longest_palindromic(s: str) -> str:

        # variable to put a palindrome in it
        output = ''

        # search about a palindrome
        for i in range(len(s)):
            for j in range(len(s) + 1):
                if len(output) >= j - i:
                    continue
                elif s[i:j] == s[i:j][::-1]:
                    output = s[i:j]
                    continue
        return output

#  i repeated the function to give output of example as a comment
#  we can use loop to do this shortly
print(Solution.longest_palindromic("babad")) # Output: "bab"
print(Solution.longest_palindromic("cbbd")) # Output: "bb"
print(Solution.longest_palindromic("a")) # Output: "a"
print(Solution.longest_palindromic("ac")) # Output: "a"
# variable to put a palindrome in it # search about a palindrome #  i repeated the function to give output of example as a comment #  we can use loop to do this shortly # Output: "bab" # Output: "bb" # Output: "a" # Output: "a"