• LeetCode (9): Greedy Algorithms

    Greedy algorithms are a problem-solving paradigm that makes the locally optimal choice at each step with the hope of finding a global optimum. While seemingly simple, the challenge lies in proving that "local optimum leads to global optimum." This article systematically covers greedy algorithm fundamentals, application scenarios, and classic problems like interval scheduling, jump game, and gas station to help you build a complete greedy algorithm framework.

  • LeetCode (10): Stack and Queue

    Stacks and queues are fundamental linear data structures that appear in countless LeetCode problems, from simple parentheses matching to complex monotonic stack optimizations. While conceptually simple — stacks follow LIFO (Last In First Out) and queues follow FIFO (First In First Out)— their applications span expression evaluation, graph traversal, sliding window optimizations, and priority-based processing. This comprehensive guide walks through stack fundamentals, classic applications (valid parentheses, min stack, RPN evaluation, daily temperatures), advanced monotonic stack techniques (next greater element, largest rectangle), queue-based BFS, priority queues for top-K problems, deque optimizations for sliding windows, and the classic "implement queue using stacks" puzzle. We'll cover time/space complexity analysis, common pitfalls, and practical interview strategies.

  • LeetCode (8): Backtracking Algorithm

    Backtracking is one of the most elegant and powerful algorithmic paradigms for solving constraint satisfaction problems. Unlike brute force that blindly explores all possibilities, backtracking builds solutions incrementally and abandons partial solutions ("backtracks") as soon as they cannot lead to a valid answer. This makes it perfect for problems like generating permutations, finding combinations, solving puzzles (N-Queens, Sudoku), and exploring decision trees. This guide teaches you the backtracking framework through five classic LeetCode problems, shows you how to identify when to use backtracking, demonstrates pruning techniques to optimize your solutions, and provides a reusable template that works across 90% of backtracking problems. We'll also cover complexity analysis, common pitfalls, and answer 10 frequently asked questions.

  • LeetCode (7): Dynamic Programming Basics

    Dynamic Programming (DP) is one of the most powerful problem-solving paradigms in computer science. While it might seem intimidating at first, understanding its core principles and patterns can transform how you approach optimization problems. guide you through the fundamentals of dynamic programming, from the theoretical foundations to practical LeetCode problem-solving strategies.

  • LeetCode (6): Binary Tree Traversal & Construction

    Binary trees are a cornerstone of algorithm interviews, appearing in problems ranging from basic traversal to complex construction challenges. Mastering binary tree techniques is essential for demonstrating algorithmic proficiency. This comprehensive guide systematically covers four traversal methods (preorder, inorder, postorder, level-order), explores both recursive and iterative implementations, and solves classic construction problems (building trees from preorder+inorder and postorder+inorder). We'll also analyze complexity, common pitfalls, optimization techniques, and variant extensions.

  • LeetCode (5): Binary Search

    Binary search is one of the most fundamental and powerful algorithms in computer science. Despite its apparent simplicity, mastering binary search requires understanding subtle boundary conditions, recognizing when to apply it, and knowing which template to use for different problem types. This algorithm appears in countless real-world systems, from database indexing to version control systems, and mastering it is essential for any serious programmer. This article provides a comprehensive guide to binary search, covering everything from basic concepts to advanced applications in LeetCode problems, along with practical insights into how this elegant algorithm powers modern computing systems.

  • LeetCode (4): Sliding Window Technique

    The sliding window technique is one of the most powerful and frequently used patterns in array and string problems. It allows us to efficiently solve problems that require examining contiguous subarrays or substrings without recalculating everything from scratch. If you've ever found yourself writing nested loops to check every possible subarray, sliding window is likely the optimization you need.

  • LeetCode (3): Linked List Operations - Reversal, Cycle Detection & Merging

    Linked lists are a cornerstone of technical interviews, testing your ability to manipulate pointers, handle edge cases, and optimize space usage. Unlike arrays, linked lists offer insertion and deletion but requirefor access. They naturally support dynamic growth but lack random access capabilities. This comprehensive guide walks through five classic problems —reversing a linked list (iterative and recursive), merging two sorted lists, detecting cycle entry points, finding intersection nodes, and removing the nth node from the end— to build a complete toolkit for linked list mastery. We'll dive deep into the trade-offs between iteration and recursion, the power of dummy nodes, and how to solve complex operations inspace.

  • LeetCode (2): Two Pointers - Collision, Fast-Slow & Sliding Window Complete Guide

    Two pointers is one of the most elegant techniques in interview algorithms: by cleverly maintaining the positional relationship between two pointers, you can reduce brute-force complexity towhile maintainingspace overhead. This guide systematically introduces three core patterns —Collision Pointers (converging from both ends), Fast-Slow Pointers (cycle detection with speed differential), and Sliding Window (dynamic subarray maintenance)— building a complete two-pointer thinking system through six classic problems. We'll also deeply analyze when to choose two pointers over hash tables, how to avoid boundary errors, and communication techniques for interviews.

  • LeetCode (1): Hash Tables - Patterns, Pitfalls & Three Classic Problems Deep Dive

    Hash tables are one of the highest ROI data structures in both interviews and real systems: by trading a small amount of memory overhead for fast membership queries and lookups, you can transform "scan all elements" solutions into near-linear time workflows. This guide builds reusable hash table thinking patterns through three LeetCode classics —Two Sum, Longest Consecutive Sequence, and Group Anagrams— to teach you what to store, how to design keys, and how to avoid common boundary-case bugs. We'll also cover advanced patterns (complement search, frequency counting, sliding window), performance comparisons, interview tips, and a debugging checklist.