> ## Documentation Index
> Fetch the complete documentation index at: https://leetcode-py.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> leetcode-py is a Python LeetCode practice environment generator with one CLI: lcpy. It is not a service or platform.
> Each problem is a directory under leetcode/ with README.md, solution.py, test_solution.py, helpers.py, and playground.ipynb. lcpy gen creates them from JSON templates bundled with the package.
> Examples are backed by tests; copy them verbatim.

# Counting in Python with Tests

> All 49 Counting LeetCode problems with tested Python solutions.

Counting holds 49 problems (18 Easy, 26 Medium, 5 Hard).
Generate any of them into the current directory with `lcpy gen -n <number>`.

<div className="sd-catalog-table">
  | # | Problem | Difficulty | Solution |
  | - | - | - | - |
  | 169 | [Majority Element](/problems/majority-element) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/majority_element/solution.py) |
  | 229 | [Majority Element II](/problems/majority-element-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/majority_element_ii/solution.py) |
  | 299 | [Bulls and Cows](/problems/bulls-and-cows) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/bulls_and_cows/solution.py) |
  | 347 | [Top K Frequent Elements](/problems/top-k-frequent-elements) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/top_k_frequent_elements/solution.py) |
  | 358 | [Rearrange String k Distance Apart](/problems/rearrange-string-k-distance-apart) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/rearrange_string_k_distance_apart/solution.py) |
  | 383 | [Ransom Note](/problems/ransom-note) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/ransom_note/solution.py) |
  | 387 | [First Unique Character in a String](/problems/first-unique-character-in-a-string) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/first_unique_character_in_a_string/solution.py) |
  | 451 | [Sort Characters By Frequency](/problems/sort-characters-by-frequency) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sort_characters_by_frequency/solution.py) |
  | 594 | [Longest Harmonious Subsequence](/problems/longest-harmonious-subsequence) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_harmonious_subsequence/solution.py) |
  | 621 | [Task Scheduler](/problems/task-scheduler) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/task_scheduler/solution.py) |
  | 692 | [Top K Frequent Words](/problems/top-k-frequent-words) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/top_k_frequent_words/solution.py) |
  | 767 | [Reorganize String](/problems/reorganize-string) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reorganize_string/solution.py) |
  | 811 | [Subdomain Visit Count](/problems/subdomain-visit-count) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/subdomain_visit_count/solution.py) |
  | 819 | [Most Common Word](/problems/most-common-word) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/most_common_word/solution.py) |
  | 869 | [Reordered Power of 2](/problems/reordered-power-of-2) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reordered_power_of_2/solution.py) |
  | 884 | [Uncommon Words from Two Sentences](/problems/uncommon-words-from-two-sentences) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/uncommon_words_from_two_sentences/solution.py) |
  | 900 | [RLE Iterator](/problems/rle-iterator) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/rle_iterator/solution.py) |
  | 914 | [X of a Kind in a Deck of Cards](/problems/x-of-a-kind-in-a-deck-of-cards) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/x_of_a_kind_in_a_deck_of_cards/solution.py) |
  | 923 | [3Sum With Multiplicity](/problems/three-sum-multiplicity) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/three_sum_multiplicity/solution.py) |
  | 945 | [Minimum Increment to Make Array Unique](/problems/minimum-increment-to-make-array-unique) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_increment_to_make_array_unique/solution.py) |
  | 992 | [Subarrays with K Different Integers](/problems/subarrays-with-k-different-integers) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/subarrays_with_k_different_integers/solution.py) |
  | 1079 | [Letter Tile Possibilities](/problems/letter-tile-possibilities) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/letter_tile_possibilities/solution.py) |
  | 1160 | [Find Words That Can Be Formed by Characters](/problems/find-words-that-can-be-formed-by-characters) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_words_that_can_be_formed_by_characters/solution.py) |
  | 1189 | [Maximum Number of Balloons](/problems/maximum-number-of-balloons) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_number_of_balloons/solution.py) |
  | 1198 | [Find Smallest Common Element in All Rows](/problems/find-smallest-common-element-in-all-rows) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_smallest_common_element_in_all_rows/solution.py) |
  | 1255 | [Maximum Score Words Formed by Letters](/problems/maximum-score-words-formed-by-letters) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_score_words_formed_by_letters/solution.py) |
  | 1267 | [Count Servers that Communicate](/problems/count-servers-that-communicate) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_servers_that_communicate/solution.py) |
  | 1394 | [Find Lucky Integer in an Array](/problems/find-lucky-integer-in-an-array) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_lucky_integer_in_an_array/solution.py) |
  | 1400 | [Construct K Palindrome Strings](/problems/construct-k-palindrome-strings) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/construct_k_palindrome_strings/solution.py) |
  | 1481 | [Least Number of Unique Integers after K Removals](/problems/least-number-of-unique-integers-after-k-removals) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/least_number_of_unique_integers_after_k_removals/solution.py) |
  | 1512 | [Number of Good Pairs](/problems/number-of-good-pairs) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_good_pairs/solution.py) |
  | 1603 | [Design Parking System](/problems/design-parking-system) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_parking_system/solution.py) |
  | 1684 | [Count the Number of Consistent Strings](/problems/count-the-number-of-consistent-strings) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_the_number_of_consistent_strings/solution.py) |
  | 1726 | [Tuple with Same Product](/problems/tuple-with-same-product) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/tuple_with_same_product/solution.py) |
  | 1790 | [Check if One String Swap Can Make Strings Equal](/problems/check-if-one-string-swap-can-make-strings-equal) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/check_if_one_string_swap_can_make_strings_equal/solution.py) |
  | 1857 | [Largest Color Value in a Directed Graph](/problems/largest-color-value-in-a-directed-graph) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/largest_color_value_in_a_directed_graph/solution.py) |
  | 1897 | [Redistribute Characters to Make All Strings Equal](/problems/redistribute-characters-to-make-all-strings-equal) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/redistribute_characters_to_make_all_strings_equal/solution.py) |
  | 2001 | [Number of Pairs of Interchangeable Rectangles](/problems/number-of-pairs-of-interchangeable-rectangles) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_pairs_of_interchangeable_rectangles/solution.py) |
  | 2013 | [Detect Squares](/problems/detect-squares) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/detect_squares/solution.py) |
  | 2053 | [Kth Distinct String in an Array](/problems/kth-distinct-string-in-an-array) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/kth_distinct_string_in_an_array/solution.py) |
  | 2182 | [Construct String With Repeat Limit](/problems/construct-string-with-repeat-limit) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/construct_string_with_repeat_limit/solution.py) |
  | 2206 | [Divide Array Into Equal Pairs](/problems/divide-array-into-equal-pairs) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/divide_array_into_equal_pairs/solution.py) |
  | 2275 | [Largest Combination With Bitwise AND Greater Than Zero](/problems/largest-combination-with-bitwise-and-greater-than-zero) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/largest_combination_with_bitwise_and_greater_than_zero/solution.py) |
  | 2364 | [Count Number of Bad Pairs](/problems/count-number-of-bad-pairs) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_number_of_bad_pairs/solution.py) |
  | 2416 | [Sum of Prefix Scores of Strings](/problems/sum-of-prefix-scores-of-strings) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sum_of_prefix_scores_of_strings/solution.py) |
  | 2870 | [Minimum Number of Operations to Make Array Empty](/problems/minimum-number-of-operations-to-make-array-empty) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_number_of_operations_to_make_array_empty/solution.py) |
  | 3016 | [Minimum Number of Pushes to Type Word II](/problems/minimum-number-of-pushes-to-type-word-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_number_of_pushes_to_type_word_ii/solution.py) |
  | 3223 | [Minimum Length of String After Operations](/problems/minimum-length-of-string-after-operations) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_length_of_string_after_operations/solution.py) |
  | 3442 | [Maximum Difference Between Even and Odd Frequency I](/problems/maximum-difference-between-even-and-odd-frequency-i) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_difference_between_even_and_odd_frequency_i/solution.py) |
</div>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.