> ## 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.

# Medium LeetCode Problems in Python with Tests

> All 819 Medium LeetCode problems with tested Python solutions. Part 1 of 5: problems 1-200.

Medium holds 819 problems.

<div className="sd-catalog-table">
  | # | Problem | Difficulty | Solution |
  | - | - | - | - |
  | 2 | [Add Two Numbers](/problems/add-two-numbers) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/add_two_numbers/solution.py) |
  | 3 | [Longest Substring Without Repeating Characters](/problems/longest-substring-without-repeating-characters) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_substring_without_repeating_characters/solution.py) |
  | 5 | [Longest Palindromic Substring](/problems/longest-palindromic-substring) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_palindromic_substring/solution.py) |
  | 6 | [Zigzag Conversion](/problems/zigzag-conversion) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/zigzag_conversion/solution.py) |
  | 7 | [Reverse Integer](/problems/reverse-integer) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reverse_integer/solution.py) |
  | 8 | [String to Integer (atoi)](/problems/string-to-integer-atoi) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/string_to_integer_atoi/solution.py) |
  | 11 | [Container With Most Water](/problems/container-with-most-water) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/container_with_most_water/solution.py) |
  | 12 | [Integer to Roman](/problems/integer-to-roman) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/integer_to_roman/solution.py) |
  | 15 | [3Sum](/problems/three-sum) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/three_sum/solution.py) |
  | 16 | [3Sum Closest](/problems/three-sum-closest) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/three_sum_closest/solution.py) |
  | 17 | [Letter Combinations of a Phone Number](/problems/letter-combinations-of-a-phone-number) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/letter_combinations_of_a_phone_number/solution.py) |
  | 18 | [4Sum](/problems/four-sum) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/four_sum/solution.py) |
  | 19 | [Remove Nth Node From End of List](/problems/remove-nth-node-from-end-of-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_nth_node_from_end_of_list/solution.py) |
  | 22 | [Generate Parentheses](/problems/generate-parentheses) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/generate_parentheses/solution.py) |
  | 24 | [Swap Nodes in Pairs](/problems/swap-nodes-in-pairs) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/swap_nodes_in_pairs/solution.py) |
  | 29 | [Divide Two Integers](/problems/divide-two-integers) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/divide_two_integers/solution.py) |
  | 31 | [Next Permutation](/problems/next-permutation) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/next_permutation/solution.py) |
  | 33 | [Search in Rotated Sorted Array](/problems/search-in-rotated-sorted-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/search_in_rotated_sorted_array/solution.py) |
  | 34 | [Find First and Last Position of Element in Sorted Array](/problems/find-first-and-last-position-of-element-in-sorted-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_first_and_last_position_of_element_in_sorted_array/solution.py) |
  | 36 | [Valid Sudoku](/problems/valid-sudoku) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/valid_sudoku/solution.py) |
  | 38 | [Count and Say](/problems/count-and-say) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_and_say/solution.py) |
  | 39 | [Combination Sum](/problems/combination-sum) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/combination_sum/solution.py) |
  | 40 | [Combination Sum II](/problems/combination-sum-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/combination_sum_ii/solution.py) |
  | 43 | [Multiply Strings](/problems/multiply-strings) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/multiply_strings/solution.py) |
  | 45 | [Jump Game II](/problems/jump-game-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/jump_game_ii/solution.py) |
  | 46 | [Permutations](/problems/permutations) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/permutations/solution.py) |
  | 47 | [Permutations II](/problems/permutations-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/permutations_ii/solution.py) |
  | 48 | [Rotate Image](/problems/rotate-image) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/rotate_image/solution.py) |
  | 49 | [Group Anagrams](/problems/group-anagrams) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/group_anagrams/solution.py) |
  | 50 | [Pow(x, n)](/problems/powx-n) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/powx_n/solution.py) |
  | 53 | [Maximum Subarray](/problems/maximum-subarray) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_subarray/solution.py) |
  | 54 | [Spiral Matrix](/problems/spiral-matrix) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/spiral_matrix/solution.py) |
  | 55 | [Jump Game](/problems/jump-game) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/jump_game/solution.py) |
  | 56 | [Merge Intervals](/problems/merge-intervals) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/merge_intervals/solution.py) |
  | 57 | [Insert Interval](/problems/insert-interval) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/insert_interval/solution.py) |
  | 59 | [Spiral Matrix II](/problems/spiral-matrix-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/spiral_matrix_ii/solution.py) |
  | 61 | [Rotate List](/problems/rotate-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/rotate_list/solution.py) |
  | 62 | [Unique Paths](/problems/unique-paths) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/unique_paths/solution.py) |
  | 63 | [Unique Paths II](/problems/unique-paths-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/unique_paths_ii/solution.py) |
  | 64 | [Minimum Path Sum](/problems/minimum-path-sum) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_path_sum/solution.py) |
  | 71 | [Simplify Path](/problems/simplify-path) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/simplify_path/solution.py) |
  | 73 | [Set Matrix Zeroes](/problems/set-matrix-zeroes) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/set_matrix_zeroes/solution.py) |
  | 74 | [Search a 2D Matrix](/problems/search-a-2d-matrix) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/search_a_2d_matrix/solution.py) |
  | 75 | [Sort Colors](/problems/sort-colors) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sort_colors/solution.py) |
  | 77 | [Combinations](/problems/combinations) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/combinations/solution.py) |
  | 78 | [Subsets](/problems/subsets) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/subsets/solution.py) |
  | 79 | [Word Search](/problems/word-search) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/word_search/solution.py) |
  | 80 | [Remove Duplicates from Sorted Array II](/problems/remove-duplicates-from-sorted-array-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_duplicates_from_sorted_array_ii/solution.py) |
  | 81 | [Search in Rotated Sorted Array II](/problems/search-in-rotated-sorted-array-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/search_in_rotated_sorted_array_ii/solution.py) |
  | 82 | [Remove Duplicates from Sorted List II](/problems/remove-duplicates-from-sorted-list-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_duplicates_from_sorted_list_ii/solution.py) |
  | 86 | [Partition List](/problems/partition-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/partition_list/solution.py) |
  | 89 | [Gray Code](/problems/gray-code) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/gray_code/solution.py) |
  | 90 | [Subsets II](/problems/subsets-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/subsets_ii/solution.py) |
  | 91 | [Decode Ways](/problems/decode-ways) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/decode_ways/solution.py) |
  | 92 | [Reverse Linked List II](/problems/reverse-linked-list-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reverse_linked_list_ii/solution.py) |
  | 93 | [Restore IP Addresses](/problems/restore-ip-addresses) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/restore_ip_addresses/solution.py) |
  | 95 | [Unique Binary Search Trees II](/problems/unique-binary-search-trees-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/unique_binary_search_trees_ii/solution.py) |
  | 96 | [Unique Binary Search Trees](/problems/unique-binary-search-trees) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/unique_binary_search_trees/solution.py) |
  | 97 | [Interleaving String](/problems/interleaving-string) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/interleaving_string/solution.py) |
  | 98 | [Validate Binary Search Tree](/problems/validate-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/validate_binary_search_tree/solution.py) |
  | 99 | [Recover Binary Search Tree](/problems/recover-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/recover_binary_search_tree/solution.py) |
  | 102 | [Binary Tree Level Order Traversal](/problems/binary-tree-level-order-traversal) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_level_order_traversal/solution.py) |
  | 103 | [Binary Tree Zigzag Level Order Traversal](/problems/binary-tree-zigzag-level-order-traversal) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_zigzag_level_order_traversal/solution.py) |
  | 105 | [Construct Binary Tree from Preorder and Inorder Traversal](/problems/construct-binary-tree-from-preorder-and-inorder-traversal) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/construct_binary_tree_from_preorder_and_inorder_traversal/solution.py) |
  | 106 | [Construct Binary Tree from Inorder and Postorder Traversal](/problems/construct-binary-tree-from-inorder-and-postorder-traversal) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/construct_binary_tree_from_inorder_and_postorder_traversal/solution.py) |
  | 107 | [Binary Tree Level Order Traversal II](/problems/binary-tree-level-order-traversal-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_level_order_traversal_ii/solution.py) |
  | 109 | [Convert Sorted List to Binary Search Tree](/problems/convert-sorted-list-to-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/convert_sorted_list_to_binary_search_tree/solution.py) |
  | 113 | [Path Sum II](/problems/path-sum-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/path_sum_ii/solution.py) |
  | 114 | [Flatten Binary Tree to Linked List](/problems/flatten-binary-tree-to-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flatten_binary_tree_to_linked_list/solution.py) |
  | 116 | [Populating Next Right Pointers In Each Node](/problems/populating-next-right-pointers-in-each-node) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/populating_next_right_pointers_in_each_node/solution.py) |
  | 117 | [Populating Next Right Pointers in Each Node II](/problems/populating-next-right-pointers-in-each-node-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/populating_next_right_pointers_in_each_node_ii/solution.py) |
  | 120 | [Triangle](/problems/triangle) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/triangle/solution.py) |
  | 122 | [Best Time to Buy and Sell Stock II](/problems/best-time-to-buy-and-sell-stock-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/best_time_to_buy_and_sell_stock_ii/solution.py) |
  | 128 | [Longest Consecutive Sequence](/problems/longest-consecutive-sequence) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_consecutive_sequence/solution.py) |
  | 129 | [Sum Root to Leaf Numbers](/problems/sum-root-to-leaf-numbers) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sum_root_to_leaf_numbers/solution.py) |
  | 130 | [Surrounded Regions](/problems/surrounded-regions) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/surrounded_regions/solution.py) |
  | 131 | [Palindrome Partitioning](/problems/palindrome-partitioning) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/palindrome_partitioning/solution.py) |
  | 133 | [Clone Graph](/problems/clone-graph) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/clone_graph/solution.py) |
  | 134 | [Gas Station](/problems/gas-station) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/gas_station/solution.py) |
  | 137 | [Single Number II](/problems/single-number-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/single_number_ii/solution.py) |
  | 138 | [Copy List with Random Pointer](/problems/copy-list-with-random-pointer) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/copy_list_with_random_pointer/solution.py) |
  | 139 | [Word Break](/problems/word-break) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/word_break/solution.py) |
  | 142 | [Linked List Cycle II](/problems/linked-list-cycle-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/linked_list_cycle_ii/solution.py) |
  | 143 | [Reorder List](/problems/reorder-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reorder_list/solution.py) |
  | 146 | [LRU Cache](/problems/lru-cache) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/lru_cache/solution.py) |
  | 147 | [Insertion Sort List](/problems/insertion-sort-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/insertion_sort_list/solution.py) |
  | 148 | [Sort List](/problems/sort-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sort_list/solution.py) |
  | 150 | [Evaluate Reverse Polish Notation](/problems/evaluate-reverse-polish-notation) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/evaluate_reverse_polish_notation/solution.py) |
  | 151 | [Reverse Words in a String](/problems/reverse-words-in-a-string) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reverse_words_in_a_string/solution.py) |
  | 152 | [Maximum Product Subarray](/problems/maximum-product-subarray) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_product_subarray/solution.py) |
  | 153 | [Find Minimum in Rotated Sorted Array](/problems/find-minimum-in-rotated-sorted-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_minimum_in_rotated_sorted_array/solution.py) |
  | 155 | [Min Stack](/problems/min-stack) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/min_stack/solution.py) |
  | 156 | [Binary Tree Upside Down](/problems/binary-tree-upside-down) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_upside_down/solution.py) |
  | 159 | [Longest Substring with At Most Two Distinct Characters](/problems/longest-substring-with-at-most-two-distinct-characters) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_substring_with_at_most_two_distinct_characters/solution.py) |
  | 161 | [One Edit Distance](/problems/one-edit-distance) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/one_edit_distance/solution.py) |
  | 162 | [Find Peak Element](/problems/find-peak-element) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_peak_element/solution.py) |
  | 164 | [Maximum Gap](/problems/maximum-gap) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_gap/solution.py) |
  | 165 | [Compare Version Numbers](/problems/compare-version-numbers) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/compare_version_numbers/solution.py) |
  | 166 | [Fraction to Recurring Decimal](/problems/fraction-to-recurring-decimal) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/fraction_to_recurring_decimal/solution.py) |
  | 167 | [Two Sum II - Input Array Is Sorted](/problems/two-sum-ii-input-array-is-sorted) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/two_sum_ii_input_array_is_sorted/solution.py) |
  | 172 | [Factorial Trailing Zeroes](/problems/factorial-trailing-zeroes) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/factorial_trailing_zeroes/solution.py) |
  | 173 | [Binary Search Tree Iterator](/problems/binary-search-tree-iterator) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_search_tree_iterator/solution.py) |
  | 179 | [Largest Number](/problems/largest-number) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/largest_number/solution.py) |
  | 186 | [Reverse Words in a String II](/problems/reverse-words-in-a-string-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reverse_words_in_a_string_ii/solution.py) |
  | 187 | [Repeated DNA Sequences](/problems/repeated-dna-sequences) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/repeated_dna_sequences/solution.py) |
  | 189 | [Rotate Array](/problems/rotate-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/rotate_array/solution.py) |
  | 198 | [House Robber](/problems/house-robber) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/house_robber/solution.py) |
  | 199 | [Binary Tree Right Side View](/problems/binary-tree-right-side-view) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_right_side_view/solution.py) |
  | 200 | [Number of Islands](/problems/number-of-islands) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_islands/solution.py) |
  | 201 | [Bitwise AND of Numbers Range](/problems/bitwise-and-of-numbers-range) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/bitwise_and_of_numbers_range/solution.py) |
  | 204 | [Count Primes](/problems/count-primes) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_primes/solution.py) |
  | 207 | [Course Schedule](/problems/course-schedule) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/course_schedule/solution.py) |
  | 208 | [Implement Trie (Prefix Tree)](/problems/implement-trie-prefix-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/implement_trie_prefix_tree/solution.py) |
  | 209 | [Minimum Size Subarray Sum](/problems/minimum-size-subarray-sum) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_size_subarray_sum/solution.py) |
  | 210 | [Course Schedule II](/problems/course-schedule-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/course_schedule_ii/solution.py) |
  | 211 | [Design Add and Search Words Data Structure](/problems/design-add-and-search-words-data-structure) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_add_and_search_words_data_structure/solution.py) |
  | 213 | [House Robber II](/problems/house-robber-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/house_robber_ii/solution.py) |
  | 215 | [Kth Largest Element in an Array](/problems/kth-largest-element-in-an-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/kth_largest_element_in_an_array/solution.py) |
  | 216 | [Combination Sum III](/problems/combination-sum-iii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/combination_sum_iii/solution.py) |
  | 221 | [Maximal Square](/problems/maximal-square) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximal_square/solution.py) |
  | 222 | [Count Complete Tree Nodes](/problems/count-complete-tree-nodes) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_complete_tree_nodes/solution.py) |
  | 223 | [Rectangle Area](/problems/rectangle-area) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/rectangle_area/solution.py) |
  | 227 | [Basic Calculator II](/problems/basic-calculator-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/basic_calculator_ii/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) |
  | 230 | [Kth Smallest Element in a BST](/problems/kth-smallest-element-in-a-bst) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/kth_smallest_element_in_a_bst/solution.py) |
  | 235 | [Lowest Common Ancestor of a Binary Search Tree](/problems/lowest-common-ancestor-of-a-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/lowest_common_ancestor_of_a_binary_search_tree/solution.py) |
  | 236 | [Lowest Common Ancestor of a Binary Tree](/problems/lowest-common-ancestor-of-a-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/lowest_common_ancestor_of_a_binary_tree/solution.py) |
  | 237 | [Delete Node in a Linked List](/problems/delete-node-in-a-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/delete_node_in_a_linked_list/solution.py) |
  | 238 | [Product of Array Except Self](/problems/product-of-array-except-self) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/product_of_array_except_self/solution.py) |
  | 240 | [Search a 2D Matrix II](/problems/search-a-2d-matrix-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/search_a_2d_matrix_ii/solution.py) |
  | 241 | [Different Ways to Add Parentheses](/problems/different-ways-to-add-parentheses) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/different_ways_to_add_parentheses/solution.py) |
  | 244 | [Shortest Word Distance II](/problems/shortest-word-distance-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shortest_word_distance_ii/solution.py) |
  | 245 | [Shortest Word Distance III](/problems/shortest-word-distance-iii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shortest_word_distance_iii/solution.py) |
  | 247 | [Strobogrammatic Number II](/problems/strobogrammatic-number-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/strobogrammatic_number_ii/solution.py) |
  | 249 | [Group Shifted Strings](/problems/group-shifted-strings) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/group_shifted_strings/solution.py) |
  | 250 | [Count Univalue Subtrees](/problems/count-univalue-subtrees) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_univalue_subtrees/solution.py) |
  | 251 | [Flatten 2D Vector](/problems/flatten-2d-vector) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flatten_2d_vector/solution.py) |
  | 253 | [Meeting Rooms II](/problems/meeting-rooms-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/meeting_rooms_ii/solution.py) |
  | 254 | [Factor Combinations](/problems/factor-combinations) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/factor_combinations/solution.py) |
  | 255 | [Verify Preorder Sequence in Binary Search Tree](/problems/verify-preorder-sequence-in-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/verify_preorder_sequence_in_binary_search_tree/solution.py) |
  | 256 | [Paint House](/problems/paint-house) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/paint_house/solution.py) |
  | 259 | [3Sum Smaller](/problems/three-sum-smaller) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/three_sum_smaller/solution.py) |
  | 260 | [Single Number III](/problems/single-number-iii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/single_number_iii/solution.py) |
  | 261 | [Graph Valid Tree](/problems/graph-valid-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/graph_valid_tree/solution.py) |
  | 264 | [Ugly Number II](/problems/ugly-number-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/ugly_number_ii/solution.py) |
  | 267 | [Palindrome Permutation II](/problems/palindrome-permutation-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/palindrome_permutation_ii/solution.py) |
  | 271 | [Encode and Decode Strings](/problems/encode-and-decode-strings) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/encode_and_decode_strings/solution.py) |
  | 274 | [H-Index](/problems/h-index) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/h_index/solution.py) |
  | 275 | [H-Index II](/problems/h-index-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/h_index_ii/solution.py) |
  | 276 | [Paint Fence](/problems/paint-fence) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/paint_fence/solution.py) |
  | 277 | [Find the Celebrity](/problems/find-the-celebrity) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_the_celebrity/solution.py) |
  | 279 | [Perfect Squares](/problems/perfect-squares) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/perfect_squares/solution.py) |
  | 280 | [Wiggle Sort](/problems/wiggle-sort) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/wiggle_sort/solution.py) |
  | 281 | [Zigzag Iterator](/problems/zigzag-iterator) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/zigzag_iterator/solution.py) |
  | 284 | [Peeking Iterator](/problems/peeking-iterator) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/peeking_iterator/solution.py) |
  | 285 | [Inorder Successor in BST](/problems/inorder-successor-in-bst) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/inorder_successor_in_bst/solution.py) |
  | 286 | [Walls And Gates](/problems/walls-and-gates) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/walls_and_gates/solution.py) |
  | 287 | [Find the Duplicate Number](/problems/find-the-duplicate-number) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_the_duplicate_number/solution.py) |
  | 288 | [Unique Word Abbreviation](/problems/unique-word-abbreviation) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/unique_word_abbreviation/solution.py) |
  | 289 | [Game of Life](/problems/game-of-life) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/game_of_life/solution.py) |
  | 291 | [Word Pattern II](/problems/word-pattern-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/word_pattern_ii/solution.py) |
  | 294 | [Flip Game II](/problems/flip-game-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flip_game_ii/solution.py) |
  | 298 | [Binary Tree Longest Consecutive Sequence](/problems/binary-tree-longest-consecutive-sequence) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_longest_consecutive_sequence/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) |
  | 300 | [Longest Increasing Subsequence](/problems/longest-increasing-subsequence) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_increasing_subsequence/solution.py) |
  | 304 | [Range Sum Query 2D - Immutable](/problems/range-sum-query-2d-immutable) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/range_sum_query_2d_immutable/solution.py) |
  | 306 | [Additive Number](/problems/additive-number) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/additive_number/solution.py) |
  | 307 | [Range Sum Query - Mutable](/problems/range-sum-query-mutable) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/range_sum_query_mutable/solution.py) |
  | 308 | [Range Sum Query 2D - Mutable](/problems/range-sum-query-2d-mutable) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/range_sum_query_2d_mutable/solution.py) |
  | 309 | [Best Time to Buy and Sell Stock with Cooldown](/problems/best-time-to-buy-and-sell-stock-with-cooldown) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/best_time_to_buy_and_sell_stock_with_cooldown/solution.py) |
  | 310 | [Minimum Height Trees](/problems/minimum-height-trees) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_height_trees/solution.py) |
  | 311 | [Sparse Matrix Multiplication](/problems/sparse-matrix-multiplication) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sparse_matrix_multiplication/solution.py) |
  | 313 | [Super Ugly Number](/problems/super-ugly-number) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/super_ugly_number/solution.py) |
  | 314 | [Binary Tree Vertical Order Traversal](/problems/binary-tree-vertical-order-traversal) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_vertical_order_traversal/solution.py) |
  | 316 | [Remove Duplicate Letters](/problems/remove-duplicate-letters) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_duplicate_letters/solution.py) |
  | 318 | [Maximum Product of Word Lengths](/problems/maximum-product-of-word-lengths) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_product_of_word_lengths/solution.py) |
  | 319 | [Bulb Switcher](/problems/bulb-switcher) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/bulb_switcher/solution.py) |
  | 320 | [Generalized Abbreviation](/problems/generalized-abbreviation) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/generalized_abbreviation/solution.py) |
  | 322 | [Coin Change](/problems/coin-change) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/coin_change/solution.py) |
  | 323 | [Number of Connected Components in an Undirected Graph](/problems/number-of-connected-components-in-an-undirected-graph) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_connected_components_in_an_undirected_graph/solution.py) |
  | 324 | [Wiggle Sort II](/problems/wiggle-sort-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/wiggle_sort_ii/solution.py) |
  | 325 | [Maximum Size Subarray Sum Equals k](/problems/maximum-size-subarray-sum-equals-k) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_size_subarray_sum_equals_k/solution.py) |
  | 328 | [Odd Even Linked List](/problems/odd-even-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/odd_even_linked_list/solution.py) |
  | 331 | [Verify Preorder Serialization of a Binary Tree](/problems/verify-preorder-serialization-of-a-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/verify_preorder_serialization_of_a_binary_tree/solution.py) |
  | 333 | [Largest BST Subtree](/problems/largest-bst-subtree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/largest_bst_subtree/solution.py) |
  | 334 | [Increasing Triplet Subsequence](/problems/increasing-triplet-subsequence) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/increasing_triplet_subsequence/solution.py) |
  | 337 | [House Robber III](/problems/house-robber-iii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/house_robber_iii/solution.py) |
  | 339 | [Nested List Weight Sum](/problems/nested-list-weight-sum) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/nested_list_weight_sum/solution.py) |
  | 340 | [Longest Substring with At Most K Distinct Characters](/problems/longest-substring-with-at-most-k-distinct-characters) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_substring_with_at_most_k_distinct_characters/solution.py) |
  | 341 | [Flatten Nested List Iterator](/problems/flatten-nested-list-iterator) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flatten_nested_list_iterator/solution.py) |
  | 343 | [Integer Break](/problems/integer-break) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/integer_break/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) |
  | 348 | [Design Tic-Tac-Toe](/problems/design-tic-tac-toe) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_tic_tac_toe/solution.py) |
  | 351 | [Android Unlock Patterns](/problems/android-unlock-patterns) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/android_unlock_patterns/solution.py) |
  | 353 | [Design Snake Game](/problems/design-snake-game) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_snake_game/solution.py) |
  | 355 | [Design Twitter](/problems/design-twitter) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_twitter/solution.py) |
  | 356 | [Line Reflection](/problems/line-reflection) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/line_reflection/solution.py) |
  | 357 | [Count Numbers with Unique Digits](/problems/count-numbers-with-unique-digits) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_numbers_with_unique_digits/solution.py) |
  | 360 | [Sort Transformed Array](/problems/sort-transformed-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sort_transformed_array/solution.py) |
  | 361 | [Bomb Enemy](/problems/bomb-enemy) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/bomb_enemy/solution.py) |
</div>

Pages: 1, [2](/catalog/medium-2), [3](/catalog/medium-3), [4](/catalog/medium-4), [5](/catalog/medium-5)


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