Solved Longest Palindromic Substring with Java and LeetCode

Day 40/100 – #100DaysOfCode 🚀 | #Java #LeetCode #TwoPointers #DynamicProgramming ✅ Problem Solved: Longest Palindromic Substring 🟣 🧩 Problem Summary: Given a string, return the longest palindromic substring within it. The substring must read the same forward and backward. 💡 Approach Used: Expand Around Center Technique Every palindrome is centered around: A single character (odd length) Or between two characters (even length) For each index: Expand left and right while characters match. Track the longest substring during expansions. This avoids unnecessary recomputation and works efficiently. ⚙️ Time Complexity: O(n²) 📦 Space Complexity: O(1) ✨ Takeaway: Sometimes, the cleanest approach comes from observing patterns — in this case, symmetry around a center 🎯 #Java #LeetCode #TwoPointers #ExpandAroundCenter #ProblemSolving #100DaysOfCode #CodingJourney

  • graphical user interface, text, application, chat or text message

To view or add a comment, sign in

Explore content categories