Day 23 of DSA Journey: Sliding Window Pattern

🚀 Day 23 of my DSA Journey (LeetCode + Java) Today’s practice was all about Sliding Window — one of the most powerful and efficient patterns for subarray and substring problems. All three problems became easy once I identified the correct window movement. ✅ Problems Solved Today: LC 209 – Minimum Size Subarray Sum LC 1456 – Maximum Number of Vowels in a Substring of Given Length LC 643 – Maximum Average Subarray I 🧠 My Experience Solving These: 🔸 209. Minimum Size Subarray Sum This problem looked complicated at first, but then I realized it can be solved using the two-pointer sliding window. Expand window using right Shrink window using left Update minimum window length whenever sum ≥ target Once I applied this approach, the solution became fully optimized. 🔸 1456. Maximum Number of Vowels in a Substring of Length k This was a clean sliding-window substring problem. First, count vowels in the first window Then slide the window by ✔ adding new char ✔ removing old char Keep track of the maximum vowel count Very efficient and elegant. 🔸 643. Maximum Average Subarray I A straightforward calculation-based problem. First window → compute initial sum Then slide the window and update sum Track maximum sum Return maxSum / k Solved in O(n) with no extra space. 📌 Key Takeaway Today: Sliding Window helps simplify problems that involve continuous subarrays / substrings. ✔ Use two pointers ✔ Expand + shrink window ✔ Update result during each move ✔ Avoid nested loops — O(n) is always better Every day I’m getting better at recognizing patterns and choosing the right technique. On to Day 24! 🚀 #DSA #LeetCode #Java #SlidingWindow #ProblemSolving #CodingJourney #Consistency #LearningDaily

To view or add a comment, sign in

Explore content categories