DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
String

Longest Palindromic Substring

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Longest Palindromic Substring** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Expand around center O(n²) or Manacher O(n) **Edge Cases to Consider:** - (1) Single character - (2) All same characters - (3) Even vs odd palindromes

Examples

Example 1
Input: "babad"
Output: "bab" or "aba"
Example 2
Input: "cbbd"
Output: "bb"
Example 3
Input: "a"
Output: "a"
Explanation: Single

Constraints

  • ▪1 <= s.length <= 10^4
  • ▪s consists of printable ASCII characters
  • ▪Solve with optimal space complexity

Watch Out For Edge Cases

  • ▪Single character
  • ▪All same characters
  • ▪Even vs odd palindromes
Frequently Asked At
AmazonGoogleMicrosoftMetaAdobeFlipkart