Sliding Window Problem Solving with Constraint Tracking

📘 DSA Journey — Day 25 Today’s focus: Sliding Window with constraint tracking. Problem solved: • Find the Longest Semi-Repetitive Substring (LeetCode 2730) Concepts used: • Sliding Window / Two-pointer technique • Constraint tracking within window • Dynamic window adjustment Key takeaway: The goal is to find the longest substring where there is at most one pair of equal adjacent characters. Using a sliding window, we expand the window while keeping track of how many adjacent equal pairs exist. If the number of such pairs exceeds 1, we shrink the window from the left until the condition is satisfied again. At each step, we maintain the maximum valid window length. This problem shows how sliding window can be adapted not just for counts or sums, but also for tracking specific patterns or conditions inside a substring. Continuing to strengthen pattern recognition and consistency in DSA problem solving. #DSA #Java #LeetCode #CodingJourney

  • graphical user interface, text, application

To view or add a comment, sign in

Explore content categories