DSA Sheet - Day 3 Arrays
🚀 DSA Sheet – Day 3: Arrays (Part 3)
This set introduces advanced patterns like Sliding Window, Backtracking, and Interval Merging. These are highly frequent in FAANG interviews — focus on understanding patterns deeply.
📊 Progress Tracker
Progress: 0 / 6 Completed
| Done | Problem | Practice | Level | Companies |
|---|---|---|---|---|
| Next Permutation | Solve | Medium | Adobe, Goldman Sachs, Uber | |
| Merge Overlapping Intervals | Solve | Medium | ||
| Longest Substring Without Repeating | Solve | Medium | Amazon, Morgan Stanley | |
| Set Matrix Zeroes | Solve | Medium | Amazon, Microsoft | |
| Word Search | Solve | Medium | Google, Goldman Sachs, Ola | |
| Product of Array Except Self | Solve | Medium | Amazon |
🧠 Key Approaches
- Next Permutation: Find breakpoint → swap → reverse suffix
- Merge Intervals: Sort intervals, merge overlaps
- Longest Substring: Sliding window + HashSet
- Set Matrix Zeroes: Use first row/column as markers
- Word Search: Backtracking (DFS)
- Product Except Self: Prefix + suffix multiplication
⚡ Quick Cheatsheet
Merge Intervals
sort(intervals.begin(), intervals.end());
vector> res;
for(auto it : intervals){
if(res.empty() || res.back()[1] < it[0])
res.push_back(it);
else
res.back()[1] = max(res.back()[1], it[1]);
}
Longest Substring Without Repeating Characters
set s;
int l = 0, res = 0;
for(int r = 0; r < n; r++){
while(s.count(str[r]))
s.erase(str[l++]);
s.insert(str[r]);
res = max(res, r - l + 1);
}
Product of Array Except Self
vector res(n, 1);
for(int i = 1; i < n; i++)
res[i] = res[i - 1] * nums[i - 1];
int suffix = 1;
for(int i = n - 1; i >= 0; i--){
res[i] *= suffix;
suffix *= nums[i];
}
🔥 Pro Tip
These problems unlock advanced patterns:
- Sliding Window
- Backtracking (DFS)
- Interval Merging