maths ::::https://schoolyourself.org/learn
pattern::https://leetcode.com/discuss/post/5908573/important-dsa-patterns-100-must-know-for-0m7j/
pattern :::::: https://thita.ai/dsa-patterns-sheet
Most problems fall into these categories. Learn to identify them:
| Pattern | Clue Words | Common Approach |
|---|---|---|
| Two Pointers | Sorted array, pairs, palindrome | Left & right pointers |
| Sliding Window | Subarray, substring, consecutive | Expand/contract window |
| Binary Search | Sorted, find target, log(n) | Left/right boundaries |
| Hash Map | Count, frequency, O(1) lookup | Store seen elements |
| Stack | Nested, parentheses, next greater | LIFO structure |
| Queue/BFS | Level-order, shortest path | FIFO structure |
| DFS | All paths, backtracking | Recursion |
| DP | Optimal, maximum, count ways | Subproblems + memoization |
| Greedy | Maximize/minimize, local optimal | Make best choice now |
| Prefix Sum | Range query, subarray sum | Cumulative sum array |
https://claude.ai/public/artifacts/36188888-1a5c-47ab-90a5-7164aef178c6

Here's a proven strategy for when you get stuck on a problem:
- 0-5 min: Read, understand, try brute force
- 5-10 min: If stuck, think about common patterns (hash map, two pointers)
- 10-15 min: Still stuck? → LOOK AT HINTS (LeetCode provides hints)
- 15 min: If no progress → READ SOLUTION, understand it, code it yourself
- 0-10 min: Understand problem, examples, edge cases
- 10-25 min: Try solving (brute force → optimize)
- 25-35 min: Stuck? → READ HINTS or look at topic tags
- 35-40 min: Still struggling? → READ SOLUTION
- 40+ min: Understand solution deeply, implement from scratch
- 0-15 min: Understand thoroughly, think about approach
- 15-40 min: Attempt solution
- 40-50 min: If stuck → HINTS/TAGS
- 50-60 min: No progress? → READ EDITORIAL
□ Read problem 2-3 times
□ Identify input/output
□ Work through examples manually
□ Think of edge cases:
- Empty input
- Single element
- All same elements
- Maximum constraints
- Negative numbers (if applicable)
□ Can you explain the problem to someone else?
□ What's the brute force solution? (Always start here!)
□ What's the time/space complexity?
□ Draw it out on paper
□ Try small examples (n=1, n=2, n=3)
□ Look for patterns
□ Ask yourself:
- Have I solved something similar?
- What data structure fits naturally?
- Is there sorting/searching involved?
- Can I use hash map for O(1) lookups?
- Is it about counting/frequency?
- Does order matter?
□ Choose an approach
□ Write pseudocode
□ Identify data structures needed
□ Think through the algorithm step-by-step
□ Verify with examples
□ Write clean code
□ Use meaningful variable names
□ Comment complex parts
□ Handle edge cases
□ Run provided examples
□ Test edge cases
□ Dry run through your code
□ Check for off-by-one errors
□ Look for array out of bounds
Option A: Use Hints (Recommended first)
- Read first hint only
- Try for 5 more minutes
- Still stuck? Next hint
- This helps you learn the thought process
Option B: Check Topic Tags
- LeetCode shows topics (DP, Binary Search, etc.)
- This narrows down the approach
- Try for 10 more minutes with this knowledge
Option C: Read Solution (If Options A & B don't help)
- DON'T just copy the code!
- Read the approach/intuition section only
- Close the solution
- Try implementing yourself
- Stuck again? Read the code
- THEN: Close everything and code from scratch
Option D: Watch Video Editorial (If you need more explanation)
- NeetCode, Abdul Bari, or LeetCode's official videos
- Understand WHY this approach works
- Code it yourself after watching
1. Write down the key insight/pattern
2. What made this problem tricky?
3. What pattern/technique did it use?
4. Add to your notes:
"Problem X uses [Pattern Y]"
Example: "Two Sum uses hash map for O(1) lookup"
5. Mark for review:
- If you got it: Review in 3 days
- If you looked at hints: Review tomorrow
- If you read solution: Review TONIGHT (before sleep)
-
Never spend more than 60 min on one problem during practice
- You're practicing, not competing
- Learning the pattern is more valuable than struggling
-
The 30-minute rule:
- If no progress after 30 min → use hints/tags
- Don't waste time being completely stuck
-
Implement the brute force FIRST:
- Even if it's slow
- Then optimize
- This prevents analysis paralysis
-
Review > Solving new problems:
- Solving 1 problem 3 times (spaced out) > solving 3 new problems once
- Repetition builds pattern recognition
-
Keep a "Stuck Log":
Problem: Two Sum Got stuck at: Optimizing from O(n²) Solution: Hash map for O(1) lookup Pattern: Space-time tradeoff -
During contests:
- If stuck on Q2 for 20+ min → move to Q3
- Come back later with fresh eyes
- Don't waste time on one problem
0-5 min: Read problem, understand examples
Input: [1,8,6,2,5,4,8,3,7]
Output: 49 (between 8 and 7)
5-15 min: Try brute force
// Check all pairs - O(n²)
int maxArea = 0;
for i in 0 to n:
for j in i+1 to n:
area = min(height[i], height[j]) * (j-i)
maxArea = max(maxArea, area)15-20 min: This works but can we optimize?
- STUCK! Can't think of better approach
20 min: Check HINT 1
- "The widest container uses the outermost lines..."
- Aha! Start from both ends?
25 min: Try implementing two pointers
left = 0, right = n-1
while left < right:
area = min(height[left], height[right]) * (right-left)
if height[left] < height[right]:
left++
else:
right--30 min: Got it! Pattern learned: Two pointers for optimization
- Pick 2-3 Easy problems
- Use this framework
- Time yourself strictly
- Write down patterns you discover
- Practice this framework on 10-15 problems
- Build your pattern recognition
- Create a "Pattern Cheat Sheet"
- Review problems you solved 3 days ago
Remember: Getting stuck is NORMAL. The goal is to learn the pattern, not to solve every problem independently. Even top competitive programmers look up solutions when learning!
Want me to walk through a specific problem with you using this framework?