LeetCode 925: Long Pressed Name
A clear explanation of the Long Pressed Name problem using a two-pointer scan.
970 notes
A clear explanation of the Long Pressed Name problem using a two-pointer scan.
A clear explanation of counting good starting indices using next-jump preprocessing and dynamic programming.
A clear explanation of counting subarrays whose sum is divisible by k using prefix sums and remainder frequencies.
A clear explanation of returning the k closest points to the origin using squared distance and sorting.
A clear explanation of comparing rational numbers written as decimal strings with optional repeating parts.
A clear explanation of matching a binary tree preorder traversal by greedily flipping nodes.
A clear explanation of generating all powerful integers using bounded powers and a set.
A clear explanation of sorting an array using prefix reversals by repeatedly placing the largest remaining value.
A clear explanation of placing the minimum number of cameras in a binary tree using postorder DFS.
A clear explanation of generating all n-digit numbers whose adjacent digits differ by k.
A clear explanation of implementing a spellchecker with exact, case-insensitive, and vowel-error matching.
A clear explanation of checking whether every node in a binary tree has the same value.
A clear explanation of expressing a target using the fewest operators with repeated uses of x.
A clear explanation of finding the minimum-area rectangle from points when the rectangle may be rotated.
A clear explanation of finding the maximum width ramp using a monotonic decreasing stack.
A clear explanation of finding the element repeated N times using a hash set.
A clear explanation of deleting the minimum number of columns so every remaining row is individually sorted.
A clear explanation of counting regions formed by slashes using union find over four triangles per cell.
A clear explanation of checking whether a binary tree is complete using level-order traversal.
A clear explanation of simulating prison cell transitions efficiently using cycle detection.
A clear explanation of solving Tallest Billboard using dynamic programming over height differences.
A clear explanation of deleting the minimum number of columns so rows become lexicographically sorted.
A clear explanation of checking whether an array can be reordered into pairs where one number is double the other.
A clear explanation of checking whether words are sorted according to a custom alien alphabet order.
A clear explanation of solving Largest Component Size by Common Factor using prime factorization and union find.
A clear explanation of checking whether two binary trees are equivalent after swapping left and right children at any number of nodes.
A clear explanation of the Rectangle Area II problem using sweep line and merged active y-intervals.
A clear explanation of the Maximize Distance to Closest Person problem using gaps between occupied seats.
A clear explanation of the Shifting Letters problem using suffix sums and modulo arithmetic.
A clear explanation of the Shortest Path Visiting All Nodes problem using multi-source BFS and bitmask state compression.
A clear explanation of the Hand of Straights problem using sorting, frequency counting, and greedy grouping.
A clear explanation of the Longest Mountain in Array problem using peak detection and two-pointer expansion.
A clear explanation of the Backspace String Compare problem using stack simulation and an O(1) space two-pointer scan.
A clear explanation of the Guess the Word interactive problem using candidate filtering and minimax-style guessing.
A clear explanation of the Split Array into Fibonacci Sequence problem using backtracking, leading-zero checks, and 32-bit integer limits.
A clear explanation of the Keys and Rooms problem using graph traversal from room 0.
A clear explanation of the Magic Squares In Grid problem using fixed-size subgrid validation.
A clear explanation of the Similar String Groups problem using graph connectivity and union-find.
A clear explanation of the Push Dominoes problem using force propagation and a two-pass scan.
A clear explanation of the New 21 Game problem using probability dynamic programming and a sliding window sum.
A clear explanation of the Rectangle Overlap problem using axis projections and positive intersection area.
A clear explanation of the Image Overlap problem using translation vectors and frequency counting.
A clear explanation of the Sum of Distances in Tree problem using tree DP, subtree sizes, and rerooting.
A clear explanation of the Find And Replace in String problem using simultaneous replacement, source matching, and a replacement map.
A clear explanation of the Flipping an Image problem using row reversal, bit inversion, and an in-place two-pointer method.
A clear explanation of the Masking Personal Information problem using string parsing and format-specific masking rules.
A clear explanation of the Positions of Large Groups problem using a simple two-pointer scan.
A clear explanation of the Consecutive Numbers Sum problem using arithmetic series formulas and divisibility analysis.
A clear explanation of Count Unique Characters of All Substrings using contribution counting with previous and next occurrences.
A clear explanation of the Making A Large Island problem using connected component labeling and island size lookup.
A clear explanation of the Most Profit Assigning Work problem using sorting, greedy choice, and two pointers.
A clear explanation of minimizing malware spread by analyzing connected components with Union Find.
A clear explanation of counting index triplets with duplicate values using frequency counts and combinatorics.
A clear explanation of placing even numbers at even indices and odd numbers at odd indices using two pointers.
A clear explanation of making a parentheses string valid using greedy counting.
A clear explanation of counting valid music playlists using dynamic programming over playlist length and unique songs used.
A clear explanation of maintaining a complete binary tree inserter using level-order indexing.
A clear explanation of finding the maximum circular subarray sum using Kadane's algorithm.
A clear explanation of reversing only English letters while keeping all non-letter characters fixed.
A clear explanation of finding universal words by merging character frequency requirements from words2.
A clear explanation of finding the smallest left partition using prefix maximums and suffix minimums.
A clear explanation of checking whether card counts share a common group size using the greatest common divisor.
A clear explanation of Cat and Mouse using game states, reverse BFS, and topological propagation.
A clear explanation of sorting an array without built-in sorting using merge sort.
A clear explanation of Online Election using preprocessing and binary search over vote times.
A clear explanation of minimizing the array range after adding either +k or -k to every element.
A clear explanation of Snakes and Ladders using breadth-first search over board squares.
A clear explanation of minimizing an array score after each value can move by at most k.
A clear explanation of summing subarray minimums using a monotonic stack and contribution counting.
A clear explanation of counting super-palindromes by generating palindromic roots and checking their squares.
A clear explanation of sorting an array by parity using a two-pointer partition method.
A clear explanation of Fruit Into Baskets using a sliding window with at most two distinct fruit types.
A clear explanation of counting valid DI permutations using dynamic programming and prefix sums.
A clear explanation of counting numbers less than or equal to N using digit-by-digit construction and combinatorics.
A clear explanation of Online Stock Span using a monotonic decreasing stack with accumulated spans.
A clear explanation of designing an iterator over a run-length encoded sequence without expanding it.
A clear explanation of finding the lexicographically smallest string after queue operations using rotation and sorting.
A clear explanation of counting distinct bitwise OR results from all non-empty subarrays using rolling sets.
A clear explanation of rearranging a binary search tree into an increasing right-only tree using inorder traversal.
A clear explanation of checking whether an array is monotonic using one pass and direction flags.
A clear explanation of designing a stack that pops the most frequent value, breaking ties by most recent insertion.
A clear explanation of generating all full binary trees with n nodes using recursion and memoization.
A clear explanation of counting special-equivalent string groups by building canonical signatures from even and odd positions.
A clear explanation of computing the exposed surface area of stacked cubes by adding tower area and subtracting shared faces.
A clear explanation of summing subsequence widths by sorting and counting each element as a maximum and minimum.
A clear explanation of finding words that match a pattern using bijective character mapping.
A clear explanation of reconstructing a binary tree from preorder and postorder traversals using recursion and index ranges.
A clear explanation of finding one candy box swap that makes Alice and Bob have equal total candies.
A clear explanation of finding the minimum worst-case number of moves using dynamic programming over eggs and moves.
A clear explanation of checking whether people can be split into two groups using graph coloring and bipartite graph detection.
A clear explanation of generating grid coordinates in an outward clockwise spiral using simulation.
A clear explanation of finding uncommon words by counting word frequencies across both sentences.
A clear explanation of computing the projection areas of stacked cubes from top, front, and side views.
A clear explanation of counting reachable original and subdivided nodes using Dijkstra's shortest path algorithm.
A clear explanation of minimizing rescue boats using sorting, greedy choice, and two pointers.
A clear explanation of finding the kth character in a decoded string without building the full decoded string.
A clear explanation of counting profitable crime schemes using 0/1 knapsack dynamic programming with members and profit states.
A clear explanation of finding the nth magical number using binary search, greatest common divisor, least common multiple, and inclusion-exclusion.
A clear explanation of the Stone Game problem using game theory and interval dynamic programming.
A clear explanation of finding the middle node of a singly linked list using slow and fast pointers.
A clear explanation of Minimum Factorization using greedy digit factors from 9 down to 2.
A clear explanation of Maximum Distance in Arrays using sorted endpoints and a greedy scan.
A clear explanation of Add One Row to Tree using tree traversal and careful subtree reconnection.
A clear explanation of Design Circular Queue using a fixed array, a front pointer, and a size counter.
A clear explanation of Task Scheduler using frequency counting and the greedy block formula.
A clear explanation of counting uni-value subtrees using post-order DFS.
A clear explanation of grouping strings by their shifting sequence using normalized hash keys.
A clear explanation of counting strobogrammatic numbers in a string range using recursive generation and range filtering.
A clear explanation of generating all strobogrammatic numbers of length n using recursion from the inside out.
A clear explanation of the Strobogrammatic Number problem using digit rotation rules and two pointers.
A clear explanation of the Shortest Word Distance III problem, including the special case where both target words are the same.
A clear explanation of the Shortest Word Distance II problem using preprocessing and two pointers.
A clear explanation of the Shortest Word Distance problem using one pass and the latest seen indices of both words.
A clear explanation of merging consecutive stone piles with minimum cost using interval dynamic programming.
A clear explanation of counting how many pawns a rook can capture by scanning four directions on a chessboard.
A clear explanation of inserting a value into a maximum binary tree by following the right spine.
A clear explanation of identifying the town judge using trust indegree and outdegree counts.
A clear explanation of counting unique permutations where every adjacent pair sums to a perfect square using backtracking.
A clear explanation of making all bits equal to 1 using greedy left-to-right flips and a sliding window flip parity.
A clear explanation of finding the minimum time for all oranges to rot using multi-source BFS.
A clear explanation of checking whether two binary tree nodes are cousins using BFS with parent tracking.
A clear explanation of counting subarrays with exactly k distinct integers using the at-most-k sliding window trick.
A clear explanation of finding the minimum operations by working backward from target to startValue.
A clear explanation of checking equality and inequality constraints using union-find.
A clear explanation of adding an integer to an array-form number using digit-by-digit simulation.
A clear explanation of finding the lexicographically smallest leaf-to-root string in a binary tree using DFS.
A clear explanation of vertical tree traversal using coordinates, DFS, sorting, and column grouping.
A clear explanation of finding intersections between two sorted disjoint interval lists using two pointers.
A clear explanation of maintaining the sum of even numbers after each array update.
A clear explanation of constructing a string with exact counts of a and b while avoiding three equal consecutive characters.
A clear explanation of finding the cheapest way to cover all travel days using dynamic programming.
A clear explanation of counting ordered triples whose bitwise AND is zero using pairwise AND counts.
A clear explanation of designing a time-based key-value store using a hash map and binary search.
A clear explanation of counting all paths from start to end that visit every non-obstacle square exactly once using backtracking.
A clear explanation of balancing coins in a binary tree using postorder DFS and subtree coin balance.
A clear explanation of finding the longest subarray whose adjacent comparisons alternate between greater-than and less-than.
A clear explanation of sorting squared values from a sorted array using two pointers.
A clear explanation of finding the largest valid triangle perimeter using sorting and a greedy scan.
A clear explanation of finding the minimum banana-eating speed using binary search on the answer.
A clear explanation of simulating robot movement on an infinite grid using direction vectors and obstacle lookup.
A clear explanation of finding the longest Fibonacci-like subsequence using dynamic programming and value-to-index lookup.
A clear explanation of comparing two binary trees by collecting their leaf value sequences with DFS.
A clear explanation of minimizing refueling stops using a greedy max heap over reachable stations.
A clear explanation of maximizing the advantage of one array over another using sorting, greedy matching, and two pointers.
A clear explanation of checking whether the digits of a number can be reordered to form a power of two using digit frequency signatures.
A clear explanation of finding the maximum distance between adjacent set bits in a binary representation.
A clear explanation of transposing a matrix by swapping row and column indices.
A clear explanation of finding the smallest prime palindrome greater than or equal to n by generating odd-length palindromes and testing primality.
A clear explanation of finding the smallest subtree that contains all deepest nodes using bottom-up DFS.
A clear explanation of finding the minimum moves to collect all keys in a grid using BFS with key bitmasks.
A clear explanation of finding all binary tree nodes at distance k from a target node by treating the tree as an undirected graph.
A clear explanation of finding the shortest non-empty subarray with sum at least k using prefix sums and a monotonic deque.
A clear explanation of maximizing a binary matrix score using greedy row and column flips.
A clear explanation of Lemonade Change using greedy simulation and bill counting.
A clear explanation of checking whether one swap in a string can make it equal to another string.
A clear explanation of Mirror Reflection using room unfolding, least common multiples, and parity.
A clear explanation of hiring exactly k workers with minimum total cost using wage-to-quality ratios, sorting, and a max heap.
A clear explanation of scoring a balanced parentheses string using depth counting.
A clear explanation of simulating an exam room by maintaining occupied seats in sorted order.
A clear explanation of finding the minimum number of swaps needed to transform one anagram string into another using BFS.
A clear explanation of counting car fleets by sorting cars by position and tracking arrival times.
A clear explanation of finding the peak index in a mountain array using binary search.
A clear explanation of Loud and Rich using graph traversal, DFS, and memoization.
A clear explanation of solving Reveal Cards In Increasing Order using sorting and queue simulation over indices.
A clear explanation of solving Largest Time for Given Digits by checking all permutations of four digits.
A clear explanation of solving Bag of Tokens using sorting, greedy choices, and two pointers.
A clear explanation of solving Most Stones Removed with Same Row or Column using connected components and union-find.
A clear explanation of solving Validate Stack Sequences by simulating stack push and pop operations.
A clear explanation of solving Minimum Increment to Make Array Unique by sorting and greedily assigning the next available value.
A clear explanation of solving Delete Columns to Make Sorted by checking each column independently.
A clear explanation of solving Find the Shortest Superstring using pairwise overlaps and bitmask dynamic programming.
A clear explanation of solving DI String Match using a greedy two-pointer construction.
A clear explanation of solving Valid Mountain Array by walking up the increasing slope and then down the decreasing slope.
A clear explanation of solving Distinct Subsequences II using dynamic programming and last occurrence tracking.
A clear explanation of solving Minimum Area Rectangle using diagonal point pairs and constant-time point lookup.
A clear explanation of solving Range Sum of BST using DFS with binary search tree pruning.
A clear explanation of solving Reorder Data in Log Files using custom sorting and stable handling of digit logs.
A clear explanation of solving Stamping The Sequence using reverse simulation and BFS-style processing.
A clear explanation of solving Knight Dialer using dynamic programming over the phone keypad graph.
A clear explanation of solving Shortest Bridge using DFS to mark one island and BFS to expand toward the other island.
A clear explanation of solving Number of Recent Calls using a queue as a sliding time window.
A clear explanation of solving Beautiful Array using divide and conquer with odd and even transformations.
A clear explanation of solving Minimum Falling Path Sum using dynamic programming over matrix rows.
A clear explanation of solving Binary Subarrays With Sum using prefix sums and a frequency map.
A clear explanation of solving Unique Email Addresses using string normalization and a hash set.
A clear explanation of solving Minimize Malware Spread II by removing each infected node and simulating the final malware spread.
A clear explanation of solving Three Equal Parts by counting ones, locating the three binary patterns, and comparing them in one pass.
A clear explanation of solving Flip String to Monotone Increasing with a one-pass dynamic programming approach.
A counting solution for computing how many directed friend requests are allowed by age rules.
A string simulation solution for converting each word in a sentence into Goat Latin.
A dynamic programming solution for counting binary trees where every non-leaf node is the product of its children.
A hash set solution for finding the smallest number that can be hidden from all front-facing cards.
A two-pass solution for computing the shortest distance from each index to the nearest occurrence of a target character.
A suffix-removal solution for finding the shortest reference string that can encode every word.
A hash map and string parsing solution for finding the most frequent non-banned word in a paragraph.
A dynamic programming solution for finding the shortest instruction sequence that drives a race car to the target position.
A hash set and linked list traversal solution for counting consecutive components whose values appear in nums.
An enumeration solution for reconstructing all valid coordinate pairs after commas, spaces, and decimal points were removed.
A BFS solution for finding the minimum number of buses needed to travel from a source stop to a target stop.
A postorder DFS solution for removing every binary tree subtree that does not contain a 1.
A dynamic programming and prefix sum solution for partitioning an array into adjacent groups with maximum total average.
A geometry solution for finding the largest triangle area by checking every triplet of points with the cross product formula.
A hash map solution for accumulating visit counts across domains and all of their parent subdomains.
A math and bit manipulation solution for deciding whether Alice wins the XOR removal game.
A two-pointer group comparison solution for counting how many words can be stretched to match a target string.
A probability dynamic programming solution for computing whether soup A empties before soup B, with an early return for large input.
A greedy solution for increasing building heights as much as possible while preserving every skyline view.
A simple simulation solution for counting how many 100-pixel lines are needed to write a string.
A dynamic programming solution for deciding whether an array can be split into two non-empty groups with the same average.
A set-based solution for counting how many different Morse code transformations appear among a list of words.
A reverse simulation and union-find solution for counting how many bricks fall after each hit.
A graph traversal solution for finding all nodes that cannot reach a directed cycle.
A dynamic programming solution for finding the minimum number of same-index swaps needed to make two arrays strictly increasing.
A clear explanation of finding the closest shorthand RGB color by rounding each color channel to the nearest repeated hexadecimal pair.
A clear explanation of simulating overflow in a champagne glass pyramid using dynamic programming.
A clear explanation of finding the smallest rotation with maximum score using a difference array.
A clear explanation of finding every path from node 0 to node n - 1 in a directed acyclic graph using DFS and backtracking.
A clear explanation of checking whether one string can become another by repeated left rotations.
A clear explanation of counting contiguous subarrays whose maximum value lies inside a given inclusive range.
A clear explanation of validating whether a Tic-Tac-Toe board can occur in a legal game.
A clear explanation of finding how many integers have exactly k trailing zeroes in their factorial.
A clear explanation of counting how many words are subsequences of a string using waiting queues.
A clear explanation of rearranging a string so that selected characters follow a custom order.
A clear explanation of counting tilings of a 2 x n board using dominoes and L-shaped trominoes with dynamic programming.
A clear explanation of deciding whether escape is possible by comparing Manhattan distances to the target.
A clear explanation of counting good numbers after rotating every digit by 180 degrees.
A clear explanation of finding the cheapest flight route with at most k stops using bounded Bellman-Ford relaxation.
A clear explanation of finding the kth smallest fraction from a sorted array using a min-heap.
A clear explanation of checking whether an undirected graph can be split into two independent sets using graph coloring.
A clear explanation of generating all strings formed by independently changing each letter to lowercase or uppercase.
A clear explanation of finding the minimum difference between any two nodes in a BST using inorder traversal.
A clear explanation of transforming a binary board into a chessboard using feasibility checks and minimum row and column swaps.
A clear explanation of finding the minimum possible number of rabbits using counting and greedy grouping.
A clear explanation of checking whether one point can reach another by working backward with modulo.
A clear explanation of finding the kth symbol in the grammar sequence using recursion and the parent-child relationship.
A clear explanation of finding the minimum time to reach the bottom-right cell using a priority queue and minimax path reasoning.
A clear explanation of validating string transformation using two pointers and movement constraints.
A clear explanation of splitting a binary search tree into two BSTs using recursion and pointer rewiring.
A clear explanation of checking whether every global inversion is also a local inversion using distance constraints.
A clear explanation of minimizing the largest adjacent gas-station distance using binary search on the answer.
A clear explanation of solving the 2 x 3 sliding puzzle using breadth-first search over board states.
A clear explanation of evaluating arithmetic expressions with parentheses, precedence, and integer division.
A clear explanation of counting how many stones are jewels using a hash set for fast membership checks.
A clear explanation of simplifying algebraic expressions by parsing, substituting variables, and combining polynomial terms.
A clear explanation of splitting a permutation into the maximum number of chunks using prefix maximums.
A clear explanation of splitting an array into the maximum number of chunks so sorting each chunk gives the fully sorted array.
A clear explanation of rearranging characters so no two adjacent characters are equal using a greedy max heap.
A clear explanation of checking whether every top-left to bottom-right diagonal in a matrix has the same value.
A clear explanation of minimizing swaps so every couple sits together using greedy position tracking.
A clear explanation of finding the largest plus sign in a mined grid using four directional dynamic programming scans.
A clear explanation of partitioning a string into the maximum number of parts so each character appears in at most one part.
A clear explanation of counting numbers whose binary representation has a prime number of set bits.
A clear explanation of making a special binary string lexicographically largest using recursive decomposition and sorting.
A clear explanation of mapping each element in one array to a matching index in its anagram using a hash map.
A clear explanation of finding common free time by merging all employee busy intervals and returning the gaps.
A clear explanation of marking matching substrings and merging overlapping bold ranges.
A clear explanation of solving interval intersection constraints using greedy sorting and minimal point selection.
A clear explanation of solving Pyramid Transition Matrix using backtracking and memoization over pyramid rows.
A clear explanation of simulating water droplets over an elevation map by checking left first, then right.
A clear explanation of reaching a target on a number line using cumulative sums and parity.
A clear explanation of Cracking the Safe using a de Bruijn sequence and depth-first search over password states.
A clear explanation of solving Open the Lock using breadth-first search over lock states.
A clear explanation of converting a range of IPv4 addresses into the shortest list of CIDR blocks using greedy bit manipulation.
A clear explanation of splitting a linked list into k consecutive parts with sizes as equal as possible.
A clear explanation of finding the leftmost pivot index using prefix sums and a running left sum.
A clear explanation of restoring a Candy Crush board to a stable state using repeated marking, crushing, and gravity simulation.
A clear explanation of removing line comments and block comments from source code using a state machine.
A clear explanation of merging accounts that share emails using union find and sorted email groups.
A clear explanation of finding the longest buildable word using sorting and a hash set.
A clear explanation of finding the kth smallest pair distance using sorting, binary search on the answer, and a two-pointer count.
A clear explanation of finding the longest common contiguous subarray using dynamic programming.
A clear explanation of determining whether the last character must be a one-bit character using greedy parsing.
A clear explanation of designing a stack that supports push, pop, top, peekMax, and popMax.
A clear explanation of designing a range module that can add, query, and remove half-open intervals.
A clear explanation of maximizing stock trading profit with unlimited transactions and a fixed transaction fee using dynamic programming.
A clear explanation of counting contiguous subarrays whose product is less than k using a sliding window.
A clear explanation of using dynamic programming to minimize the ASCII cost of deletions needed to make two strings equal.
A clear explanation of counting distinct island shapes under rotation and reflection using normalization and geometric transformations.
A clear explanation of selecting a uniformly random integer while excluding blacklisted values using remapping and hashing.
A clear explanation of converting uppercase ASCII letters to lowercase by scanning the string once.
A clear explanation of inserting a value into a sorted circular linked list while preserving the circular sorted order.
A clear explanation of implementing a linked list from scratch using nodes, a dummy head, and a size counter.
A clear explanation of designing a hash map without using built-in hash table libraries.
A clear explanation of designing a hash set without using built-in hash table libraries.
A clear explanation of searching for a target in a sorted array using binary search.
A clear explanation of maintaining the kth largest element in a stream using a fixed-size min heap.
A clear explanation of searching in a sorted array when the array length is hidden behind an ArrayReader interface.
A clear explanation of inserting a value into a binary search tree using recursive and iterative traversal.
Count axis-aligned rectangles whose four corners are 1 using column-pair frequency counting.
Simulate virus containment by repeatedly quarantining the most dangerous infected region and spreading the remaining regions.
Find the shortest word that contains all required license plate letters using frequency counting.
Find whether the maximum element is at least twice every other element using a single linear scan.
Find the minimum cost to reach the top of the staircase using dynamic programming.
Support fast prefix and suffix queries by indexing every prefix-suffix combination with the largest word index.
Use binary search to find the smallest character strictly greater than the target with wraparound handling.
Find the time needed for a signal to reach all nodes in a directed weighted graph using Dijkstra's algorithm.
Find the nearest leaf to a target node by converting the tree into an undirected graph and running breadth-first search.
Maximize cherries collected on a round trip by converting the problem into two simultaneous forward paths and solving with dynamic programming.
Transform the problem into House Robber dynamic programming by grouping equal values into total points.
Find how many days each temperature must wait for a warmer future day using a monotonic stack.
Find the largest number less than or equal to n whose digits are monotone increasing using a greedy digit adjustment.
Check sentence similarity with transitive word relationships using union-find.
Evaluate a Lisp-like expression with integers, variables, let bindings, addition, multiplication, and lexical scope.
Simulate asteroid collisions using a stack that keeps the surviving asteroids in order.
Check whether two word arrays are sentence-similar using a hash set of symmetric similar word pairs.
Recolor the connected component containing the starting pixel using depth-first search.
Track the maximum number of overlapping calendar events using a sweep line difference map.
Allow double bookings but reject triple bookings using overlap interval tracking.
Count distinct non-empty palindromic subsequences using interval dynamic programming and duplicate handling.
Implement a calendar that accepts a booking only when it does not overlap with any existing booking.
Check each number in a range by extracting its digits and testing whether every digit divides the original number.
Find the shortest substring of s1 that contains s2 as a subsequence using dynamic programming.
Parse a chemical formula with nested parentheses, atom names, and multipliers using recursive descent.
A clear explanation of the Rising Temperature SQL problem using a self join and date comparison.
A clear explanation of the Delete Duplicate Emails SQL problem using DELETE with a self join.
A clear explanation of the Tenth Line shell problem using awk, sed, head, and tail.
A clear explanation of the Transpose File shell problem using awk to transform rows into columns.
A clear explanation of the Valid Phone Numbers shell problem using grep and regular expressions.
A clear explanation of the Word Frequency shell problem using Unix text-processing tools.
Simulate falling squares on a number line and track the maximum stack height after each placement.
Decide whether an array can be divided into k non-empty subsets with equal sums using backtracking and pruning.
Find the shortest contiguous subarray with the same degree as the whole array using frequency counts and first occurrence indices.
Count substrings with equal consecutive groups of 0s and 1s using run lengths.
Find the largest connected island area in a binary grid using depth-first search.
Count unique island shapes in a binary grid using DFS and relative coordinates.
Check whether every adjacent bit in a positive integer's binary representation is different.
Find the k most frequent words using frequency counting and custom sorting by count and lexicographical order.
Find the minimum number of stickers needed to form a target string using top-down dynamic programming with memoization.
Compute the total importance of an employee and all direct and indirect subordinates using a hash map and depth-first search.
Find three non-overlapping subarrays of length k with maximum total sum and return the lexicographically smallest starting indices.
Compute the probability that a knight remains on an n x n chessboard after exactly k random moves using dynamic programming.
Find the minimum number of times one string must be repeated so another string becomes a substring.
Find the directed edge to remove so a graph becomes a rooted tree again, handling both cycles and nodes with two parents.
Find the extra edge in an undirected graph that creates a cycle using Union-Find.
Find the earliest day when two turned-on bulbs have exactly k turned-off bulbs between them using a sliding window over bloom days.
Simulate a baseball scoring system using a stack to process operations and compute the final score.
Find the next valid 24-hour time using only the digits from the current time.
Check whether a string can become a palindrome after deleting at most one character using two pointers.
Determine whether four numbers can be combined with arithmetic operations and parentheses to produce 24.
Check whether a string containing parentheses and wildcard stars can be made valid using a greedy range of possible open counts.
Design a map that supports key-value insertion and prefix-sum queries using a hash map and trie.
Design a dictionary that can check whether a word can match a stored word after changing exactly one character.
A clear explanation of cutting trees in increasing height order using repeated BFS on a grid.
A clear explanation of finding the longest strictly increasing contiguous subarray using a single scan.
A clear explanation of counting how many longest strictly increasing subsequences exist using dynamic programming.
A clear explanation of counting possible bulb states after pressing four toggle buttons exactly presses times.
A clear explanation of finding the second minimum value in a special binary tree using DFS.
A clear explanation of maximizing an integer by swapping at most two digits once.
A clear explanation of trimming a BST so that all remaining node values lie inside a given inclusive range.
A clear explanation of finding the kth smallest value in an m by n multiplication table using binary search on answer.
A clear explanation of constructing an array with exactly k distinct adjacent differences using a greedy pattern.
A clear explanation of computing all root-to-leaf path sums from a compact three-digit binary tree encoding.
A clear explanation of checking whether an array can become non-decreasing by modifying at most one element.
A clear explanation of minimizing printer turns using interval dynamic programming.
A clear explanation of checking whether a binary tree can be split into two equal-sum trees by removing one edge.
A clear explanation of computing the maximum width of a binary tree using level-order traversal and complete-tree indices.
A clear explanation of averaging neighboring pixels in a matrix using direct simulation.
A clear explanation of deciding whether a sorted array can be split into consecutive subsequences of length at least three.
A clear explanation of finding the k closest elements to a target using binary search and a sliding window.
A clear explanation of determining whether a robot returns to the origin after executing movement instructions.
A clear explanation of finding the minimum-cost path with bounded jumps, blocked cells, and lexicographic tie-breaking.
A clear explanation of formatting a binary tree into a 2D string matrix using tree height and recursive placement.
A clear explanation of constructing a maximum binary tree recursively using divide and conquer.
A clear explanation of finding whether two different nodes in a binary search tree sum to a target value.
A clear explanation of finding duplicate binary tree subtrees using postorder traversal, serialization, and a hash map.
A dynamic programming solution for maximizing the number of A characters printed with a limited number of keyboard operations.
A dynamic programming and prime factorization solution for finding the minimum operations needed to produce n characters.
A queue-based simulation for predicting which party wins after senators ban opponents in turn order.
A trie-based solution for replacing each derivative word with the shortest matching root.
A center expansion solution for counting every palindromic substring in a string.
A greedy interval scheduling solution for finding the longest chain of valid pairs.
A counting and math solution for finding the duplicated number and the missing number in a corrupted set.
A binary search solution for finding the maximum average of any contiguous subarray with length at least k.
A sliding window solution for finding the maximum average among all contiguous subarrays of fixed length k.
A trie-based design for returning the top three historical sentences for a typed prefix.
An array-based circular buffer solution for implementing a fixed-size double-ended queue.
A string parsing solution for reducing a linear equation into coefficient and constant terms.
A dynamic programming solution for counting decodings of a digit string with wildcard characters.
A DFS and memoization solution for finding the minimum cost to satisfy item needs using individual prices and reusable special offers.
A breadth-first search solution for computing the average value of nodes at each level of a binary tree.
A stack-based solution for computing exclusive execution time from nested start and end logs.
A design solution for storing timestamped logs and retrieving IDs by inclusive time range at a chosen granularity.
A dynamic programming and combinatorics solution for counting permutations with no fixed positions.
A two-pointer and number theory solution for checking whether an integer can be written as the sum of two square numbers.
A heap-based solution for finding the smallest range that contains at least one number from each sorted list.
A design solution for a small Excel-like spreadsheet that supports set, get, and dynamic sum formulas.
A greedy heap solution for taking the maximum number of courses before their deadlines.
A dynamic programming solution for counting permutations of 1 to n with exactly k inverse pairs.
A clear explanation of finding the largest product of three numbers using sorting or constant-space tracking.
A recursive tree traversal guide for merging two binary trees node by node.
A string-marking guide for adding bold tags around all matched words while merging overlapping and adjacent bold regions.
A two-pointer guide for counting triplets that can form valid triangles after sorting the side lengths.
A hash map guide for grouping file paths by identical file content and returning only duplicate groups.
A recursive guide for converting a binary tree into a preorder parenthesized string while preserving the one-to-one mapping between the tree and the string.
A greedy guide for determining whether a given number of flowers can be planted without violating the no-adjacent-flowers rule.
A guide to implementing a lazy iterator over a run-length encoded string without fully decompressing it.
A clear explanation of checking whether two strings are anagrams using character frequency counting.
A clear explanation of generating all possible results from different parenthesizations using divide and conquer recursion.
A clear explanation of searching a row-sorted and column-sorted matrix using the top-right corner elimination method.
A clear explanation of finding the maximum value in every sliding window using a monotonic deque.
A clear explanation of computing each product except self using prefix and suffix products without division.
A clear explanation of deleting a node from a singly linked list when only that node is given.
A clear explanation of finding the lowest common ancestor in a normal binary tree using recursive depth-first search.
A clear explanation of finding the lowest common ancestor in a binary search tree using BST ordering properties.
A clear explanation of checking whether a singly linked list is a palindrome using fast and slow pointers plus in-place reversal.
A detailed explanation of counting how many times digit one appears from 0 to n using positional digit analysis.
A detailed explanation of implementing a FIFO queue using two LIFO stacks with amortized constant time operations.
A clear explanation of determining whether an integer is a power of two using binary properties and bit manipulation.
A clear explanation of finding the kth smallest value in a binary search tree using inorder traversal.
A clear explanation of finding all elements that appear more than n/3 times using the extended Boyer-Moore voting algorithm.
A clear explanation of summarizing a sorted unique integer array into compact consecutive ranges.
A detailed explanation of evaluating arithmetic expressions with stack-based parsing and operator precedence.
A clear explanation of inverting a binary tree using recursive depth-first traversal.
A clear SQL guide for solving Combine Two Tables using LEFT JOIN.
A clear explanation of Pow(x, n) using binary exponentiation to compute powers in logarithmic time.
A clear explanation of Group Anagrams using a hash map keyed by each word's sorted character signature.
A clear explanation of Rotate Image using in-place matrix transpose and row reversal.
A clear explanation of Permutations II using sorting, depth-first search, and duplicate-skipping backtracking.
A clear explanation of Permutations using depth-first search and backtracking.
A clear explanation of Jump Game II using a greedy range expansion approach to find the minimum number of jumps.
A clear explanation of Wildcard Matching using dynamic programming over string and pattern prefixes.
A clear explanation of Multiply Strings using grade-school multiplication with digit arrays.
A clear explanation of the Trapping Rain Water problem using left and right boundaries, then an optimized two-pointer solution.
A clear explanation of the First Missing Positive problem using in-place index placement to achieve O(n) time and O(1) extra space.
Search for a target value in a binary search tree and return the subtree rooted at the matching node.
Find the longest path in a binary tree where every node on the path has the same value using depth-first search.
A clear explanation of finding the nth positive integer that does not contain the digit 9 using base-9 conversion.
A clear digit dynamic programming solution for counting numbers whose binary representation does not contain consecutive ones.
A clear hash map solution for finding common strings with the smallest index sum.
A clear math solution for counting the maximum values after repeated top-left matrix increment operations.
A clear hash map solution for finding the longest subsequence whose maximum and minimum differ by exactly one.
A clear geometry solution for checking whether four unordered points form a valid square.
A clear parsing and math solution for evaluating fraction addition and subtraction expressions.
A clear stack-based parser for validating nested XML-like tags with CDATA sections.
A clear DFS solution for returning the postorder traversal of an N-ary tree.
A clear DFS solution for returning the preorder traversal of an N-ary tree.
A clear design guide for implementing an in-memory file system with directory listing, directory creation, file append, and file read operations.
A clear convex hull solution for returning all trees that lie on the fence boundary.
A clear dynamic programming solution for finding the minimum deletions needed to make two strings equal.
A clear graph traversal solution for finding all processes terminated when killing a target process.
A clear linear-time solution for finding the shortest subarray that must be sorted to make the whole array sorted.
A clear dynamic programming solution for counting paths that move a ball out of a grid boundary.
A clear explanation of Distribute Candies using a set to count candy types and a simple limit argument.
A clear explanation of Squirrel Simulation using Manhattan distance and the special first trip.
A clear explanation of Subtree of Another Tree using recursive tree matching and DFS.
A clear explanation of Maximum Vacation Days using dynamic programming over weeks and cities.
A clear explanation of Permutation in String using a fixed-size sliding window and character frequency counts.
A clear explanation of Reshape the Matrix using index mapping from the original matrix to the reshaped matrix.
A clear explanation of Array Nesting using cycle detection over a permutation.
A clear explanation of Find the Closest Palindrome using prefix mirroring and a small candidate set.
A clear explanation of Binary Tree Tilt using postorder DFS to compute subtree sums and accumulate tilt.
A clear explanation of Longest Line of Consecutive One in Matrix using dynamic programming over four directions.
A clear explanation of Array Partition using sorting and adjacent pairing to maximize the sum of pair minimums.
A clear explanation of Subarray Sum Equals K using prefix sums and a hash map to count matching subarrays in linear time.
A clear explanation of Maximum Depth of N-ary Tree using recursive depth-first search.
A clear explanation of Reverse Words in a String III using two-pointer scanning and string reversal.
A clear explanation of Next Greater Element III using the next permutation algorithm on the digits of an integer.
A clear explanation of Split Concatenated Strings using string reversal choices and enumeration of every possible cut point.
A clear explanation of Brick Wall using prefix sums and a hash map to find the best vertical cut position.
A clear explanation of Optimal Division using the structure of division expressions to build the maximum-value expression.
A clear explanation of Student Attendance Record II using dynamic programming over absence count and late streak.
A clear explanation of Student Attendance Record I using simple string checks and a one-pass counter solution.
A clear explanation of finding the longest increasing or decreasing consecutive path in a binary tree using DFS.
A clear explanation of splitting an array into four equal-sum parts using prefix sums and set-based search.
A clear explanation of counting connected components in an undirected graph represented by an adjacency matrix.
A clear explanation of maximizing remove-box scores using interval dynamic programming with memoization.
A clear explanation of collecting the boundary of a binary tree using separate left boundary, leaves, and right boundary traversals.
A clear explanation of building the final tournament bracket by repeatedly pairing strongest and weakest teams.
A clear explanation of finding the longest path between any two nodes in a binary tree using DFS height computation.
A clear explanation of computing the distance to the nearest zero in a binary matrix using multi-source BFS.
A clear explanation of reversing the first k characters in every 2k block of a string.
A clear explanation of finding the only non-duplicate element in a sorted array using binary search.
A clear explanation of finding the minimum difference between 24-hour clock times using minute conversion and sorting.
A clear explanation of converting a BST into a greater tree using reverse inorder traversal and a running sum.
A clear explanation of multiplying complex numbers represented as strings using algebraic expansion.
A clear explanation of parsing a parenthesized string recursively to construct a binary tree.
A clear explanation of designing a simple URL encoder and decoder using a hash map and generated keys.
A clear explanation of counting black lonely pixels using row counts, column counts, and duplicate row patterns.
A clear explanation of counting unique pairs whose absolute difference is k using frequency counting.
A clear explanation of counting black pixels that are alone in both their row and column.
A clear explanation of finding the minimum difference between two BST node values using inorder traversal.
A clear explanation of updating a Minesweeper board using DFS flood fill and adjacent mine counting.
A clear explanation of weighted random sampling using prefix sums and binary search.
A clear explanation of generating minimal unique word abbreviations using grouping and trie prefixes.
A clear explanation of counting beautiful arrangements using backtracking and divisibility pruning.
A clear explanation of finding the longest contiguous subarray with equal numbers of 0 and 1 using prefix sums and a hash map.
A clear explanation of finding the longest dictionary word obtainable as a subsequence using two pointers and sorting rules.
A clear explanation of detecting a subarray whose sum is a multiple of k using prefix sums and modular arithmetic.
A clear explanation of finding the longest uncommon subsequence among many strings using subsequence checks.
A clear explanation of randomly flipping zero cells in a matrix without repetition using hash mapping and virtual swapping.
A clear explanation of counting coin-change combinations using dynamic programming.
A clear explanation of balancing dresses across washing machines using greedy prefix flow.
A clear explanation of finding the maximum value at every depth of a binary tree using level-order traversal.
A clear explanation of finding the minimum steps to spell a key on a circular ring using dynamic programming and memoized DFS.
A clear explanation of finding the leftmost value in the deepest row of a binary tree using level-order traversal.
A clear explanation of finding the inorder successor in a binary search tree when nodes contain parent pointers.
A clear explanation of finding the most frequent subtree sum in a binary tree using postorder DFS and a frequency map.
A clear explanation of assigning athlete ranks from scores using sorting while preserving original indices.
A clear explanation of finding the shortest rolling distance in a maze using Dijkstra’s algorithm.
A clear explanation of finding the next greater element in a circular array using a monotonic stack.
A clear explanation of maximizing capital by selecting at most k projects using sorting and a max heap.
A clear explanation of finding the most frequent value or values in a binary search tree using inorder traversal.
A clear explanation of finding the longest uncommon subsequence between two strings using simple case analysis.
A clear explanation of checking whether a word uses capital letters correctly by counting uppercase letters.
A clear explanation of finding the length of the longest palindromic subsequence using interval dynamic programming.
A clear explanation of finding the first device used by each player using SQL aggregation and a join.
A clear explanation of finding each player's first login date using SQL aggregation.
A clear explanation of computing Fibonacci numbers using dynamic programming and iterative state transitions.
A clear explanation of checking whether a number equals the sum of its positive divisors excluding itself.
A clear explanation of converting an integer into its base 7 string representation using repeated division.
A clear explanation of merging two quad-trees using recursive logical OR operations.
A clear explanation of calculating the fraction of players who logged in again the day after their first login.
A clear explanation of computing cumulative games played per player and date using SQL window functions.
A clear explanation of filtering words that can be typed using only one row of an American keyboard.
A clear explanation of finding the shortest rolling-ball path to the hole using Dijkstra with lexicographic tie-breaking.
A clear explanation of returning matrix elements in diagonal zigzag order by grouping cells with the same row plus column index.
A clear explanation of uniformly picking an integer point from non-overlapping rectangles using prefix sums and binary search.
A clear explanation of finding the next greater element using a monotonic decreasing stack and hash map.
A clear explanation of calculating total poisoned duration by merging overlapping attack intervals.
A clear explanation of counting sign assignments that reach a target using recursion first, then subset-sum dynamic programming.
A clear explanation of counting pairs where nums[i] is greater than twice nums[j] using merge sort.
A clear explanation of finding rectangle dimensions with a fixed area and the smallest length-width difference.
A clear explanation of generating all distinct non-decreasing subsequences using DFS, backtracking, and per-level duplicate control.
A clear explanation of deciding whether a rolling ball can stop at the destination using BFS or DFS over stopping cells.
A clear explanation of cleaning an unknown grid using DFS, relative coordinates, and physical backtracking.
A clear explanation of solving Zuma Game with DFS, memoization, and chain-removal simulation.
A clear explanation of finding the longest run of 1s after flipping at most one 0 using a sliding window.
A clear explanation of predicting whether Player 1 can win using minimax dynamic programming over score difference.
A clear explanation of finding the longest streak of 1s in a binary array with a single pass.
A clear explanation of constructing the lexicographically smallest permutation that matches an I and D pattern.
A clear explanation of finding the smallest base where n is written as all ones using geometric series and binary search.
A clear explanation of reformatting a license key by removing dashes, uppercasing characters, and grouping from the right.
A clear explanation of constructing the magical string by using the string itself as run-length instructions.
A clear explanation of maintaining the median of each fixed-size window using two heaps and lazy deletion.
A clear explanation of finding the largest palindrome made from the product of two n-digit numbers by generating palindrome candidates directly.
A clear explanation of generating uniformly random points inside a circle using polar coordinates.
A clear explanation of computing the total Hamming distance across all pairs by counting different bits column by column.
A clear explanation of finding the bitwise complement of a positive integer using a binary mask.
A clear explanation of finding the minimum heater radius by sorting positions and matching each house to its nearest heater.
A clear explanation of solving the largest subset problem as a two-dimensional 0/1 knapsack over zero and one counts.
A clear explanation of deciding whether matchsticks can form a square using backtracking, sorting, and pruning.
A clear explanation of finding all words that can be formed by concatenating at least two shorter words from the same list.
A clear explanation of interval dynamic programming for encoding a string into the shortest k[encoded_string] form.
A clear explanation of generating a uniform random integer from 1 to 10 using only rand7 and rejection sampling.
A clear explanation of checking whether ordered points form a convex polygon using cross products.
A clear explanation of validating IPv4 and IPv6 addresses by checking segment count, length, characters, range, and leading-zero rules.
A clear explanation of counting unique substrings that appear in the infinite alphabet wraparound string using dynamic programming by ending character.
A clear explanation of counting how many repeated copies of one string can be obtained as a subsequence of another repeated string.
A clear explanation of minimizing debt-settlement transactions using net balances, backtracking, and memoization-style pruning.
A clear explanation of solving the Can I Win game using minimax recursion, bitmask state compression, and memoization.
A clear explanation of counting the perimeter of an island in a grid by adding land-cell edges and subtracting shared edges.
A clear explanation of why the median minimizes the number of moves needed to make all array elements equal.
A clear explanation of computing the Hamming distance between two integers using XOR and bit counting.
A clear explanation of designing an LFU cache with O(1) average get and put operations.
A clear explanation of checking whether a string can be built by repeating one of its proper substrings.
A clear explanation of the combinatorics behind finding the minimum number of pigs needed to identify the poisonous bucket.
A clear explanation of detecting a valid cycle in a circular array using fast and slow pointers.
A clear explanation of detecting a 132 pattern using reverse traversal and a monotonic stack.
A clear explanation of the greedy two-pointer solution for maximizing the number of content children.
A clear explanation of counting zero-sum tuples across four arrays using pair sums and a hash map.
A clear explanation of the math behind making all array elements equal by incrementing n - 1 elements at a time.
A clear explanation of the greedy interval solution for finding the minimum number of arrows needed to burst all balloons.
A clear explanation of sorting characters by decreasing frequency using a hash map and sorting.
Delete a node from a binary search tree while preserving the BST property using recursive search and inorder successor replacement.
Serialize a binary search tree compactly with preorder traversal and rebuild it using BST value bounds.
Find all missing numbers from 1 to n in O(n) time using in-place index marking.
Count ordered boomerang tuples by fixing each point as the center and grouping other points by squared distance.
Count arithmetic subsequences of length at least three using dynamic programming with one hash map per ending index.
Add two numbers stored in forward-order linked lists using stacks and carry propagation.
Check whether nums is the unique shortest supersequence of given subsequences using topological sorting.
Compress a character array in-place using two pointers and grouped character counting.
Find all duplicated numbers in an array in O(n) time and O(1) extra space using index marking.
Find the maximum number of complete staircase rows that can be formed using binary search and triangular numbers.
Find the k-th integer in lexicographical order without generating all numbers, using prefix counting over a conceptual trie.
Evaluate a nested ternary expression using a right-to-left stack parser.
Find all starting indices where an anagram of p appears in s using a fixed-size sliding window.
Count downward paths in a binary tree whose values sum to targetSum using DFS and prefix sums.
Find, for each interval, the interval with the smallest start point greater than or equal to its end point using sorting and binary search.
Remove the minimum number of intervals so the remaining intervals do not overlap, using greedy sorting by end time.
Count the number of word segments in a string by detecting transitions from spaces to non-space characters.
Find the minimum number of valid one-character gene mutations using breadth-first search.
Design a data structure that supports increment, decrement, get minimum key, and get maximum key in average O(1) time.
Convert an N-ary tree into a binary tree and reconstruct it using the left-child right-sibling representation.
Flatten a multilevel doubly linked list in-place using depth-first traversal and pointer splicing.
Traverse an N-ary tree level by level using breadth-first search.
Serialize an N-ary tree into a string and reconstruct the same tree using preorder traversal with child counts.
Build a quad tree from a binary square grid using recursive divide and conquer.
Convert a BST into a sorted circular doubly linked list in-place using inorder traversal.
A clear explanation of building all word squares using backtracking with prefix pruning.
A clear explanation of finding the longest substring that can become all one letter using a sliding window.
A clear explanation of reconstructing digits from shuffled English words using character frequency counts and unique identifying letters.
A clear explanation of checking whether rows and columns read the same using direct index comparison.
A clear explanation of finding the maximum XOR of two numbers using greedy bit prefixes.
A clear explanation of counting battleships in a board using one-pass observation without modifying the grid.
A clear explanation of fitting a sentence onto a screen using cyclic string simulation and greedy row transitions.
A clear explanation of finding cells that can flow to both oceans using reverse graph traversal from the borders.
A clear explanation of deciding whether an array can be split into two equal-sum subsets using 0/1 knapsack dynamic programming.
A clear explanation of adding two non-negative integer strings using manual digit-by-digit simulation.
A clear explanation of finding the third distinct maximum number using one pass and constant space.
A clear explanation of counting arithmetic subarrays using dynamic programming and consecutive differences.
A clear explanation of the Fizz Buzz problem using direct simulation and divisibility checks.
A clear explanation of finding the shortest abbreviation that does not conflict with any dictionary word using bit masks.
A clear explanation of finding the longest palindrome length that can be built from given letters using character counts.
A clear explanation of trapping rain water in a 2D elevation map using a min heap and boundary expansion.
A clear explanation of the Sum of Left Leaves problem using depth-first traversal of a binary tree.
A clear explanation of the Frog Jump problem using dynamic programming with reachable jump sizes.
A clear explanation of checking the minimum edits needed to make a password strong using greedy handling of length, missing character types, and repeated runs.
A clear explanation of minimizing the largest subarray sum using binary search on the answer and greedy validation.
A clear explanation of validating a word abbreviation using two pointers and number parsing.
A clear explanation of reconstructing a queue using greedy sorting and indexed insertion.
A clear explanation of converting integers to hexadecimal using bit manipulation and two's complement representation.
A clear explanation of the Remove K Digits problem using a greedy monotonic stack.
A clear explanation of the Binary Watch problem using bit counting over all valid times.
A clear explanation of finding the nth digit in the infinite integer sequence using digit groups and arithmetic.
A clear explanation of solving division equations using graph traversal and weighted edges.
A clear explanation of picking a uniformly random index for a target value using reservoir sampling, with an alternative hash map approach.
A clear explanation of reducing an integer to 1 with the fewest operations using greedy bit decisions.
A clear explanation of maximizing the rotation function using a recurrence instead of simulating every rotation.
A clear explanation of finding the longest substring where every character appears at least k times using divide and conquer.
A clear explanation of decoding nested repeat expressions using a stack.
A clear explanation of validating a byte sequence as UTF-8 using bit masks and a continuation-byte counter.
A clear explanation of checking whether one string is a subsequence of another using two pointers.
A clear explanation of checking whether many small axis-aligned rectangles form one exact rectangular cover using area and corner parity.
A clear explanation of finding the last remaining number after alternating left-to-right and right-to-left eliminations.
A clear explanation of finding the extra character added to a shuffled string using counting and XOR.
A clear explanation of computing the longest absolute path to a file from a serialized file system string using path lengths by depth.
A clear explanation of finding the first non-repeating character in a string using character frequency counting.
A clear explanation of generating numbers from 1 to n in lexicographical order using an iterative DFS-style traversal.
A clear explanation of parsing a serialized nested integer string using a stack.
A clear explanation of shuffling an array uniformly using the Fisher-Yates algorithm while supporting reset.
A clear explanation of checking whether one string can be constructed from another using character frequency counting.
A clear explanation of selecting a random linked list node with equal probability using reservoir sampling.
A clear explanation of designing a randomized multiset with average O(1) insert, remove, and getRandom operations.
A clear explanation of designing a randomized set with average O(1) insert, remove, and getRandom operations.
A clear explanation of designing a phone directory that can allocate, check, and release numbers efficiently.
A clear explanation of finding the kth smallest value in a row-sorted and column-sorted matrix using binary search on values.
A clear explanation of Combination Sum IV using dynamic programming to count ordered combinations that sum to a target.
A clear explanation of the Wiggle Subsequence problem using dynamic programming intuition and an optimized greedy solution.
A clear explanation of finding the minimum guaranteed cost using interval dynamic programming.
A clear explanation of finding the picked number using binary search and the guess API.
A clear explanation of finding the k smallest pair sums from two sorted arrays using a min heap and best-first search.
A clear explanation of computing large modular exponentiation using fast power, modular arithmetic, and digit decomposition.
A clear explanation of adding two integers without using plus or minus by using XOR, AND, carry, and a 32-bit mask.
A clear explanation of applying many range updates efficiently using a difference array and prefix sums.
A clear explanation of adding one to a number stored as a linked list using the rightmost non-nine digit.
A clear explanation of finding the largest subset where every pair is divisible using sorting, dynamic programming, and parent reconstruction.
A clear explanation of checking whether an integer is a perfect square using binary search without sqrt.
A clear explanation of grouping binary tree nodes by the round in which they become leaves using postorder DFS.
A clear explanation of solving the Water and Jug Problem using Bézout's identity and greatest common divisor.
A clear explanation of computing inverse depth weighted sum using level-order traversal.
A clear explanation of reducing a 2D rectangle problem to a 1D prefix-sum problem with binary search.
A clear explanation of designing a hit counter for the last 5 minutes using a queue with compressed timestamps.
A clear explanation of finding the best bomb placement in a grid using cached row and column segment counts.
A clear explanation of sorting values after applying a quadratic function using two pointers.
A clear explanation of designing a logger that prints each message at most once every 10 seconds using a hash map.
A clear explanation of rearranging a string so equal characters are at least k positions apart using a heap and cooldown queue.
A clear explanation of counting numbers with unique digits using combinatorics.
A clear explanation of checking whether 2D points are symmetric around a vertical line using min and max x-coordinates.
A clear explanation of implementing a simplified Twitter using hash maps, sets, timestamps, and a heap.
A clear explanation of solving Russian Doll Envelopes using sorting and longest increasing subsequence.
A clear explanation of implementing Snake Game with a deque for body order and a set for constant-time collision checks.
A clear explanation of maintaining disjoint sorted intervals from a stream using insertion and merging.
A clear explanation of Android Unlock Patterns using backtracking, a jump table, and symmetry optimization.
A clear explanation of Intersection of Two Arrays II using frequency counting.
A clear explanation of Intersection of Two Arrays using hash sets for uniqueness and fast lookup.
A clear explanation of Design Tic-Tac-Toe using row, column, and diagonal counters for constant-time winner checks.
A clear explanation of Top K Frequent Elements using frequency counting and bucket sort.
A clear explanation of Moving Average from Data Stream using a queue and rolling sum.
A clear explanation of Reverse Vowels of a String using two pointers and selective swaps.
A clear explanation of Reverse String using two pointers and in-place swaps.
A clear explanation of Integer Break using dynamic programming, with a note on the greedy math solution.
A clear explanation of Power of Four using bit manipulation and binary properties.
A clear explanation of Flatten Nested List Iterator using lazy stack-based flattening.
A clear explanation of Longest Substring with At Most K Distinct Characters using a sliding window and character counts.
A clear explanation of Nested List Weight Sum using depth-first search over a nested structure.
A clear explanation of Counting Bits using dynamic programming and bit manipulation.
A clear explanation of House Robber III using tree dynamic programming with rob and skip states.
A clear explanation of Palindrome Pairs using reversed-word lookup and palindrome split checks.
A clear explanation of Self Crossing using constant-space checks for the only possible crossing patterns.
A clear explanation of Increasing Triplet Subsequence using greedy tracking of two minimum values.
A clear explanation of Largest BST Subtree using postorder traversal and subtree state propagation.
A clear explanation of Reconstruct Itinerary using a directed graph and Hierholzer's algorithm.
A clear explanation of verifying preorder serialization using slot counting without reconstructing the tree.
A clear explanation of Patching Array using a greedy smallest-missing-sum invariant.
A clear explanation of Longest Increasing Path in a Matrix using DFS with memoization.
A clear explanation of Odd Even Linked List using in-place pointer rewiring.
A clear explanation of Count of Range Sum using prefix sums and merge sort counting.
A clear explanation of the Power of Three problem using repeated division and integer arithmetic.
A clear explanation of Maximum Size Subarray Sum Equals k using prefix sums and earliest-index hashing.
A clear explanation of Wiggle Sort II using sorting, median splitting, and virtual indexing.
A clear explanation of counting connected components using Union-Find and graph traversal.
A clear explanation of Coin Change using dynamic programming for minimum coin count.
A clear explanation of Create Maximum Number using monotonic stacks for subsequences and greedy merging.
A clear explanation of Generalized Abbreviation using backtracking to choose whether each character is kept or abbreviated.
A clear explanation of Bulb Switcher using divisor parity and perfect squares.
A clear explanation of Maximum Product of Word Lengths using bit masks to test disjoint character sets efficiently.
A clear explanation of Shortest Distance from All Buildings using BFS from each building with distance and reach accumulation.
A clear explanation of Remove Duplicate Letters using a greedy monotonic stack.
A clear explanation of Count of Smaller Numbers After Self using coordinate compression and a Fenwick Tree.
A clear explanation of Binary Tree Vertical Order Traversal using BFS with column indices.
A clear explanation of Super Ugly Number using dynamic programming with one pointer per prime.
A clear explanation of Burst Balloons using interval dynamic programming and the last-burst idea.
A clear explanation of Sparse Matrix Multiplication using non-zero entries to avoid wasted work.
A clear explanation of Minimum Height Trees using leaf trimming to find the center of a tree.
A clear explanation of Best Time to Buy and Sell Stock with Cooldown using dynamic programming states.
A clear explanation of Range Sum Query 2D - Mutable using a 2D Fenwick Tree for efficient updates and rectangle sum queries.
A clear explanation of Range Sum Query - Mutable using a Fenwick Tree for efficient updates and range sums.
A clear explanation of Additive Number using split enumeration and deterministic checking.
A clear explanation of Number of Islands II using Union-Find to dynamically merge connected land cells.
A clear explanation of Range Sum Query 2D - Immutable using a 2D prefix sum matrix for constant-time rectangle queries.
A clear explanation of Range Sum Query - Immutable using prefix sums for constant-time range queries.
A clear explanation of Smallest Rectangle Enclosing Black Pixels using binary search on rows and columns.
A clear explanation of Remove Invalid Parentheses using BFS to guarantee the minimum number of removals.
A dynamic programming and patience sorting solution for finding the longest strictly increasing subsequence in an array.
A counting solution for producing the Bulls and Cows hint while handling duplicate digits correctly.
A DFS solution for finding the longest parent-to-child path where each node value increases by exactly one.
A preorder DFS codec for converting a binary tree to a string and reconstructing the same tree from that string.
A median-based solution for minimizing total Manhattan distance in a grid.
A two-heap data structure for adding numbers from a stream and returning the current median in constant time.
A recursive game theory solution with memoization for deciding whether the starting player can force a win.
A simple string scanning solution for generating every possible next state after flipping one consecutive ++ pair into --.
A game theory solution for deciding whether the first player can win by using the losing-position pattern of multiples of four.
A backtracking solution for matching a pattern string to a target string using a bijective character-to-substring mapping.
A hash map solution for checking whether a pattern string and a space-separated word string form a bijection.
An in-place matrix simulation for computing the next state of Conway's Game of Life using temporary encoded states.
A hash map design for checking whether a word's abbreviation is unique in a dictionary.
A Floyd cycle detection solution for finding the repeated number without modifying the array and using constant extra space.
A multi-source BFS solution for filling each empty room with its shortest distance to the nearest gate.
A binary-search-style solution for finding the smallest node greater than p in a binary search tree.
A wrapper iterator design that supports peeking at the next element without advancing the iterator.
A two-pointer in-place solution for moving all zeroes to the end while preserving the relative order of non-zero elements.
A backtracking solution for inserting operators into a numeric string so the expression evaluates to a target value.
A queue-based iterator design for returning elements from two vectors in alternating order, with a clean extension to k vectors.
A greedy in-place solution for rearranging an array into a non-strict wiggle pattern.
A dynamic programming solution for finding the least number of perfect square numbers that sum to n.
A binary search solution for finding the first bad version while minimizing calls to the isBadVersion API.
A two-pass solution for finding a celebrity using the knows API with O(n) calls and O(1) extra space.
A dynamic programming solution for counting ways to paint fence posts with no more than two adjacent posts sharing the same color.
A clear explanation of the H-Index II problem using binary search on a sorted citations array.
A clear explanation of the H-Index problem using sorting, then an optimized counting approach.
A clear explanation of the Integer to English Words problem using three-digit chunks and scale words.
A clear explanation of the Closest Binary Search Tree Value II problem using inorder traversal and a fixed-size sliding window.
A clear explanation of the Encode and Decode Strings problem using length-prefix encoding.
A clear explanation of the Closest Binary Search Tree Value problem using the BST property to walk toward the target.
A clear explanation of the Alien Dictionary problem using graph construction and topological sorting.
A clear explanation of the Missing Number problem using sum formula and XOR.
A clear explanation of the Palindrome Permutation II problem using character counts and backtracking over half of the palindrome.
A clear explanation of the Palindrome Permutation problem using character parity counting.
A clear explanation of the Paint House II problem using optimized dynamic programming with minimum and second minimum tracking.
A clear explanation of the Ugly Number II problem using dynamic programming with three pointers.
A clear explanation of the Ugly Number problem using repeated division by the only allowed prime factors.
A clear explanation of the Graph Valid Tree problem using Union Find to detect cycles and verify connectivity.
A clear explanation of the Single Number III problem using XOR partitioning to isolate the two unique numbers.
A clear explanation of the 3Sum Smaller problem using sorting and the two-pointer technique.
A clear explanation of the Add Digits problem using repeated digit sums first, then the digital root formula.
A clear explanation of the Binary Tree Paths problem using DFS backtracking to collect every root-to-leaf path.
A clear explanation of the Paint House problem using dynamic programming with constant space.
A clear explanation of the Verify Preorder Sequence in Binary Search Tree problem using a monotonic stack and lower bound tracking.
A clear explanation of the Factor Combinations problem using DFS backtracking with non-decreasing factors.
A clear explanation of the Meeting Rooms II problem using a min heap to track active meeting end times.
A clear explanation of the Meeting Rooms problem using interval sorting to detect overlaps.
A clear explanation of the Flatten 2D Vector problem using row and column pointers to implement an iterator.
A clear explanation of implementing a LIFO stack using only FIFO queue operations.
A clear explanation of evaluating an expression with plus, minus, spaces, and parentheses using a stack.
A clear explanation of computing the total covered area of two axis-aligned rectangles by subtracting their overlap.
A clear explanation of counting nodes in a complete binary tree faster than visiting every node.
A clear explanation of finding the largest square of 1s in a binary matrix using dynamic programming.
A clear explanation of checking nearby indices with nearby values using a sliding window and bucket hashing.
A clear explanation of detecting whether equal values appear within distance k using a hash map or sliding window set.
A clear explanation of computing the skyline formed by buildings using sweep line and a max-heap.
A clear explanation of detecting duplicates in an array using a hash set and sorting.
A clear explanation of finding k distinct numbers from 1 to 9 that sum to n using backtracking.
A clear explanation of finding the kth largest element using sorting, a min-heap, and Quickselect.
A clear explanation of building the shortest palindrome by finding the longest palindromic prefix using KMP.
A clear explanation of maximizing robbed money from circularly arranged houses using dynamic programming.
A clear explanation of finding multiple words in a character board using a Trie and DFS backtracking.
A clear explanation of designing a word dictionary with addWord and wildcard search using a Trie and DFS.
A clear explanation of finding a valid course ordering using topological sorting and cycle detection.
A clear explanation of finding the shortest contiguous subarray whose sum is at least target using a sliding window.
A clear explanation of implementing a Trie with insert, search, and startsWith operations.
A clear explanation of detecting cycles in a prerequisite graph using topological sorting and DFS.
A clear explanation of reversing a singly linked list using iterative and recursive approaches.
A clear explanation of checking whether two strings follow the same character mapping pattern.
A clear explanation of counting prime numbers less than n using the Sieve of Eratosthenes.
A clear explanation of removing all linked list nodes with a target value using iteration and a dummy node.
A clear explanation of detecting whether repeated digit-square sums eventually reach 1.
A clear explanation of finding the bitwise AND of every number in an inclusive range using the common binary prefix.
A detailed guide to solving Same Tree with recursive DFS and structural comparison.
A detailed guide to solving Recover Binary Search Tree with inorder traversal and two misplaced nodes.
A detailed guide to solving Validate Binary Search Tree with recursive lower and upper bounds.
A detailed guide to solving Interleaving String with two-dimensional dynamic programming.
A detailed guide to solving Unique Binary Search Trees with dynamic programming and the Catalan recurrence.
A detailed guide to solving Unique Binary Search Trees II with recursive tree generation over value ranges.
A detailed guide to solving Binary Tree Inorder Traversal with recursion and an iterative stack.
A detailed guide to solving Restore IP Addresses with backtracking over four valid IP segments.
A detailed guide to solving Reverse Linked List II with a dummy node and in-place sublist reversal.
A detailed guide to solving Decode Ways with dynamic programming and careful handling of zeroes.
A detailed guide to solving Subsets II with sorting, backtracking, and duplicate skipping.
A detailed guide to solving Gray Code using the binary-to-Gray-code formula.
A detailed guide to solving Merge Sorted Array in-place by merging from the back with three pointers.
A detailed guide to solving Scramble String with recursive dynamic programming and memoization.
A detailed guide to solving Partition List with two dummy lists while preserving relative order.
A detailed guide to solving Maximal Rectangle by converting each matrix row into a histogram and applying a monotonic stack.
A detailed guide to solving Largest Rectangle in Histogram with a monotonic increasing stack.
A detailed guide to solving Remove Duplicates from Sorted List with one pointer and in-place linked list rewiring.
A detailed guide to solving Remove Duplicates from Sorted List II with a dummy node and pointer rewiring.
A detailed guide to solving Search in Rotated Sorted Array II with modified binary search and duplicate handling.
A detailed guide to solving Remove Duplicates from Sorted Array II with an in-place two-pointer method.
A detailed guide to solving Word Search with depth-first search and backtracking on a grid.
A detailed guide to solving Subsets with backtracking and the include-or-skip recursion idea.
A detailed guide to solving Combinations with backtracking and pruning.
A detailed guide to solving Minimum Window Substring with a sliding window and frequency counters.
A clear explanation of counting connected groups of land cells in a grid using DFS or BFS.
A clear explanation of returning the visible nodes from the right side of a binary tree using level-order traversal.
A clear explanation of maximizing robbery profit without robbing adjacent houses using dynamic programming.
A clear explanation of counting set bits in an integer using bit manipulation and Brian Kernighan's algorithm.
A clear explanation of reversing the bits of a 32-bit integer using bit manipulation.
A clear explanation of rotating an array to the right by k steps using in-place reversal.
A clear explanation of maximizing stock trading profit with at most k transactions using dynamic programming.
A clear explanation of finding repeated 10-letter DNA substrings using a fixed-size sliding window and hash sets.
A clear explanation of reversing the order of words in a character array in-place using two reversals.
A clear explanation of arranging non-negative integers to form the largest possible concatenated number using a custom sort order.
A clear explanation of computing the minimum initial health needed to survive a dungeon using reverse dynamic programming.
A clear explanation of designing an iterator over a BST using controlled inorder traversal with a stack.
A clear explanation of converting an Excel column title into its numeric index using base 26 accumulation.
A clear explanation of designing a data structure that supports add and find operations for pair sums.
A clear explanation of finding the element that appears more than half the time using Boyer-Moore voting.
A clear explanation of converting a positive integer into an Excel column title using bijective base 26.
A clear explanation of finding two numbers in a sorted array using two pointers and constant extra space.
A clear explanation of converting a fraction into decimal form and detecting repeating fractional parts with a hash map.
A clear explanation of comparing version strings revision by revision while ignoring leading zeros.
A clear explanation of finding the maximum adjacent gap in sorted order using buckets and the pigeonhole principle.
A clear explanation of finding all missing ranges inside an inclusive interval by scanning sorted unique numbers.
A clear explanation of finding any peak element using binary search on the slope of the array.
A clear explanation of checking whether two strings are exactly one edit apart using a linear scan.
A clear explanation of finding the node where two singly linked lists intersect using two pointers.
A clear explanation of finding the longest substring with at most two distinct characters using a sliding window.
A clear explanation of implementing read with read4 when read may be called multiple times.
A clear explanation of implementing read using the given read4 API and copying only the needed characters.
A clear explanation of flipping a binary tree upside down by rewiring pointers from the left spine.
A clear explanation of designing a stack that can return the current minimum element in constant time.
A clear explanation of finding the minimum element in a rotated sorted array that may contain duplicates.
A clear explanation of finding the minimum element in a rotated sorted array using binary search.
A detailed explanation of tracking both maximum and minimum products while scanning the array.
A clear explanation of reversing word order while removing extra spaces.
Evaluate an arithmetic expression written in Reverse Polish Notation using a stack.
Find the maximum number of points lying on the same straight line using slope counting and normalization.
Sort a singly linked list in ascending order using merge sort with fast and slow pointers.
Sort a singly linked list using insertion sort by splicing each node into a growing sorted list.
Design an LRU cache with O(1) get and put operations using a hash map and doubly linked list.
Return the postorder traversal of a binary tree using recursion or an iterative stack-based approach.
Return the preorder traversal of a binary tree using recursion or an explicit stack.
Reorder a singly linked list in-place by finding the middle, reversing the second half, and merging the two halves alternately.
Find the node where a linked list cycle begins using Floyd’s tortoise and hare algorithm with cycle entry mathematics.
Detect whether a linked list contains a cycle using Floyd’s tortoise and hare two-pointer algorithm.
Return all valid sentences formed by inserting spaces into a string so every word belongs to the dictionary, using DFS with memoization.
Decide whether a string can be segmented into dictionary words using dynamic programming over prefixes.
Create a deep copy of a linked list with next and random pointers using hash maps or interleaved node cloning.
Find the number that appears once when every other number appears three times using bit counting or finite-state bit manipulation.
Find the only number that appears once using the XOR operator, while every other number appears exactly twice.
Compute the minimum candies needed using two greedy passes, one from the left and one from the right.
Find the unique starting gas station index using a greedy scan with total fuel balance and current tank balance.
Create a deep copy of a connected undirected graph using DFS and a hash map from original nodes to cloned nodes.
Find the minimum number of cuts needed to split a string into palindromic substrings using palindrome precomputation and dynamic programming.
Generate all ways to split a string so that every piece is a palindrome, using backtracking with palindrome precomputation.
Capture surrounded O regions by marking border-connected O cells first, then flipping the remaining O cells.
Compute the sum of all numbers formed by root-to-leaf paths using depth-first search and decimal accumulation.
Find the longest run of consecutive integers in an unsorted array using a hash set and sequence-start detection.
Use breadth-first search to find the shortest transformation sequence length between two words.
Find all shortest word transformation sequences using BFS to build shortest-path parents, then backtracking to reconstruct every answer.
A clear explanation of checking whether a string is a palindrome after ignoring non-alphanumeric characters and case.
A clear explanation of finding the maximum path sum in a binary tree using bottom-up depth-first search.
A clear explanation of maximizing stock profit with at most two transactions using dynamic programming.
A clear explanation of maximizing stock profit with unlimited transactions using a greedy single-pass method.
A clear explanation of finding the maximum profit from one stock transaction using a single pass.
A clear explanation of finding the minimum path sum in a triangle using bottom-up dynamic programming.
A clear explanation of generating a single row of Pascal's Triangle using in-place dynamic programming.
A clear explanation of generating Pascal's Triangle row by row using dynamic programming.
A clear explanation of connecting next pointers in any binary tree using constant extra space.
A clear explanation of connecting next pointers in a perfect binary tree using constant extra space.
A clear explanation of counting distinct subsequences using dynamic programming.
A clear explanation of flattening a binary tree into a linked list in preorder traversal order using recursive depth-first search.
A clear explanation of finding all root-to-leaf paths whose values add up to a target sum using depth-first search and backtracking.
A clear explanation of checking whether a binary tree has a root-to-leaf path whose values add up to a target sum.
A clear explanation of finding the minimum depth of a binary tree using breadth-first search.
A clear explanation of checking whether a binary tree is height-balanced using bottom-up depth-first search.
A clear explanation of converting a sorted linked list into a height-balanced binary search tree using slow and fast pointers.
A clear explanation of building a height-balanced binary search tree from a sorted array using divide and conquer.
A clear explanation of returning binary tree levels from bottom to top using breadth-first search.
A clear explanation of rebuilding a binary tree from inorder and postorder traversals using recursion and an index map.
A clear explanation of rebuilding a binary tree from preorder and inorder traversals using recursion and an index map.
A clear explanation of finding the maximum depth of a binary tree using recursive depth-first search.
A clear explanation of zigzag level order traversal using breadth-first search and alternating level direction.
A clear explanation of binary tree level order traversal using breadth-first search and a queue.
A clear explanation of checking whether a binary tree is symmetric using mirror recursion.
A clear guide to sorting an array of 0s, 1s, and 2s in place using the Dutch National Flag algorithm.
A clear guide to searching a sorted 2D matrix using binary search over a virtual one-dimensional array.
A clear guide to setting matrix rows and columns to zero in place using the first row and first column as markers.
A clear guide to computing the minimum number of insert, delete, and replace operations needed to convert one string into another.
A clear guide to simplifying Unix-style file paths using a stack.
A clear guide to counting distinct ways to climb stairs using dynamic programming.
A clear guide to computing the integer square root using binary search without built-in exponent functions.
A clear guide to formatting text with greedy line packing and even space distribution.
A clear guide to adding two binary strings using two pointers and a carry.
A clear guide to adding one to a large integer represented as an array of digits.
A clear guide to validating whether a string is a valid number using grammar rules and one left-to-right scan.
A clear guide to finding the minimum path sum in a grid using dynamic programming.
A clear guide to counting unique paths in a grid with obstacles using dynamic programming.
A clear guide to counting unique paths in a grid using dynamic programming.
A clear guide to rotating a linked list to the right by k places using a circular list.
A clear guide to finding the kth permutation sequence using factorial blocks instead of generating all permutations.
A clear guide to generating an n x n matrix filled from 1 to n squared in spiral order.
A clear guide to solving Length of Last Word by scanning the string from right to left.
A clear guide to solving Insert Interval with one linear scan over sorted, non-overlapping intervals.
A clear guide to solving Merge Intervals by sorting intervals and merging them in one pass.
A clear guide to solving Jump Game with greedy reachability.
A clear guide to reading a matrix in spiral order using shrinking boundaries.
A clear guide to solving Maximum Subarray with brute force first, then Kadane's dynamic programming algorithm.
A clear guide to solving N-Queens II by counting valid queen placements with backtracking.
A clear guide to solving N-Queens with backtracking, row-by-row placement, and constant-time conflict checks.
A clear explanation of finding unique combinations that sum to a target when each array element may be used at most once.
A clear explanation of finding all unique combinations that sum to a target using backtracking.
A clear explanation of generating the count-and-say sequence using run-length encoding.
A clear explanation of solving a Sudoku board using backtracking and constraint checking.
A clear explanation of checking whether a partially filled Sudoku board is valid using hash sets.
A clear explanation of finding the index of a target, or where it should be inserted, using binary search.
A clear explanation of finding the first and last index of a target in a sorted array using two binary searches.
A clear explanation of searching a rotated sorted array in logarithmic time using modified binary search.
A clear explanation of finding the longest well-formed parentheses substring using a stack of indices.
A clear explanation of finding the next lexicographically greater permutation in place using a right-to-left scan.
A clear explanation of finding all starting indices where a substring is formed by concatenating every word exactly once.
A clear explanation of integer division without using multiplication, division, or modulo, using repeated doubling with bit shifts.
A clear explanation of finding the first occurrence of one string inside another using direct string matching.
A clear explanation of removing all occurrences of a value from an array in place using a write pointer.
A clear explanation of removing duplicates from a sorted array in place using two pointers.
A detailed explanation of reversing linked-list nodes in groups of k using pointer manipulation and constant extra space.
A detailed explanation of swapping every two adjacent nodes in a linked list using pointer manipulation.
A detailed explanation of merging k sorted linked lists using a min heap.
A detailed explanation of generating all well-formed parentheses strings using backtracking.
A detailed explanation of merging two sorted linked lists using a dummy node and pointer splicing.
A detailed explanation of checking whether a bracket string is valid using a stack.
A detailed explanation of removing the nth node from the end of a singly linked list using two pointers and a dummy node.
A detailed explanation of finding all unique quadruplets that sum to a target using sorting and two pointers.
A detailed explanation of generating all possible phone keypad letter combinations using backtracking.
A detailed explanation of finding the sum of three integers closest to a target using sorting and two pointers.
A detailed explanation of finding all unique triplets that sum to zero using sorting and two pointers.
A detailed explanation of finding the longest common prefix among an array of strings by comparing characters column by column.
A detailed explanation of converting a Roman numeral string into an integer using symbol values and the subtraction rule.
A detailed explanation of converting an integer into a Roman numeral using a fixed value-symbol table and greedy subtraction.
A detailed explanation of finding the maximum water container area using two pointers.
A detailed explanation of matching a full string against a simplified regular expression with dot and star using dynamic programming.
A detailed explanation of checking whether an integer is a palindrome using digit operations without converting it to a string.
A detailed explanation of parsing a string into a 32-bit signed integer with whitespace, sign, digit reading, and clamping rules.
A detailed explanation of reversing a signed 32-bit integer while handling overflow correctly.
A detailed explanation of converting a string into a zigzag pattern using row simulation.
A detailed explanation of finding the longest palindromic substring using expand-around-center.
A detailed explanation of finding the median of two sorted arrays using binary search over partitions.
A clear explanation of the longest substring problem using sliding window and a hash set.
A detailed explanation of the Add Two Numbers linked list problem, including digit-by-digit addition, carry handling, and linked list construction.
A clear explanation of the Two Sum problem using brute force first, then an optimized hash map solution.
A clear explanation of counting trailing zeroes in n! by counting factors of 5 instead of computing the factorial directly.
A clear SQL solution for finding employees whose salaries are in the top three unique salary levels within their department.
A clear SQL solution for finding every employee who earns the highest salary in their department.
A clear SQL solution for finding customers who have no matching rows in the Orders table.
A clear SQL solution for reporting email values that appear more than once in the Person table.
A clear SQL solution for finding employees whose salary is greater than their manager's salary using a self join.
A clear SQL solution for finding numbers that appear at least three times consecutively in the Logs table.
A clear SQL solution for ranking scores with dense ranking, where ties share the same rank and no rank numbers are skipped.
A clear SQL solution for finding the nth highest distinct salary from the Employee table.
A clear SQL solution for finding the second highest distinct salary from the Employee table.