Enumeration LeetCode Problems: All 80, With Python Solutions

Every problem in this library that LeetCode tags Enumeration 80 in total, 75 of them with a complete Python solution, a worked example and the time and space complexity of the approach.

  • 80 problems
  • 20 Easy
  • 40 Medium
  • 20 Hard

Enumeration problems by difficulty

Problems with a complete Python solution are listed first, then by ascending problem number.

Easy (20)

#ProblemDifficultyTopics
1534Count Good TripletsEasyArray, Enumeration
1566Detect Pattern of Length M Repeated K or More TimesEasyArray, Enumeration
1863Sum of All Subset XOR TotalsEasyBit Manipulation, Array, Math +3
1925Count Square Sum TriplesEasyMath, Enumeration
1952Three DivisorsEasyMath, Enumeration, Number Theory
1995Count Special QuadrupletsEasyArray, Hash Table, Enumeration
2094Finding 3-Digit Even NumbersEasyRecursion, Array, Hash Table +2
2259Remove Digit From Number to Maximize ResultEasyGreedy, String, Enumeration
2309Greatest English Letter in Upper and Lower CaseEasyHash Table, String, Enumeration
2367Number of Arithmetic TripletsEasyArray, Hash Table, Two Pointers +1
2427Number of Common FactorsEasyMath, Enumeration, Number Theory
2437Number of Valid Clock TimesEasyString, Enumeration
2605Form Smallest Number From Two Digit ArraysEasyArray, Hash Table, Enumeration
2765Longest Alternating SubarrayEasyArray, Enumeration
2778Sum of Squares of Special ElementsEasyArray, Enumeration
2843Count Symmetric IntegersEasyMath, Enumeration
2928Distribute Candies Among Children IEasyMath, Combinatorics, Enumeration
2951Find the PeaksEasyArray, Enumeration
2970Count the Number of Incremovable Subarrays IEasyArray, Two Pointers, Binary Search +1
800Similar RGB ColorPremiumEasyMath, String, Enumeration

Medium (40)

#ProblemDifficultyTopics
204Count PrimesMediumArray, Math, Enumeration +1
816Ambiguous CoordinatesMediumString, Backtracking, Enumeration
845Longest Mountain in ArrayMediumArray, Two Pointers, Dynamic Programming +1
869Reordered Power of 2MediumHash Table, Math, Counting +2
949Largest Time for Given DigitsMediumArray, String, Backtracking +1
970Powerful IntegersMediumHash Table, Math, Enumeration
1291Sequential DigitsMediumEnumeration
1620Coordinate With Maximum Network QualityMediumArray, Enumeration
1625Lexicographically Smallest String After Applying OperationsMediumDepth-First Search, Breadth-First Search, String +1
1638Count Substrings That Differ by One CharacterMediumHash Table, String, Dynamic Programming +1
1849Splitting a String Into Descending Consecutive ValuesMediumString, Backtracking, Enumeration
1958Check if Move is LegalMediumArray, Enumeration, Matrix
2018Check if Word Can Be Placed In CrosswordMediumArray, Enumeration, Matrix
2044Count Number of Maximum Bitwise-OR SubsetsMediumBit Manipulation, Array, Backtracking +1
2048Next Greater Numerically Balanced NumberMediumHash Table, Math, Backtracking +2
2162Minimum Cost to Set Cooking TimeMediumMath, Enumeration
2171Removing Minimum Number of Magic BeansMediumGreedy, Array, Enumeration +2
2212Maximum Points in an Archery CompetitionMediumBit Manipulation, Array, Backtracking +1
2232Minimize Result by Adding Parentheses to ExpressionMediumString, Enumeration
2240Number of Ways to Buy Pens and PencilsMediumMath, Enumeration
2249Count Lattice Points Inside a CircleMediumGeometry, Array, Hash Table +2
2261K Divisible Elements SubarraysMediumTrie, Array, Hash Table +3
2310Sum of Numbers With Units Digit KMediumGreedy, Math, Dynamic Programming +1
2397Maximum Rows Covered by ColumnsMediumBit Manipulation, Array, Backtracking +2
2443Sum of Number and Its ReverseMediumMath, Enumeration
2708Maximum Strength of a GroupMediumGreedy, Bit Manipulation, Array +4
2735Collecting ChocolatesMediumArray, Enumeration
2749Minimum Operations to Make the Integer ZeroMediumBit Manipulation, Brainteaser, Enumeration
2761Prime Pairs With Target SumMediumArray, Math, Enumeration +1
2768Number of Black BlocksMediumArray, Hash Table, Enumeration
2800Shortest String That Contains Three StringsMediumGreedy, String, Enumeration
2844Minimum Operations to Make a Special NumberMediumGreedy, Math, String +1
2860Happy StudentsMediumArray, Enumeration, Sorting
2929Distribute Candies Among Children IIMediumMath, Combinatorics, Enumeration
2934Minimum Operations to Maximize Last Elements in ArraysMediumArray, Enumeration
2947Count Beautiful Substrings IMediumHash Table, Math, String +3
2975Maximum Square Area by Removing Fences From a FieldMediumArray, Hash Table, Enumeration
681Next Closest TimePremiumMediumHash Table, String, Backtracking +1
1999Smallest Greater Multiple Made of Two DigitsPremiumMediumMath, Enumeration
2417Closest Fair IntegerPremiumMediumMath, Enumeration

Hard (20)

#ProblemDifficultyTopics
479Largest Palindrome ProductHardMath, Enumeration
829Consecutive Numbers SumHardMath, Enumeration
906Super PalindromesHardMath, String, Enumeration
1601Maximum Number of Achievable Transfer RequestsHardBit Manipulation, Array, Backtracking +1
1617Count Subtrees With Max Distance Between CitiesHardBit Manipulation, Tree, Dynamic Programming +2
1761Minimum Degree of a Connected Trio in a GraphHardGraph, Enumeration
2014Longest Subsequence Repeated k TimesHardGreedy, String, Backtracking +2
2025Maximum Number of Ways to Partition an ArrayHardArray, Hash Table, Counting +2
2081Sum of k-Mirror NumbersHardMath, Enumeration
2122Recover the Original ArrayHardArray, Hash Table, Two Pointers +2
2151Maximum Good People Based on StatementsHardBit Manipulation, Array, Backtracking +1
2234Maximum Total Beauty of the GardensHardGreedy, Array, Two Pointers +4
2242Maximum Score of a Node SequenceHardGraph, Array, Enumeration +1
2306Naming a CompanyHardBit Manipulation, Array, Hash Table +2
2440Create Components With Same ValueHardTree, Depth-First Search, Array +2
2468Split Message Based on LimitHardString, Binary Search, Enumeration
2552Count Increasing QuadrupletsHardBinary Indexed Tree, Array, Dynamic Programming +2
2763Sum of Imbalance Numbers of All SubarraysHardArray, Hash Table, Enumeration
2959Number of Possible Sets of Closing BranchesHardBit Manipulation, Graph, Enumeration +2
1956Minimum Time For K Virus Variants to SpreadPremiumHardGeometry, Array, Math +2

When the Enumeration problem arrives live

Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.