• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
September 24, 2024 |130 Views

SDE Sheet - Longest Palindrome in a String

Description
Discussion

This video is part of the Binary Search Tree section under GFG SDE Sheet.

Given a string str, find the longest palindromic substring in str. Substring of string str: str[ i . . . . j ] where 0 ≤ i ≤ j < len(str). Return the longest palindromic substring of str.

Palindrome string: A string that reads the same backward. More formally, str is a palindrome if reverse(str) = str. In case of conflict, return the substring which occurs first ( with the least starting index).

Examples :

Input: str = "aaaabbaa" Output: aabbaa Explanation: The longest Palindromic substring is "aabbaa".

Do check out:-
Problem: https://www.geeksforgeeks.org/problems/longest-palindrome-in-a-string3411/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/
Article Link: https://www.geeksforgeeks.org/longest-palindromic-substring-using-dynamic-programming-2/