|
| 1 | +# Day 29 |
| 2 | + |
| 3 | +## ⭐️ Longest Substring Without Repeating Characters – 29.1 |
| 4 | +### 🔗 Problem |
| 5 | +[LeetCode #3 – Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/) |
| 6 | + |
| 7 | +### 🧠 Core Idea |
| 8 | +Maintain a sliding window with two pointers and a hash map to track the last seen index of each character. |
| 9 | +When a duplicate is found inside the current window, move the left pointer just past the previous occurrence to keep the substring unique. |
| 10 | +Continuously update the maximum window length as you expand the right pointer. |
| 11 | + |
| 12 | +### 📊 Example |
| 13 | +Input: `s = "abcabcbb"` |
| 14 | + |
| 15 | +Output: `3` -> Longest substring is `"abc"` |
| 16 | + |
| 17 | +### ⏱️ Complexity |
| 18 | +- Time: O(n) – Each character is processed at most twice |
| 19 | + |
| 20 | +- Space: O(k) – At most one entry per unique character |
| 21 | + |
| 22 | +👉 See full code in [longest_substring_without_repeating_characters.py](https://github.com/lyushher/LeetCode-Python-Easy-DSA/blob/main/day-29/longest_substring_without_repeating_characters.py) |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## ⭐️ Summary Ranges – 29.2 |
| 27 | +### 🔗 Problem |
| 28 | +[LeetCode #228 – Summary Ranges](https://leetcode.com/problems/summary-ranges/) |
| 29 | + |
| 30 | +### 🧠 Core Idea |
| 31 | +Track the start of each range while scanning the array. |
| 32 | +Whenever consecutive order breaks, record the range as either a single number or a "start->end" string, then reset the start. |
| 33 | +After the loop, append the final range. |
| 34 | + |
| 35 | +### 📊 Example |
| 36 | +Input: `nums = [0,1,2,4,5,7]` |
| 37 | + |
| 38 | +Output: `["0->2","4->5","7"]` |
| 39 | + |
| 40 | +### ⏱️ Complexity |
| 41 | +- Time: O(n) – Single pass through the array |
| 42 | + |
| 43 | +- Space: O(1) – Excluding the output list |
| 44 | + |
| 45 | +👉 See full code in [summary_ranges.py](https://github.com/lyushher/LeetCode-Python-Easy-DSA/blob/main/day-29/summary_ranges.py) |
0 commit comments