You’re interviewing for a backend or data engineering role at a FAANG-level company. The interviewer describes a real product scenario:
A large messaging, search, or content moderation platform analyzes user-generated text to detect patterns like mirrored phrases, repeated sequences, or symmetric tokens. These patterns can help:
- identify spam campaigns
- detect automated bot behavior
- find repeated templates in messages
- improve search relevance using symmetric phrases
The platform represents a text record as a string s. Your task is to find the longest contiguous segment of text that reads the same forward and backward.
This is a common practice coding problem for DSA question might ask in Google, Amazon, Netflix, Meta, Apple, Microsoft, Uber, and Bloomberg interviews.
Your Task
Given a string s, return the longest palindromic substring in s.
A palindrome is a string that reads the same forward and backward.
A substring must be contiguous.
If multiple answers have the same maximum length, return any one of them.
Input Format
Output Format
- A string representing the longest palindromic substring