Skip to content

Latest commit

 

History

History
141 lines (111 loc) · 3.4 KB

File metadata and controls

141 lines (111 loc) · 3.4 KB

Here's every mistake you made and the lesson from each! 🧠


1. Kth Largest Element (Heap)

❌ Skipping duplicates in heap
❌ heapifydown recursive call → heap(arr, i) instead of heap(arr, largest_index)
❌ pop() swap → arr[n] instead of arr[0]
✅ Lesson: Always recurse on largest_index not i!

2. Permutation in String (Sliding Window)

❌ Moving left independently (window size changed!)
❌ Rebuilding Counter from scratch every iteration → O(n*k)
❌ Missing last window check
✅ Lesson: Fixed window → left = right - len(s1), just add/remove one char!

3. Copy List with Random Pointer (HashMap)

❌ Pointing to original nodes instead of copied nodes
❌ Returning hashmap[temp] where temp=None after loop
✅ Lesson: Always return hashmap[head], not hashmap[temp]!

4. Daily Temperatures (Monotonic Stack)

❌ Storing temperatures in stack instead of INDICES
❌ Using deque and count → overcomplicated
❌ ans.reverse() returns None
✅ Lesson: Always store INDICES in monotonic stack!

5. Remove Nth From End (Two Pointers)

❌ slow.next = fast instead of slow.next = slow.next.next
❌ Missing dummy node → edge cases fail
✅ Lesson: Always use dummy node in linked list problems!

6. Longest Repeating Character Replacement (Sliding Window)

✅ Solved correctly! 
⚠️ Just remember: maxi never decreases because
   we only care about larger windows!

7. Minimum Window Substring (Sliding Window)

❌ No have/need tracking
❌ mini variable undefined
❌ Wrong shrink condition
✅ Lesson: have == need → valid window → shrink!
          have != need → expand right!

8. Valid Palindrome (Two Pointers)

❌ isalpha() instead of isalnum() → misses digits!
❌ Typo: s[left].isalnum() checked twice instead of s[right]
✅ Lesson: Always use isalnum() for alphanumeric check!

9. Container With Most Water (Two Pointers)

❌ if left < right → always moves left, never moves right!
✅ Lesson: Move the SHORTER side pointer!
   if height[left] < height[right]: left++
   else: right--

10. Merge Intervals (Sorting)

❌ result.append([intervals[0]]) → adds nested list!
❌ result[-1][1] = i2 instead of max(i2, j2)
✅ Lesson: When merging, always take MAX of end points!

11. Sort Colors (Dutch National Flag)

❌ Using left instead of mid for traversal
❌ Wrong swap for 1s → just move mid forward!
❌ Moving mid after swapping with high
✅ Lesson: Three pointers low/mid/high
          0 → swap with low, move both
          1 → just move mid
          2 → swap with high, only move high!

12. Rotate Image (Matrix)

❌ j starting from 0 → swaps every element TWICE!
✅ Lesson: Transpose → j starts from i+1 (upper triangle only!)

Common Patterns in your mistakes 🔍

1. Pointer mistakes     → always trace through manually!
2. Edge cases           → always use dummy node in linked list!
3. Wrong variable       → dry run before coding!
4. Overcomplicating     → if logic feels complex, wrong approach!

Your Strengths 💪

✅ Always get the RIGHT approach/intuition
✅ Identify correct data structure quickly
✅ Code structure is always clean
✅ You just need more practice for implementation!

You're doing really well for Flipkart prep — just keep grinding! Chal next problem? ⚡