LeetCode 974: Subarray Sums Divisible by K
A clear explanation of counting subarrays whose sum is divisible by k using prefix sums and remainder frequencies.
109 notes
A clear explanation of counting subarrays whose sum is divisible by k using prefix sums and remainder frequencies.
A clear explanation of generating all powerful integers using bounded powers and a set.
A clear explanation of implementing a spellchecker with exact, case-insensitive, and vowel-error matching.
A clear explanation of finding the minimum-area rectangle from points when the rectangle may be rotated.
A clear explanation of finding the element repeated N times using a hash set.
A clear explanation of simulating prison cell transitions efficiently using cycle detection.
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 the Hand of Straights problem using sorting, frequency counting, and greedy grouping.
A clear explanation of counting index triplets with duplicate values using frequency counts and combinatorics.
A clear explanation of finding universal words by merging character frequency requirements from words2.
A clear explanation of checking whether card counts share a common group size using the greatest common divisor.
A clear explanation of Online Election using preprocessing and binary search over vote times.
A clear explanation of Fruit Into Baskets using a sliding window with at most two distinct fruit types.
A clear explanation of designing a stack that pops the most frequent value, breaking ties by most recent insertion.
A clear explanation of counting special-equivalent string groups by building canonical signatures from even and odd positions.
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 uncommon words by counting word frequencies across both sentences.
A clear explanation of counting subarrays with exactly k distinct integers using the at-most-k sliding window trick.
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 finding the longest Fibonacci-like subsequence using dynamic programming and value-to-index lookup.
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 checking whether one swap in a string can make it equal to another string.
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 rearranging characters so no two adjacent characters are equal using a greedy max heap.
A clear explanation of minimizing swaps so every couple sits together using greedy position tracking.
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 mapping each element in one array to a matching index in its anagram using a hash map.
A clear explanation of solving Pyramid Transition Matrix using backtracking and memoization over pyramid rows.
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 selecting a uniformly random integer while excluding blacklisted values using remapping and hashing.
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.
Count axis-aligned rectangles whose four corners are 1 using column-pair frequency counting.
Find the shortest word that contains all required license plate letters using frequency counting.
Support fast prefix and suffix queries by indexing every prefix-suffix combination with the largest word index.
Transform the problem into House Robber dynamic programming by grouping equal values into total points.
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.
Check whether two word arrays are sentence-similar using a hash set of symmetric similar word pairs.
A trie-based solution for replacing each derivative word with the shortest matching root.
A counting and math solution for finding the duplicated number and the missing number in a corrupted set.
A string-marking guide for adding bold tags around all matched words while merging overlapping and adjacent bold regions.
A hash map guide for grouping file paths by identical file content and returning only duplicate groups.
A clear explanation of checking whether two strings are anagrams using character frequency counting.
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 Group Anagrams using a hash map keyed by each word's sorted character signature.
A clear explanation of the First Missing Positive problem using in-place index placement to achieve O(n) time and O(1) extra space.
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 filtering words that can be typed using only one row of an American keyboard.
A clear explanation of finding the next greater element using a monotonic decreasing stack and hash map.
A clear explanation of generating all distinct non-decreasing subsequences using DFS, backtracking, and per-level duplicate control.
A clear explanation of maintaining the median of each fixed-size window using two heaps and lazy deletion.
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.
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.
Design a data structure that supports increment, decrement, get minimum key, and get maximum key in average O(1) time.
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 finding the longest palindrome length that can be built from given letters using character counts.
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 finding the longest substring where every character appears at least k times using divide and conquer.
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 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 checking whether one string can be constructed from another using character frequency counting.
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 logger that prints each message at most once every 10 seconds using a hash map.
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 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 Longest Substring with At Most K Distinct Characters using a sliding window and character counts.
A clear explanation of Palindrome Pairs using reversed-word lookup and palindrome split checks.
A clear explanation of Maximum Size Subarray Sum Equals k using prefix sums and earliest-index hashing.
A clear explanation of Binary Tree Vertical Order Traversal using BFS with column indices.
A clear explanation of Sparse Matrix Multiplication using non-zero entries to avoid wasted work.
A counting solution for producing the Bulls and Cows hint while handling duplicate digits correctly.
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.
A hash map design for checking whether a word's abbreviation is unique in a dictionary.
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 finding repeated 10-letter DNA substrings using a fixed-size sliding window and hash sets.
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 fraction into decimal form and detecting repeating fractional parts with a hash map.
A clear explanation of finding the longest substring with at most two distinct characters using a sliding window.
Find the longest run of consecutive integers in an unsorted array using a hash set and sequence-start detection.
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 all starting indices where a substring is formed by concatenating every word exactly once.
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.
Hash functions, collision resolution strategies, open addressing, chaining, dynamic resizing, perfect hashing, concurrent maps, and probabilistic filters.
Retrieve a value by computing a hash and probing a table for the corresponding key.