combinatorics
combinatorics is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.
Interview Signal
Frequently tests problem modeling, edge handling, and verbal clarity.
Common Pitfall
Template-only answers break under follow-up questioning.
Practice Strategy
Practice in 3-5 problem rounds and always review complexity alternatives.
Recommended Progression
Unique Paths
Calculate the number of unique paths for a robot to move on an m x n grid with only right and down movements.
Poor Pigs
Find the minimum number of pigs required to determine the poisonous bucket within a set time using state transition dyna…
Number of Music Playlists
Solve the Number of Music Playlists problem with dynamic programming, focusing on state transitions and combinatorics to…
Ugly Number III
Find the nth positive integer divisible by a, b, or c using binary search over the answer space efficiently and accurate…
Count All Valid Pickup and Delivery Options
Count all valid pickup and delivery sequences for n orders where deliveries occur after pickups using dynamic programmin…
Probability of a Two Boxes Having The Same Number of Distinct Balls
Compute the probability that two boxes contain the same number of distinct balls using careful combinatorial and DP meth…
Number of Ways to Reorder Array to Get Same BST
Determine the number of ways to reorder an array to get the same binary search tree (BST) from its insertion order.
Number of Sets of K Non-Overlapping Line Segments
Count all valid arrangements of k non-overlapping line segments on n points using state transition dynamic programming.
Count Sorted Vowel Strings
Calculate the number of length-n strings with vowels only that are sorted lexicographically using state transitions.
Kth Smallest Instructions
Find the kth smallest lexicographic instruction sequence for reaching a destination in a grid using state transition dyn…
Count Ways to Make Array With Product
Determine the number of arrays of size n where the product equals k using prime factorization and combinatorial DP techn…
Minimum Number of Operations to Make String Sorted
Calculate the minimum operations to sort a string using combinatorial math and string manipulation techniques efficientl…
Sum of All Subset XOR Totals
Compute the sum of all subset XOR totals using a backtracking search with pruning for arrays of small size.
Number of Ways to Rearrange Sticks With K Sticks Visible
Calculate the number of arrangements of n uniquely-sized sticks so exactly k sticks are visible using dynamic programmin…
Count Ways to Build Rooms in an Ant Colony
Solve the problem of counting distinct ways to build rooms in an ant colony using dynamic programming and topological or…
Vowels of All Substrings
Compute the total number of vowels in all substrings of a given string using efficient state transition dynamic programm…
Find Triangular Sum of an Array
The problem asks for calculating the triangular sum of an array through repeated pairwise summation.
Count the Number of Ideal Arrays
This problem involves counting the number of ideal arrays of a given length under certain conditions using state transit…
Number of Ways to Reach a Position After Exactly k Steps
Find the number of ways to reach a position after exactly k steps on an infinite number line using dynamic programming.
Count Anagrams
Learn to count distinct anagrams for a multi-word string using hash tables, math, and combinatorics efficiently.
The Number of Beautiful Subsets
Count all non-empty subsets of an array where no two numbers have an absolute difference equal to k, using array scannin…
Count K-Subsequences of a String With Maximum Beauty
Determine the number of k-length unique subsequences in a string that maximize the sum of character frequencies efficien…
Distribute Candies Among Children I
Given two integers n and limit, find the number of ways to distribute n candies among 3 children, with no child receivin…
Distribute Candies Among Children II
Determine how to distribute n candies among 3 children without exceeding a limit on individual candies.
Number of Strings Which Can Be Rearranged to Contain Substring
Calculate how many strings of length n can be rearranged to contain "leet" using dynamic programming and combinatorics.
Count the Number of Infection Sequences
Calculate all valid infection sequences in a line by using array positions and combinatorial math efficiently for n peop…
Count the Number of Good Partitions
Calculate how many ways to partition an array into contiguous subarrays where no number repeats across segments using ha…
Kth Smallest Amount With Single Denomination Combination
Find the kth smallest amount using only one coin denomination at a time, applying binary search efficiently over possibl…
Right Triangles
Count all possible right triangles in a 2D boolean grid using array scanning and hash lookup for efficiency.
Find Number of Ways to Reach the K-th Stair
Determine the total number of ways to reach the k-th stair using a state transition dynamic programming approach with co…
Find the N-th Value After K Seconds
Solve for the N-th value after K seconds by simulating array updates and using prefix sum techniques.
Find the Count of Monotonic Pairs I
Compute the number of monotonic pairs in an integer array using state transition dynamic programming efficiently.
Find the Count of Monotonic Pairs II
This problem involves finding the count of monotonic pairs in an array using dynamic programming and combinatorics techn…
Find the Count of Good Integers
Count good integers by rearranging digits to form k-palindromic numbers, leveraging hash tables and math techniques.
Sorted GCD Pair Queries
Solve the Sorted GCD Pair Queries problem by efficiently counting and locating GCDs of all array pairs using hash mappin…
Find the Number of Possible Ways for an Event
Given n performers, x stages, and y scores, calculate the number of possible ways to assign performers and score bands.
Count Number of Balanced Permutations
Determine how many distinct permutations of a digit string are balanced using state transition dynamic programming effic…
Count K-Reducible Numbers Less Than N
This problem challenges you to count the K-reducible numbers less than a given binary integer using dynamic programming.
Subsequences with a Unique Middle Mode I
Count subsequences of size 5 with a unique middle mode in an integer array using hash table and combinatorics.
Count the Number of Arrays with K Matching Adjacent Elements
Count the number of valid arrays with exactly k adjacent elements that are equal, using math and combinatorics technique…
Manhattan Distances of All Arrangements of Pieces
This problem challenges you to calculate Manhattan distances in all valid arrangements of identical pieces on a grid.
Maximum and Minimum Sums of at Most Size K Subsequences
Find the sum of the maximum and minimum elements of subsequences with at most k elements, using dynamic programming.
Check If Digits Are Equal in String After Operations I
Simulate repeated adjacent digit sums modulo 10 until two digits remain, then check whether those final digits match.
Check If Digits Are Equal in String After Operations II
Determine if repeated digit-sum operations on a numeric string reduce it to two equal digits using math and string techn…
Permutations IV
Find the k-th alternating permutation of numbers 1 to n, ensuring no adjacent numbers share parity, using array and math…
Smallest Palindromic Rearrangement II
Find the k-th lexicographically smallest palindromic rearrangement of a given palindromic string s.
Find Sum of Array Product of Magical Sequences
Use state transition dynamic programming to count magical index sequences and accumulate weighted products without enume…
Count the Number of Computer Unlocking Permutations
Calculate the total valid unlocking sequences for computers based on their complexity using array and combinatorics logi…
Number of Integers With Popcount-Depth Equal to K I
Calculate the number of integers in a given range with a specific popcount-depth using state transition dynamic programm…