Day 19 of Problem Solving Series In Python | Geethu Talks

Table of Contents
Day 19 of Problem Solving Series
👋 Hi friends! Geethu Talks ki welcome. Mundu nunchi, venaka nunchi okkate ela chaduvuthaam? Ee roju palindrome check cheddam, two pointers technique tho.
🎬 Reel chudaledha? Instagram / YouTube lo @GeethuTalks ni follow avvandi.
🧩 Real-life Problem
Oka booking reference code 12321 mundu nunchi, venaka nunchi okkate undha ani check cheyyali.
📋 Task: Code teesukuni palindrome ena check cheyyandi.
📥 Sample input: 12321
📤 Sample output: Palindrome code!
📚 Concepts Covered
- ↔️ Two pointers (left & right)
- 🔁
while left < right - 🚩 Flag variable
- 🛑
break
🧠 Step 1: Logic Build Cheddam
Rendu chepala nunchi lopaliki vasthaam:
- Left = 0, Right = last index
- Left and right characters same na check
- Veru ayithe: palindrome kaadu, stop
- Same ayithe: left → mundu, right → venaka. Meet ayye varaku repeat
💡 Analogy: Rendu friends rendu chepala nunchi nadichi madhyalo kalavadam laga. Prathi adugulo vallu same ga undali.
💻 Step 2: Python Code
code = input("Enter booking code: ")
left = 0
right = len(code) - 1
is_palindrome = True
while left < right:
if code[left] != code[right]:
is_palindrome = False
break
left = left + 1
right = right - 1
if is_palindrome:
print("Palindrome code!")
else:
print("Not a palindrome")
✅ Output
Enter booking code: 12321
Palindrome code!
🔍 Line by line
| Code | Meaning |
|---|---|
left = 0 | Start pointer |
right = len(code) - 1 | Last index (len – 1) |
code[left] != code[right] | Ye chepa characters veru ayithe |
break | Mismatch dorikagane aapeyyadam |
left + 1, right - 1 | Pointers lopaliki |
⚠️ Common Mistake Alert
❌ Wrong: Capital/small difference ignore cheyyakapothe Madam palindrome kaadu ani vasthundi
code = "Madam"
print(code[0] == code[4]) # 'M' vs 'm'
Result:
False
✅ Right: Mundu code = code.lower() chesi tarvatha check cheyyandi.
💡 Bonus tip: Loop lo pointers move cheyyakapothe loop eppatiki aagadu (infinite loop). Last index eppudu len() - 1.
📝 Quick Recap
- ✔️ Two pointers: rendu chepala nunchi
- ✔️ Mismatch dorikithe
break - ✔️ Case problem kosam
lower()
🏋️ Practice Problems
🟢 Easy: ‘python’ ni reverse chesi print cheyyandi (loop tho).
Expected output: nohtyp
🟡 Medium: Spaces and case ignore chesi ‘Nurses Run’ palindrome ena check cheyyandi.
Expected output: Palindrome
🔴 Challenge: [‘madam’, ‘python’, ‘level’, ‘code’, ‘noon’] lo palindromes entha?
Expected output: 3
💬 Mee answers comments lo share cheyyandi!
🚀 Next: Day 20 – Missing Jersey Number
Follow @GeethuTalks and stay tuned! 💛
⬅️ Previous: Day 18 of Problem Solving Series In Python
check out our website for more resources
Day 19 of Problem Solving Series Day 19 of Problem Solving Series Day 19 of Problem Solving Series

