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

# Hard LeetCode Problems in Python with Tests

> All 276 Hard LeetCode problems with tested Python solutions. Part 1 of 2: problems 1-200.

Hard holds 276 problems.

<div className="sd-catalog-table">
  | # | Problem | Difficulty | Solution |
  | - | - | - | - |
  | 4 | [Median of Two Sorted Arrays](/problems/median-of-two-sorted-arrays) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/median_of_two_sorted_arrays/solution.py) |
  | 10 | [Regular Expression Matching](/problems/regular-expression-matching) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/regular_expression_matching/solution.py) |
  | 23 | [Merge k Sorted Lists](/problems/merge-k-sorted-lists) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/merge_k_sorted_lists/solution.py) |
  | 25 | [Reverse Nodes in k-Group](/problems/reverse-nodes-in-k-group) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reverse_nodes_in_k_group/solution.py) |
  | 30 | [Substring with Concatenation of All Words](/problems/substring-with-concatenation-of-all-words) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/substring_with_concatenation_of_all_words/solution.py) |
  | 32 | [Longest Valid Parentheses](/problems/longest-valid-parentheses) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_valid_parentheses/solution.py) |
  | 37 | [Sudoku Solver](/problems/sudoku-solver) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sudoku_solver/solution.py) |
  | 41 | [First Missing Positive](/problems/first-missing-positive) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/first_missing_positive/solution.py) |
  | 42 | [Trapping Rain Water](/problems/trapping-rain-water) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/trapping_rain_water/solution.py) |
  | 44 | [Wildcard Matching](/problems/wildcard-matching) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/wildcard_matching/solution.py) |
  | 51 | [N-Queens](/problems/n-queens) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/n_queens/solution.py) |
  | 52 | [N-Queens II](/problems/n-queens-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/n_queens_ii/solution.py) |
  | 60 | [Permutation Sequence](/problems/permutation-sequence) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/permutation_sequence/solution.py) |
  | 65 | [Valid Number](/problems/valid-number) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/valid_number/solution.py) |
  | 68 | [Text Justification](/problems/text-justification) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/text_justification/solution.py) |
  | 72 | [Edit Distance](/problems/edit-distance) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/edit_distance/solution.py) |
  | 76 | [Minimum Window Substring](/problems/minimum-window-substring) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_window_substring/solution.py) |
  | 84 | [Largest Rectangle in Histogram](/problems/largest-rectangle-in-histogram) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/largest_rectangle_in_histogram/solution.py) |
  | 85 | [Maximal Rectangle](/problems/maximal-rectangle) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximal_rectangle/solution.py) |
  | 87 | [Scramble String](/problems/scramble-string) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/scramble_string/solution.py) |
  | 115 | [Distinct Subsequences](/problems/distinct-subsequences) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/distinct_subsequences/solution.py) |
  | 123 | [Best Time to Buy and Sell Stock III](/problems/best-time-to-buy-and-sell-stock-iii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/best_time_to_buy_and_sell_stock_iii/solution.py) |
  | 124 | [Binary Tree Maximum Path Sum](/problems/binary-tree-maximum-path-sum) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_maximum_path_sum/solution.py) |
  | 126 | [Word Ladder II](/problems/word-ladder-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/word_ladder_ii/solution.py) |
  | 127 | [Word Ladder](/problems/word-ladder) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/word_ladder/solution.py) |
  | 132 | [Palindrome Partitioning II](/problems/palindrome-partitioning-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/palindrome_partitioning_ii/solution.py) |
  | 135 | [Candy](/problems/candy) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/candy/solution.py) |
  | 140 | [Word Break II](/problems/word-break-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/word_break_ii/solution.py) |
  | 149 | [Max Points on a Line](/problems/max-points-on-a-line) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/max_points_on_a_line/solution.py) |
  | 154 | [Find Minimum in Rotated Sorted Array II](/problems/find-minimum-in-rotated-sorted-array-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_minimum_in_rotated_sorted_array_ii/solution.py) |
  | 158 | [Read N Characters Given read4 II - Call Multiple Times](/problems/read-n-characters-given-read4-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/read_n_characters_given_read4_ii/solution.py) |
  | 174 | [Dungeon Game](/problems/dungeon-game) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/dungeon_game/solution.py) |
  | 188 | [Best Time to Buy and Sell Stock IV](/problems/best-time-to-buy-and-sell-stock-iv) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/best_time_to_buy_and_sell_stock_iv/solution.py) |
  | 212 | [Word Search II](/problems/word-search-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/word_search_ii/solution.py) |
  | 214 | [Shortest Palindrome](/problems/shortest-palindrome) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shortest_palindrome/solution.py) |
  | 218 | [The Skyline Problem](/problems/the-skyline-problem) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/the_skyline_problem/solution.py) |
  | 220 | [Contains Duplicate III](/problems/contains-duplicate-iii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/contains_duplicate_iii/solution.py) |
  | 224 | [Basic Calculator](/problems/basic-calculator) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/basic_calculator/solution.py) |
  | 233 | [Number of Digit One](/problems/number-of-digit-one) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_digit_one/solution.py) |
  | 239 | [Sliding Window Maximum](/problems/sliding-window-maximum) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sliding_window_maximum/solution.py) |
  | 248 | [Strobogrammatic Number III](/problems/strobogrammatic-number-iii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/strobogrammatic_number_iii/solution.py) |
  | 265 | [Paint House II](/problems/paint-house-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/paint_house_ii/solution.py) |
  | 269 | [Alien Dictionary](/problems/alien-dictionary) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/alien_dictionary/solution.py) |
  | 272 | [Closest Binary Search Tree Value II](/problems/closest-bst-value-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/closest_bst_value_ii/solution.py) |
  | 273 | [Integer to English Words](/problems/integer-to-english-words) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/integer_to_english_words/solution.py) |
  | 282 | [Expression Add Operators](/problems/expression-add-operators) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/expression_add_operators/solution.py) |
  | 295 | [Find Median from Data Stream](/problems/find-median-from-data-stream) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_median_from_data_stream/solution.py) |
  | 296 | [Best Meeting Point](/problems/best-meeting-point) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/best_meeting_point/solution.py) |
  | 297 | [Serialize and Deserialize Binary Tree](/problems/serialize-and-deserialize-binary-tree) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/serialize_and_deserialize_binary_tree/solution.py) |
  | 301 | [Remove Invalid Parentheses](/problems/remove-invalid-parentheses) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_invalid_parentheses/solution.py) |
  | 302 | [Smallest Rectangle Enclosing Black Pixels](/problems/smallest-rectangle-enclosing-black-pixels) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/smallest_rectangle_enclosing_black_pixels/solution.py) |
  | 305 | [Number of Islands II](/problems/number-of-islands-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_islands_ii/solution.py) |
  | 312 | [Burst Balloons](/problems/burst-balloons) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/burst_balloons/solution.py) |
  | 315 | [Count of Smaller Numbers After Self](/problems/count-smaller-numbers-after-self) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_smaller_numbers_after_self/solution.py) |
  | 317 | [Shortest Distance from All Buildings](/problems/shortest-distance-from-all-buildings) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shortest_distance_from_all_buildings/solution.py) |
  | 321 | [Create Maximum Number](/problems/create-maximum-number) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/create_maximum_number/solution.py) |
  | 327 | [Count of Range Sum](/problems/count-of-range-sum) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_of_range_sum/solution.py) |
  | 329 | [Longest Increasing Path in a Matrix](/problems/longest-increasing-path-in-a-matrix) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_increasing_path_in_a_matrix/solution.py) |
  | 330 | [Patching Array](/problems/patching-array) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/patching_array/solution.py) |
  | 332 | [Reconstruct Itinerary](/problems/reconstruct-itinerary) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reconstruct_itinerary/solution.py) |
  | 335 | [Self Crossing](/problems/self-crossing) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/self_crossing/solution.py) |
  | 336 | [Palindrome Pairs](/problems/palindrome-pairs) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/palindrome_pairs/solution.py) |
  | 352 | [Data Stream as Disjoint Intervals](/problems/data-stream-as-disjoint-intervals) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/data_stream_as_disjoint_intervals/solution.py) |
  | 354 | [Russian Doll Envelopes](/problems/russian-doll-envelopes) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/russian_doll_envelopes/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) |
  | 363 | [Max Sum of Rectangle No Larger Than K](/problems/max-sum-of-rectangle-no-larger-than-k) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/max_sum_of_rectangle_no_larger_than_k/solution.py) |
  | 381 | [Insert Delete GetRandom O(1) - Duplicates allowed](/problems/insert-delete-getrandom-o1-duplicates-allowed) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/insert_delete_getrandom_o1_duplicates_allowed/solution.py) |
  | 391 | [Perfect Rectangle](/problems/perfect-rectangle) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/perfect_rectangle/solution.py) |
  | 403 | [Frog Jump](/problems/frog-jump) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/frog_jump/solution.py) |
  | 407 | [Trapping Rain Water II](/problems/trapping-rain-water-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/trapping_rain_water_ii/solution.py) |
  | 410 | [Split Array Largest Sum](/problems/split-array-largest-sum) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/split_array_largest_sum/solution.py) |
  | 411 | [Minimum Unique Word Abbreviation](/problems/minimum-unique-word-abbreviation) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_unique_word_abbreviation/solution.py) |
  | 420 | [Strong Password Checker](/problems/strong-password-checker) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/strong_password_checker/solution.py) |
  | 425 | [Word Squares](/problems/word-squares) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/word_squares/solution.py) |
  | 428 | [Serialize and Deserialize N-ary Tree](/problems/serialize-and-deserialize-n-ary-tree) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/serialize_and_deserialize_n_ary_tree/solution.py) |
  | 431 | [Encode N-ary Tree to Binary Tree](/problems/encode-n-ary-tree-to-binary-tree) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/encode_n_ary_tree_to_binary_tree/solution.py) |
  | 432 | [All O\`one Data Structure](/problems/all-oone-data-structure) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/all_oone_data_structure/solution.py) |
  | 440 | [K-th Smallest in Lexicographical Order](/problems/k-th-smallest-in-lexicographical-order) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/k_th_smallest_in_lexicographical_order/solution.py) |
  | 446 | [Arithmetic Slices II - Subsequence](/problems/arithmetic-slices-ii-subsequence) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/arithmetic_slices_ii_subsequence/solution.py) |
  | 458 | [Poor Pigs](/problems/poor-pigs) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/poor_pigs/solution.py) |
  | 460 | [LFU Cache](/problems/lfu-cache) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/lfu_cache/solution.py) |
  | 465 | [Optimal Account Balancing](/problems/optimal-account-balancing) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/optimal_account_balancing/solution.py) |
  | 466 | [Count The Repetitions](/problems/count-the-repetitions) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_the_repetitions/solution.py) |
  | 471 | [Encode String with Shortest Length](/problems/encode-string-with-shortest-length) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/encode_string_with_shortest_length/solution.py) |
  | 472 | [Concatenated Words](/problems/concatenated-words) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/concatenated_words/solution.py) |
  | 479 | [Largest Palindrome Product](/problems/largest-palindrome-product) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/largest_palindrome_product/solution.py) |
  | 480 | [Sliding Window Median](/problems/sliding-window-median) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sliding_window_median/solution.py) |
  | 483 | [Smallest Good Base](/problems/smallest-good-base) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/smallest_good_base/solution.py) |
  | 488 | [Zuma Game](/problems/zuma-game) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/zuma_game/solution.py) |
  | 489 | [Robot Room Cleaner](/problems/robot-room-cleaner) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/robot_room_cleaner/solution.py) |
  | 493 | [Reverse Pairs](/problems/reverse-pairs) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reverse_pairs/solution.py) |
  | 499 | [The Maze III](/problems/the-maze-iii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/the_maze_iii/solution.py) |
  | 502 | [IPO](/problems/ipo) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/ipo/solution.py) |
  | 514 | [Freedom Trail](/problems/freedom-trail) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/freedom_trail/solution.py) |
  | 517 | [Super Washing Machines](/problems/super-washing-machines) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/super_washing_machines/solution.py) |
  | 527 | [Word Abbreviation](/problems/word-abbreviation) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/word_abbreviation/solution.py) |
  | 546 | [Remove Boxes](/problems/remove-boxes) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_boxes/solution.py) |
  | 548 | [Split Array with Equal Sum](/problems/split-array-with-equal-sum) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/split_array_with_equal_sum/solution.py) |
  | 552 | [Student Attendance Record II](/problems/student-attendance-record-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/student_attendance_record_ii/solution.py) |
  | 564 | [Find the Closest Palindrome](/problems/find-the-closest-palindrome) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_the_closest_palindrome/solution.py) |
  | 568 | [Maximum Vacation Days](/problems/maximum-vacation-days) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_vacation_days/solution.py) |
  | 587 | [Erect the Fence](/problems/erect-the-fence) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/erect_the_fence/solution.py) |
  | 588 | [Design In-Memory File System](/problems/design-in-memory-file-system) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_in_memory_file_system/solution.py) |
  | 591 | [Tag Validator](/problems/tag-validator) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/tag_validator/solution.py) |
  | 600 | [Non-negative Integers without Consecutive Ones](/problems/non-negative-integers-without-consecutive-ones) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/non_negative_integers_without_consecutive_ones/solution.py) |
  | 629 | [K Inverse Pairs Array](/problems/k-inverse-pairs-array) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/k_inverse_pairs_array/solution.py) |
  | 630 | [Course Schedule III](/problems/course-schedule-iii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/course_schedule_iii/solution.py) |
  | 631 | [Design Excel Sum Formula](/problems/design-excel-sum-formula) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_excel_sum_formula/solution.py) |
  | 632 | [Smallest Range Covering Elements from K Lists](/problems/smallest-range-covering-elements-from-k-lists) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/smallest_range_covering_elements_from_k_lists/solution.py) |
  | 639 | [Decode Ways II](/problems/decode-ways-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/decode_ways_ii/solution.py) |
  | 642 | [Design Search Autocomplete System](/problems/design-search-autocomplete-system) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_search_autocomplete_system/solution.py) |
  | 644 | [Maximum Average Subarray II](/problems/maximum-average-subarray-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_average_subarray_ii/solution.py) |
  | 656 | [Coin Path](/problems/coin-path) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/coin_path/solution.py) |
  | 660 | [Remove 9](/problems/remove-9) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_9/solution.py) |
  | 664 | [Strange Printer](/problems/strange-printer) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/strange_printer/solution.py) |
  | 668 | [Kth Smallest Number in Multiplication Table](/problems/kth-smallest-number-in-multiplication-table) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/kth_smallest_number_in_multiplication_table/solution.py) |
  | 675 | [Cut Off Trees for Golf Event](/problems/cut-off-trees-for-golf-event) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/cut_off_trees_for_golf_event/solution.py) |
  | 679 | [24 Game](/problems/game-24) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/game_24/solution.py) |
  | 683 | [K Empty Slots](/problems/k-empty-slots) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/k_empty_slots/solution.py) |
  | 685 | [Redundant Connection II](/problems/redundant-connection-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/redundant_connection_ii/solution.py) |
  | 689 | [Maximum Sum of 3 Non-Overlapping Subarrays](/problems/maximum-sum-of-3-non-overlapping-subarrays) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_sum_of_3_non_overlapping_subarrays/solution.py) |
  | 691 | [Stickers to Spell Word](/problems/stickers-to-spell-word) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/stickers_to_spell_word/solution.py) |
  | 699 | [Falling Squares](/problems/falling-squares) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/falling_squares/solution.py) |
  | 710 | [Random Pick with Blacklist](/problems/random-pick-with-blacklist) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/random_pick_with_blacklist/solution.py) |
  | 711 | [Number of Distinct Islands II](/problems/number-of-distinct-islands-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_distinct_islands_ii/solution.py) |
  | 715 | [Range Module](/problems/range-module) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/range_module/solution.py) |
  | 716 | [Max Stack](/problems/max-stack) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/max_stack/solution.py) |
  | 719 | [Find K-th Smallest Pair Distance](/problems/find-k-th-smallest-pair-distance) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_k_th_smallest_pair_distance/solution.py) |
  | 726 | [Number of Atoms](/problems/number-of-atoms) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_atoms/solution.py) |
  | 727 | [Minimum Window Subsequence](/problems/minimum-window-subsequence) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_window_subsequence/solution.py) |
  | 730 | [Count Different Palindromic Subsequences](/problems/count-palindromic-subsequences) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_palindromic_subsequences/solution.py) |
  | 732 | [My Calendar III](/problems/my-calendar-iii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/my_calendar_iii/solution.py) |
  | 736 | [Parse Lisp Expression](/problems/parse-lisp-expression) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/parse_lisp_expression/solution.py) |
  | 741 | [Cherry Pickup](/problems/cherry-pickup) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/cherry_pickup/solution.py) |
  | 745 | [Prefix and Suffix Search](/problems/prefix-and-suffix-search) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/prefix_and_suffix_search/solution.py) |
  | 749 | [Contain Virus](/problems/contain-virus) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/contain_virus/solution.py) |
  | 753 | [Cracking the Safe](/problems/cracking-the-safe) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/cracking_the_safe/solution.py) |
  | 757 | [Set Intersection Size At Least Two](/problems/set-intersection-size-at-least-two) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/set_intersection_size_at_least_two/solution.py) |
  | 759 | [Employee Free Time](/problems/employee-free-time) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/employee_free_time/solution.py) |
  | 761 | [Special Binary String](/problems/special-binary-string) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/special_binary_string/solution.py) |
  | 765 | [Couples Holding Hands](/problems/couples-holding-hands) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/couples_holding_hands/solution.py) |
  | 768 | [Max Chunks To Make Sorted II](/problems/max-chunks-to-make-sorted-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/max_chunks_to_make_sorted_ii/solution.py) |
  | 770 | [Basic Calculator IV](/problems/basic-calculator-iv) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/basic_calculator_iv/solution.py) |
  | 772 | [Basic Calculator III](/problems/basic-calculator-iii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/basic_calculator_iii/solution.py) |
  | 773 | [Sliding Puzzle](/problems/sliding-puzzle) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sliding_puzzle/solution.py) |
  | 774 | [Minimize Max Distance to Gas Station](/problems/minimize-max-distance-to-gas-station) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimize_max_distance_to_gas_station/solution.py) |
  | 778 | [Swim in Rising Water](/problems/swim-in-rising-water) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/swim_in_rising_water/solution.py) |
  | 780 | [Reaching Points](/problems/reaching-points) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reaching_points/solution.py) |
  | 782 | [Transform to Chessboard](/problems/transform-to-chessboard) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/transform_to_chessboard/solution.py) |
  | 793 | [Preimage Size of Factorial Zeroes Function](/problems/preimage-size-of-factorial-zeroes-function) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/preimage_size_of_factorial_zeroes_function/solution.py) |
  | 798 | [Smallest Rotation with Highest Score](/problems/smallest-rotation-with-highest-score) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/smallest_rotation_with_highest_score/solution.py) |
  | 801 | [Minimum Swaps To Make Sequences Increasing](/problems/minimum-swaps-to-make-sequences-increasing) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_swaps_to_make_sequences_increasing/solution.py) |
  | 803 | [Bricks Falling When Hit](/problems/bricks-falling-when-hit) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/bricks_falling_when_hit/solution.py) |
  | 805 | [Split Array With Same Average](/problems/split-array-with-same-average) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/split_array_with_same_average/solution.py) |
  | 810 | [Chalkboard XOR Game](/problems/chalkboard-xor-game) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/chalkboard_xor_game/solution.py) |
  | 815 | [Bus Routes](/problems/bus-routes) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/bus_routes/solution.py) |
  | 818 | [Race Car](/problems/race-car) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/race_car/solution.py) |
  | 827 | [Making A Large Island](/problems/making-a-large-island) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/making_a_large_island/solution.py) |
  | 828 | [Count Unique Characters of All Substrings of a Given String](/problems/count-unique-characters-of-all-substrings-of-a-given-string) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_unique_characters_of_all_substrings_of_a_given_string/solution.py) |
  | 829 | [Consecutive Numbers Sum](/problems/consecutive-numbers-sum) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/consecutive_numbers_sum/solution.py) |
  | 834 | [Sum of Distances in Tree](/problems/sum-of-distances-in-tree) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sum_of_distances_in_tree/solution.py) |
  | 839 | [Similar String Groups](/problems/similar-string-groups) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/similar_string_groups/solution.py) |
  | 843 | [Guess the Word](/problems/guess-the-word) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/guess_the_word/solution.py) |
  | 847 | [Shortest Path Visiting All Nodes](/problems/shortest-path-visiting-all-nodes) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shortest_path_visiting_all_nodes/solution.py) |
  | 850 | [Rectangle Area II](/problems/rectangle-area-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/rectangle_area_ii/solution.py) |
  | 854 | [K-Similar Strings](/problems/k-similarity) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/k_similarity/solution.py) |
  | 857 | [Minimum Cost to Hire K Workers](/problems/minimum-cost-to-hire-k-workers) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_cost_to_hire_k_workers/solution.py) |
  | 862 | [Shortest Subarray with Sum at Least K](/problems/shortest-subarray-with-sum-at-least-k) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shortest_subarray_with_sum_at_least_k/solution.py) |
  | 864 | [Shortest Path to Get All Keys](/problems/shortest-path-to-get-all-keys) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shortest_path_to_get_all_keys/solution.py) |
  | 871 | [Minimum Number of Refueling Stops](/problems/minimum-number-of-refueling-stops) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_number_of_refueling_stops/solution.py) |
  | 878 | [Nth Magical Number](/problems/nth-magical-number) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/nth_magical_number/solution.py) |
  | 879 | [Profitable Schemes](/problems/profitable-schemes) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/profitable_schemes/solution.py) |
  | 882 | [Reachable Nodes In Subdivided Graph](/problems/reachable-nodes-in-subdivided-graph) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reachable_nodes_in_subdivided_graph/solution.py) |
  | 887 | [Super Egg Drop](/problems/super-egg-drop) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/super_egg_drop/solution.py) |
  | 891 | [Sum of Subsequence Widths](/problems/sum-of-subseq-widths) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sum_of_subseq_widths/solution.py) |
  | 895 | [Maximum Frequency Stack](/problems/maximum-frequency-stack) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_frequency_stack/solution.py) |
  | 899 | [Orderly Queue](/problems/orderly-queue) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/orderly_queue/solution.py) |
  | 902 | [Numbers At Most N Given Digit Set](/problems/numbers-at-most-n-given-digit-set) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/numbers_at_most_n_given_digit_set/solution.py) |
  | 903 | [Valid Permutations for DI Sequence](/problems/valid-permutations-for-di-sequence) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/valid_permutations_for_di_sequence/solution.py) |
  | 906 | [Super Palindromes](/problems/super-palindromes) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/super_palindromes/solution.py) |
  | 913 | [Cat and Mouse](/problems/cat-and-mouse) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/cat_and_mouse/solution.py) |
  | 920 | [Number of Music Playlists](/problems/number-of-music-playlists) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_music_playlists/solution.py) |
  | 924 | [Minimize Malware Spread](/problems/minimize-malware-spread) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimize_malware_spread/solution.py) |
  | 927 | [Three Equal Parts](/problems/three-equal-parts) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/three_equal_parts/solution.py) |
  | 928 | [Minimize Malware Spread II](/problems/minimize-malware-spread-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimize_malware_spread_ii/solution.py) |
  | 936 | [Stamping The Sequence](/problems/stamping-the-sequence) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/stamping_the_sequence/solution.py) |
  | 940 | [Distinct Subsequences II](/problems/distinct-subsequences-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/distinct_subsequences_ii/solution.py) |
  | 943 | [Find the Shortest Superstring](/problems/find-the-shortest-superstring) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_the_shortest_superstring/solution.py) |
  | 952 | [Largest Component Size by Common Factor](/problems/largest-component-size-by-common-factor) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/largest_component_size_by_common_factor/solution.py) |
  | 956 | [Tallest Billboard](/problems/tallest-billboard) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/tallest_billboard/solution.py) |
  | 960 | [Delete Columns to Make Sorted III](/problems/delete-columns-to-make-sorted-iii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/delete_columns_to_make_sorted_iii/solution.py) |
  | 964 | [Least Operators to Express Number](/problems/least-operators-to-express-number) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/least_operators_to_express_number/solution.py) |
  | 968 | [Binary Tree Cameras](/problems/binary-tree-cameras) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_cameras/solution.py) |
  | 972 | [Equal Rational Numbers](/problems/equal-rational-numbers) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/equal_rational_numbers/solution.py) |
  | 975 | [Odd Even Jump](/problems/odd-even-jumps) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/odd_even_jumps/solution.py) |
  | 980 | [Unique Paths III](/problems/unique-paths-iii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/unique_paths_iii/solution.py) |
  | 982 | [Triples with Bitwise AND Equal To Zero](/problems/triples-with-bitwise-and-equal-to-zero) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/triples_with_bitwise_and_equal_to_zero/solution.py) |
  | 987 | [Vertical Order Traversal of a Binary Tree](/problems/vertical-order-traversal-of-a-binary-tree) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/vertical_order_traversal_of_a_binary_tree/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) |
  | 995 | [Minimum Number of K Consecutive Bit Flips](/problems/minimum-number-of-k-consecutive-bit-flips) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_number_of_k_consecutive_bit_flips/solution.py) |
</div>

Pages: 1, [2](/catalog/hard-2)


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