Check Palindrome Using Recursion in 50 Days of Code Challenge

Day 45 of my #50DaysOfCode challenge is done ✅ 📌 Problem Solved Check Palindrome Using Recursion We were given a string s. Task was to check whether it is a palindrome. Using recursion. --- 💻 Approach (Recursion + Two Pointers) 🔹️Take two pointers: start and end. 🔹️Base case:   ▪️If start >= end → return true 🔹️Compare characters at start and end. 🔹️If not equal → return false 🔹️If equal → move inward   ▪️start + 1   ▪️end - 1 🔹️Call function again for inner substring Keep checking until pointers meet. --- 📊 Complexity Analysis Time Complexity: O(n) Space Complexity: O(n) Due to recursion stack. --- 📚 What I learned today: ▫️Recursion can replicate iterative two-pointer logic. ▫️Each recursive call reduces problem size by 2. ▫️Base condition ensures termination at center. ▫️Space complexity increases due to call stack. Day 44 completed. Recursion patterns getting stronger 🚀 #50DaysOfCode #CodingChallenge #Consistency #LearningInPublic

To view or add a comment, sign in

Explore content categories