
Asked in Goldman Sachs
Find the Longest Palindromic Substring
Given a string ‘S’ composed of lowercase English letters, your task is to identify the longest palindromic substring within ‘S’.
If there are multiple longest palindromic substrings of the same length, return the rightmost one in the given string.
Example:
Input:
bbbab
Output:
bab
Explanation:
In the string “bbbab”, there are two longest palindromic substrings of equal length: “bbb” and “bab”. The rightmost one, “bab”, should be returned.
Constraints:
1 <= T <= 50
1 <= N <= 100
Where ‘N’ is the length of the string.
Note:
A substring is a contiguous sequence of characters within a string. A string is a palindrome if it reads the same forwards and backwards.
Note:
You do not need to print anything; this has been handled. Implement the function to return the desired result.

AnswerBot
4mo
Find the longest palindromic substring in a given string, returning the rightmost one if multiple substrings are of the same length.
Use dynamic programming to check for palindromes within the string.
S...read more
Help your peers!
Add answer anonymously...
Top Software Developer Intern Interview Questions Asked at Goldman Sachs
Q. Write the code for Merge Sort.
Q. Given a sorted array of integers nums and an integer target, write a function to...read more
Q. Rectangle Area Problem Statement You are provided with a list of rectangles, eac...read more
Interview Questions Asked to Software Developer Intern at Other Companies
Top Skill-Based Questions for Goldman Sachs Software Developer Intern
C++ Interview Questions and Answers
300 Questions
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Operating Systems Interview Questions and Answers
250 Questions
System Design Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

