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
SATISH KUMAR’s Post
More Relevant Posts
-
Earlier this week, I wrote about the developer loop - learn, practice, apply, repeat. So I put it into practice. Just staying sharp, working through DSA problems in Python. Came across max_subarray_sum. Solved it. Moved on. Then I went back to see how other people approached it… and ran into Kadane’s algorithm : ``` def max_subarray_sum(nums): max_sum = current_sum = nums[0] for num in nums[1:]: current_sum = max(num, current_sum + num) max_sum = max(max_sum, current_sum) return max_sum ``` Same problem. Cleaner logic. O(n) instead of brute force. Here's what I'm trying to say: going back to problems you’ve already solved might feel like you’re wasting time… but you’re not. It isn't. Sometimes it’s only when you revisit something with a fresh mind that you actually see better approaches you missed the first time. There’s almost always more than one way to solve a problem. Which one is "best"? That's a conversation for another day. What’s something you revisited and understood completely differently the second time? #Python #DSA #SoftwareEngineering #DeveloperLife #TechCanada
To view or add a comment, sign in
-
🚀 FastAPI just unlocked something big. With FastAPI 0.136.0 officially supporting free-threaded Python (No-GIL), I wanted to test what actually changes in real-world APIs — beyond the hype. So I ran controlled benchmarks comparing: 🐍 Python 3.12 — with GIL ⚡ Python 3.13.0t — No-GIL Same code. Same API. No changes. 💥 The result: ~8× improvement in CPU-bound performance. That’s a massive shift for: 🤖 ML inference APIs 📊 Data processing workloads 🧠 CPU-heavy backend systems ⚙️ High-performance backend services This feels like a major step forward for Python backend performance. Curious to hear what others think about the No-GIL shift 👇 #FastAPI #Python #Performance #Backend #Concurrency #AI #NoGIL #ThinkAI
To view or add a comment, sign in
-
-
A plain LLM call says: "The answer to 6 × 7 is 42." An agent calls multiply(6, 7), gets 42, then says: "The answer is 42." One returns text. The other runs code. We put together langgraph-zero-to-agent at Theseus AI Lab. Free, open source, 4 modules. Python basics is all you need to start. Module 1: you wire the graph by hand. Every node, every edge, every tool binding. Module 2: same agent, rebuilt with create_agent(). You see what abstraction actually buys you. Module 3: a coding assistant with a local shell. It writes Python files and runs them on your machine. Module 4: OpenAI Responses API. Web search, code interpreter, reasoning built in. 🔗 https://lnkd.in/dpgwyqq8 #LangGraph #AIAgents #Python #OpenSource
To view or add a comment, sign in
-
-
🚀 Day 20 of My Python Journey – Solved Find First and Last Position of Element! 💻✨ Today I worked on finding the first and last occurrence of an element in a sorted array ✅ This problem helped me understand how powerful Binary Search can be when slightly modified. 📌 Problem Statement Given a sorted array, find the starting and ending position of a target value. If the target is not found, return [-1, -1]. Example: nums = [5,7,7,8,8,10] target = 8 ✅ Output: [3,4] 🔍 My Approach Instead of using a normal binary search once, I used it twice: First → to find the first occurrence Second → to find the last occurrence The idea is: When target is found, don’t stop Keep searching on the left side (for first position) Keep searching on the right side (for last position) This small modification makes a big difference 🚀 💡 Key Learning This problem helped me understand: ✔ Advanced Binary Search techniques ✔ How to modify standard algorithms ✔ Handling edge cases carefully ✔ Writing efficient search logic ⏱ Complexity Time Complexity: O(log n) Space Complexity: O(1) Really liked this one because it shows how a basic concept can be extended to solve more complex problems 🔥 #Python #DSA #BinarySearch
To view or add a comment, sign in
-
-
🚀 FastAPI just unlocked something big. With FastAPI 0.136.0 officially supporting free-threaded Python (No-GIL), I wanted to see what actually changes in real-world APIs. So I ran controlled benchmarks comparing: • Python 3.12 (GIL) • Python 3.13.0t (No-GIL) Same code. Same API. No changes. 💥 Result: ~8× improvement in CPU-bound performance. This shift is huge for: • ML inference APIs • Data processing workloads • CPU-heavy backend systems I’ve broken down the full experiment, setup, and results here: 👉 https://lnkd.in/dQdrr5gE Curious to hear what others think about this shift 👇 #FastAPI #Python #Performance #Backend #Concurrency #AI
To view or add a comment, sign in
-
-
It’s amazing how the Python language has been developing over the years and how the team behind FastAPI has been keeping up with these changes. By using a “modern” Python-stack based on uv+FastAPI developers have been gaining so much “free” performance upgrades. This has real world impact way beyond the developer experience.
🚀 FastAPI just unlocked something big. With FastAPI 0.136.0 officially supporting free-threaded Python (No-GIL), I wanted to see what actually changes in real-world APIs. So I ran controlled benchmarks comparing: • Python 3.12 (GIL) • Python 3.13.0t (No-GIL) Same code. Same API. No changes. 💥 Result: ~8× improvement in CPU-bound performance. This shift is huge for: • ML inference APIs • Data processing workloads • CPU-heavy backend systems I’ve broken down the full experiment, setup, and results here: 👉 https://lnkd.in/dQdrr5gE Curious to hear what others think about this shift 👇 #FastAPI #Python #Performance #Backend #Concurrency #AI
To view or add a comment, sign in
-
-
Interesting to see FastAPI moving toward No-GIL 🔥 Curious how this would behave in real-world scenarios like document parsing or image processing and what role ProcessPoolExecutor or multi-worker setups would still play.
🚀 FastAPI just unlocked something big. With FastAPI 0.136.0 officially supporting free-threaded Python (No-GIL), I wanted to see what actually changes in real-world APIs. So I ran controlled benchmarks comparing: • Python 3.12 (GIL) • Python 3.13.0t (No-GIL) Same code. Same API. No changes. 💥 Result: ~8× improvement in CPU-bound performance. This shift is huge for: • ML inference APIs • Data processing workloads • CPU-heavy backend systems I’ve broken down the full experiment, setup, and results here: 👉 https://lnkd.in/dQdrr5gE Curious to hear what others think about this shift 👇 #FastAPI #Python #Performance #Backend #Concurrency #AI
To view or add a comment, sign in
-
-
Day 22 of my DSA journey Today I worked on the Sliding Window technique. It is a useful optimization approach for problems involving subarrays or substrings. Instead of recalculating values repeatedly, it helps reuse previous computations and reduces time complexity. Problem: Maximum Sum Subarray of Size K Given an array of integers and a number k, find the maximum sum of any contiguous subarray of size k. Brute Force Approach: Check all possible subarrays of size k and calculate their sums. Time Complexity: O(n²) Optimized Approach (Sliding Window): Calculate the sum of the first window of size k Slide the window by one element at a time Add the next element and remove the previous element from the sum Track the maximum sum Python Code: def max_sum_subarray(arr, k): window_sum = sum(arr[:k]) max_sum = window_sum for i in range(k, len(arr)): window_sum += arr[i] window_sum -= arr[i-k] max_sum = max(max_sum, window_sum) return max_sum arr = [2, 1, 5, 1, 3, 2] k = 3 print(max_sum_subarray(arr, k)) Time Complexity: O(n) Space Complexity: O(1) Learning: Sliding Window significantly improves performance in problems related to subarrays and substrings. I will practice more variations like variable window size and string-based problems next. #DSA #CodingJourney #SlidingWindow #Python #100DaysOfCode
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development