SATISH KUMAR’s Post

Day 65 of my #100DaysOfCode challenge 🚀 Today I worked on finding the Longest Palindromic Substring using the Expand Around Center approach in Python. This is a very popular interview problem that tests your understanding of strings and two-pointer techniques. What the program does: • Takes a string as input • Finds the longest substring that is a palindrome • Uses center expansion (no brute force) • Works for both odd & even length palindromes Example Outputs: "babad" → bab "cbbd" → bb "racecar" → racecar "forgeeksskeegfor" → geeksskeeg How the logic works: Key idea: Expand from center 1. Treat each index as center 2. Expand for odd length (i, i) 3. Expand for even length (i, i+1) 4. Track maximum length found 5. Return longest substring This avoids checking all substrings ❌ → efficient ✔️ Why this is important: – Classic string problem in interviews – Builds understanding of: Two-pointer technique Substring expansion – Better than brute force O(n³) approach – Asked in companies like Google, Amazon Time Complexity: O(n²) Space Complexity: O(1) Key Takeaways: – Center expansion technique – Handling odd & even palindromes – Efficient substring checking – Writing optimized string algorithms #100DaysOfCode #Day65 #Python #Programming #Strings #Palindrome #Algorithms #DSA #CodingPractice #ProblemSolving #InterviewPrep #LearnByDoing #DeveloperJourney #Consistency #BTech #CSE #AIandML #VITBhopal #TechJourney

  • text

To view or add a comment, sign in

Explore content categories