Skip to main content

Algorithms-1

A collection of algorithm solutions with deep-dive explanations, pattern-based learning, and step-by-step thinking processes. Each document goes beyond "here's the answer" — it traces how you arrive at the solution from first principles.


What's Inside​

General Foundations​

Decision frameworks for choosing the right approach — Greedy vs DP vs Divide & Conquer — plus core learning principles that apply across all algorithm categories.

Sorting Algorithms​

Classic sorting algorithms explained from the ground up:

  • Bubble Sort — mechanics and analysis
  • Quick Sort — partitioning strategy and performance
  • Merge Sort — divide & conquer in action

Consecutive Subsequence — A Full Problem-Solving Journey​

A single problem deconstructed across 9 parts, showing the complete arc from confusion to clarity:

Problem Statement → Thinking Process → Algorithm Discovery → Implementation → Complete Trace → Constraints vs Edge Cases → Safety Mechanisms → Unmet Needs → Key Takeaways

This is a model for how to approach any unfamiliar problem.

Recursion & Backtracking​

Recursive thinking patterns with worked examples:

  • GroupSum — recursive subset selection
  • Word Search — backtracking on a grid
  • Validate BST — recursive tree verification

Dynamic Programming — 16 Patterns, 67 Documents​

The largest section by far. DP problems are organized by pattern, not difficulty, so you build transferable intuition.


Dynamic Programming Spotlight​

The DP collection covers 16 patterns ordered by real interview frequency:

Tier 1 — Must Master (55% of interview questions):

  • Linear Sequence (26%) — Fibonacci, Climbing Stairs, House Robber, Max Subarray, Decode Ways
  • LIS (16%) — Longest Increasing Subsequence and variants
  • Knapsack (13%) — 0/1 Knapsack, Coin Change, Partition Equal Subset Sum

Tier 2 — High Frequency (28%):

  • Grid Traversal — Unique Paths, Minimum Path Sum
  • String DP / LCS — Edit Distance, Longest Common Subsequence, Sequence Alignment
  • Subset Sum & Partition — partition problems and bounded knapsack

Tier 3 — Medium Frequency (11%):

  • Palindrome DP — Longest Palindromic Substring/Subsequence, Palindromic Substrings
  • Interval DP — Burst Balloons and interval-based recurrences
  • Counting DP — combinatorial counting patterns

Tier 4 — Specialized (6%):

  • State Machine DP — Stock Buy/Sell series (II, III, IV)
  • Tree DP — House Robber III, tree-based recurrences
  • DAG DP, Game Theory, Probability, Bitmask/Digit DP, DP Optimizations

Many problems include multiple documents — a "journey" narrative tracing the thinking process, a "first principles" breakdown, and a "3 approaches" comparison showing brute force → optimized → optimal.


How to Navigate​

Use the sidebar categories on the left to browse by topic. Within Dynamic Programming, documents are prefixed by pattern number (pattern1-, pattern2-, etc.) so related problems stay grouped together.

Recommended starting points:

  • New to algorithms? Start with General → Learning Principles
  • Want to see the methodology? Read the Consecutive Subsequence series end-to-end
  • Preparing for interviews? Jump to DP → Patterns Overview for the frequency-based learning path