LeetCode 02xx
LeetCode practice notes for problems 200 through 299, including A clear explanation of counting connected groups of land cells in a grid using DFS or BFS.
LeetCode 02xx
| # | Title | Difficulty | Description |
|---|---|---|---|
| 200 | LeetCode 200: Number of Islands | Medium | A clear explanation of counting connected groups of land cells in a grid using DFS or BFS. |
| 201 | LeetCode 201: Bitwise AND of Numbers Range | Medium | A clear explanation of finding the bitwise AND of every number in an inclusive range using the common binary prefix. |
| 202 | LeetCode 202: Happy Number | Easy | A clear explanation of detecting whether repeated digit-square sums eventually reach 1. |
| 203 | LeetCode 203: Remove Linked List Elements | Easy | A clear explanation of removing all linked list nodes with a target value using iteration and a dummy node. |
| 204 | LeetCode 204: Count Primes | Medium | A clear explanation of counting prime numbers less than n using the Sieve of Eratosthenes. |
| 205 | LeetCode 205: Isomorphic Strings | Easy | A clear explanation of checking whether two strings follow the same character mapping pattern. |
| 206 | LeetCode 206: Reverse Linked List | Easy | A clear explanation of reversing a singly linked list using iterative and recursive approaches. |
| 207 | LeetCode 207: Course Schedule | Medium | A clear explanation of detecting cycles in a prerequisite graph using topological sorting and DFS. |
| 208 | LeetCode 208: Implement Trie Prefix Tree | Medium | A clear explanation of implementing a Trie with insert, search, and startsWith operations. |
| 209 | LeetCode 209: Minimum Size Subarray Sum | Medium | A clear explanation of finding the shortest contiguous subarray whose sum is at least target using a sliding window. |
| 210 | LeetCode 210: Course Schedule II | Medium | A clear explanation of finding a valid course ordering using topological sorting and cycle detection. |
| 211 | LeetCode 211: Design Add and Search Words Data Structure | Medium | A clear explanation of designing a word dictionary with addWord and wildcard search using a Trie and DFS. |
| 212 | LeetCode 212: Word Search II | Hard | A clear explanation of finding multiple words in a character board using a Trie and DFS backtracking. |
| 213 | LeetCode 213: House Robber II | Medium | A clear explanation of maximizing robbed money from circularly arranged houses using dynamic programming. |
| 214 | LeetCode 214: Shortest Palindrome | Hard | A clear explanation of building the shortest palindrome by finding the longest palindromic prefix using KMP. |
| 215 | LeetCode 215: Kth Largest Element in an Array | Medium | A clear explanation of finding the kth largest element using sorting, a min-heap, and Quickselect. |
| 216 | LeetCode 216: Combination Sum III | Medium | A clear explanation of finding k distinct numbers from 1 to 9 that sum to n using backtracking. |
| 217 | LeetCode 217: Contains Duplicate | Easy | A clear explanation of detecting duplicates in an array using a hash set and sorting. |
| 218 | LeetCode 218: The Skyline Problem | Hard | A clear explanation of computing the skyline formed by buildings using sweep line and a max-heap. |
| 219 | LeetCode 219: Contains Duplicate II | Easy | A clear explanation of detecting whether equal values appear within distance k using a hash map or sliding window set. |
| 220 | LeetCode 220: Contains Duplicate III | Hard | A clear explanation of checking nearby indices with nearby values using a sliding window and bucket hashing. |
| 221 | LeetCode 221: Maximal Square | Medium | A clear explanation of finding the largest square of 1s in a binary matrix using dynamic programming. |
| 222 | LeetCode 222: Count Complete Tree Nodes | Easy | A clear explanation of counting nodes in a complete binary tree faster than visiting every node. |
| 223 | LeetCode 223: Rectangle Area | Medium | A clear explanation of computing the total covered area of two axis-aligned rectangles by subtracting their overlap. |
| 224 | LeetCode 224: Basic Calculator | Hard | A clear explanation of evaluating an expression with plus, minus, spaces, and parentheses using a stack. |
| 225 | LeetCode 225: Implement Stack using Queues | Easy | A clear explanation of implementing a LIFO stack using only FIFO queue operations. |
| 226 | LeetCode 226: Invert Binary Tree | Easy | A clear explanation of inverting a binary tree using recursive depth-first traversal. |
| 227 | LeetCode 227: Basic Calculator II | Medium | A detailed explanation of evaluating arithmetic expressions with stack-based parsing and operator precedence. |
| 228 | LeetCode 228: Summary Ranges | Easy | A clear explanation of summarizing a sorted unique integer array into compact consecutive ranges. |
| 229 | LeetCode 229: Majority Element II | Medium | A clear explanation of finding all elements that appear more than n/3 times using the extended Boyer-Moore voting algorithm. |
| 230 | LeetCode 230: Kth Smallest Element in a BST | Medium | A clear explanation of finding the kth smallest value in a binary search tree using inorder traversal. |
| 231 | LeetCode 231: Power of Two | Easy | A clear explanation of determining whether an integer is a power of two using binary properties and bit manipulation. |
| 232 | LeetCode 232: Implement Queue using Stacks | Easy | A detailed explanation of implementing a FIFO queue using two LIFO stacks with amortized constant time operations. |
| 233 | LeetCode 233: Number of Digit One | Hard | A detailed explanation of counting how many times digit one appears from 0 to n using positional digit analysis. |
| 234 | LeetCode 234: Palindrome Linked List | Easy | A clear explanation of checking whether a singly linked list is a palindrome using fast and slow pointers plus in-place reversal. |
| 235 | LeetCode 235: Lowest Common Ancestor of a Binary Search Tree | Medium | A clear explanation of finding the lowest common ancestor in a binary search tree using BST ordering properties. |
| 236 | LeetCode 236: Lowest Common Ancestor of a Binary Tree | Medium | A clear explanation of finding the lowest common ancestor in a normal binary tree using recursive depth-first search. |
| 237 | LeetCode 237: Delete Node in a Linked List | Medium | A clear explanation of deleting a node from a singly linked list when only that node is given. |
| 238 | LeetCode 238: Product of Array Except Self | Medium | A clear explanation of computing each product except self using prefix and suffix products without division. |
| 239 | LeetCode 239: Sliding Window Maximum | Hard | A clear explanation of finding the maximum value in every sliding window using a monotonic deque. |
| 240 | LeetCode 240: Search a 2D Matrix II | Medium | A clear explanation of searching a row-sorted and column-sorted matrix using the top-right corner elimination method. |
| 241 | LeetCode 241: Different Ways to Add Parentheses | Medium | A clear explanation of generating all possible results from different parenthesizations using divide and conquer recursion. |
| 242 | LeetCode 242: Valid Anagram | Easy | A clear explanation of checking whether two strings are anagrams using character frequency counting. |
| 243 | LeetCode 243: Shortest Word Distance | Easy | A clear explanation of the Shortest Word Distance problem using one pass and the latest seen indices of both words. |
| 244 | LeetCode 244: Shortest Word Distance II | Medium | A clear explanation of the Shortest Word Distance II problem using preprocessing and two pointers. |
| 245 | LeetCode 245: Shortest Word Distance III | Medium | A clear explanation of the Shortest Word Distance III problem, including the special case where both target words are the same. |
| 246 | LeetCode 246: Strobogrammatic Number | Easy | A clear explanation of the Strobogrammatic Number problem using digit rotation rules and two pointers. |
| 247 | LeetCode 247: Strobogrammatic Number II | Medium | A clear explanation of generating all strobogrammatic numbers of length n using recursion from the inside out. |
| 248 | LeetCode 248: Strobogrammatic Number III | Hard | A clear explanation of counting strobogrammatic numbers in a string range using recursive generation and range filtering. |
| 249 | LeetCode 249: Group Shifted Strings | Medium | A clear explanation of grouping strings by their shifting sequence using normalized hash keys. |
| 250 | LeetCode 250: Count Univalue Subtrees | Medium | A clear explanation of counting uni-value subtrees using post-order DFS. |
| 251 | LeetCode 251: Flatten 2D Vector | Medium | A clear explanation of the Flatten 2D Vector problem using row and column pointers to implement an iterator. |
| 252 | LeetCode 252: Meeting Rooms | Easy | A clear explanation of the Meeting Rooms problem using interval sorting to detect overlaps. |
| 253 | LeetCode 253: Meeting Rooms II | Medium | A clear explanation of the Meeting Rooms II problem using a min heap to track active meeting end times. |
| 254 | LeetCode 254: Factor Combinations | Medium | A clear explanation of the Factor Combinations problem using DFS backtracking with non-decreasing factors. |
| 255 | LeetCode 255: Verify Preorder Sequence in Binary Search Tree | Medium | A clear explanation of the Verify Preorder Sequence in Binary Search Tree problem using a monotonic stack and lower bound tracking. |
| 256 | LeetCode 256: Paint House | Medium | A clear explanation of the Paint House problem using dynamic programming with constant space. |
| 257 | LeetCode 257: Binary Tree Paths | Easy | A clear explanation of the Binary Tree Paths problem using DFS backtracking to collect every root-to-leaf path. |
| 258 | LeetCode 258: Add Digits | Easy | A clear explanation of the Add Digits problem using repeated digit sums first, then the digital root formula. |
| 259 | LeetCode 259: 3Sum Smaller | Medium | A clear explanation of the 3Sum Smaller problem using sorting and the two-pointer technique. |
| 260 | LeetCode 260: Single Number III | Medium | A clear explanation of the Single Number III problem using XOR partitioning to isolate the two unique numbers. |
| 261 | LeetCode 261: Graph Valid Tree | Medium | A clear explanation of the Graph Valid Tree problem using Union Find to detect cycles and verify connectivity. |
| 262 | LeetCode 262: Trips and Users | Hard | A clear explanation of the Trips and Users SQL problem using joins, filtering, grouping, and conditional aggregation. |
| 263 | LeetCode 263: Ugly Number | Easy | A clear explanation of the Ugly Number problem using repeated division by the only allowed prime factors. |
| 264 | LeetCode 264: Ugly Number II | Medium | A clear explanation of the Ugly Number II problem using dynamic programming with three pointers. |
| 265 | LeetCode 265: Paint House II | Hard | A clear explanation of the Paint House II problem using optimized dynamic programming with minimum and second minimum tracking. |
| 266 | LeetCode 266: Palindrome Permutation | Easy | A clear explanation of the Palindrome Permutation problem using character parity counting. |
| 267 | LeetCode 267: Palindrome Permutation II | Medium | A clear explanation of the Palindrome Permutation II problem using character counts and backtracking over half of the palindrome. |
| 268 | LeetCode 268: Missing Number | Easy | A clear explanation of the Missing Number problem using sum formula and XOR. |
| 269 | LeetCode 269: Alien Dictionary | Hard | A clear explanation of the Alien Dictionary problem using graph construction and topological sorting. |
| 270 | LeetCode 270: Closest Binary Search Tree Value | Easy | A clear explanation of the Closest Binary Search Tree Value problem using the BST property to walk toward the target. |
| 271 | LeetCode 271: Encode and Decode Strings | Medium | A clear explanation of the Encode and Decode Strings problem using length-prefix encoding. |
| 272 | LeetCode 272: Closest Binary Search Tree Value II | Hard | A clear explanation of the Closest Binary Search Tree Value II problem using inorder traversal and a fixed-size sliding window. |
| 273 | LeetCode 273: Integer to English Words | Hard | A clear explanation of the Integer to English Words problem using three-digit chunks and scale words. |
| 274 | LeetCode 274: H-Index | Medium | A clear explanation of the H-Index problem using sorting, then an optimized counting approach. |
| 275 | LeetCode 275: H-Index II | Medium | A clear explanation of the H-Index II problem using binary search on a sorted citations array. |
| 276 | LeetCode 276: Paint Fence | Medium | A dynamic programming solution for counting ways to paint fence posts with no more than two adjacent posts sharing the same color. |
| 277 | LeetCode 277: Find the Celebrity | Medium | A two-pass solution for finding a celebrity using the knows API with O(n) calls and O(1) extra space. |
| 278 | LeetCode 278: First Bad Version | Easy | A binary search solution for finding the first bad version while minimizing calls to the isBadVersion API. |
| 279 | LeetCode 279: Perfect Squares | Medium | A dynamic programming solution for finding the least number of perfect square numbers that sum to n. |
| 280 | LeetCode 280: Wiggle Sort | Medium | A greedy in-place solution for rearranging an array into a non-strict wiggle pattern. |
| 281 | LeetCode 281: Zigzag Iterator | Medium | A queue-based iterator design for returning elements from two vectors in alternating order, with a clean extension to k vectors. |
| 282 | LeetCode 282: Expression Add Operators | Hard | A backtracking solution for inserting operators into a numeric string so the expression evaluates to a target value. |
| 283 | LeetCode 283: Move Zeroes | Easy | A two-pointer in-place solution for moving all zeroes to the end while preserving the relative order of non-zero elements. |
| 284 | LeetCode 284: Peeking Iterator | Medium | A wrapper iterator design that supports peeking at the next element without advancing the iterator. |
| 285 | LeetCode 285: Inorder Successor in BST | Medium | A binary-search-style solution for finding the smallest node greater than p in a binary search tree. |
| 286 | LeetCode 286: Walls and Gates | Medium | A multi-source BFS solution for filling each empty room with its shortest distance to the nearest gate. |
| 287 | LeetCode 287: Find the Duplicate Number | Medium | A Floyd cycle detection solution for finding the repeated number without modifying the array and using constant extra space. |
| 288 | LeetCode 288: Unique Word Abbreviation | Medium | A hash map design for checking whether a word's abbreviation is unique in a dictionary. |
| 289 | LeetCode 289: Game of Life | Medium | An in-place matrix simulation for computing the next state of Conway's Game of Life using temporary encoded states. |
| 290 | LeetCode 290: Word Pattern | Easy | A hash map solution for checking whether a pattern string and a space-separated word string form a bijection. |
| 291 | LeetCode 291: Word Pattern II | Medium | A backtracking solution for matching a pattern string to a target string using a bijective character-to-substring mapping. |
| 292 | LeetCode 292: Nim Game | Easy | A game theory solution for deciding whether the first player can win by using the losing-position pattern of multiples of four. |
| 293 | LeetCode 293: Flip Game | Easy | A simple string scanning solution for generating every possible next state after flipping one consecutive ++ pair into --. |
| 294 | LeetCode 294: Flip Game II | Medium | A recursive game theory solution with memoization for deciding whether the starting player can force a win. |
| 295 | LeetCode 295: Find Median from Data Stream | Hard | A two-heap data structure for adding numbers from a stream and returning the current median in constant time. |
| 296 | LeetCode 296: Best Meeting Point | Hard | A median-based solution for minimizing total Manhattan distance in a grid. |
| 297 | LeetCode 297: Serialize and Deserialize Binary Tree | Hard | A preorder DFS codec for converting a binary tree to a string and reconstructing the same tree from that string. |
| 298 | LeetCode 298: Binary Tree Longest Consecutive Sequence | Medium | A DFS solution for finding the longest parent-to-child path where each node value increases by exactly one. |
| 299 | LeetCode 299: Bulls and Cows | Medium | A counting solution for producing the Bulls and Cows hint while handling duplicate digits correctly. |