> ## 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, Part 2

> All 819 Medium LeetCode problems with tested Python solutions. Part 2 of 5: problems 201-400.

Medium holds 819 problems.

<div className="sd-catalog-table">
  | # | Problem | Difficulty | Solution |
  | - | - | - | - |
  | 362 | [Design Hit Counter](/problems/design-hit-counter) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_hit_counter/solution.py) |
  | 364 | [Nested List Weight Sum II](/problems/nested-list-weight-sum-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/nested_list_weight_sum_ii/solution.py) |
  | 365 | [Water and Jug Problem](/problems/water-and-jug-problem) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/water_and_jug_problem/solution.py) |
  | 366 | [Find Leaves of Binary Tree](/problems/find-leaves-of-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_leaves_of_binary_tree/solution.py) |
  | 368 | [Largest Divisible Subset](/problems/largest-divisible-subset) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/largest_divisible_subset/solution.py) |
  | 369 | [Plus One Linked List](/problems/plus-one-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/plus_one_linked_list/solution.py) |
  | 370 | [Range Addition](/problems/range-addition) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/range_addition/solution.py) |
  | 371 | [Sum of Two Integers](/problems/sum-of-two-integers) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sum_of_two_integers/solution.py) |
  | 372 | [Super Pow](/problems/super-pow) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/super_pow/solution.py) |
  | 373 | [Find K Pairs with Smallest Sums](/problems/find-k-pairs-with-smallest-sums) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_k_pairs_with_smallest_sums/solution.py) |
  | 375 | [Guess Number Higher or Lower II](/problems/guess-number-higher-or-lower-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/guess_number_higher_or_lower_ii/solution.py) |
  | 376 | [Wiggle Subsequence](/problems/wiggle-subsequence) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/wiggle_subsequence/solution.py) |
  | 377 | [Combination Sum IV](/problems/combination-sum-iv) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/combination_sum_iv/solution.py) |
  | 378 | [Kth Smallest Element in a Sorted Matrix](/problems/kth-smallest-element-in-a-sorted-matrix) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/kth_smallest_element_in_a_sorted_matrix/solution.py) |
  | 379 | [Design Phone Directory](/problems/design-phone-directory) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_phone_directory/solution.py) |
  | 380 | [Insert Delete GetRandom O(1)](/problems/insert-delete-getrandom-o1) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/insert_delete_getrandom_o1/solution.py) |
  | 382 | [Linked List Random Node](/problems/linked-list-random-node) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/linked_list_random_node/solution.py) |
  | 384 | [Shuffle an Array](/problems/shuffle-an-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shuffle_an_array/solution.py) |
  | 385 | [Mini Parser](/problems/mini-parser) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/mini_parser/solution.py) |
  | 386 | [Lexicographical Numbers](/problems/lexicographical-numbers) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/lexicographical_numbers/solution.py) |
  | 388 | [Longest Absolute File Path](/problems/longest-absolute-file-path) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_absolute_file_path/solution.py) |
  | 390 | [Elimination Game](/problems/elimination-game) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/elimination_game/solution.py) |
  | 393 | [UTF-8 Validation](/problems/utf-8-validation) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/utf_8_validation/solution.py) |
  | 394 | [Decode String](/problems/decode-string) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/decode_string/solution.py) |
  | 395 | [Longest Substring with At Least K Repeating Characters](/problems/longest-substring-with-at-least-k-repeating-characters) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_substring_with_at_least_k_repeating_characters/solution.py) |
  | 396 | [Rotate Function](/problems/rotate-function) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/rotate_function/solution.py) |
  | 397 | [Integer Replacement](/problems/integer-replacement) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/integer_replacement/solution.py) |
  | 398 | [Random Pick Index](/problems/random-pick-index) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/random_pick_index/solution.py) |
  | 399 | [Evaluate Division](/problems/evaluate-division) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/evaluate_division/solution.py) |
  | 400 | [Nth Digit](/problems/nth-digit) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/nth_digit/solution.py) |
  | 402 | [Remove K Digits](/problems/remove-k-digits) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_k_digits/solution.py) |
  | 406 | [Queue Reconstruction by Height](/problems/queue-reconstruction-by-height) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/queue_reconstruction_by_height/solution.py) |
  | 413 | [Arithmetic Slices](/problems/arithmetic-slices) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/arithmetic_slices/solution.py) |
  | 416 | [Partition Equal Subset Sum](/problems/partition-equal-subset-sum) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/partition_equal_subset_sum/solution.py) |
  | 417 | [Pacific Atlantic Water Flow](/problems/pacific-atlantic-water-flow) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/pacific_atlantic_water_flow/solution.py) |
  | 418 | [Sentence Screen Fitting](/problems/sentence-screen-fitting) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sentence_screen_fitting/solution.py) |
  | 419 | [Battleships in a Board](/problems/battleships-in-a-board) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/battleships_in_a_board/solution.py) |
  | 421 | [Maximum XOR of Two Numbers in an Array](/problems/maximum-xor-of-two-numbers-in-an-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_xor_of_two_numbers_in_an_array/solution.py) |
  | 423 | [Reconstruct Original Digits from English](/problems/reconstruct-original-digits-from-english) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reconstruct_original_digits_from_english/solution.py) |
  | 424 | [Longest Repeating Character Replacement](/problems/longest-repeating-character-replacement) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_repeating_character_replacement/solution.py) |
  | 426 | [Convert Binary Search Tree to Sorted Doubly Linked List](/problems/convert-binary-search-tree-to-sorted-doubly-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/convert_binary_search_tree_to_sorted_doubly_linked_list/solution.py) |
  | 427 | [Construct Quad Tree](/problems/construct-quad-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/construct_quad_tree/solution.py) |
  | 429 | [N-ary Tree Level Order Traversal](/problems/n-ary-tree-level-order-traversal) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/n_ary_tree_level_order_traversal/solution.py) |
  | 430 | [Flatten a Multilevel Doubly Linked List](/problems/flatten-a-multilevel-doubly-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flatten_a_multilevel_doubly_linked_list/solution.py) |
  | 433 | [Minimum Genetic Mutation](/problems/minimum-genetic-mutation) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_genetic_mutation/solution.py) |
  | 435 | [Non-overlapping Intervals](/problems/non-overlapping-intervals) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/non_overlapping_intervals/solution.py) |
  | 436 | [Find Right Interval](/problems/find-right-interval) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_right_interval/solution.py) |
  | 437 | [Path Sum III](/problems/path-sum-iii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/path_sum_iii/solution.py) |
  | 438 | [Find All Anagrams in a String](/problems/find-all-anagrams-in-a-string) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_all_anagrams_in_a_string/solution.py) |
  | 439 | [Ternary Expression Parser](/problems/ternary-expression-parser) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/ternary_expression_parser/solution.py) |
  | 442 | [Find All Duplicates in an Array](/problems/find-all-duplicates-in-an-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_all_duplicates_in_an_array/solution.py) |
  | 443 | [String Compression](/problems/string-compression) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/string_compression/solution.py) |
  | 444 | [Sequence Reconstruction](/problems/sequence-reconstruction) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sequence_reconstruction/solution.py) |
  | 445 | [Add Two Numbers II](/problems/add-two-numbers-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/add_two_numbers_ii/solution.py) |
  | 447 | [Number of Boomerangs](/problems/number-of-boomerangs) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_boomerangs/solution.py) |
  | 449 | [Serialize and Deserialize BST](/problems/serialize-and-deserialize-bst) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/serialize_and_deserialize_bst/solution.py) |
  | 450 | [Delete Node in a BST](/problems/delete-node-in-a-bst) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/delete_node_in_a_bst/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) |
  | 452 | [Minimum Number of Arrows to Burst Balloons](/problems/minimum-number-of-arrows-to-burst-balloons) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_number_of_arrows_to_burst_balloons/solution.py) |
  | 453 | [Minimum Moves to Equal Array Elements](/problems/minimum-moves-to-equal-array-elements) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_moves_to_equal_array_elements/solution.py) |
  | 454 | [4Sum II](/problems/four-sum-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/four_sum_ii/solution.py) |
  | 456 | [132 Pattern](/problems/pattern-132) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/pattern_132/solution.py) |
  | 457 | [Circular Array Loop](/problems/circular-array-loop) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/circular_array_loop/solution.py) |
  | 462 | [Minimum Moves to Equal Array Elements II](/problems/minimum-moves-to-equal-array-elements-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_moves_to_equal_array_elements_ii/solution.py) |
  | 464 | [Can I Win](/problems/can-i-win) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/can_i_win/solution.py) |
  | 467 | [Unique Substrings in Wraparound String](/problems/unique-substrings-in-wraparound-string) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/unique_substrings_in_wraparound_string/solution.py) |
  | 468 | [Validate IP Address](/problems/validate-ip-address) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/validate_ip_address/solution.py) |
  | 469 | [Convex Polygon](/problems/convex-polygon) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/convex_polygon/solution.py) |
  | 470 | [Implement Rand10() Using Rand7()](/problems/implement-rand10-using-rand7) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/implement_rand10_using_rand7/solution.py) |
  | 473 | [Matchsticks to Square](/problems/matchsticks-to-square) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/matchsticks_to_square/solution.py) |
  | 474 | [Ones and Zeroes](/problems/ones-and-zeroes) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/ones_and_zeroes/solution.py) |
  | 475 | [Heaters](/problems/heaters) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/heaters/solution.py) |
  | 477 | [Total Hamming Distance](/problems/total-hamming-distance) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/total_hamming_distance/solution.py) |
  | 478 | [Generate Random Point in a Circle](/problems/generate-random-point-in-a-circle) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/generate_random_point_in_a_circle/solution.py) |
  | 481 | [Magical String](/problems/magical-string) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/magical_string/solution.py) |
  | 484 | [Find Permutation](/problems/find-permutation) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_permutation/solution.py) |
  | 486 | [Predict the Winner](/problems/predict-the-winner) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/predict_the_winner/solution.py) |
  | 487 | [Max Consecutive Ones II](/problems/max-consecutive-ones-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/max_consecutive_ones_ii/solution.py) |
  | 490 | [The Maze](/problems/the-maze) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/the_maze/solution.py) |
  | 491 | [Non-decreasing Subsequences](/problems/non-decreasing-subsequences) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/non_decreasing_subsequences/solution.py) |
  | 494 | [Target Sum](/problems/target-sum) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/target_sum/solution.py) |
  | 497 | [Random Point in Non-overlapping Rectangles](/problems/random-point-in-non-overlapping-rectangles) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/random_point_in_non_overlapping_rectangles/solution.py) |
  | 498 | [Diagonal Traverse](/problems/diagonal-traverse) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/diagonal_traverse/solution.py) |
  | 503 | [Next Greater Element II](/problems/next-greater-element-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/next_greater_element_ii/solution.py) |
  | 505 | [The Maze II](/problems/the-maze-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/the_maze_ii/solution.py) |
  | 508 | [Most Frequent Subtree Sum](/problems/most-frequent-subtree-sum) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/most_frequent_subtree_sum/solution.py) |
  | 510 | [Inorder Successor in BST II](/problems/inorder-successor-in-bst-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/inorder_successor_in_bst_ii/solution.py) |
  | 513 | [Find Bottom Left Tree Value](/problems/find-bottom-left-tree-value) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_bottom_left_tree_value/solution.py) |
  | 515 | [Find Largest Value in Each Tree Row](/problems/find-largest-value-in-each-tree-row) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_largest_value_in_each_tree_row/solution.py) |
  | 516 | [Longest Palindromic Subsequence](/problems/longest-palindromic-subsequence) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_palindromic_subsequence/solution.py) |
  | 518 | [Coin Change II](/problems/coin-change-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/coin_change_ii/solution.py) |
  | 519 | [Random Flip Matrix](/problems/random-flip-matrix) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/random_flip_matrix/solution.py) |
  | 522 | [Longest Uncommon Subsequence II](/problems/longest-uncommon-subsequence-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_uncommon_subsequence_ii/solution.py) |
  | 523 | [Continuous Subarray Sum](/problems/continuous-subarray-sum) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/continuous_subarray_sum/solution.py) |
  | 524 | [Longest Word in Dictionary through Deleting](/problems/longest-word-in-dictionary-through-deleting) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_word_in_dictionary_through_deleting/solution.py) |
  | 525 | [Contiguous Array](/problems/contiguous-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/contiguous_array/solution.py) |
  | 526 | [Beautiful Arrangement](/problems/beautiful-arrangement) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/beautiful_arrangement/solution.py) |
  | 528 | [Random Pick with Weight](/problems/random-pick-with-weight) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/random_pick_with_weight/solution.py) |
  | 529 | [Minesweeper](/problems/minesweeper) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minesweeper/solution.py) |
  | 531 | [Lonely Pixel I](/problems/lonely-pixel-i) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/lonely_pixel_i/solution.py) |
  | 532 | [K-diff Pairs in an Array](/problems/k-diff-pairs-in-an-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/k_diff_pairs_in_an_array/solution.py) |
  | 533 | [Lonely Pixel II](/problems/lonely-pixel-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/lonely_pixel_ii/solution.py) |
  | 535 | [Encode and Decode TinyURL](/problems/encode-and-decode-tinyurl) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/encode_and_decode_tinyurl/solution.py) |
  | 536 | [Construct Binary Tree from String](/problems/construct-binary-tree-from-string) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/construct_binary_tree_from_string/solution.py) |
  | 537 | [Complex Number Multiplication](/problems/complex-number-multiply) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/complex_number_multiply/solution.py) |
  | 538 | [Convert BST to Greater Tree](/problems/convert-bst-to-greater-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/convert_bst_to_greater_tree/solution.py) |
  | 539 | [Minimum Time Difference](/problems/minimum-time-difference) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_time_difference/solution.py) |
  | 540 | [Single Element in a Sorted Array](/problems/single-element-in-a-sorted-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/single_element_in_a_sorted_array/solution.py) |
  | 542 | [01 Matrix](/problems/zero-one-matrix) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/zero_one_matrix/solution.py) |
  | 544 | [Output Contest Matches](/problems/output-contest-matches) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/output_contest_matches/solution.py) |
  | 545 | [Boundary of Binary Tree](/problems/boundary-of-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/boundary_of_binary_tree/solution.py) |
  | 547 | [Number of Provinces](/problems/number-of-provinces) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_provinces/solution.py) |
  | 549 | [Binary Tree Longest Consecutive Sequence II](/problems/binary-tree-longest-consecutive-sequence-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_longest_consecutive_sequence_ii/solution.py) |
  | 553 | [Optimal Division](/problems/optimal-division) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/optimal_division/solution.py) |
  | 554 | [Brick Wall](/problems/brick-wall) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/brick_wall/solution.py) |
  | 555 | [Split Concatenated Strings](/problems/split-concatenated-strings) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/split_concatenated_strings/solution.py) |
  | 556 | [Next Greater Element III](/problems/next-greater-element-iii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/next_greater_element_iii/solution.py) |
  | 558 | [Logical OR of Two Binary Grids Represented as Quad-Trees](/problems/logical-or-of-two-binary-grids-represented-as-quad-trees) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/logical_or_of_two_binary_grids_represented_as_quad_trees/solution.py) |
  | 560 | [Subarray Sum Equals K](/problems/subarray-sum-equals-k) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/subarray_sum_equals_k/solution.py) |
  | 562 | [Longest Line of Consecutive One in Matrix](/problems/longest-line-of-consecutive-one-in-matrix) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_line_of_consecutive_one_in_matrix/solution.py) |
  | 565 | [Array Nesting](/problems/array-nesting) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/array_nesting/solution.py) |
  | 567 | [Permutation in String](/problems/permutation-in-string) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/permutation_in_string/solution.py) |
  | 573 | [Squirrel Simulation](/problems/squirrel-simulation) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/squirrel_simulation/solution.py) |
  | 576 | [Out of Boundary Paths](/problems/out-of-boundary-paths) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/out_of_boundary_paths/solution.py) |
  | 581 | [Shortest Unsorted Continuous Subarray](/problems/shortest-unsorted-continuous-subarray) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shortest_unsorted_continuous_subarray/solution.py) |
  | 582 | [Kill Process](/problems/kill-process) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/kill_process/solution.py) |
  | 583 | [Delete Operation for Two Strings](/problems/delete-operation-for-two-strings) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/delete_operation_for_two_strings/solution.py) |
  | 592 | [Fraction Addition and Subtraction](/problems/fraction-addition-and-subtraction) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/fraction_addition_and_subtraction/solution.py) |
  | 593 | [Valid Square](/problems/valid-square) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/valid_square/solution.py) |
  | 606 | [Construct String from Binary Tree](/problems/construct-string-from-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/construct_string_from_binary_tree/solution.py) |
  | 609 | [Find Duplicate File in System](/problems/find-duplicate-file-in-system) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_duplicate_file_in_system/solution.py) |
  | 611 | [Valid Triangle Number](/problems/valid-triangle-number) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/valid_triangle_number/solution.py) |
  | 616 | [Add Bold Tag in String](/problems/add-bold-tag-in-string) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/add_bold_tag_in_string/solution.py) |
  | 621 | [Task Scheduler](/problems/task-scheduler) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/task_scheduler/solution.py) |
  | 622 | [Design Circular Queue](/problems/design-circular-queue) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_circular_queue/solution.py) |
  | 623 | [Add One Row to Tree](/problems/add-one-row-to-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/add_one_row_to_tree/solution.py) |
  | 624 | [Maximum Distance in Arrays](/problems/maximum-distance-in-arrays) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_distance_in_arrays/solution.py) |
  | 625 | [Minimum Factorization](/problems/minimum-factorization) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_factorization/solution.py) |
  | 633 | [Sum of Square Numbers](/problems/sum-of-square-numbers) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sum_of_square_numbers/solution.py) |
  | 634 | [Find the Derangement of An Array](/problems/find-the-derangement-of-an-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_the_derangement_of_an_array/solution.py) |
  | 635 | [Design Log Storage System](/problems/design-log-storage-system) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_log_storage_system/solution.py) |
  | 636 | [Exclusive Time of Functions](/problems/exclusive-time-of-functions) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/exclusive_time_of_functions/solution.py) |
  | 638 | [Shopping Offers](/problems/shopping-offers) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shopping_offers/solution.py) |
  | 640 | [Solve the Equation](/problems/solve-the-equation) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/solve_the_equation/solution.py) |
  | 641 | [Design Circular Deque](/problems/design-circular-deque) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_circular_deque/solution.py) |
  | 646 | [Maximum Length of Pair Chain](/problems/maximum-length-of-pair-chain) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_length_of_pair_chain/solution.py) |
  | 647 | [Palindromic Substrings](/problems/palindromic-substrings) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/palindromic_substrings/solution.py) |
  | 648 | [Replace Words](/problems/replace-words) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/replace_words/solution.py) |
  | 649 | [Dota2 Senate](/problems/dota2-senate) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/dota2_senate/solution.py) |
  | 650 | [2 Keys Keyboard](/problems/two-keys-keyboard) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/two_keys_keyboard/solution.py) |
  | 651 | [4 Keys Keyboard](/problems/four-keys-keyboard) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/four_keys_keyboard/solution.py) |
  | 652 | [Find Duplicate Subtrees](/problems/find-duplicate-subtrees) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_duplicate_subtrees/solution.py) |
  | 654 | [Maximum Binary Tree](/problems/maximum-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_binary_tree/solution.py) |
  | 655 | [Print Binary Tree](/problems/print-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/print_binary_tree/solution.py) |
  | 658 | [Find K Closest Elements](/problems/find-k-closest-elements) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_k_closest_elements/solution.py) |
  | 659 | [Split Array into Consecutive Subsequences](/problems/split-array-into-consecutive-subsequences) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/split_array_into_consecutive_subsequences/solution.py) |
  | 662 | [Maximum Width of Binary Tree](/problems/maximum-width-of-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_width_of_binary_tree/solution.py) |
  | 663 | [Equal Tree Partition](/problems/equal-tree-partition) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/equal_tree_partition/solution.py) |
  | 665 | [Non-decreasing Array](/problems/non-decreasing-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/non_decreasing_array/solution.py) |
  | 666 | [Path Sum IV](/problems/path-sum-iv) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/path_sum_iv/solution.py) |
  | 667 | [Beautiful Arrangement II](/problems/beautiful-arrangement-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/beautiful_arrangement_ii/solution.py) |
  | 669 | [Trim a Binary Search Tree](/problems/trim-a-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/trim_a_binary_search_tree/solution.py) |
  | 670 | [Maximum Swap](/problems/maximum-swap) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_swap/solution.py) |
  | 672 | [Bulb Switcher II](/problems/bulb-switcher-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/bulb_switcher_ii/solution.py) |
  | 673 | [Number of Longest Increasing Subsequence](/problems/number-of-longest-increasing-subsequence) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_longest_increasing_subsequence/solution.py) |
  | 676 | [Implement Magic Dictionary](/problems/implement-magic-dictionary) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/implement_magic_dictionary/solution.py) |
  | 677 | [Map Sum Pairs](/problems/map-sum-pairs) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/map_sum_pairs/solution.py) |
  | 678 | [Valid Parenthesis String](/problems/valid-parenthesis-string) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/valid_parenthesis_string/solution.py) |
  | 681 | [Next Closest Time](/problems/next-closest-time) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/next_closest_time/solution.py) |
  | 684 | [Redundant Connection](/problems/redundant-connection) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/redundant_connection/solution.py) |
  | 686 | [Repeated String Match](/problems/repeated-string-match) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/repeated_string_match/solution.py) |
  | 687 | [Longest Univalue Path](/problems/longest-univalue-path) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_univalue_path/solution.py) |
  | 688 | [Knight Probability in Chessboard](/problems/knight-probability-in-chessboard) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/knight_probability_in_chessboard/solution.py) |
  | 690 | [Employee Importance](/problems/employee-importance) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/employee_importance/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) |
  | 694 | [Number of Distinct Islands](/problems/number-of-distinct-islands) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_distinct_islands/solution.py) |
  | 695 | [Max Area of Island](/problems/max-area-of-island) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/max_area_of_island/solution.py) |
  | 698 | [Partition to K Equal Sum Subsets](/problems/partition-to-k-equal-sum-subsets) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/partition_to_k_equal_sum_subsets/solution.py) |
  | 701 | [Insert into a Binary Search Tree](/problems/insert-into-a-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/insert_into_a_binary_search_tree/solution.py) |
  | 702 | [Search in a Sorted Array of Unknown Size](/problems/search-in-a-sorted-array-of-unknown-size) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/search_in_a_sorted_array_of_unknown_size/solution.py) |
  | 707 | [Design Linked List](/problems/design-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_linked_list/solution.py) |
  | 708 | [Insert into a Sorted Circular Linked List](/problems/insert-into-a-sorted-circular-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/insert_into_a_sorted_circular_linked_list/solution.py) |
  | 712 | [Minimum ASCII Delete Sum for Two Strings](/problems/minimum-ascii-delete-sum-for-two-strings) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_ascii_delete_sum_for_two_strings/solution.py) |
  | 713 | [Subarray Product Less Than K](/problems/subarray-product-less-than-k) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/subarray_product_less_than_k/solution.py) |
  | 714 | [Best Time to Buy and Sell Stock with Transaction Fee](/problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/best_time_to_buy_and_sell_stock_with_transaction_fee/solution.py) |
  | 718 | [Maximum Length of Repeated Subarray](/problems/maximum-length-of-repeated-subarray) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_length_of_repeated_subarray/solution.py) |
  | 720 | [Longest Word in Dictionary](/problems/longest-word-in-dictionary) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_word_in_dictionary/solution.py) |
  | 721 | [Accounts Merge](/problems/accounts-merge) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/accounts_merge/solution.py) |
  | 722 | [Remove Comments](/problems/remove-comments) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_comments/solution.py) |
  | 723 | [Candy Crush](/problems/candy-crush) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/candy_crush/solution.py) |
  | 725 | [Split Linked List in Parts](/problems/split-linked-list-in-parts) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/split_linked_list_in_parts/solution.py) |
  | 729 | [My Calendar I](/problems/my-calendar-i) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/my_calendar_i/solution.py) |
  | 731 | [My Calendar II](/problems/my-calendar-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/my_calendar_ii/solution.py) |
  | 735 | [Asteroid Collision](/problems/asteroid-collision) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/asteroid_collision/solution.py) |
  | 737 | [Sentence Similarity II](/problems/sentence-similarity-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sentence_similarity_ii/solution.py) |
  | 738 | [Monotone Increasing Digits](/problems/monotone-increasing-digits) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/monotone_increasing_digits/solution.py) |
  | 739 | [Daily Temperatures](/problems/daily-temperatures) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/daily_temperatures/solution.py) |
  | 740 | [Delete and Earn](/problems/delete-and-earn) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/delete_and_earn/solution.py) |
  | 742 | [Closest Leaf in a Binary Tree](/problems/closest-leaf-in-a-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/closest_leaf_in_a_binary_tree/solution.py) |
  | 743 | [Network Delay Time](/problems/network-delay-time) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/network_delay_time/solution.py) |
</div>

Pages: [1](/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.