Algorithms Skill
Skill Metadata
skill_config:
version: "1.0.0"
category: problem-solving
prerequisites: [cs-foundations]
estimated_time: "8-12 weeks"
difficulty: intermediate-advanced
parameter_validation:
pattern:
type: string
enum: [search, sort, dp, greedy, backtrack, divide-conquer, graph]
required: true
language:
type: string
enum: [python, java, cpp, javascript]
default: python
retry_config:
max_attempts: 3
backoff_strategy: exponential
initial_delay_ms: 500
observability:
log_level: INFO
metrics: [pattern_usage, solution_complexity, hint_count]
Quick Start
Become a master problem solver through systematic algorithm design.
Common Algorithm Patterns
Searching & Sorting (Week 1)
- Linear search O(n)
- Binary search O(log n)
- Merge sort O(n log n)
- Quick sort O(n log n) average
- Heap sort O(n log n)
Divide & Conquer (Week 2)
- Split problem into subproblems
- Solve recursively
- Combine results
- Analyze with recurrence relations
Dynamic Programming (Weeks 3-4)
- Identify overlapping subproblems
- Define state and transitions
- Memoization vs tabulation
- Classic problems: Fibonacci, knapsack, LCS
Greedy Algorithms (Week 5)
- Make optimal local choice
- Examples: Huffman coding, Dijkstra, activity selection
- When to use: optimal substructure + greedy choice property
Backtracking (Week 6)
- Explore all solutions
- Backtrack when dead end
- Pruning branches
- N-Queens, permutations, sudoku solver
Problem-Solving Framework
- Understand: Read problem, identify constraints, find examples
- Plan: Recognize pattern, think brute force, optimize
- Code: Write clean code, handle edge cases
- Optimize: Improve time/space complexity
- Verify: Test, verify analysis
Must-Know Problems
- Array Problems: Two sum, max subarray, product of array
- String Problems: Longest substring, pattern matching, anagrams
- Tree Problems: Traversal, BST, LCA, path sum
- Graph Problems: Shortest path, cycle detection, topological sort
- DP Problems: Fibonacci, knapsack, coin change, edit distance
- Math Problems: Prime numbers, GCD, power
Troubleshooting
| Issue |
Root Cause |
Resolution |
| TLE |
Wrong complexity class |
Find better algorithm |
| WA |
Edge case missing |
Test empty, single, max inputs |
| RE |
Index out of bounds |
Add bounds checking |
| Stack overflow |
Deep recursion |
Convert to iteration |
Complexity Quick Reference
| Problem |
Best |
Average |
Worst |
| Merge sort |
O(n log n) |
O(n log n) |
O(n log n) |
| Quick sort |
O(n log n) |
O(n log n) |
O(n²) |
| Binary search |
O(1) |
O(log n) |
O(log n) |
| Linear search |
O(1) |
O(n/2) |
O(n) |
Interview Tips
- Communicate your approach
- Discuss time/space trade-offs
- Code cleanly on the first try
- Test with examples
- Optimize if time permits
1---2name: algorithms3description: Master algorithm design, common patterns, optimization techniques, and problem-solving strategies. Learn to solve any computational challenge efficiently.4---56# Algorithms Skill78## Skill Metadata910```yaml11skill_config:12 version: "1.0.0"13 category: problem-solving14 prerequisites: [cs-foundations]15 estimated_time: "8-12 weeks"16 difficulty: intermediate-advanced1718 parameter_validation:19 pattern:20 type: string21 enum: [search, sort, dp, greedy, backtrack, divide-conquer, graph]22 required: true23 language:24 type: string25 enum: [python, java, cpp, javascript]26 default: python2728 retry_config:29 max_attempts: 330 backoff_strategy: exponential31 initial_delay_ms: 5003233 observability:34 log_level: INFO35 metrics: [pattern_usage, solution_complexity, hint_count]36```3738---3940## Quick Start4142Become a master problem solver through systematic algorithm design.4344### Common Algorithm Patterns4546**Searching & Sorting (Week 1)**47- Linear search O(n)48- Binary search O(log n)49- Merge sort O(n log n)50- Quick sort O(n log n) average51- Heap sort O(n log n)5253**Divide & Conquer (Week 2)**54- Split problem into subproblems55- Solve recursively56- Combine results57- Analyze with recurrence relations5859**Dynamic Programming (Weeks 3-4)**60- Identify overlapping subproblems61- Define state and transitions62- Memoization vs tabulation63- Classic problems: Fibonacci, knapsack, LCS6465**Greedy Algorithms (Week 5)**66- Make optimal local choice67- Examples: Huffman coding, Dijkstra, activity selection68- When to use: optimal substructure + greedy choice property6970**Backtracking (Week 6)**71- Explore all solutions72- Backtrack when dead end73- Pruning branches74- N-Queens, permutations, sudoku solver7576---7778## Problem-Solving Framework79801. **Understand**: Read problem, identify constraints, find examples812. **Plan**: Recognize pattern, think brute force, optimize823. **Code**: Write clean code, handle edge cases834. **Optimize**: Improve time/space complexity845. **Verify**: Test, verify analysis8586---8788## Must-Know Problems8990- **Array Problems**: Two sum, max subarray, product of array91- **String Problems**: Longest substring, pattern matching, anagrams92- **Tree Problems**: Traversal, BST, LCA, path sum93- **Graph Problems**: Shortest path, cycle detection, topological sort94- **DP Problems**: Fibonacci, knapsack, coin change, edit distance95- **Math Problems**: Prime numbers, GCD, power9697---9899## Troubleshooting100101| Issue | Root Cause | Resolution |102|-------|------------|------------|103| TLE | Wrong complexity class | Find better algorithm |104| WA | Edge case missing | Test empty, single, max inputs |105| RE | Index out of bounds | Add bounds checking |106| Stack overflow | Deep recursion | Convert to iteration |107108---109110## Complexity Quick Reference111112| Problem | Best | Average | Worst |113|---------|------|---------|-------|114| Merge sort | O(n log n) | O(n log n) | O(n log n) |115| Quick sort | O(n log n) | O(n log n) | O(n²) |116| Binary search | O(1) | O(log n) | O(log n) |117| Linear search | O(1) | O(n/2) | O(n) |118119---120121## Interview Tips122123- Communicate your approach124- Discuss time/space trade-offs125- Code cleanly on the first try126- Test with examples127- Optimize if time permits