From ce6b5442cd7b9f7bc216be589e4ab481e67642dc Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 16 Feb 2022 15:49:36 +0800 Subject: [PATCH] A:new --- README.md | 541 ++++++------------ problems/01-matrix/README.md | 6 +- .../README.md | 61 ++ .../README.md | 103 ++++ .../README.md | 2 +- problems/account-balance/README.md | 2 +- problems/active-users/README.md | 6 +- .../add-minimum-number-of-rungs/README.md | 13 +- problems/add-two-numbers/README.md | 6 +- problems/adding-spaces-to-a-string/README.md | 82 +++ problems/ads-performance/README.md | 6 +- .../README.md | 16 +- .../README.md | 92 +++ .../README.md | 29 +- problems/all-oone-data-structure/README.md | 8 +- .../all-possible-full-binary-trees/README.md | 2 +- problems/allocate-mailboxes/README.md | 46 +- .../README.md | 40 ++ problems/android-unlock-patterns/README.md | 6 +- problems/apples-oranges/README.md | 6 +- problems/arithmetic-subarrays/README.md | 4 - problems/armstrong-number/README.md | 6 +- .../available-captures-for-rook/README.md | 6 +- .../README.md | 37 +- problems/average-waiting-time/README.md | 3 - problems/avoid-flood-in-the-city/README.md | 18 +- problems/backspace-string-compare/README.md | 10 +- problems/bag-of-tokens/README.md | 8 +- problems/battleships-in-a-board/README.md | 8 +- problems/beautiful-arrangement/README.md | 2 +- .../README.md | 35 +- .../README.md | 7 - .../README.md | 8 +- .../README.md | 20 +- .../README.md | 2 +- .../README.md | 6 +- problems/binary-subarrays-with-sum/README.md | 8 +- .../README.md | 6 +- .../binary-tree-right-side-view/README.md | 6 +- problems/binary-tree-upside-down/README.md | 6 +- .../README.md | 2 +- problems/break-a-palindrome/README.md | 13 - .../brightest-position-on-street/README.md | 2 +- .../README.md | 39 +- .../README.md | 6 +- problems/build-the-equation/README.md | 17 + problems/build-the-equation/mysql_schemas.sql | 5 + problems/burst-balloons/README.md | 8 +- problems/calculate-salaries/README.md | 6 +- problems/campus-bikes/README.md | 6 +- .../README.md | 3 + .../README.md | 5 +- .../README.md | 8 +- problems/capital-gainloss/README.md | 6 +- problems/capitalize-the-title/README.md | 74 +++ problems/car-fleet-ii/README.md | 7 +- problems/car-pooling/README.md | 22 +- problems/cat-and-mouse-ii/README.md | 30 +- .../cheapest-flights-within-k-stops/README.md | 6 +- .../README.md | 25 +- .../README.md | 86 +++ .../README.md | 34 +- .../README.md | 20 +- .../README.md | 66 +++ .../README.md | 3 + .../README.md | 26 - .../README.md | 18 - .../README.md | 18 +- .../README.md | 3 + .../README.md | 60 ++ .../check-if-n-and-its-double-exist/README.md | 9 +- .../README.md | 9 - .../README.md | 10 +- .../README.md | 23 +- .../README.md | 5 +- problems/cherry-pickup-ii/README.md | 49 +- problems/cherry-pickup/README.md | 6 +- .../README.md | 34 ++ problems/cinema-seat-allocation/README.md | 4 +- .../README.md | 41 +- .../README.md | 6 +- problems/clone-n-ary-tree/README.md | 6 +- .../README.md | 2 +- problems/closest-dessert-cost/README.md | 7 - problems/combination-sum-ii/README.md | 6 +- problems/combination-sum/README.md | 20 +- .../complement-of-base-10-integer/README.md | 6 +- .../README.md | 2 +- problems/consecutive-characters/README.md | 31 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- problems/container-with-most-water/README.md | 28 +- problems/contiguous-array/README.md | 6 +- problems/continuous-subarray-sum/README.md | 6 +- .../convert-1d-array-into-2d-array/README.md | 19 +- .../convert-bst-to-greater-tree/README.md | 16 +- .../README.md | 33 +- .../README.md | 4 +- .../README.md | 22 +- .../README.md | 17 - problems/corporate-flight-bookings/README.md | 6 +- problems/count-all-possible-routes/README.md | 22 +- .../README.md | 6 +- problems/count-binary-substrings/README.md | 6 +- .../README.md | 70 +++ .../README.md | 6 +- .../README.md | 62 ++ .../README.md | 99 ++++ problems/count-good-meals/README.md | 5 + .../count-good-nodes-in-binary-tree/README.md | 6 +- problems/count-good-triplets/README.md | 3 - problems/count-largest-group/README.md | 25 +- .../README.md | 14 - .../count-nice-pairs-in-an-array/README.md | 3 + .../README.md | 2 +- .../README.md | 2 + problems/count-number-of-teams/README.md | 8 +- .../README.md | 13 +- .../count-operations-to-obtain-zero/README.md | 69 +++ problems/count-pairs-in-two-arrays/README.md | 2 +- .../count-pairs-with-xor-in-a-range/README.md | 2 +- .../count-servers-that-communicate/README.md | 4 +- .../README.md | 6 +- .../mysql_schemas.sql | 20 +- problems/count-sub-islands/README.md | 7 +- .../README.md | 2 +- .../README.md | 20 +- .../README.md | 7 +- problems/count-the-hidden-sequences/README.md | 96 ++++ .../README.md | 2 +- .../count-the-number-of-experiments/README.md | 2 +- .../README.md | 25 +- .../README.md | 9 +- .../README.md | 86 +++ problems/counting-bits/README.md | 8 +- .../README.md | 3 + problems/create-a-session-bar-chart/README.md | 6 +- .../README.md | 6 +- .../decode-the-slanted-ciphertext/README.md | 8 - problems/decode-ways-ii/README.md | 1 + problems/decode-xored-permutation/README.md | 2 +- .../README.md | 28 +- problems/deepest-leaves-sum/README.md | 6 +- problems/degree-of-an-array/README.md | 6 +- problems/delete-duplicate-emails/README.md | 48 +- .../delete-duplicate-emails/mysql_schemas.sql | 7 +- .../README.md | 23 - .../README.md | 31 +- .../README.md | 6 +- .../README.md | 75 +++ .../README.md | 15 - .../README.md | 2 +- problems/describe-the-painting/README.md | 4 + .../design-a-file-sharing-system/README.md | 7 +- problems/design-bitset/README.md | 78 +++ problems/design-excel-sum-formula/README.md | 6 +- problems/design-file-system/README.md | 6 +- problems/design-hashmap/README.md | 9 +- problems/design-log-storage-system/README.md | 2 +- problems/design-movie-rental-system/README.md | 4 +- problems/design-parking-system/README.md | 2 +- problems/design-skiplist/README.md | 7 +- problems/design-snake-game/README.md | 6 +- problems/design-underground-system/README.md | 5 +- problems/destroying-asteroids/README.md | 78 +++ .../README.md | 27 +- .../README.md | 18 +- .../README.md | 13 - .../README.md | 3 + problems/detonate-the-maximum-bombs/README.md | 93 +++ problems/diagonal-traverse-ii/README.md | 33 +- problems/diameter-of-binary-tree/README.md | 9 +- problems/distant-barcodes/README.md | 4 +- problems/distinct-echo-substrings/README.md | 4 +- .../distribute-coins-in-binary-tree/README.md | 18 +- .../distribute-repeating-integers/README.md | 21 +- .../README.md | 73 +++ .../README.md | 2 +- .../README.md | 7 +- .../README.md | 95 +++ .../README.md | 3 + .../README.md | 33 ++ .../README.md | 2 +- problems/elimination-game/README.md | 6 +- .../README.md | 2 +- problems/encode-and-decode-strings/README.md | 8 +- problems/encode-and-decode-tinyurl/README.md | 2 +- .../README.md | 6 +- problems/equal-rational-numbers/README.md | 6 +- problems/erect-the-fence-ii/README.md | 2 +- problems/escape-a-large-maze/README.md | 4 +- .../README.md | 2 +- .../README.md | 6 - problems/even-odd-tree/README.md | 30 +- problems/excel-sheet-column-number/README.md | 13 +- .../README.md | 86 +++ problems/fair-candy-swap/README.md | 15 +- problems/filling-bookcase-shelves/README.md | 6 +- .../README.md | 6 +- .../README.md | 20 +- problems/find-a-peak-element-ii/README.md | 3 + .../README.md | 4 +- .../find-all-duplicates-in-an-array/README.md | 6 +- .../README.md | 67 +++ .../find-all-people-with-secret/README.md | 95 +++ .../README.md | 82 +++ problems/find-all-the-lonely-nodes/README.md | 4 + problems/find-and-replace-in-string/README.md | 6 +- problems/find-and-replace-pattern/README.md | 6 +- .../README.md | 6 +- .../README.md | 2 +- problems/find-duplicate-subtrees/README.md | 1 + .../README.md | 10 +- .../README.md | 67 +++ .../find-good-days-to-rob-the-bank/README.md | 86 +++ .../find-if-path-exists-in-graph/README.md | 10 +- problems/find-k-closest-elements/README.md | 6 +- .../README.md | 6 +- .../README.md | 26 +- .../README.md | 13 +- .../find-latest-group-of-size-m/README.md | 25 +- .../find-longest-awesome-substring/README.md | 11 +- .../find-lucky-integer-in-an-array/README.md | 18 +- .../README.md | 6 +- problems/find-missing-observations/README.md | 8 - .../README.md | 3 + .../README.md | 3 + problems/find-root-of-n-ary-tree/README.md | 5 +- .../README.md | 24 +- .../README.md | 72 +++ .../README.md | 75 +++ .../README.md | 70 +++ .../README.md | 11 +- .../README.md | 3 - .../README.md | 30 +- .../find-the-middle-index-in-array/README.md | 19 +- .../README.md | 8 - problems/find-the-missing-ids/README.md | 5 + .../README.md | 6 +- .../README.md | 16 +- .../README.md | 16 +- .../README.md | 3 +- .../README.md | 24 +- .../README.md | 33 +- .../README.md | 8 - .../finding-3-digit-even-numbers/README.md | 73 +++ problems/finding-mk-average/README.md | 7 +- .../README.md | 5 +- .../README.md | 2 +- .../README.md | 6 +- problems/fizz-buzz-multithreaded/README.md | 6 +- .../README.md | 6 +- problems/flip-game-ii/README.md | 6 +- .../README.md | 6 +- .../README.md | 26 +- problems/four-divisors/README.md | 6 +- .../frog-position-after-t-seconds/README.md | 23 +- problems/fruit-into-baskets/README.md | 8 - problems/game-play-analysis-i/README.md | 6 +- problems/get-the-maximum-score/README.md | 19 +- .../README.md | 6 +- .../README.md | 2 +- .../group-sold-products-by-the-date/README.md | 6 +- problems/groups-of-strings/README.md | 96 ++++ .../guess-number-higher-or-lower/README.md | 38 +- problems/guess-the-word/README.md | 2 +- problems/hexspeak/README.md | 6 +- problems/hopper-company-queries-i/README.md | 5 - problems/hopper-company-queries-iii/README.md | 5 - problems/house-robber-iii/README.md | 2 +- problems/house-robber/README.md | 6 +- .../README.md | 6 +- problems/html-entity-parser/README.md | 45 +- problems/image-overlap/README.md | 6 +- problems/immediate-food-delivery-i/README.md | 6 +- problems/immediate-food-delivery-ii/README.md | 6 +- .../implement-rand10-using-rand7/README.md | 6 +- problems/implement-strstr/README.md | 6 +- .../increasing-decreasing-string/README.md | 37 +- problems/integer-replacement/README.md | 6 +- problems/integer-to-english-words/README.md | 36 +- .../README.md | 83 +++ problems/is-graph-bipartite/README.md | 6 +- problems/jump-game-iii/README.md | 6 +- problems/jump-game-v/README.md | 25 +- problems/jump-game-vi/README.md | 8 +- .../README.md | 121 ++++ problems/k-radius-subarray-averages/README.md | 87 +++ .../README.md | 6 +- .../README.md | 81 +++ problems/kill-process/README.md | 6 +- problems/koko-eating-bananas/README.md | 1 + .../kth-largest-element-in-a-stream/README.md | 6 +- problems/largest-1-bordered-square/README.md | 6 +- problems/largest-magic-square/README.md | 3 - problems/largest-multiple-of-three/README.md | 15 +- problems/largest-number/README.md | 18 +- .../largest-odd-number-in-string/README.md | 2 +- problems/largest-perimeter-triangle/README.md | 25 +- problems/largest-subarray-length-k/README.md | 2 +- .../README.md | 20 +- .../README.md | 8 - .../README.md | 29 +- .../README.md | 6 +- .../README.md | 2 +- problems/leetcodify-similar-friends/README.md | 3 + .../README.md | 8 +- problems/letter-case-permutation/README.md | 24 +- .../README.md | 19 +- problems/line-reflection/README.md | 6 +- problems/linked-list-in-binary-tree/README.md | 2 +- problems/logger-rate-limiter/README.md | 6 +- .../README.md | 5 + .../README.md | 6 +- .../longest-arithmetic-subsequence/README.md | 6 +- .../README.md | 8 - .../README.md | 3 + .../README.md | 12 +- .../longest-duplicate-substring/README.md | 10 +- problems/longest-happy-prefix/README.md | 16 +- problems/longest-happy-string/README.md | 28 +- .../longest-harmonious-subsequence/README.md | 6 +- .../README.md | 2 +- problems/longest-mountain-in-array/README.md | 6 +- problems/longest-nice-substring/README.md | 14 +- .../README.md | 80 +++ .../README.md | 3 + .../README.md | 21 +- .../README.md | 8 - .../longest-uncommon-subsequence-ii/README.md | 6 +- problems/longest-univalue-path/README.md | 6 +- problems/longest-winning-streak/README.md | 17 + .../longest-winning-streak/mysql_schemas.sql | 10 + problems/low-quality-problems/README.md | 2 +- .../README.md | 8 + .../README.md | 6 +- problems/majority-element-ii/README.md | 13 +- problems/majority-element/README.md | 6 +- problems/make-sum-divisible-by-p/README.md | 15 - .../README.md | 28 +- problems/making-file-names-unique/README.md | 26 +- problems/map-sum-pairs/README.md | 10 +- problems/matrix-block-sum/README.md | 9 +- .../matrix-cells-in-distance-order/README.md | 10 +- problems/matrix-diagonal-sum/README.md | 3 + problems/max-consecutive-ones-iii/README.md | 9 +- .../README.md | 6 +- problems/max-value-of-equation/README.md | 7 +- problems/maximal-rectangle/README.md | 20 +- .../README.md | 5 +- .../README.md | 2 +- .../README.md | 3 + problems/maximum-and-sum-of-array/README.md | 69 +++ .../README.md | 8 +- .../maximum-ascending-subarray-sum/README.md | 10 +- .../README.md | 2 +- .../README.md | 65 +-- .../README.md | 6 +- .../README.md | 8 - problems/maximum-distance-in-arrays/README.md | 2 +- .../README.md | 2 +- .../README.md | 88 +++ .../README.md | 99 ++++ .../README.md | 8 + .../README.md | 114 ++++ problems/maximum-ice-cream-bars/README.md | 2 +- .../README.md | 8 - .../README.md | 30 +- .../README.md | 19 +- .../README.md | 45 +- .../README.md | 2 + .../README.md | 14 +- .../README.md | 38 +- .../maximum-number-of-eaten-apples/README.md | 5 +- .../README.md | 35 +- .../README.md | 31 +- .../README.md | 2 +- .../README.md | 22 +- .../README.md | 14 +- .../README.md | 4 +- .../README.md | 25 +- .../README.md | 5 +- .../README.md | 61 ++ .../maximum-path-quality-of-a-graph/README.md | 13 +- .../maximum-performance-of-a-team/README.md | 3 + .../README.md | 21 +- .../README.md | 14 - .../maximum-product-of-word-lengths/README.md | 6 +- .../README.md | 25 +- .../maximum-repeating-substring/README.md | 3 - .../README.md | 72 +++ .../README.md | 4 + .../README.md | 5 +- .../README.md | 5 +- .../README.md | 3 + .../maximum-students-taking-exam/README.md | 4 +- .../maximum-sum-bst-in-binary-tree/README.md | 20 +- .../README.md | 6 +- .../README.md | 89 +++ problems/maximum-units-on-a-truck/README.md | 2 +- .../README.md | 2 +- .../README.md | 14 - problems/meeting-rooms-ii/README.md | 8 +- .../merge-bsts-to-create-single-bst/README.md | 8 - .../merge-in-between-linked-lists/README.md | 2 +- problems/merge-intervals/README.md | 1 + problems/merge-strings-alternately/README.md | 3 + .../README.md | 16 +- .../min-cost-to-connect-all-points/README.md | 42 +- problems/mini-parser/README.md | 6 +- .../minimize-deviation-in-array/README.md | 4 +- .../README.md | 5 +- .../minimum-absolute-difference/README.md | 17 +- .../README.md | 20 +- .../README.md | 8 +- problems/minimum-area-rectangle-ii/README.md | 16 +- .../README.md | 75 +++ .../README.md | 100 ++++ .../README.md | 4 +- .../minimum-cost-to-cut-a-stick/README.md | 3 + .../minimum-cost-to-merge-stones/README.md | 6 +- .../README.md | 34 ++ .../README.md | 6 +- .../README.md | 2 +- .../README.md | 98 ++++ .../README.md | 3 + .../README.md | 1 + .../README.md | 25 +- .../README.md | 90 +++ .../README.md | 22 +- .../README.md | 20 +- .../README.md | 8 +- .../README.md | 2 +- .../minimum-falling-path-sum-ii/README.md | 3 + problems/minimum-falling-path-sum/README.md | 6 +- problems/minimum-genetic-mutation/README.md | 6 +- problems/minimum-incompatibility/README.md | 2 +- .../README.md | 16 +- .../README.md | 28 +- .../README.md | 2 +- .../minimum-jumps-to-reach-home/README.md | 2 +- .../README.md | 41 +- .../README.md | 82 +++ .../README.md | 87 +++ .../README.md | 50 +- .../README.md | 20 +- .../README.md | 34 +- .../README.md | 15 +- .../README.md | 36 +- .../README.md | 45 ++ .../README.md | 13 - .../README.md | 3 + .../README.md | 8 +- .../README.md | 14 - .../README.md | 24 +- .../README.md | 2 +- .../README.md | 23 +- .../README.md | 28 +- .../README.md | 40 +- .../README.md | 37 +- .../README.md | 78 +++ .../README.md | 100 ++++ .../README.md | 40 ++ .../README.md | 34 +- .../README.md | 7 - .../README.md | 3 + .../README.md | 2 +- .../README.md | 2 +- problems/minimum-suffix-flips/README.md | 70 +++ .../README.md | 67 +++ .../README.md | 91 +++ .../README.md | 9 +- .../README.md | 22 +- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 67 +++ .../README.md | 97 ++++ .../README.md | 2 +- problems/missing-number/README.md | 17 +- problems/monotone-increasing-digits/README.md | 6 +- problems/monthly-transactions-ii/README.md | 9 +- .../monthly-transactions-ii/mysql_schemas.sql | 4 +- problems/my-calendar-i/README.md | 6 +- problems/my-calendar-ii/README.md | 2 +- .../README.md | 2 +- problems/new-users-daily-count/README.md | 6 +- problems/non-decreasing-array/README.md | 9 +- problems/nth-highest-salary/README.md | 6 +- problems/number-of-1-bits/README.md | 6 +- .../number-of-corner-rectangles/README.md | 6 +- .../README.md | 46 +- problems/number-of-digit-one/README.md | 10 +- .../README.md | 4 +- .../number-of-good-leaf-nodes-pairs/README.md | 26 +- .../README.md | 26 +- .../number-of-laser-beams-in-a-bank/README.md | 89 +++ .../number-of-lines-to-write-string/README.md | 6 +- .../README.md | 4 +- .../README.md | 34 +- .../README.md | 35 +- .../number-of-segments-in-a-string/README.md | 24 +- .../README.md | 25 +- .../README.md | 75 +++ .../README.md | 2 +- .../README.md | 5 +- .../README.md | 6 +- .../README.md | 31 +- .../README.md | 5 +- .../README.md | 31 +- .../README.md | 3 + .../README.md | 26 +- .../README.md | 11 +- .../README.md | 3 - .../README.md | 35 ++ .../README.md | 31 +- .../README.md | 8 - .../README.md | 83 +++ .../README.md | 16 +- .../README.md | 25 +- .../README.md | 57 +- .../README.md | 13 +- .../README.md | 20 +- .../README.md | 30 +- .../README.md | 30 +- .../numbers-with-repeated-digits/README.md | 6 +- problems/odd-even-jump/README.md | 6 +- .../README.md | 4 +- .../order-two-columns-independently/README.md | 17 + .../mysql_schemas.sql | 6 + .../README.md | 2 +- problems/paint-fence/README.md | 6 +- problems/paint-house-iii/README.md | 17 +- problems/palindrome-linked-list/README.md | 6 +- problems/palindrome-pairs/README.md | 1 + .../palindrome-partitioning-iii/README.md | 3 + problems/palindrome-removal/README.md | 6 +- problems/parallel-courses-ii/README.md | 11 +- .../README.md | 74 +++ problems/partition-list/README.md | 6 +- problems/path-sum-ii/README.md | 8 +- problems/path-sum/README.md | 15 +- problems/path-with-minimum-effort/README.md | 10 +- problems/perfect-rectangle/README.md | 8 - problems/pizza-with-3n-slices/README.md | 44 +- problems/plus-one-linked-list/README.md | 6 +- problems/poor-pigs/README.md | 6 +- .../README.md | 7 +- problems/possible-bipartition/README.md | 6 +- .../README.md | 39 ++ problems/power-of-three/README.md | 32 +- problems/prime-arrangements/README.md | 6 +- problems/print-in-order/README.md | 6 +- problems/prison-cells-after-n-days/README.md | 8 +- .../README.md | 16 - .../product-of-array-except-self/README.md | 6 +- .../products-price-for-each-store/README.md | 3 + .../projection-area-of-3d-shapes/README.md | 25 +- .../put-boxes-into-the-warehouse-ii/README.md | 5 +- .../README.md | 6 +- .../queries-quality-and-percentage/README.md | 3 + .../queue-reconstruction-by-height/README.md | 2 +- problems/race-car/README.md | 6 +- problems/random-pick-index/README.md | 8 +- problems/random-pick-with-weight/README.md | 29 +- problems/range-sum-query-mutable/README.md | 8 +- problems/rank-scores/README.md | 6 +- problems/rank-transform-of-a-matrix/README.md | 9 +- problems/reach-a-number/README.md | 6 +- .../README.md | 72 +++ .../rearrange-spaces-between-words/README.md | 32 +- .../README.md | 6 +- .../rearrange-words-in-a-sentence/README.md | 6 +- problems/recover-the-original-array/README.md | 95 +++ problems/rectangle-overlap/README.md | 8 +- problems/rectangles-area/README.md | 6 +- .../reduce-array-size-to-the-half/README.md | 27 +- problems/reducing-dishes/README.md | 11 +- problems/reformat-phone-number/README.md | 16 +- .../README.md | 46 ++ problems/remove-covered-intervals/README.md | 23 +- problems/remove-interval/README.md | 6 +- .../README.md | 2 +- .../README.md | 8 - .../README.md | 3 + .../README.md | 94 +++ .../README.md | 85 +++ .../README.md | 6 +- problems/repeated-string-match/README.md | 23 +- .../README.md | 19 +- problems/reported-posts-ii/README.md | 6 +- problems/restore-the-array/README.md | 24 +- problems/reverse-bits/README.md | 8 +- problems/reverse-linked-list/README.md | 10 +- .../README.md | 28 +- problems/reverse-words-in-a-string/README.md | 20 +- problems/rings-and-rods/README.md | 83 +++ problems/rotate-array/README.md | 8 +- problems/rotate-function/README.md | 6 +- .../README.md | 3 - problems/russian-doll-envelopes/README.md | 10 +- problems/sales-analysis-ii/README.md | 4 + problems/sales-by-day-of-the-week/README.md | 6 +- problems/search-insert-position/README.md | 33 +- problems/search-suggestions-system/README.md | 22 +- problems/second-highest-salary/README.md | 52 +- .../second-highest-salary/mysql_schemas.sql | 8 +- .../README.md | 1 - problems/self-crossing/README.md | 6 +- .../README.md | 15 - problems/sentence-similarity-iii/README.md | 7 - .../README.md | 113 ++++ problems/set-matrix-zeroes/README.md | 10 +- problems/set-mismatch/README.md | 2 +- problems/shift-2d-grid/README.md | 6 +- problems/shortest-bridge/README.md | 20 +- problems/shortest-completing-word/README.md | 22 +- .../README.md | 6 +- .../shortest-path-in-a-hidden-grid/README.md | 4 + problems/shortest-path-to-get-food/README.md | 6 +- .../README.md | 18 +- .../shortest-way-to-form-string/README.md | 3 +- problems/shuffle-string/README.md | 33 +- problems/shuffle-the-array/README.md | 6 +- problems/simplify-path/README.md | 15 +- problems/single-row-keyboard/README.md | 6 +- .../README.md | 2 +- .../smallest-index-with-equal-value/README.md | 8 - .../README.md | 28 +- .../README.md | 2 +- .../README.md | 19 +- .../README.md | 59 ++ .../README.md | 92 +++ problems/sort-an-array/README.md | 12 +- .../README.md | 3 - .../README.md | 81 +++ .../README.md | 36 +- .../README.md | 37 +- .../README.md | 2 +- problems/sort-transformed-array/README.md | 6 +- problems/sorting-the-sentence/README.md | 3 + .../README.md | 7 - .../README.md | 49 +- .../README.md | 22 +- .../split-array-with-same-average/README.md | 6 +- .../README.md | 13 +- .../README.md | 9 - problems/squares-of-a-sorted-array/README.md | 6 +- problems/stamping-the-grid/README.md | 78 +++ problems/stamping-the-sequence/README.md | 8 +- .../README.md | 75 +++ problems/stepping-numbers/README.md | 6 +- problems/stock-price-fluctuation/README.md | 1 + problems/stone-game-ii/README.md | 6 +- problems/stone-game-iii/README.md | 38 +- problems/stone-game-iv/README.md | 33 +- problems/stone-game-vii/README.md | 11 - problems/strange-printer-ii/README.md | 16 +- problems/stream-of-characters/README.md | 10 +- .../string-matching-in-an-array/README.md | 6 +- problems/string-to-integer-atoi/README.md | 41 +- .../strings-differ-by-one-character/README.md | 2 +- problems/strobogrammatic-number-iii/README.md | 6 +- problems/strobogrammatic-number/README.md | 6 +- problems/strong-friendship/README.md | 2 +- .../student-attendance-record-ii/README.md | 6 +- problems/subrectangle-queries/README.md | 2 +- .../README.md | 35 ++ .../README.md | 2 +- .../README.md | 9 +- .../README.md | 2 +- problems/sudoku-solver/README.md | 6 +- problems/sum-of-square-numbers/README.md | 21 - problems/sum-of-subarray-minimums/README.md | 6 +- problems/sum-of-subarray-ranges/README.md | 83 +++ problems/sum-of-subsequence-widths/README.md | 6 +- problems/surface-area-of-3d-shapes/README.md | 27 +- problems/surrounded-regions/README.md | 2 +- problems/suspicious-bank-accounts/README.md | 2 +- problems/swap-adjacent-in-lr-string/README.md | 27 +- .../README.md | 20 +- .../swapping-nodes-in-a-linked-list/README.md | 28 +- problems/symmetric-tree/README.md | 6 +- problems/synonymous-sentences/README.md | 8 +- .../README.md | 17 + .../mysql_schemas.sql | 5 + .../README.md | 2 +- .../README.md | 28 +- problems/the-kth-factor-of-n/README.md | 26 +- .../README.md | 3 + .../README.md | 49 +- .../README.md | 17 + .../mysql_schemas.sql | 11 + .../README.md | 17 + .../mysql_schemas.sql | 12 + .../the-number-of-rich-customers/README.md | 2 +- .../README.md | 13 - problems/the-winner-university/README.md | 2 +- problems/thousand-separator/README.md | 16 +- problems/three-divisors/README.md | 3 + problems/throne-inheritance/README.md | 5 +- problems/time-based-key-value-store/README.md | 5 +- .../README.md | 39 +- problems/total-sales-amount-by-year/README.md | 6 +- problems/trapping-rain-water/README.md | 6 +- problems/tuple-with-same-product/README.md | 16 +- problems/two-sum/README.md | 10 +- .../README.md | 47 ++ .../README.md | 6 +- .../README.md | 2 +- problems/utf-8-validation/README.md | 2 +- problems/valid-arrangement-of-pairs/README.md | 87 +++ problems/valid-parenthesis-string/README.md | 1 + problems/valid-word-abbreviation/README.md | 7 +- problems/verbal-arithmetic-puzzle/README.md | 19 +- problems/video-stitching/README.md | 19 +- problems/vowels-of-all-substrings/README.md | 12 +- problems/water-bottles/README.md | 34 +- problems/watering-plants-ii/README.md | 94 +++ .../README.md | 3 + .../weather-type-in-each-country/README.md | 6 +- problems/where-will-the-ball-fall/README.md | 2 +- problems/wiggle-subsequence/README.md | 11 +- problems/word-abbreviation/README.md | 6 +- problems/word-pattern-ii/README.md | 6 +- problems/word-squares/README.md | 2 +- problems/word-subsets/README.md | 32 +- problems/xor-operation-in-an-array/README.md | 31 +- problems/xor-queries-of-a-subarray/README.md | 2 +- readme/1-300.md | 102 ++-- readme/1201-1500.md | 94 +-- readme/1501-1800.md | 388 +++++++++++++ readme/301-600.md | 96 ++-- readme/601-900.md | 96 ++-- readme/901-1200.md | 96 ++-- tag/array/README.md | 102 +++- tag/backtracking/README.md | 4 + tag/binary-indexed-tree/README.md | 2 +- tag/binary-search-tree/README.md | 2 +- tag/binary-search/README.md | 15 +- tag/binary-tree/README.md | 13 +- tag/bit-manipulation/README.md | 8 +- tag/bitmask/README.md | 2 + tag/breadth-first-search/README.md | 14 +- tag/concurrency/README.md | 2 +- tag/counting/README.md | 8 + tag/data-stream/README.md | 2 + tag/depth-first-search/README.md | 16 +- tag/design/README.md | 8 +- tag/divide-and-conquer/README.md | 4 +- tag/doubly-linked-list/README.md | 2 +- tag/dynamic-programming/README.md | 23 +- tag/enumeration/README.md | 6 +- tag/eulerian-circuit/README.md | 1 + tag/geometry/README.md | 6 +- tag/graph/README.md | 9 +- tag/greedy/README.md | 21 +- tag/hash-function/README.md | 2 + tag/hash-table/README.md | 35 +- tag/heap-priority-queue/README.md | 8 +- tag/iterator/README.md | 2 +- tag/linked-list/README.md | 8 +- tag/math/README.md | 30 +- tag/matrix/README.md | 12 +- tag/merge-sort/README.md | 2 +- tag/monotonic-stack/README.md | 2 + tag/number-theory/README.md | 1 + tag/ordered-set/README.md | 10 +- tag/prefix-sum/README.md | 9 +- tag/queue/README.md | 1 + tag/recursion/README.md | 4 +- tag/rolling-hash/README.md | 2 + tag/segment-tree/README.md | 3 +- tag/shortest-path/README.md | 3 +- tag/simulation/README.md | 13 +- tag/sliding-window/README.md | 6 + tag/sorting/README.md | 29 +- tag/stack/README.md | 6 +- tag/string/README.md | 37 +- tag/topological-sort/README.md | 2 + tag/tree/README.md | 13 +- tag/two-pointers/README.md | 10 +- tag/union-find/README.md | 2 + 783 files changed, 10343 insertions(+), 5686 deletions(-) create mode 100644 problems/a-number-after-a-double-reversal/README.md create mode 100644 problems/abbreviating-the-product-of-a-range/README.md create mode 100644 problems/adding-spaces-to-a-string/README.md create mode 100644 problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md create mode 100644 problems/amount-of-new-area-painted-each-day/README.md create mode 100644 problems/build-the-equation/README.md create mode 100644 problems/build-the-equation/mysql_schemas.sql create mode 100644 problems/capitalize-the-title/README.md create mode 100644 problems/check-if-a-parentheses-string-can-be-valid/README.md create mode 100644 problems/check-if-all-as-appears-before-all-bs/README.md create mode 100644 problems/check-if-every-row-and-column-contains-all-numbers/README.md create mode 100644 problems/choose-numbers-from-two-arrays-in-range/README.md create mode 100644 problems/count-common-words-with-one-occurrence/README.md create mode 100644 problems/count-elements-with-strictly-smaller-and-greater-elements/README.md create mode 100644 problems/count-fertile-pyramids-in-a-land/README.md create mode 100644 problems/count-operations-to-obtain-zero/README.md create mode 100644 problems/count-the-hidden-sequences/README.md create mode 100644 problems/count-words-obtained-after-adding-a-letter/README.md create mode 100644 problems/delete-the-middle-node-of-a-linked-list/README.md create mode 100644 problems/design-bitset/README.md create mode 100644 problems/destroying-asteroids/README.md create mode 100644 problems/detonate-the-maximum-bombs/README.md create mode 100644 problems/divide-a-string-into-groups-of-size-k/README.md create mode 100644 problems/earliest-possible-day-of-full-bloom/README.md create mode 100644 problems/elements-in-array-after-removing-and-replacing-elements/README.md create mode 100644 problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md create mode 100644 problems/find-all-lonely-numbers-in-the-array/README.md create mode 100644 problems/find-all-people-with-secret/README.md create mode 100644 problems/find-all-possible-recipes-from-given-supplies/README.md create mode 100644 problems/find-first-palindromic-string-in-the-array/README.md create mode 100644 problems/find-good-days-to-rob-the-bank/README.md create mode 100644 problems/find-subsequence-of-length-k-with-the-largest-sum/README.md create mode 100644 problems/find-substring-with-given-hash-value/README.md create mode 100644 problems/find-target-indices-after-sorting-array/README.md create mode 100644 problems/finding-3-digit-even-numbers/README.md create mode 100644 problems/groups-of-strings/README.md create mode 100644 problems/intervals-between-identical-elements/README.md create mode 100644 problems/k-highest-ranked-items-within-a-price-range/README.md create mode 100644 problems/k-radius-subarray-averages/README.md create mode 100644 problems/keep-multiplying-found-values-by-two/README.md create mode 100644 problems/longest-palindrome-by-concatenating-two-letter-words/README.md create mode 100644 problems/longest-winning-streak/README.md create mode 100644 problems/longest-winning-streak/mysql_schemas.sql create mode 100644 problems/maximum-and-sum-of-array/README.md create mode 100644 problems/maximum-employees-to-be-invited-to-a-meeting/README.md create mode 100644 problems/maximum-fruits-harvested-after-at-most-k-steps/README.md create mode 100644 problems/maximum-good-people-based-on-statements/README.md create mode 100644 problems/maximum-number-of-words-found-in-sentences/README.md create mode 100644 problems/maximum-running-time-of-n-computers/README.md create mode 100644 problems/maximum-twin-sum-of-a-linked-list/README.md create mode 100644 problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md create mode 100644 problems/minimum-cost-of-buying-candies-with-discount/README.md create mode 100644 problems/minimum-cost-to-reach-city-with-discounts/README.md create mode 100644 problems/minimum-cost-to-set-cooking-time/README.md create mode 100644 problems/minimum-difference-in-sums-after-removal-of-elements/README.md create mode 100644 problems/minimum-moves-to-reach-target-score/README.md create mode 100644 problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses/README.md create mode 100644 problems/minimum-number-of-lines-to-cover-points/README.md create mode 100644 problems/minimum-operations-to-make-the-array-alternating/README.md create mode 100644 problems/minimum-operations-to-make-the-array-k-increasing/README.md create mode 100644 problems/minimum-operations-to-remove-adjacent-ones-in-matrix/README.md create mode 100644 problems/minimum-suffix-flips/README.md create mode 100644 problems/minimum-sum-of-four-digit-number-after-splitting-digits/README.md create mode 100644 problems/minimum-swaps-to-group-all-1s-together-ii/README.md create mode 100644 problems/minimum-time-to-make-rope-colorful/README.md create mode 100644 problems/minimum-time-to-remove-all-cars-containing-illegal-goods/README.md create mode 100644 problems/number-of-laser-beams-in-a-bank/README.md create mode 100644 problems/number-of-smooth-descent-periods-of-a-stock/README.md create mode 100644 problems/number-of-unique-flavors-after-sharing-k-candies/README.md create mode 100644 problems/number-of-ways-to-divide-a-long-corridor/README.md create mode 100644 problems/order-two-columns-independently/README.md create mode 100644 problems/order-two-columns-independently/mysql_schemas.sql create mode 100644 problems/partition-array-according-to-given-pivot/README.md create mode 100644 problems/pour-water-between-buckets-to-make-water-levels-equal/README.md create mode 100644 problems/rearrange-array-elements-by-sign/README.md create mode 100644 problems/recover-the-original-array/README.md create mode 100644 problems/remove-all-ones-with-row-and-column-flips/README.md create mode 100644 problems/removing-minimum-and-maximum-from-array/README.md create mode 100644 problems/removing-minimum-number-of-magic-beans/README.md create mode 100644 problems/rings-and-rods/README.md create mode 100644 problems/sequentially-ordinal-rank-tracker/README.md create mode 100644 problems/smallest-value-of-the-rearranged-number/README.md create mode 100644 problems/solving-questions-with-brainpower/README.md create mode 100644 problems/sort-even-and-odd-indices-independently/README.md create mode 100644 problems/stamping-the-grid/README.md create mode 100644 problems/step-by-step-directions-from-a-binary-tree-node-to-another/README.md create mode 100644 problems/subsequence-of-size-k-with-the-largest-even-sum/README.md create mode 100644 problems/sum-of-subarray-ranges/README.md create mode 100644 problems/the-airport-with-the-most-traffic/README.md create mode 100644 problems/the-airport-with-the-most-traffic/mysql_schemas.sql create mode 100644 problems/the-number-of-passengers-in-each-bus-i/README.md create mode 100644 problems/the-number-of-passengers-in-each-bus-i/mysql_schemas.sql create mode 100644 problems/the-number-of-passengers-in-each-bus-ii/README.md create mode 100644 problems/the-number-of-passengers-in-each-bus-ii/mysql_schemas.sql create mode 100644 problems/unique-substrings-with-equal-digit-frequency/README.md create mode 100644 problems/valid-arrangement-of-pairs/README.md create mode 100644 problems/watering-plants-ii/README.md create mode 100644 readme/1501-1800.md diff --git a/README.md b/README.md index d8ed2b05d..340a1f882 100644 --- a/README.md +++ b/README.md @@ -19,68 +19,165 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
[1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
[301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
[601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
[901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
[1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
[1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
[1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
[2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
| # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 2084 | [Drop Type 1 Orders for Customers With Type 0 Orders](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders) 🔒 | [MySQL](problems/drop-type-1-orders-for-customers-with-type-0-orders) | Medium | -| 2083 | [Substrings That Begin and End With the Same Letter](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [Go](problems/substrings-that-begin-and-end-with-the-same-letter) | Medium | -| 2082 | [The Number of Rich Customers](https://leetcode.com/problems/the-number-of-rich-customers) 🔒 | [MySQL](problems/the-number-of-rich-customers) | Easy | +| 2173 | [Longest Winning Streak](https://leetcode.com/problems/longest-winning-streak) 🔒 | [MySQL](problems/longest-winning-streak) | Hard | +| 2172 | [Maximum AND Sum of Array](https://leetcode.com/problems/maximum-and-sum-of-array "数组的最大与和") | [Go](problems/maximum-and-sum-of-array) | Hard | +| 2171 | [Removing Minimum Number of Magic Beans](https://leetcode.com/problems/removing-minimum-number-of-magic-beans "拿出最少数目的魔法豆") | [Go](problems/removing-minimum-number-of-magic-beans) | Medium | +| 2170 | [Minimum Operations to Make the Array Alternating](https://leetcode.com/problems/minimum-operations-to-make-the-array-alternating "使数组变成交替数组的最少操作数") | [Go](problems/minimum-operations-to-make-the-array-alternating) | Medium | +| 2169 | [Count Operations to Obtain Zero](https://leetcode.com/problems/count-operations-to-obtain-zero "得到 0 的操作数") | [Go](problems/count-operations-to-obtain-zero) | Easy | +| 2168 | [Unique Substrings With Equal Digit Frequency](https://leetcode.com/problems/unique-substrings-with-equal-digit-frequency) 🔒 | [Go](problems/unique-substrings-with-equal-digit-frequency) | Medium | +| 2167 | [Minimum Time to Remove All Cars Containing Illegal Goods](https://leetcode.com/problems/minimum-time-to-remove-all-cars-containing-illegal-goods "移除所有载有违禁货物车厢所需的最少时间") | [Go](problems/minimum-time-to-remove-all-cars-containing-illegal-goods) | Hard | +| 2166 | [Design Bitset](https://leetcode.com/problems/design-bitset "设计位集") | [Go](problems/design-bitset) | Medium | +| 2165 | [Smallest Value of the Rearranged Number](https://leetcode.com/problems/smallest-value-of-the-rearranged-number "重排数字的最小值") | [Go](problems/smallest-value-of-the-rearranged-number) | Medium | +| 2164 | [Sort Even and Odd Indices Independently](https://leetcode.com/problems/sort-even-and-odd-indices-independently "对奇偶下标分别排序") | [Go](problems/sort-even-and-odd-indices-independently) | Easy | +| 2163 | [Minimum Difference in Sums After Removal of Elements](https://leetcode.com/problems/minimum-difference-in-sums-after-removal-of-elements "删除元素后和的最小差值") | [Go](problems/minimum-difference-in-sums-after-removal-of-elements) | Hard | +| 2162 | [Minimum Cost to Set Cooking Time](https://leetcode.com/problems/minimum-cost-to-set-cooking-time "设置时间的最少代价") | [Go](problems/minimum-cost-to-set-cooking-time) | Medium | +| 2161 | [Partition Array According to Given Pivot](https://leetcode.com/problems/partition-array-according-to-given-pivot "根据给定数字划分数组") | [Go](problems/partition-array-according-to-given-pivot) | Medium | +| 2160 | [Minimum Sum of Four Digit Number After Splitting Digits](https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits "拆分数位后四位数字的最小和") | [Go](problems/minimum-sum-of-four-digit-number-after-splitting-digits) | Easy | +| 2159 | [Order Two Columns Independently](https://leetcode.com/problems/order-two-columns-independently) 🔒 | [MySQL](problems/order-two-columns-independently) | Medium | +| 2158 | [Amount of New Area Painted Each Day](https://leetcode.com/problems/amount-of-new-area-painted-each-day) 🔒 | [Go](problems/amount-of-new-area-painted-each-day) | Hard | +| 2157 | [Groups of Strings](https://leetcode.com/problems/groups-of-strings "字符串分组") | [Go](problems/groups-of-strings) | Hard | +| 2156 | [Find Substring With Given Hash Value](https://leetcode.com/problems/find-substring-with-given-hash-value "查找给定哈希值的子串") | [Go](problems/find-substring-with-given-hash-value) | Hard | +| 2155 | [All Divisions With the Highest Score of a Binary Array](https://leetcode.com/problems/all-divisions-with-the-highest-score-of-a-binary-array "分组得分最高的所有下标") | [Go](problems/all-divisions-with-the-highest-score-of-a-binary-array) | Medium | +| 2154 | [Keep Multiplying Found Values by Two](https://leetcode.com/problems/keep-multiplying-found-values-by-two "将找到的值乘以 2") | [Go](problems/keep-multiplying-found-values-by-two) | Easy | +| 2153 | [The Number of Passengers in Each Bus II](https://leetcode.com/problems/the-number-of-passengers-in-each-bus-ii) 🔒 | [MySQL](problems/the-number-of-passengers-in-each-bus-ii) | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](https://leetcode.com/problems/minimum-number-of-lines-to-cover-points) 🔒 | [Go](problems/minimum-number-of-lines-to-cover-points) | Medium | +| 2151 | [Maximum Good People Based on Statements](https://leetcode.com/problems/maximum-good-people-based-on-statements "基于陈述统计最多好人数") | [Go](problems/maximum-good-people-based-on-statements) | Hard | +| 2150 | [Find All Lonely Numbers in the Array](https://leetcode.com/problems/find-all-lonely-numbers-in-the-array "找出数组中的所有孤独数字") | [Go](problems/find-all-lonely-numbers-in-the-array) | Medium | +| 2149 | [Rearrange Array Elements by Sign](https://leetcode.com/problems/rearrange-array-elements-by-sign "按符号重排数组") | [Go](problems/rearrange-array-elements-by-sign) | Medium | +| 2148 | [Count Elements With Strictly Smaller and Greater Elements](https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements "元素计数") | [Go](problems/count-elements-with-strictly-smaller-and-greater-elements) | Easy | +| 2147 | [Number of Ways to Divide a Long Corridor](https://leetcode.com/problems/number-of-ways-to-divide-a-long-corridor "分隔长廊的方案数") | [Go](problems/number-of-ways-to-divide-a-long-corridor) | Hard | +| 2146 | [K Highest Ranked Items Within a Price Range](https://leetcode.com/problems/k-highest-ranked-items-within-a-price-range "价格范围内最高排名的 K 样物品") | [Go](problems/k-highest-ranked-items-within-a-price-range) | Medium | +| 2145 | [Count the Hidden Sequences](https://leetcode.com/problems/count-the-hidden-sequences "统计隐藏数组数目") | [Go](problems/count-the-hidden-sequences) | Medium | +| 2144 | [Minimum Cost of Buying Candies With Discount](https://leetcode.com/problems/minimum-cost-of-buying-candies-with-discount "打折购买糖果的最小开销") | [Go](problems/minimum-cost-of-buying-candies-with-discount) | Easy | +| 2143 | [Choose Numbers From Two Arrays in Range](https://leetcode.com/problems/choose-numbers-from-two-arrays-in-range) 🔒 | [Go](problems/choose-numbers-from-two-arrays-in-range) | Hard | +| 2142 | [The Number of Passengers in Each Bus I](https://leetcode.com/problems/the-number-of-passengers-in-each-bus-i) 🔒 | [MySQL](problems/the-number-of-passengers-in-each-bus-i) | Medium | +| 2141 | [Maximum Running Time of N Computers](https://leetcode.com/problems/maximum-running-time-of-n-computers "同时运行 N 台电脑的最长时间") | [Go](problems/maximum-running-time-of-n-computers) | Hard | +| 2140 | [Solving Questions With Brainpower](https://leetcode.com/problems/solving-questions-with-brainpower "解决智力问题") | [Go](problems/solving-questions-with-brainpower) | Medium | +| 2139 | [Minimum Moves to Reach Target Score](https://leetcode.com/problems/minimum-moves-to-reach-target-score "得到目标值的最少行动次数") | [Go](problems/minimum-moves-to-reach-target-score) | Medium | +| 2138 | [Divide a String Into Groups of Size k](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k "将字符串拆分为若干长度为 k 的组") | [Go](problems/divide-a-string-into-groups-of-size-k) | Easy | +| 2137 | [Pour Water Between Buckets to Make Water Levels Equal](https://leetcode.com/problems/pour-water-between-buckets-to-make-water-levels-equal) 🔒 | [Go](problems/pour-water-between-buckets-to-make-water-levels-equal) | Medium | +| 2136 | [Earliest Possible Day of Full Bloom](https://leetcode.com/problems/earliest-possible-day-of-full-bloom "全部开花的最早一天") | [Go](problems/earliest-possible-day-of-full-bloom) | Hard | +| 2135 | [Count Words Obtained After Adding a Letter](https://leetcode.com/problems/count-words-obtained-after-adding-a-letter "统计追加字母可以获得的单词数") | [Go](problems/count-words-obtained-after-adding-a-letter) | Medium | +| 2134 | [Minimum Swaps to Group All 1's Together II](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii "最少交换次数来组合所有的 1 II") | [Go](problems/minimum-swaps-to-group-all-1s-together-ii) | Medium | +| 2133 | [Check if Every Row and Column Contains All Numbers](https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers "检查是否每一行每一列都包含全部整数") | [Go](problems/check-if-every-row-and-column-contains-all-numbers) | Easy | +| 2132 | [Stamping the Grid](https://leetcode.com/problems/stamping-the-grid "用邮票贴满网格图") | [Go](problems/stamping-the-grid) | Hard | +| 2131 | [Longest Palindrome by Concatenating Two Letter Words](https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words "连接两字母单词得到的最长回文串") | [Go](problems/longest-palindrome-by-concatenating-two-letter-words) | Medium | +| 2130 | [Maximum Twin Sum of a Linked List](https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list "链表最大孪生和") | [Go](problems/maximum-twin-sum-of-a-linked-list) | Medium | +| 2129 | [Capitalize the Title](https://leetcode.com/problems/capitalize-the-title "将标题首字母大写") | [Go](problems/capitalize-the-title) | Easy | +| 2128 | [Remove All Ones With Row and Column Flips](https://leetcode.com/problems/remove-all-ones-with-row-and-column-flips) 🔒 | [Go](problems/remove-all-ones-with-row-and-column-flips) | Medium | +| 2127 | [Maximum Employees to Be Invited to a Meeting](https://leetcode.com/problems/maximum-employees-to-be-invited-to-a-meeting "参加会议的最多员工数") | [Go](problems/maximum-employees-to-be-invited-to-a-meeting) | Hard | +| 2126 | [Destroying Asteroids](https://leetcode.com/problems/destroying-asteroids "摧毁小行星") | [Go](problems/destroying-asteroids) | Medium | +| 2125 | [Number of Laser Beams in a Bank](https://leetcode.com/problems/number-of-laser-beams-in-a-bank "银行中的激光束数量") | [Go](problems/number-of-laser-beams-in-a-bank) | Medium | +| 2124 | [Check if All A's Appears Before All B's](https://leetcode.com/problems/check-if-all-as-appears-before-all-bs "检查是否所有 A 都在 B 之前") | [Go](problems/check-if-all-as-appears-before-all-bs) | Easy | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](https://leetcode.com/problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [Go](problems/minimum-operations-to-remove-adjacent-ones-in-matrix) | Hard | +| 2122 | [Recover the Original Array](https://leetcode.com/problems/recover-the-original-array "还原原数组") | [Go](problems/recover-the-original-array) | Hard | +| 2121 | [Intervals Between Identical Elements](https://leetcode.com/problems/intervals-between-identical-elements "相同元素的间隔之和") | [Go](problems/intervals-between-identical-elements) | Medium | +| 2120 | [Execution of All Suffix Instructions Staying in a Grid](https://leetcode.com/problems/execution-of-all-suffix-instructions-staying-in-a-grid "执行所有后缀指令") | [Go](problems/execution-of-all-suffix-instructions-staying-in-a-grid) | Medium | +| 2119 | [A Number After a Double Reversal](https://leetcode.com/problems/a-number-after-a-double-reversal "反转两次的数字") | [Go](problems/a-number-after-a-double-reversal) | Easy | +| 2118 | [Build the Equation](https://leetcode.com/problems/build-the-equation) 🔒 | [MySQL](problems/build-the-equation) | Hard | +| 2117 | [Abbreviating the Product of a Range](https://leetcode.com/problems/abbreviating-the-product-of-a-range "一个区间内所有数乘积的缩写") | [Go](problems/abbreviating-the-product-of-a-range) | Hard | +| 2116 | [Check if a Parentheses String Can Be Valid](https://leetcode.com/problems/check-if-a-parentheses-string-can-be-valid "判断一个括号字符串是否有效") | [Go](problems/check-if-a-parentheses-string-can-be-valid) | Medium | +| 2115 | [Find All Possible Recipes from Given Supplies](https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies "从给定原材料中找到所有可以做出的菜") | [Go](problems/find-all-possible-recipes-from-given-supplies) | Medium | +| 2114 | [Maximum Number of Words Found in Sentences](https://leetcode.com/problems/maximum-number-of-words-found-in-sentences "句子中的最多单词数") | [Go](problems/maximum-number-of-words-found-in-sentences) | Easy | +| 2113 | [Elements in Array After Removing and Replacing Elements](https://leetcode.com/problems/elements-in-array-after-removing-and-replacing-elements) 🔒 | [Go](problems/elements-in-array-after-removing-and-replacing-elements) | Medium | +| 2112 | [The Airport With the Most Traffic](https://leetcode.com/problems/the-airport-with-the-most-traffic) 🔒 | [MySQL](problems/the-airport-with-the-most-traffic) | Medium | +| 2111 | [Minimum Operations to Make the Array K-Increasing](https://leetcode.com/problems/minimum-operations-to-make-the-array-k-increasing "使数组 K 递增的最少操作次数") | [Go](problems/minimum-operations-to-make-the-array-k-increasing) | Hard | +| 2110 | [Number of Smooth Descent Periods of a Stock](https://leetcode.com/problems/number-of-smooth-descent-periods-of-a-stock "股票平滑下跌阶段的数目") | [Go](problems/number-of-smooth-descent-periods-of-a-stock) | Medium | +| 2109 | [Adding Spaces to a String](https://leetcode.com/problems/adding-spaces-to-a-string "向字符串添加空格") | [Go](problems/adding-spaces-to-a-string) | Medium | +| 2108 | [Find First Palindromic String in the Array](https://leetcode.com/problems/find-first-palindromic-string-in-the-array "找出数组中的第一个回文字符串") | [Go](problems/find-first-palindromic-string-in-the-array) | Easy | +| 2107 | [Number of Unique Flavors After Sharing K Candies](https://leetcode.com/problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [Go](problems/number-of-unique-flavors-after-sharing-k-candies) | Medium | +| 2106 | [Maximum Fruits Harvested After at Most K Steps](https://leetcode.com/problems/maximum-fruits-harvested-after-at-most-k-steps "摘水果") | [Go](problems/maximum-fruits-harvested-after-at-most-k-steps) | Hard | +| 2105 | [Watering Plants II](https://leetcode.com/problems/watering-plants-ii "给植物浇水 II") | [Go](problems/watering-plants-ii) | Medium | +| 2104 | [Sum of Subarray Ranges](https://leetcode.com/problems/sum-of-subarray-ranges "子数组范围和") | [Go](problems/sum-of-subarray-ranges) | Medium | +| 2103 | [Rings and Rods](https://leetcode.com/problems/rings-and-rods "环和杆") | [Go](problems/rings-and-rods) | Easy | +| 2102 | [Sequentially Ordinal Rank Tracker](https://leetcode.com/problems/sequentially-ordinal-rank-tracker "序列顺序查询") | [Go](problems/sequentially-ordinal-rank-tracker) | Hard | +| 2101 | [Detonate the Maximum Bombs](https://leetcode.com/problems/detonate-the-maximum-bombs "引爆最多的炸弹") | [Go](problems/detonate-the-maximum-bombs) | Medium | +| 2100 | [Find Good Days to Rob the Bank](https://leetcode.com/problems/find-good-days-to-rob-the-bank "适合打劫银行的日子") | [Go](problems/find-good-days-to-rob-the-bank) | Medium | +| 2099 | [Find Subsequence of Length K With the Largest Sum](https://leetcode.com/problems/find-subsequence-of-length-k-with-the-largest-sum "找到和最大的长度为 K 的子序列") | [Go](problems/find-subsequence-of-length-k-with-the-largest-sum) | Easy | +| 2098 | [Subsequence of Size K With the Largest Even Sum](https://leetcode.com/problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [Go](problems/subsequence-of-size-k-with-the-largest-even-sum) | Medium | +| 2097 | [Valid Arrangement of Pairs](https://leetcode.com/problems/valid-arrangement-of-pairs "合法重新排列数对") | [Go](problems/valid-arrangement-of-pairs) | Hard | +| 2096 | [Step-By-Step Directions From a Binary Tree Node to Another](https://leetcode.com/problems/step-by-step-directions-from-a-binary-tree-node-to-another "从二叉树一个节点到另一个节点每一步的方向") | [Go](problems/step-by-step-directions-from-a-binary-tree-node-to-another) | Medium | +| 2095 | [Delete the Middle Node of a Linked List](https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list "删除链表的中间节点") | [Go](problems/delete-the-middle-node-of-a-linked-list) | Medium | +| 2094 | [Finding 3-Digit Even Numbers](https://leetcode.com/problems/finding-3-digit-even-numbers "找出 3 位偶数") | [Go](problems/finding-3-digit-even-numbers) | Easy | +| 2093 | [Minimum Cost to Reach City With Discounts](https://leetcode.com/problems/minimum-cost-to-reach-city-with-discounts) 🔒 | [Go](problems/minimum-cost-to-reach-city-with-discounts) | Medium | +| 2092 | [Find All People With Secret](https://leetcode.com/problems/find-all-people-with-secret "找出知晓秘密的所有专家") | [Go](problems/find-all-people-with-secret) | Hard | +| 2091 | [Removing Minimum and Maximum From Array](https://leetcode.com/problems/removing-minimum-and-maximum-from-array "从数组中移除最大值和最小值") | [Go](problems/removing-minimum-and-maximum-from-array) | Medium | +| 2090 | [K Radius Subarray Averages](https://leetcode.com/problems/k-radius-subarray-averages "半径为 k 的子数组平均值") | [Go](problems/k-radius-subarray-averages) | Medium | +| 2089 | [Find Target Indices After Sorting Array](https://leetcode.com/problems/find-target-indices-after-sorting-array "找出数组排序后的目标下标") | [Go](problems/find-target-indices-after-sorting-array) | Easy | +| 2088 | [Count Fertile Pyramids in a Land](https://leetcode.com/problems/count-fertile-pyramids-in-a-land "统计农场中肥沃金字塔的数目") | [Go](problems/count-fertile-pyramids-in-a-land) | Hard | +| 2087 | [Minimum Cost Homecoming of a Robot in a Grid](https://leetcode.com/problems/minimum-cost-homecoming-of-a-robot-in-a-grid "网格图中机器人回家的最小代价") | [Go](problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | Medium | +| 2086 | [Minimum Number of Buckets Required to Collect Rainwater from Houses](https://leetcode.com/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses "从房屋收集雨水需要的最少水桶数") | [Go](problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | Medium | +| 2085 | [Count Common Words With One Occurrence](https://leetcode.com/problems/count-common-words-with-one-occurrence "统计出现过一次的公共字符串") | [Go](problems/count-common-words-with-one-occurrence) | Easy | +| 2084 | [Drop Type 1 Orders for Customers With Type 0 Orders](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders "为订单类型为 0 的客户删除类型为 1 的订单") 🔒 | [MySQL](problems/drop-type-1-orders-for-customers-with-type-0-orders) | Medium | +| 2083 | [Substrings That Begin and End With the Same Letter](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter "求以相同字母开头和结尾的子串总数") 🔒 | [Go](problems/substrings-that-begin-and-end-with-the-same-letter) | Medium | +| 2082 | [The Number of Rich Customers](https://leetcode.com/problems/the-number-of-rich-customers "富有客户的数量") 🔒 | [MySQL](problems/the-number-of-rich-customers) | Easy | | 2081 | [Sum of k-Mirror Numbers](https://leetcode.com/problems/sum-of-k-mirror-numbers "k 镜像数字的和") | [Go](problems/sum-of-k-mirror-numbers) | Hard | | 2080 | [Range Frequency Queries](https://leetcode.com/problems/range-frequency-queries "区间内查询数字的频率") | [Go](problems/range-frequency-queries) | Medium | | 2079 | [Watering Plants](https://leetcode.com/problems/watering-plants "给植物浇水") | [Go](problems/watering-plants) | Medium | @@ -90,18 +187,18 @@ LeetCode Problems' Solutions | 2075 | [Decode the Slanted Ciphertext](https://leetcode.com/problems/decode-the-slanted-ciphertext "解码斜向换位密码") | [Go](problems/decode-the-slanted-ciphertext) | Medium | | 2074 | [Reverse Nodes in Even Length Groups](https://leetcode.com/problems/reverse-nodes-in-even-length-groups "反转偶数长度组的节点") | [Go](problems/reverse-nodes-in-even-length-groups) | Medium | | 2073 | [Time Needed to Buy Tickets](https://leetcode.com/problems/time-needed-to-buy-tickets "买票需要的时间") | [Go](problems/time-needed-to-buy-tickets) | Easy | -| 2072 | [The Winner University](https://leetcode.com/problems/the-winner-university) 🔒 | [MySQL](problems/the-winner-university) | Easy | +| 2072 | [The Winner University](https://leetcode.com/problems/the-winner-university "赢得比赛的大学") 🔒 | [MySQL](problems/the-winner-university) | Easy | | 2071 | [Maximum Number of Tasks You Can Assign](https://leetcode.com/problems/maximum-number-of-tasks-you-can-assign "你可以安排的最多任务数目") | [Go](problems/maximum-number-of-tasks-you-can-assign) | Hard | | 2070 | [Most Beautiful Item for Each Query](https://leetcode.com/problems/most-beautiful-item-for-each-query "每一个查询的最大美丽值") | [Go](problems/most-beautiful-item-for-each-query) | Medium | | 2069 | [Walking Robot Simulation II](https://leetcode.com/problems/walking-robot-simulation-ii "模拟行走机器人 II") | [Go](problems/walking-robot-simulation-ii) | Medium | | 2068 | [Check Whether Two Strings are Almost Equivalent](https://leetcode.com/problems/check-whether-two-strings-are-almost-equivalent "检查两个字符串是否几乎相等") | [Go](problems/check-whether-two-strings-are-almost-equivalent) | Easy | | 2067 | [Number of Equal Count Substrings](https://leetcode.com/problems/number-of-equal-count-substrings) 🔒 | [Go](problems/number-of-equal-count-substrings) | Medium | -| 2066 | [Account Balance](https://leetcode.com/problems/account-balance) 🔒 | [MySQL](problems/account-balance) | Medium | +| 2066 | [Account Balance](https://leetcode.com/problems/account-balance "账户余额") 🔒 | [MySQL](problems/account-balance) | Medium | | 2065 | [Maximum Path Quality of a Graph](https://leetcode.com/problems/maximum-path-quality-of-a-graph "最大化一张图中的路径价值") | [Go](problems/maximum-path-quality-of-a-graph) | Hard | | 2064 | [Minimized Maximum of Products Distributed to Any Store](https://leetcode.com/problems/minimized-maximum-of-products-distributed-to-any-store "分配给商店的最多商品的最小值") | [Go](problems/minimized-maximum-of-products-distributed-to-any-store) | Medium | | 2063 | [Vowels of All Substrings](https://leetcode.com/problems/vowels-of-all-substrings "所有子字符串中的元音") | [Go](problems/vowels-of-all-substrings) | Medium | | 2062 | [Count Vowel Substrings of a String](https://leetcode.com/problems/count-vowel-substrings-of-a-string "统计字符串中的元音子字符串") | [Go](problems/count-vowel-substrings-of-a-string) | Easy | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [Go](problems/number-of-spaces-cleaning-robot-cleaned) | Medium | +| 2061 | [Number of Spaces Cleaning Robot Cleaned](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned "扫地机器人清扫过的空间个数") 🔒 | [Go](problems/number-of-spaces-cleaning-robot-cleaned) | Medium | | 2060 | [Check if an Original String Exists Given Two Encoded Strings](https://leetcode.com/problems/check-if-an-original-string-exists-given-two-encoded-strings "同源字符串检测") | [Go](problems/check-if-an-original-string-exists-given-two-encoded-strings) | Hard | | 2059 | [Minimum Operations to Convert Number](https://leetcode.com/problems/minimum-operations-to-convert-number "转化数字的最小运算数") | [Go](problems/minimum-operations-to-convert-number) | Medium | | 2058 | [Find the Minimum and Maximum Number of Nodes Between Critical Points](https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points "找出临界点之间的最小和最大距离") | [Go](problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points) | Medium | @@ -110,38 +207,38 @@ LeetCode Problems' Solutions | 2055 | [Plates Between Candles](https://leetcode.com/problems/plates-between-candles "蜡烛之间的盘子") | [Go](problems/plates-between-candles) | Medium | | 2054 | [Two Best Non-Overlapping Events](https://leetcode.com/problems/two-best-non-overlapping-events "两个最好的不重叠活动") | [Go](problems/two-best-non-overlapping-events) | Medium | | 2053 | [Kth Distinct String in an Array](https://leetcode.com/problems/kth-distinct-string-in-an-array "数组中第 K 个独一无二的字符串") | [Go](problems/kth-distinct-string-in-an-array) | Easy | -| 2052 | [Minimum Cost to Separate Sentence Into Rows](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [Go](problems/minimum-cost-to-separate-sentence-into-rows) | Medium | +| 2052 | [Minimum Cost to Separate Sentence Into Rows](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows "将句子分隔成行的最低成本") 🔒 | [Go](problems/minimum-cost-to-separate-sentence-into-rows) | Medium | | 2051 | [The Category of Each Member in the Store](https://leetcode.com/problems/the-category-of-each-member-in-the-store) 🔒 | [MySQL](problems/the-category-of-each-member-in-the-store) | Medium | | 2050 | [Parallel Courses III](https://leetcode.com/problems/parallel-courses-iii "并行课程 III") | [Go](problems/parallel-courses-iii) | Hard | | 2049 | [Count Nodes With the Highest Score](https://leetcode.com/problems/count-nodes-with-the-highest-score "统计最高分的节点数目") | [Go](problems/count-nodes-with-the-highest-score) | Medium | | 2048 | [Next Greater Numerically Balanced Number](https://leetcode.com/problems/next-greater-numerically-balanced-number "下一个更大的数值平衡数") | [Go](problems/next-greater-numerically-balanced-number) | Medium | | 2047 | [Number of Valid Words in a Sentence](https://leetcode.com/problems/number-of-valid-words-in-a-sentence "句子中的有效单词数") | [Go](problems/number-of-valid-words-in-a-sentence) | Easy | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [Go](problems/sort-linked-list-already-sorted-using-absolute-values) | Medium | +| 2046 | [Sort Linked List Already Sorted Using Absolute Values](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values "给按照绝对值排序的链表排序") 🔒 | [Go](problems/sort-linked-list-already-sorted-using-absolute-values) | Medium | | 2045 | [Second Minimum Time to Reach Destination](https://leetcode.com/problems/second-minimum-time-to-reach-destination "到达目的地的第二短时间") | [Go](problems/second-minimum-time-to-reach-destination) | Hard | | 2044 | [Count Number of Maximum Bitwise-OR Subsets](https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets "统计按位或能得到最大值的子集数目") | [Go](problems/count-number-of-maximum-bitwise-or-subsets) | Medium | | 2043 | [Simple Bank System](https://leetcode.com/problems/simple-bank-system "简易银行系统") | [Go](problems/simple-bank-system) | Medium | | 2042 | [Check if Numbers Are Ascending in a Sentence](https://leetcode.com/problems/check-if-numbers-are-ascending-in-a-sentence "检查句子中的数字是否递增") | [Go](problems/check-if-numbers-are-ascending-in-a-sentence) | Easy | -| 2041 | [Accepted Candidates From the Interviews](https://leetcode.com/problems/accepted-candidates-from-the-interviews) 🔒 | [MySQL](problems/accepted-candidates-from-the-interviews) | Medium | +| 2041 | [Accepted Candidates From the Interviews](https://leetcode.com/problems/accepted-candidates-from-the-interviews "面试中被录取的候选人") 🔒 | [MySQL](problems/accepted-candidates-from-the-interviews) | Medium | | 2040 | [Kth Smallest Product of Two Sorted Arrays](https://leetcode.com/problems/kth-smallest-product-of-two-sorted-arrays "两个有序数组的第 K 小乘积") | [Go](problems/kth-smallest-product-of-two-sorted-arrays) | Hard | | 2039 | [The Time When the Network Becomes Idle](https://leetcode.com/problems/the-time-when-the-network-becomes-idle "网络空闲的时刻") | [Go](problems/the-time-when-the-network-becomes-idle) | Medium | | 2038 | [Remove Colored Pieces if Both Neighbors are the Same Color](https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color "如果相邻两个颜色均相同则删除当前颜色") | [Go](problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | Medium | | 2037 | [Minimum Number of Moves to Seat Everyone](https://leetcode.com/problems/minimum-number-of-moves-to-seat-everyone "使每位学生都有座位的最少移动次数") | [Go](problems/minimum-number-of-moves-to-seat-everyone) | Easy | -| 2036 | [Maximum Alternating Subarray Sum](https://leetcode.com/problems/maximum-alternating-subarray-sum) 🔒 | [Go](problems/maximum-alternating-subarray-sum) | Medium | +| 2036 | [Maximum Alternating Subarray Sum](https://leetcode.com/problems/maximum-alternating-subarray-sum "最大交替子数组和") 🔒 | [Go](problems/maximum-alternating-subarray-sum) | Medium | | 2035 | [Partition Array Into Two Arrays to Minimize Sum Difference](https://leetcode.com/problems/partition-array-into-two-arrays-to-minimize-sum-difference "将数组分成两个数组并最小化数组和的差") | [Go](problems/partition-array-into-two-arrays-to-minimize-sum-difference) | Hard | | 2034 | [Stock Price Fluctuation](https://leetcode.com/problems/stock-price-fluctuation "股票价格波动") | [Go](problems/stock-price-fluctuation) | Medium | | 2033 | [Minimum Operations to Make a Uni-Value Grid](https://leetcode.com/problems/minimum-operations-to-make-a-uni-value-grid "获取单值网格的最小操作数") | [Go](problems/minimum-operations-to-make-a-uni-value-grid) | Medium | | 2032 | [Two Out of Three](https://leetcode.com/problems/two-out-of-three "至少在两个数组中出现的值") | [Go](problems/two-out-of-three) | Easy | -| 2031 | [Count Subarrays With More Ones Than Zeros](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [Go](problems/count-subarrays-with-more-ones-than-zeros) | Medium | +| 2031 | [Count Subarrays With More Ones Than Zeros](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros "1 比 0 多的子数组个数") 🔒 | [Go](problems/count-subarrays-with-more-ones-than-zeros) | Medium | | 2030 | [Smallest K-Length Subsequence With Occurrences of a Letter](https://leetcode.com/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter "含特定字母的最小子序列") | [Go](problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | Hard | | 2029 | [Stone Game IX](https://leetcode.com/problems/stone-game-ix "石子游戏 IX") | [Go](problems/stone-game-ix) | Medium | | 2028 | [Find Missing Observations](https://leetcode.com/problems/find-missing-observations "找出缺失的观测数据") | [Go](problems/find-missing-observations) | Medium | | 2027 | [Minimum Moves to Convert String](https://leetcode.com/problems/minimum-moves-to-convert-string "转换字符串的最少操作次数") | [Go](problems/minimum-moves-to-convert-string) | Easy | -| 2026 | [Low-Quality Problems](https://leetcode.com/problems/low-quality-problems) 🔒 | [MySQL](problems/low-quality-problems) | Easy | +| 2026 | [Low-Quality Problems](https://leetcode.com/problems/low-quality-problems "低质量的问题") 🔒 | [MySQL](problems/low-quality-problems) | Easy | | 2025 | [Maximum Number of Ways to Partition an Array](https://leetcode.com/problems/maximum-number-of-ways-to-partition-an-array "分割数组的最多方案数") | [Go](problems/maximum-number-of-ways-to-partition-an-array) | Hard | | 2024 | [Maximize the Confusion of an Exam](https://leetcode.com/problems/maximize-the-confusion-of-an-exam "考试的最大困扰度") | [Go](problems/maximize-the-confusion-of-an-exam) | Medium | | 2023 | [Number of Pairs of Strings With Concatenation Equal to Target](https://leetcode.com/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target "连接后等于目标字符串的字符串对") | [Go](problems/number-of-pairs-of-strings-with-concatenation-equal-to-target) | Medium | | 2022 | [Convert 1D Array Into 2D Array](https://leetcode.com/problems/convert-1d-array-into-2d-array "将一维数组转变成二维数组") | [Go](problems/convert-1d-array-into-2d-array) | Easy | -| 2021 | [Brightest Position on Street](https://leetcode.com/problems/brightest-position-on-street) 🔒 | [Go](problems/brightest-position-on-street) | Medium | +| 2021 | [Brightest Position on Street](https://leetcode.com/problems/brightest-position-on-street "街上最亮的位置") 🔒 | [Go](problems/brightest-position-on-street) | Medium | | 2020 | [Number of Accounts That Did Not Stream](https://leetcode.com/problems/number-of-accounts-that-did-not-stream) 🔒 | [MySQL](problems/number-of-accounts-that-did-not-stream) | Medium | | 2019 | [The Score of Students Solving Math Expression](https://leetcode.com/problems/the-score-of-students-solving-math-expression "解出数学表达式的学生分数") | [Go](problems/the-score-of-students-solving-math-expression) | Hard | | 2018 | [Check if Word Can Be Placed In Crossword](https://leetcode.com/problems/check-if-word-can-be-placed-in-crossword "判断单词是否能放入填字游戏内") | [Go](problems/check-if-word-can-be-placed-in-crossword) | Medium | @@ -157,13 +254,13 @@ LeetCode Problems' Solutions | 2008 | [Maximum Earnings From Taxi](https://leetcode.com/problems/maximum-earnings-from-taxi "出租车的最大盈利") | [Go](problems/maximum-earnings-from-taxi) | Medium | | 2007 | [Find Original Array From Doubled Array](https://leetcode.com/problems/find-original-array-from-doubled-array "从双倍数组中还原原数组") | [Go](problems/find-original-array-from-doubled-array) | Medium | | 2006 | [Count Number of Pairs With Absolute Difference K](https://leetcode.com/problems/count-number-of-pairs-with-absolute-difference-k "差的绝对值为 K 的数对数目") | [Go](problems/count-number-of-pairs-with-absolute-difference-k) | Easy | -| 2005 | [Subtree Removal Game with Fibonacci Tree](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree) 🔒 | [Go](problems/subtree-removal-game-with-fibonacci-tree) | Hard | +| 2005 | [Subtree Removal Game with Fibonacci Tree](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree "斐波那契树的移除子树游戏") 🔒 | [Go](problems/subtree-removal-game-with-fibonacci-tree) | Hard | | 2004 | [The Number of Seniors and Juniors to Join the Company](https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company) 🔒 | [MySQL](problems/the-number-of-seniors-and-juniors-to-join-the-company) | Hard | | 2003 | [Smallest Missing Genetic Value in Each Subtree](https://leetcode.com/problems/smallest-missing-genetic-value-in-each-subtree "每棵子树内缺失的最小基因值") | [Go](problems/smallest-missing-genetic-value-in-each-subtree) | Hard | | 2002 | [Maximum Product of the Length of Two Palindromic Subsequences](https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-subsequences "两个回文子序列长度的最大乘积") | [Go](problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | Medium | | 2001 | [Number of Pairs of Interchangeable Rectangles](https://leetcode.com/problems/number-of-pairs-of-interchangeable-rectangles "可互换矩形的组数") | [Go](problems/number-of-pairs-of-interchangeable-rectangles) | Medium | | 2000 | [Reverse Prefix of Word](https://leetcode.com/problems/reverse-prefix-of-word "反转单词前缀") | [Go](problems/reverse-prefix-of-word) | Easy | -| 1999 | [Smallest Greater Multiple Made of Two Digits](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits) 🔒 | [Go](problems/smallest-greater-multiple-made-of-two-digits) | Medium | +| 1999 | [Smallest Greater Multiple Made of Two Digits](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits "最小的仅由两个数组成的倍数") 🔒 | [Go](problems/smallest-greater-multiple-made-of-two-digits) | Medium | | 1998 | [GCD Sort of an Array](https://leetcode.com/problems/gcd-sort-of-an-array "数组的最大公因数排序") | [Go](problems/gcd-sort-of-an-array) | Hard | | 1997 | [First Day Where You Have Been in All the Rooms](https://leetcode.com/problems/first-day-where-you-have-been-in-all-the-rooms "访问完所有房间的第一天") | [Go](problems/first-day-where-you-have-been-in-all-the-rooms) | Medium | | 1996 | [The Number of Weak Characters in the Game](https://leetcode.com/problems/the-number-of-weak-characters-in-the-game "游戏中弱角色的数量") | [Go](problems/the-number-of-weak-characters-in-the-game) | Medium | @@ -172,9 +269,9 @@ LeetCode Problems' Solutions | 1993 | [Operations on Tree](https://leetcode.com/problems/operations-on-tree "树上的操作") | [Go](problems/operations-on-tree) | Medium | | 1992 | [Find All Groups of Farmland](https://leetcode.com/problems/find-all-groups-of-farmland "找到所有的农场组") | [Go](problems/find-all-groups-of-farmland) | Medium | | 1991 | [Find the Middle Index in Array](https://leetcode.com/problems/find-the-middle-index-in-array "找到数组的中间位置") | [Go](problems/find-the-middle-index-in-array) | Easy | -| 1990 | [Count the Number of Experiments](https://leetcode.com/problems/count-the-number-of-experiments) 🔒 | [MySQL](problems/count-the-number-of-experiments) | Medium | +| 1990 | [Count the Number of Experiments](https://leetcode.com/problems/count-the-number-of-experiments "统计实验的数量") 🔒 | [MySQL](problems/count-the-number-of-experiments) | Medium | | 1989 | [Maximum Number of People That Can Be Caught in Tag](https://leetcode.com/problems/maximum-number-of-people-that-can-be-caught-in-tag) 🔒 | [Go](problems/maximum-number-of-people-that-can-be-caught-in-tag) | Medium | -| 1988 | [Find Cutoff Score for Each School](https://leetcode.com/problems/find-cutoff-score-for-each-school) 🔒 | [MySQL](problems/find-cutoff-score-for-each-school) | Medium | +| 1988 | [Find Cutoff Score for Each School](https://leetcode.com/problems/find-cutoff-score-for-each-school "找出每所学校的最低分数要求") 🔒 | [MySQL](problems/find-cutoff-score-for-each-school) | Medium | | 1987 | [Number of Unique Good Subsequences](https://leetcode.com/problems/number-of-unique-good-subsequences "不同的好子序列数目") | [Go](problems/number-of-unique-good-subsequences) | Hard | | 1986 | [Minimum Number of Work Sessions to Finish the Tasks](https://leetcode.com/problems/minimum-number-of-work-sessions-to-finish-the-tasks "完成任务的最少工作时间段") | [Go](problems/minimum-number-of-work-sessions-to-finish-the-tasks) | Medium | | 1985 | [Find the Kth Largest Integer in the Array](https://leetcode.com/problems/find-the-kth-largest-integer-in-the-array "找出数组中的第 K 大整数") | [Go](problems/find-the-kth-largest-integer-in-the-array) | Medium | @@ -184,19 +281,19 @@ LeetCode Problems' Solutions | 1981 | [Minimize the Difference Between Target and Chosen Elements](https://leetcode.com/problems/minimize-the-difference-between-target-and-chosen-elements "最小化目标值与所选元素的差") | [Go](problems/minimize-the-difference-between-target-and-chosen-elements) | Medium | | 1980 | [Find Unique Binary String](https://leetcode.com/problems/find-unique-binary-string "找出不同的二进制字符串") | [Go](problems/find-unique-binary-string) | Medium | | 1979 | [Find Greatest Common Divisor of Array](https://leetcode.com/problems/find-greatest-common-divisor-of-array "找出数组的最大公约数") | [Go](problems/find-greatest-common-divisor-of-array) | Easy | -| 1978 | [Employees Whose Manager Left the Company](https://leetcode.com/problems/employees-whose-manager-left-the-company) 🔒 | [MySQL](problems/employees-whose-manager-left-the-company) | Easy | +| 1978 | [Employees Whose Manager Left the Company](https://leetcode.com/problems/employees-whose-manager-left-the-company "上级经理已离职的公司员工") 🔒 | [MySQL](problems/employees-whose-manager-left-the-company) | Easy | | 1977 | [Number of Ways to Separate Numbers](https://leetcode.com/problems/number-of-ways-to-separate-numbers "划分数字的方案数") | [Go](problems/number-of-ways-to-separate-numbers) | Hard | | 1976 | [Number of Ways to Arrive at Destination](https://leetcode.com/problems/number-of-ways-to-arrive-at-destination "到达目的地的方案数") | [Go](problems/number-of-ways-to-arrive-at-destination) | Medium | | 1975 | [Maximum Matrix Sum](https://leetcode.com/problems/maximum-matrix-sum "最大方阵和") | [Go](problems/maximum-matrix-sum) | Medium | | 1974 | [Minimum Time to Type Word Using Special Typewriter](https://leetcode.com/problems/minimum-time-to-type-word-using-special-typewriter "使用特殊打字机键入单词的最少时间") | [Go](problems/minimum-time-to-type-word-using-special-typewriter) | Easy | -| 1973 | [Count Nodes Equal to Sum of Descendants](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants) 🔒 | [Go](problems/count-nodes-equal-to-sum-of-descendants) | Medium | -| 1972 | [First and Last Call On the Same Day](https://leetcode.com/problems/first-and-last-call-on-the-same-day) 🔒 | [MySQL](problems/first-and-last-call-on-the-same-day) | Hard | +| 1973 | [Count Nodes Equal to Sum of Descendants](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants "值等于子节点值之和的节点数量") 🔒 | [Go](problems/count-nodes-equal-to-sum-of-descendants) | Medium | +| 1972 | [First and Last Call On the Same Day](https://leetcode.com/problems/first-and-last-call-on-the-same-day "同一天的第一个电话和最后一个电话") 🔒 | [MySQL](problems/first-and-last-call-on-the-same-day) | Hard | | 1971 | [Find if Path Exists in Graph](https://leetcode.com/problems/find-if-path-exists-in-graph "寻找图中是否存在路径") | [Go](problems/find-if-path-exists-in-graph) | Easy | | 1970 | [Last Day Where You Can Still Cross](https://leetcode.com/problems/last-day-where-you-can-still-cross "你能穿过矩阵的最后一天") | [Go](problems/last-day-where-you-can-still-cross) | Hard | | 1969 | [Minimum Non-Zero Product of the Array Elements](https://leetcode.com/problems/minimum-non-zero-product-of-the-array-elements "数组元素的最小非零乘积") | [Go](problems/minimum-non-zero-product-of-the-array-elements) | Medium | | 1968 | [Array With Elements Not Equal to Average of Neighbors](https://leetcode.com/problems/array-with-elements-not-equal-to-average-of-neighbors "构造元素不等于两相邻元素平均值的数组") | [Go](problems/array-with-elements-not-equal-to-average-of-neighbors) | Medium | | 1967 | [Number of Strings That Appear as Substrings in Word](https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word "作为子字符串出现在单词中的字符串数目") | [Go](problems/number-of-strings-that-appear-as-substrings-in-word) | Easy | -| 1966 | [Binary Searchable Numbers in an Unsorted Array](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array) 🔒 | [Go](problems/binary-searchable-numbers-in-an-unsorted-array) | Medium | +| 1966 | [Binary Searchable Numbers in an Unsorted Array](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array "未排序数组中的可被二分搜索的数") 🔒 | [Go](problems/binary-searchable-numbers-in-an-unsorted-array) | Medium | | 1965 | [Employees With Missing Information](https://leetcode.com/problems/employees-with-missing-information "丢失信息的雇员") 🔒 | [MySQL](problems/employees-with-missing-information) | Easy | | 1964 | [Find the Longest Valid Obstacle Course at Each Position](https://leetcode.com/problems/find-the-longest-valid-obstacle-course-at-each-position "找出到每个位置为止最长的有效障碍赛跑路线") | [Go](problems/find-the-longest-valid-obstacle-course-at-each-position) | Hard | | 1963 | [Minimum Number of Swaps to Make the String Balanced](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-string-balanced "使字符串平衡的最小交换次数") | [Go](problems/minimum-number-of-swaps-to-make-the-string-balanced) | Medium | @@ -213,7 +310,7 @@ LeetCode Problems' Solutions | 1952 | [Three Divisors](https://leetcode.com/problems/three-divisors "三除数") | [Go](problems/three-divisors) | Easy | | 1951 | [All the Pairs With the Maximum Number of Common Followers](https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers "查询具有最多共同关注者的所有两两结对组") 🔒 | [MySQL](problems/all-the-pairs-with-the-maximum-number-of-common-followers) | Medium | | 1950 | [Maximum of Minimum Values in All Subarrays](https://leetcode.com/problems/maximum-of-minimum-values-in-all-subarrays "所有子数组最小值中的最大值") 🔒 | [Go](problems/maximum-of-minimum-values-in-all-subarrays) | Medium | -| 1949 | [Strong Friendship](https://leetcode.com/problems/strong-friendship) 🔒 | [MySQL](problems/strong-friendship) | Medium | +| 1949 | [Strong Friendship](https://leetcode.com/problems/strong-friendship "坚定的友谊") 🔒 | [MySQL](problems/strong-friendship) | Medium | | 1948 | [Delete Duplicate Folders in System](https://leetcode.com/problems/delete-duplicate-folders-in-system "删除系统中的重复文件夹") | [Go](problems/delete-duplicate-folders-in-system) | Hard | | 1947 | [Maximum Compatibility Score Sum](https://leetcode.com/problems/maximum-compatibility-score-sum "最大兼容性评分和") | [Go](problems/maximum-compatibility-score-sum) | Medium | | 1946 | [Largest Number After Mutating Substring](https://leetcode.com/problems/largest-number-after-mutating-substring "子字符串突变后可能得到的最大整数") | [Go](problems/largest-number-after-mutating-substring) | Medium | @@ -223,7 +320,7 @@ LeetCode Problems' Solutions | 1942 | [The Number of the Smallest Unoccupied Chair](https://leetcode.com/problems/the-number-of-the-smallest-unoccupied-chair "最小未被占据椅子的编号") | [Go](problems/the-number-of-the-smallest-unoccupied-chair) | Medium | | 1941 | [Check if All Characters Have Equal Number of Occurrences](https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences "检查是否所有字符出现次数相同") | [Go](problems/check-if-all-characters-have-equal-number-of-occurrences) | Easy | | 1940 | [Longest Common Subsequence Between Sorted Arrays](https://leetcode.com/problems/longest-common-subsequence-between-sorted-arrays "排序数组之间的最长公共子序列") 🔒 | [Go](problems/longest-common-subsequence-between-sorted-arrays) | Medium | -| 1939 | [Users That Actively Request Confirmation Messages](https://leetcode.com/problems/users-that-actively-request-confirmation-messages) 🔒 | [MySQL](problems/users-that-actively-request-confirmation-messages) | Easy | +| 1939 | [Users That Actively Request Confirmation Messages](https://leetcode.com/problems/users-that-actively-request-confirmation-messages "主动请求确认消息的用户") 🔒 | [MySQL](problems/users-that-actively-request-confirmation-messages) | Easy | | 1938 | [Maximum Genetic Difference Query](https://leetcode.com/problems/maximum-genetic-difference-query "查询最大基因差") | [Go](problems/maximum-genetic-difference-query) | Hard | | 1937 | [Maximum Number of Points with Cost](https://leetcode.com/problems/maximum-number-of-points-with-cost "扣分后的最大得分") | [Go](problems/maximum-number-of-points-with-cost) | Medium | | 1936 | [Add Minimum Number of Rungs](https://leetcode.com/problems/add-minimum-number-of-rungs "新增的最少台阶数") | [Go](problems/add-minimum-number-of-rungs) | Medium | @@ -238,14 +335,14 @@ LeetCode Problems' Solutions | 1927 | [Sum Game](https://leetcode.com/problems/sum-game "求和游戏") | [Go](problems/sum-game) | Medium | | 1926 | [Nearest Exit from Entrance in Maze](https://leetcode.com/problems/nearest-exit-from-entrance-in-maze "迷宫中离入口最近的出口") | [Go](problems/nearest-exit-from-entrance-in-maze) | Medium | | 1925 | [Count Square Sum Triples](https://leetcode.com/problems/count-square-sum-triples "统计平方和三元组的数目") | [Go](problems/count-square-sum-triples) | Easy | -| 1924 | [Erect the Fence II](https://leetcode.com/problems/erect-the-fence-ii) 🔒 | [Go](problems/erect-the-fence-ii) | Hard | +| 1924 | [Erect the Fence II](https://leetcode.com/problems/erect-the-fence-ii "安装栅栏 II") 🔒 | [Go](problems/erect-the-fence-ii) | Hard | | 1923 | [Longest Common Subpath](https://leetcode.com/problems/longest-common-subpath "最长公共子路径") | [Go](problems/longest-common-subpath) | Hard | | 1922 | [Count Good Numbers](https://leetcode.com/problems/count-good-numbers "统计好数字的数目") | [Go](problems/count-good-numbers) | Medium | | 1921 | [Eliminate Maximum Number of Monsters](https://leetcode.com/problems/eliminate-maximum-number-of-monsters "消灭怪物的最大数量") | [Go](problems/eliminate-maximum-number-of-monsters) | Medium | | 1920 | [Build Array from Permutation](https://leetcode.com/problems/build-array-from-permutation "基于排列构建数组") | [Go](problems/build-array-from-permutation) | Easy | | 1919 | [Leetcodify Similar Friends](https://leetcode.com/problems/leetcodify-similar-friends "兴趣相同的朋友") 🔒 | [MySQL](problems/leetcodify-similar-friends) | Hard | | 1918 | [Kth Smallest Subarray Sum](https://leetcode.com/problems/kth-smallest-subarray-sum "第 K 小的子数组和·") 🔒 | [Go](problems/kth-smallest-subarray-sum) | Medium | -| 1917 | [Leetcodify Friends Recommendations](https://leetcode.com/problems/leetcodify-friends-recommendations) 🔒 | [MySQL](problems/leetcodify-friends-recommendations) | Hard | +| 1917 | [Leetcodify Friends Recommendations](https://leetcode.com/problems/leetcodify-friends-recommendations "Leetcodify 好友推荐") 🔒 | [MySQL](problems/leetcodify-friends-recommendations) | Hard | | 1916 | [Count Ways to Build Rooms in an Ant Colony](https://leetcode.com/problems/count-ways-to-build-rooms-in-an-ant-colony "统计为蚁群构筑房间的不同顺序") | [Go](problems/count-ways-to-build-rooms-in-an-ant-colony) | Hard | | 1915 | [Number of Wonderful Substrings](https://leetcode.com/problems/number-of-wonderful-substrings "最美子字符串的数目") | [Go](problems/number-of-wonderful-substrings) | Medium | | 1914 | [Cyclically Rotating a Grid](https://leetcode.com/problems/cyclically-rotating-a-grid "循环轮转矩阵") | [Go](problems/cyclically-rotating-a-grid) | Medium | @@ -260,7 +357,7 @@ LeetCode Problems' Solutions | 1905 | [Count Sub Islands](https://leetcode.com/problems/count-sub-islands "统计子岛屿") | [Go](problems/count-sub-islands) | Medium | | 1904 | [The Number of Full Rounds You Have Played](https://leetcode.com/problems/the-number-of-full-rounds-you-have-played "你完成的完整对局数") | [Go](problems/the-number-of-full-rounds-you-have-played) | Medium | | 1903 | [Largest Odd Number in String](https://leetcode.com/problems/largest-odd-number-in-string "字符串中的最大奇数") | [Go](problems/largest-odd-number-in-string) | Easy | -| 1902 | [Depth of BST Given Insertion Order](https://leetcode.com/problems/depth-of-bst-given-insertion-order) 🔒 | [Go](problems/depth-of-bst-given-insertion-order) | Medium | +| 1902 | [Depth of BST Given Insertion Order](https://leetcode.com/problems/depth-of-bst-given-insertion-order "给定二叉搜索树的插入顺序求深度") 🔒 | [Go](problems/depth-of-bst-given-insertion-order) | Medium | | 1901 | [Find a Peak Element II](https://leetcode.com/problems/find-a-peak-element-ii "找出顶峰元素 II") | [Go](problems/find-a-peak-element-ii) | Medium | | 1900 | [The Earliest and Latest Rounds Where Players Compete](https://leetcode.com/problems/the-earliest-and-latest-rounds-where-players-compete "最佳运动员的比拼回合") | [Go](problems/the-earliest-and-latest-rounds-where-players-compete) | Hard | | 1899 | [Merge Triplets to Form Target Triplet](https://leetcode.com/problems/merge-triplets-to-form-target-triplet "合并若干三元组以形成目标三元组") | [Go](problems/merge-triplets-to-form-target-triplet) | Medium | @@ -277,7 +374,7 @@ LeetCode Problems' Solutions | 1888 | [Minimum Number of Flips to Make the Binary String Alternating](https://leetcode.com/problems/minimum-number-of-flips-to-make-the-binary-string-alternating "使二进制字符串字符交替的最少反转次数") | [Go](problems/minimum-number-of-flips-to-make-the-binary-string-alternating) | Medium | | 1887 | [Reduction Operations to Make the Array Elements Equal](https://leetcode.com/problems/reduction-operations-to-make-the-array-elements-equal "使数组元素相等的减少操作次数") | [Go](problems/reduction-operations-to-make-the-array-elements-equal) | Medium | | 1886 | [Determine Whether Matrix Can Be Obtained By Rotation](https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation "判断矩阵经轮转后是否一致") | [Go](problems/determine-whether-matrix-can-be-obtained-by-rotation) | Easy | -| 1885 | [Count Pairs in Two Arrays](https://leetcode.com/problems/count-pairs-in-two-arrays) 🔒 | [Go](problems/count-pairs-in-two-arrays) | Medium | +| 1885 | [Count Pairs in Two Arrays](https://leetcode.com/problems/count-pairs-in-two-arrays "统计数对") 🔒 | [Go](problems/count-pairs-in-two-arrays) | Medium | | 1884 | [Egg Drop With 2 Eggs and N Floors](https://leetcode.com/problems/egg-drop-with-2-eggs-and-n-floors "鸡蛋掉落-两枚鸡蛋") | [Go](problems/egg-drop-with-2-eggs-and-n-floors) | Medium | | 1883 | [Minimum Skips to Arrive at Meeting On Time](https://leetcode.com/problems/minimum-skips-to-arrive-at-meeting-on-time "准时抵达会议现场的最小跳过休息次数") | [Go](problems/minimum-skips-to-arrive-at-meeting-on-time) | Hard | | 1882 | [Process Tasks Using Servers](https://leetcode.com/problems/process-tasks-using-servers "使用服务器处理任务") | [Go](problems/process-tasks-using-servers) | Medium | @@ -287,7 +384,7 @@ LeetCode Problems' Solutions | 1878 | [Get Biggest Three Rhombus Sums in a Grid](https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid "矩阵中最大的三个菱形和") | [Go](problems/get-biggest-three-rhombus-sums-in-a-grid) | Medium | | 1877 | [Minimize Maximum Pair Sum in Array](https://leetcode.com/problems/minimize-maximum-pair-sum-in-array "数组中最大数对和的最小值") | [Go](problems/minimize-maximum-pair-sum-in-array) | Medium | | 1876 | [Substrings of Size Three with Distinct Characters](https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters "长度为三且各字符不同的子字符串") | [Go](problems/substrings-of-size-three-with-distinct-characters) | Easy | -| 1875 | [Group Employees of the Same Salary](https://leetcode.com/problems/group-employees-of-the-same-salary) 🔒 | [MySQL](problems/group-employees-of-the-same-salary) | Medium | +| 1875 | [Group Employees of the Same Salary](https://leetcode.com/problems/group-employees-of-the-same-salary "将工资相同的雇员分组") 🔒 | [MySQL](problems/group-employees-of-the-same-salary) | Medium | | 1874 | [Minimize Product Sum of Two Arrays](https://leetcode.com/problems/minimize-product-sum-of-two-arrays "两个数组的最小乘积和") 🔒 | [Go](problems/minimize-product-sum-of-two-arrays) | Medium | | 1873 | [Calculate Special Bonus](https://leetcode.com/problems/calculate-special-bonus "计算特殊奖金") 🔒 | [MySQL](problems/calculate-special-bonus) | Easy | | 1872 | [Stone Game VIII](https://leetcode.com/problems/stone-game-viii "石子游戏 VIII") | [Go](problems/stone-game-viii) | Hard | @@ -295,7 +392,7 @@ LeetCode Problems' Solutions | 1870 | [Minimum Speed to Arrive on Time](https://leetcode.com/problems/minimum-speed-to-arrive-on-time "准时到达的列车最小时速") | [Go](problems/minimum-speed-to-arrive-on-time) | Medium | | 1869 | [Longer Contiguous Segments of Ones than Zeros](https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros "哪种连续子字符串更长") | [Go](problems/longer-contiguous-segments-of-ones-than-zeros) | Easy | | 1868 | [Product of Two Run-Length Encoded Arrays](https://leetcode.com/problems/product-of-two-run-length-encoded-arrays "两个行程编码数组的积") 🔒 | [Go](problems/product-of-two-run-length-encoded-arrays) | Medium | -| 1867 | [Orders With Maximum Quantity Above Average](https://leetcode.com/problems/orders-with-maximum-quantity-above-average) 🔒 | [MySQL](problems/orders-with-maximum-quantity-above-average) | Medium | +| 1867 | [Orders With Maximum Quantity Above Average](https://leetcode.com/problems/orders-with-maximum-quantity-above-average "最大数量高于平均水平的订单") 🔒 | [MySQL](problems/orders-with-maximum-quantity-above-average) | Medium | | 1866 | [Number of Ways to Rearrange Sticks With K Sticks Visible](https://leetcode.com/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible "恰有 K 根木棍可以看到的排列数目") | [Go](problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible) | Hard | | 1865 | [Finding Pairs With a Certain Sum](https://leetcode.com/problems/finding-pairs-with-a-certain-sum "找出和为指定值的下标对") | [Go](problems/finding-pairs-with-a-certain-sum) | Medium | | 1864 | [Minimum Number of Swaps to Make the Binary String Alternating](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating "构成交替字符串需要的最小交换次数") | [Go](problems/minimum-number-of-swaps-to-make-the-binary-string-alternating) | Medium | @@ -319,7 +416,7 @@ LeetCode Problems' Solutions | 1846 | [Maximum Element After Decreasing and Rearranging](https://leetcode.com/problems/maximum-element-after-decreasing-and-rearranging "减小和重新排列数组后的最大元素") | [Go](problems/maximum-element-after-decreasing-and-rearranging) | Medium | | 1845 | [Seat Reservation Manager](https://leetcode.com/problems/seat-reservation-manager "座位预约管理系统") | [Go](problems/seat-reservation-manager) | Medium | | 1844 | [Replace All Digits with Characters](https://leetcode.com/problems/replace-all-digits-with-characters "将所有数字用字符替换") | [Go](problems/replace-all-digits-with-characters) | Easy | -| 1843 | [Suspicious Bank Accounts](https://leetcode.com/problems/suspicious-bank-accounts) 🔒 | [MySQL](problems/suspicious-bank-accounts) | Medium | +| 1843 | [Suspicious Bank Accounts](https://leetcode.com/problems/suspicious-bank-accounts "可疑银行账户") 🔒 | [MySQL](problems/suspicious-bank-accounts) | Medium | | 1842 | [Next Palindrome Using Same Digits](https://leetcode.com/problems/next-palindrome-using-same-digits "下个由相同数字构成的回文串") 🔒 | [Go](problems/next-palindrome-using-same-digits) | Hard | | 1841 | [League Statistics](https://leetcode.com/problems/league-statistics "联赛信息统计") 🔒 | [MySQL](problems/league-statistics) | Medium | | 1840 | [Maximum Building Height](https://leetcode.com/problems/maximum-building-height "最高建筑高度") | [Go](problems/maximum-building-height) | Hard | @@ -362,303 +459,3 @@ LeetCode Problems' Solutions | 1803 | [Count Pairs With XOR in a Range](https://leetcode.com/problems/count-pairs-with-xor-in-a-range "统计异或值在范围内的数对有多少") | [Go](problems/count-pairs-with-xor-in-a-range) | Hard | | 1802 | [Maximum Value at a Given Index in a Bounded Array](https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array "有界数组中指定下标处的最大值") | [Go](problems/maximum-value-at-a-given-index-in-a-bounded-array) | Medium | | 1801 | [Number of Orders in the Backlog](https://leetcode.com/problems/number-of-orders-in-the-backlog "积压订单中的订单总数") | [Go](problems/number-of-orders-in-the-backlog) | Medium | -| 1800 | [Maximum Ascending Subarray Sum](https://leetcode.com/problems/maximum-ascending-subarray-sum "最大升序子数组和") | [Go](problems/maximum-ascending-subarray-sum) | Easy | -| 1799 | [Maximize Score After N Operations](https://leetcode.com/problems/maximize-score-after-n-operations "N 次操作后的最大分数和") | [Go](problems/maximize-score-after-n-operations) | Hard | -| 1798 | [Maximum Number of Consecutive Values You Can Make](https://leetcode.com/problems/maximum-number-of-consecutive-values-you-can-make "你能构造出连续值的最大数目") | [Go](problems/maximum-number-of-consecutive-values-you-can-make) | Medium | -| 1797 | [Design Authentication Manager](https://leetcode.com/problems/design-authentication-manager "设计一个验证系统") | [Go](problems/design-authentication-manager) | Medium | -| 1796 | [Second Largest Digit in a String](https://leetcode.com/problems/second-largest-digit-in-a-string "字符串中第二大的数字") | [Go](problems/second-largest-digit-in-a-string) | Easy | -| 1795 | [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table "每个产品在不同商店的价格") 🔒 | [MySQL](problems/rearrange-products-table) | Easy | -| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "统计距离最小的子串对个数") 🔒 | [Go](problems/count-pairs-of-equal-substrings-with-minimum-difference) | Medium | -| 1793 | [Maximum Score of a Good Subarray](https://leetcode.com/problems/maximum-score-of-a-good-subarray "好子数组的最大分数") | [Go](problems/maximum-score-of-a-good-subarray) | Hard | -| 1792 | [Maximum Average Pass Ratio](https://leetcode.com/problems/maximum-average-pass-ratio "最大平均通过率") | [Go](problems/maximum-average-pass-ratio) | Medium | -| 1791 | [Find Center of Star Graph](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") | [Go](problems/find-center-of-star-graph) | Easy | -| 1790 | [Check if One String Swap Can Make Strings Equal](https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal "仅执行一次字符串交换能否使两个字符串相等") | [Go](problems/check-if-one-string-swap-can-make-strings-equal) | Easy | -| 1789 | [Primary Department for Each Employee](https://leetcode.com/problems/primary-department-for-each-employee "员工的直属部门") 🔒 | [MySQL](problems/primary-department-for-each-employee) | Easy | -| 1788 | [Maximize the Beauty of the Garden](https://leetcode.com/problems/maximize-the-beauty-of-the-garden "最大化花园的美观度") 🔒 | [Go](problems/maximize-the-beauty-of-the-garden) | Hard | -| 1787 | [Make the XOR of All Segments Equal to Zero](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零") | [Go](problems/make-the-xor-of-all-segments-equal-to-zero) | Hard | -| 1786 | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](problems/number-of-restricted-paths-from-first-to-last-node) | Medium | -| 1785 | [Minimum Elements to Add to Form a Given Sum](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素") | [Go](problems/minimum-elements-to-add-to-form-a-given-sum) | Medium | -| 1784 | [Check if Binary String Has at Most One Segment of Ones](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones "检查二进制字符串字段") | [Go](problems/check-if-binary-string-has-at-most-one-segment-of-ones) | Easy | -| 1783 | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles "大满贯数量") 🔒 | [MySQL](problems/grand-slam-titles) | Medium | -| 1782 | [Count Pairs Of Nodes](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") | [Go](problems/count-pairs-of-nodes) | Hard | -| 1781 | [Sum of Beauty of All Substrings](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和") | [Go](problems/sum-of-beauty-of-all-substrings) | Medium | -| 1780 | [Check if Number is a Sum of Powers of Three](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和") | [Go](problems/check-if-number-is-a-sum-of-powers-of-three) | Medium | -| 1779 | [Find Nearest Point That Has the Same X or Y Coordinate](https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate "找到最近的有相同 X 或 Y 坐标的点") | [Go](problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | Easy | -| 1778 | [Shortest Path in a Hidden Grid](https://leetcode.com/problems/shortest-path-in-a-hidden-grid "未知网格中的最短路径") 🔒 | [Go](problems/shortest-path-in-a-hidden-grid) | Medium | -| 1777 | [Product's Price for Each Store](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") 🔒 | [MySQL](problems/products-price-for-each-store) | Easy | -| 1776 | [Car Fleet II](https://leetcode.com/problems/car-fleet-ii "车队 II") | [Go](problems/car-fleet-ii) | Hard | -| 1775 | [Equal Sum Arrays With Minimum Number of Operations](https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations "通过最少操作次数使数组的和相等") | [Go](problems/equal-sum-arrays-with-minimum-number-of-operations) | Medium | -| 1774 | [Closest Dessert Cost](https://leetcode.com/problems/closest-dessert-cost "最接近目标价格的甜点成本") | [Go](problems/closest-dessert-cost) | Medium | -| 1773 | [Count Items Matching a Rule](https://leetcode.com/problems/count-items-matching-a-rule "统计匹配检索规则的物品数量") | [Go](problems/count-items-matching-a-rule) | Easy | -| 1772 | [Sort Features by Popularity](https://leetcode.com/problems/sort-features-by-popularity "按受欢迎程度排列功能") 🔒 | [Go](problems/sort-features-by-popularity) | Medium | -| 1771 | [Maximize Palindrome Length From Subsequences](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度") | [Go](problems/maximize-palindrome-length-from-subsequences) | Hard | -| 1770 | [Maximum Score from Performing Multiplication Operations](https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations "执行乘法运算的最大分数") | [Go](problems/maximum-score-from-performing-multiplication-operations) | Medium | -| 1769 | [Minimum Number of Operations to Move All Balls to Each Box](https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box "移动所有球到每个盒子所需的最小操作数") | [Go](problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | Medium | -| 1768 | [Merge Strings Alternately](https://leetcode.com/problems/merge-strings-alternately "交替合并字符串") | [Go](problems/merge-strings-alternately) | Easy | -| 1767 | [Find the Subtasks That Did Not Execute](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute "寻找没有被执行的任务对") 🔒 | [MySQL](problems/find-the-subtasks-that-did-not-execute) | Hard | -| 1766 | [Tree of Coprimes](https://leetcode.com/problems/tree-of-coprimes "互质树") | [Go](problems/tree-of-coprimes) | Hard | -| 1765 | [Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak "地图中的最高点") | [Go](problems/map-of-highest-peak) | Medium | -| 1764 | [Form Array by Concatenating Subarrays of Another Array](https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array "通过连接另一个数组的子数组得到一个数组") | [Go](problems/form-array-by-concatenating-subarrays-of-another-array) | Medium | -| 1763 | [Longest Nice Substring](https://leetcode.com/problems/longest-nice-substring "最长的美好子字符串") | [Go](problems/longest-nice-substring) | Easy | -| 1762 | [Buildings With an Ocean View](https://leetcode.com/problems/buildings-with-an-ocean-view "能看到海景的建筑物") 🔒 | [Go](problems/buildings-with-an-ocean-view) | Medium | -| 1761 | [Minimum Degree of a Connected Trio in a Graph](https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph "一个图中连通三元组的最小度数") | [Go](problems/minimum-degree-of-a-connected-trio-in-a-graph) | Hard | -| 1760 | [Minimum Limit of Balls in a Bag](https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag "袋子里最少数目的球") | [Go](problems/minimum-limit-of-balls-in-a-bag) | Medium | -| 1759 | [Count Number of Homogenous Substrings](https://leetcode.com/problems/count-number-of-homogenous-substrings "统计同构子字符串的数目") | [Go](problems/count-number-of-homogenous-substrings) | Medium | -| 1758 | [Minimum Changes To Make Alternating Binary String](https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string "生成交替二进制字符串的最少操作数") | [Go](problems/minimum-changes-to-make-alternating-binary-string) | Easy | -| 1757 | [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products "可回收且低脂的产品") 🔒 | [MySQL](problems/recyclable-and-low-fat-products) | Easy | -| 1756 | [Design Most Recently Used Queue](https://leetcode.com/problems/design-most-recently-used-queue "设计最近使用(MRU)队列") 🔒 | [Go](problems/design-most-recently-used-queue) | Medium | -| 1755 | [Closest Subsequence Sum](https://leetcode.com/problems/closest-subsequence-sum "最接近目标值的子序列和") | [Go](problems/closest-subsequence-sum) | Hard | -| 1754 | [Largest Merge Of Two Strings](https://leetcode.com/problems/largest-merge-of-two-strings "构造字典序最大的合并字符串") | [Go](problems/largest-merge-of-two-strings) | Medium | -| 1753 | [Maximum Score From Removing Stones](https://leetcode.com/problems/maximum-score-from-removing-stones "移除石子的最大得分") | [Go](problems/maximum-score-from-removing-stones) | Medium | -| 1752 | [Check if Array Is Sorted and Rotated](https://leetcode.com/problems/check-if-array-is-sorted-and-rotated "检查数组是否经排序和轮转得到") | [Go](problems/check-if-array-is-sorted-and-rotated) | Easy | -| 1751 | [Maximum Number of Events That Can Be Attended II](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended-ii "最多可以参加的会议数目 II") | [Go](problems/maximum-number-of-events-that-can-be-attended-ii) | Hard | -| 1750 | [Minimum Length of String After Deleting Similar Ends](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends "删除字符串两端相同字符后的最短长度") | [Go](problems/minimum-length-of-string-after-deleting-similar-ends) | Medium | -| 1749 | [Maximum Absolute Sum of Any Subarray](https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray "任意子数组和的绝对值的最大值") | [Go](problems/maximum-absolute-sum-of-any-subarray) | Medium | -| 1748 | [Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements "唯一元素的和") | [Go](problems/sum-of-unique-elements) | Easy | -| 1747 | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts "应该被禁止的Leetflex账户") 🔒 | [MySQL](problems/leetflex-banned-accounts) | Medium | -| 1746 | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation "经过一次操作后的最大子数组和") 🔒 | [Go](problems/maximum-subarray-sum-after-one-operation) | Medium | -| 1745 | [Palindrome Partitioning IV](https://leetcode.com/problems/palindrome-partitioning-iv "回文串分割 IV") | [Go](problems/palindrome-partitioning-iv) | Hard | -| 1744 | [Can You Eat Your Favorite Candy on Your Favorite Day?](https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day "你能在你最喜欢的那天吃到你最喜欢的糖果吗?") | [Go](problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | Medium | -| 1743 | [Restore the Array From Adjacent Pairs](https://leetcode.com/problems/restore-the-array-from-adjacent-pairs "从相邻元素对还原数组") | [Go](problems/restore-the-array-from-adjacent-pairs) | Medium | -| 1742 | [Maximum Number of Balls in a Box](https://leetcode.com/problems/maximum-number-of-balls-in-a-box "盒子中小球的最大数量") | [Go](problems/maximum-number-of-balls-in-a-box) | Easy | -| 1741 | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee "查找每个员工花费的总时间") 🔒 | [MySQL](problems/find-total-time-spent-by-each-employee) | Easy | -| 1740 | [Find Distance in a Binary Tree](https://leetcode.com/problems/find-distance-in-a-binary-tree "找到二叉树中的距离") 🔒 | [Go](problems/find-distance-in-a-binary-tree) | Medium | -| 1739 | [Building Boxes](https://leetcode.com/problems/building-boxes "放置盒子") | [Go](problems/building-boxes) | Hard | -| 1738 | [Find Kth Largest XOR Coordinate Value](https://leetcode.com/problems/find-kth-largest-xor-coordinate-value "找出第 K 大的异或坐标值") | [Go](problems/find-kth-largest-xor-coordinate-value) | Medium | -| 1737 | [Change Minimum Characters to Satisfy One of Three Conditions](https://leetcode.com/problems/change-minimum-characters-to-satisfy-one-of-three-conditions "满足三条件之一需改变的最少字符数") | [Go](problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | Medium | -| 1736 | [Latest Time by Replacing Hidden Digits](https://leetcode.com/problems/latest-time-by-replacing-hidden-digits "替换隐藏数字得到的最晚时间") | [Go](problems/latest-time-by-replacing-hidden-digits) | Easy | -| 1735 | [Count Ways to Make Array With Product](https://leetcode.com/problems/count-ways-to-make-array-with-product "生成乘积数组的方案数") | [Go](problems/count-ways-to-make-array-with-product) | Hard | -| 1734 | [Decode XORed Permutation](https://leetcode.com/problems/decode-xored-permutation "解码异或后的排列") | [Go](problems/decode-xored-permutation) | Medium | -| 1733 | [Minimum Number of People to Teach](https://leetcode.com/problems/minimum-number-of-people-to-teach "需要教语言的最少人数") | [Go](problems/minimum-number-of-people-to-teach) | Medium | -| 1732 | [Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude "找到最高海拔") | [Go](problems/find-the-highest-altitude) | Easy | -| 1731 | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee "每位经理的下属员工数量") 🔒 | [MySQL](problems/the-number-of-employees-which-report-to-each-employee) | Easy | -| 1730 | [Shortest Path to Get Food](https://leetcode.com/problems/shortest-path-to-get-food "获取食物的最短路径") 🔒 | [Go](problems/shortest-path-to-get-food) | Medium | -| 1729 | [Find Followers Count](https://leetcode.com/problems/find-followers-count "求关注者的数量") 🔒 | [MySQL](problems/find-followers-count) | Easy | -| 1728 | [Cat and Mouse II](https://leetcode.com/problems/cat-and-mouse-ii "猫和老鼠 II") | [Go](problems/cat-and-mouse-ii) | Hard | -| 1727 | [Largest Submatrix With Rearrangements](https://leetcode.com/problems/largest-submatrix-with-rearrangements "重新排列后的最大子矩阵") | [Go](problems/largest-submatrix-with-rearrangements) | Medium | -| 1726 | [Tuple with Same Product](https://leetcode.com/problems/tuple-with-same-product "同积元组") | [Go](problems/tuple-with-same-product) | Medium | -| 1725 | [Number Of Rectangles That Can Form The Largest Square](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square "可以形成最大正方形的矩形数目") | [Go](problems/number-of-rectangles-that-can-form-the-largest-square) | Easy | -| 1724 | [Checking Existence of Edge Length Limited Paths II](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii "检查边长度限制的路径是否存在 II") 🔒 | [Go](problems/checking-existence-of-edge-length-limited-paths-ii) | Hard | -| 1723 | [Find Minimum Time to Finish All Jobs](https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs "完成所有工作的最短时间") | [Go](problems/find-minimum-time-to-finish-all-jobs) | Hard | -| 1722 | [Minimize Hamming Distance After Swap Operations](https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations "执行交换操作后的最小汉明距离") | [Go](problems/minimize-hamming-distance-after-swap-operations) | Medium | -| 1721 | [Swapping Nodes in a Linked List](https://leetcode.com/problems/swapping-nodes-in-a-linked-list "交换链表中的节点") | [Go](problems/swapping-nodes-in-a-linked-list) | Medium | -| 1720 | [Decode XORed Array](https://leetcode.com/problems/decode-xored-array "解码异或后的数组") | [Go](problems/decode-xored-array) | Easy | -| 1719 | [Number Of Ways To Reconstruct A Tree](https://leetcode.com/problems/number-of-ways-to-reconstruct-a-tree "重构一棵树的方案数") | [Go](problems/number-of-ways-to-reconstruct-a-tree) | Hard | -| 1718 | [Construct the Lexicographically Largest Valid Sequence](https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence "构建字典序最大的可行序列") | [Go](problems/construct-the-lexicographically-largest-valid-sequence) | Medium | -| 1717 | [Maximum Score From Removing Substrings](https://leetcode.com/problems/maximum-score-from-removing-substrings "删除子字符串的最大得分") | [Go](problems/maximum-score-from-removing-substrings) | Medium | -| 1716 | [Calculate Money in Leetcode Bank](https://leetcode.com/problems/calculate-money-in-leetcode-bank "计算力扣银行的钱") | [Go](problems/calculate-money-in-leetcode-bank) | Easy | -| 1715 | [Count Apples and Oranges](https://leetcode.com/problems/count-apples-and-oranges "苹果和橘子的个数") 🔒 | [MySQL](problems/count-apples-and-oranges) | Medium | -| 1714 | [Sum Of Special Evenly-Spaced Elements In Array](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array "数组中特殊等间距元素的和") 🔒 | [Go](problems/sum-of-special-evenly-spaced-elements-in-array) | Hard | -| 1713 | [Minimum Operations to Make a Subsequence](https://leetcode.com/problems/minimum-operations-to-make-a-subsequence "得到子序列的最少操作次数") | [Go](problems/minimum-operations-to-make-a-subsequence) | Hard | -| 1712 | [Ways to Split Array Into Three Subarrays](https://leetcode.com/problems/ways-to-split-array-into-three-subarrays "将数组分成三个子数组的方案数") | [Go](problems/ways-to-split-array-into-three-subarrays) | Medium | -| 1711 | [Count Good Meals](https://leetcode.com/problems/count-good-meals "大餐计数") | [Go](problems/count-good-meals) | Medium | -| 1710 | [Maximum Units on a Truck](https://leetcode.com/problems/maximum-units-on-a-truck "卡车上的最大单元数") | [Go](problems/maximum-units-on-a-truck) | Easy | -| 1709 | [Biggest Window Between Visits](https://leetcode.com/problems/biggest-window-between-visits "访问日期之间最大的空档期") 🔒 | [MySQL](problems/biggest-window-between-visits) | Medium | -| 1708 | [Largest Subarray Length K](https://leetcode.com/problems/largest-subarray-length-k "长度为 K 的最大子数组") 🔒 | [Go](problems/largest-subarray-length-k) | Easy | -| 1707 | [Maximum XOR With an Element From Array](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") | [Go](problems/maximum-xor-with-an-element-from-array) | Hard | -| 1706 | [Where Will the Ball Fall](https://leetcode.com/problems/where-will-the-ball-fall "球会落何处") | [Go](problems/where-will-the-ball-fall) | Medium | -| 1705 | [Maximum Number of Eaten Apples](https://leetcode.com/problems/maximum-number-of-eaten-apples "吃苹果的最大数目") | [Go](problems/maximum-number-of-eaten-apples) | Medium | -| 1704 | [Determine if String Halves Are Alike](https://leetcode.com/problems/determine-if-string-halves-are-alike "判断字符串的两半是否相似") | [Go](problems/determine-if-string-halves-are-alike) | Easy | -| 1703 | [Minimum Adjacent Swaps for K Consecutive Ones](https://leetcode.com/problems/minimum-adjacent-swaps-for-k-consecutive-ones "得到连续 K 个 1 的最少相邻交换次数") | [Go](problems/minimum-adjacent-swaps-for-k-consecutive-ones) | Hard | -| 1702 | [Maximum Binary String After Change](https://leetcode.com/problems/maximum-binary-string-after-change "修改后的最大二进制字符串") | [Go](problems/maximum-binary-string-after-change) | Medium | -| 1701 | [Average Waiting Time](https://leetcode.com/problems/average-waiting-time "平均等待时间") | [Go](problems/average-waiting-time) | Medium | -| 1700 | [Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch "无法吃午餐的学生数量") | [Go](problems/number-of-students-unable-to-eat-lunch) | Easy | -| 1699 | [Number of Calls Between Two Persons](https://leetcode.com/problems/number-of-calls-between-two-persons "两人之间的通话次数") 🔒 | [MySQL](problems/number-of-calls-between-two-persons) | Medium | -| 1698 | [Number of Distinct Substrings in a String](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string "字符串的不同子字符串个数") 🔒 | [Go](problems/number-of-distinct-substrings-in-a-string) | Medium | -| 1697 | [Checking Existence of Edge Length Limited Paths](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths "检查边长度限制的路径是否存在") | [Go](problems/checking-existence-of-edge-length-limited-paths) | Hard | -| 1696 | [Jump Game VI](https://leetcode.com/problems/jump-game-vi "跳跃游戏 VI") | [Go](problems/jump-game-vi) | Medium | -| 1695 | [Maximum Erasure Value](https://leetcode.com/problems/maximum-erasure-value "删除子数组的最大得分") | [Go](problems/maximum-erasure-value) | Medium | -| 1694 | [Reformat Phone Number](https://leetcode.com/problems/reformat-phone-number "重新格式化电话号码") | [Go](problems/reformat-phone-number) | Easy | -| 1693 | [Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners "每天的领导和合伙人") 🔒 | [MySQL](problems/daily-leads-and-partners) | Easy | -| 1692 | [Count Ways to Distribute Candies](https://leetcode.com/problems/count-ways-to-distribute-candies "计算分配糖果的不同方式") 🔒 | [Go](problems/count-ways-to-distribute-candies) | Hard | -| 1691 | [Maximum Height by Stacking Cuboids](https://leetcode.com/problems/maximum-height-by-stacking-cuboids "堆叠长方体的最大高度") | [Go](problems/maximum-height-by-stacking-cuboids) | Hard | -| 1690 | [Stone Game VII](https://leetcode.com/problems/stone-game-vii "石子游戏 VII") | [Go](problems/stone-game-vii) | Medium | -| 1689 | [Partitioning Into Minimum Number Of Deci-Binary Numbers](https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers "十-二进制数的最少数目") | [Go](problems/partitioning-into-minimum-number-of-deci-binary-numbers) | Medium | -| 1688 | [Count of Matches in Tournament](https://leetcode.com/problems/count-of-matches-in-tournament "比赛中的配对次数") | [Go](problems/count-of-matches-in-tournament) | Easy | -| 1687 | [Delivering Boxes from Storage to Ports](https://leetcode.com/problems/delivering-boxes-from-storage-to-ports "从仓库到码头运输箱子") | [Go](problems/delivering-boxes-from-storage-to-ports) | Hard | -| 1686 | [Stone Game VI](https://leetcode.com/problems/stone-game-vi "石子游戏 VI") | [Go](problems/stone-game-vi) | Medium | -| 1685 | [Sum of Absolute Differences in a Sorted Array](https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array "有序数组中差绝对值之和") | [Go](problems/sum-of-absolute-differences-in-a-sorted-array) | Medium | -| 1684 | [Count the Number of Consistent Strings](https://leetcode.com/problems/count-the-number-of-consistent-strings "统计一致字符串的数目") | [Go](problems/count-the-number-of-consistent-strings) | Easy | -| 1683 | [Invalid Tweets](https://leetcode.com/problems/invalid-tweets "无效的推文") 🔒 | [MySQL](problems/invalid-tweets) | Easy | -| 1682 | [Longest Palindromic Subsequence II](https://leetcode.com/problems/longest-palindromic-subsequence-ii "最长回文子序列 II") 🔒 | [Go](problems/longest-palindromic-subsequence-ii) | Medium | -| 1681 | [Minimum Incompatibility](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") | [Go](problems/minimum-incompatibility) | Hard | -| 1680 | [Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers "连接连续二进制数字") | [Go](problems/concatenation-of-consecutive-binary-numbers) | Medium | -| 1679 | [Max Number of K-Sum Pairs](https://leetcode.com/problems/max-number-of-k-sum-pairs "K 和数对的最大数目") | [Go](problems/max-number-of-k-sum-pairs) | Medium | -| 1678 | [Goal Parser Interpretation](https://leetcode.com/problems/goal-parser-interpretation "设计 Goal 解析器") | [Go](problems/goal-parser-interpretation) | Easy | -| 1677 | [Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices "发票中的产品金额") 🔒 | [MySQL](problems/products-worth-over-invoices) | Easy | -| 1676 | [Lowest Common Ancestor of a Binary Tree IV](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv "二叉树的最近公共祖先 IV") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iv) | Medium | -| 1675 | [Minimize Deviation in Array](https://leetcode.com/problems/minimize-deviation-in-array "数组的最小偏移量") | [Go](problems/minimize-deviation-in-array) | Hard | -| 1674 | [Minimum Moves to Make Array Complementary](https://leetcode.com/problems/minimum-moves-to-make-array-complementary "使数组互补的最少操作次数") | [Go](problems/minimum-moves-to-make-array-complementary) | Medium | -| 1673 | [Find the Most Competitive Subsequence](https://leetcode.com/problems/find-the-most-competitive-subsequence "找出最具竞争力的子序列") | [Go](problems/find-the-most-competitive-subsequence) | Medium | -| 1672 | [Richest Customer Wealth](https://leetcode.com/problems/richest-customer-wealth "最富有客户的资产总量") | [Go](problems/richest-customer-wealth) | Easy | -| 1671 | [Minimum Number of Removals to Make Mountain Array](https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array "得到山形数组的最少删除次数") | [Go](problems/minimum-number-of-removals-to-make-mountain-array) | Hard | -| 1670 | [Design Front Middle Back Queue](https://leetcode.com/problems/design-front-middle-back-queue "设计前中后队列") | [Go](problems/design-front-middle-back-queue) | Medium | -| 1669 | [Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists "合并两个链表") | [Go](problems/merge-in-between-linked-lists) | Medium | -| 1668 | [Maximum Repeating Substring](https://leetcode.com/problems/maximum-repeating-substring "最大重复子字符串") | [Go](problems/maximum-repeating-substring) | Easy | -| 1667 | [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table "修复表中的名字") 🔒 | [MySQL](problems/fix-names-in-a-table) | Easy | -| 1666 | [Change the Root of a Binary Tree](https://leetcode.com/problems/change-the-root-of-a-binary-tree "改变二叉树的根节点") 🔒 | [Go](problems/change-the-root-of-a-binary-tree) | Medium | -| 1665 | [Minimum Initial Energy to Finish Tasks](https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks "完成所有任务的最少初始能量") | [Go](problems/minimum-initial-energy-to-finish-tasks) | Hard | -| 1664 | [Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array "生成平衡数组的方案数") | [Go](problems/ways-to-make-a-fair-array) | Medium | -| 1663 | [Smallest String With A Given Numeric Value](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value "具有给定数值的最小字符串") | [Go](problems/smallest-string-with-a-given-numeric-value) | Medium | -| 1662 | [Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent "检查两个字符串数组是否相等") | [Go](problems/check-if-two-string-arrays-are-equivalent) | Easy | -| 1661 | [Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine "每台机器的进程平均运行时间") 🔒 | [MySQL](problems/average-time-of-process-per-machine) | Easy | -| 1660 | [Correct a Binary Tree](https://leetcode.com/problems/correct-a-binary-tree "纠正二叉树") 🔒 | [Go](problems/correct-a-binary-tree) | Medium | -| 1659 | [Maximize Grid Happiness](https://leetcode.com/problems/maximize-grid-happiness "最大化网格幸福感") | [Go](problems/maximize-grid-happiness) | Hard | -| 1658 | [Minimum Operations to Reduce X to Zero](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero "将 x 减到 0 的最小操作数") | [Go](problems/minimum-operations-to-reduce-x-to-zero) | Medium | -| 1657 | [Determine if Two Strings Are Close](https://leetcode.com/problems/determine-if-two-strings-are-close "确定两个字符串是否接近") | [Go](problems/determine-if-two-strings-are-close) | Medium | -| 1656 | [Design an Ordered Stream](https://leetcode.com/problems/design-an-ordered-stream "设计有序流") | [Go](problems/design-an-ordered-stream) | Easy | -| 1655 | [Distribute Repeating Integers](https://leetcode.com/problems/distribute-repeating-integers "分配重复整数") | [Go](problems/distribute-repeating-integers) | Hard | -| 1654 | [Minimum Jumps to Reach Home](https://leetcode.com/problems/minimum-jumps-to-reach-home "到家的最少跳跃次数") | [Go](problems/minimum-jumps-to-reach-home) | Medium | -| 1653 | [Minimum Deletions to Make String Balanced](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced "使字符串平衡的最少删除次数") | [Go](problems/minimum-deletions-to-make-string-balanced) | Medium | -| 1652 | [Defuse the Bomb](https://leetcode.com/problems/defuse-the-bomb "拆炸弹") | [Go](problems/defuse-the-bomb) | Easy | -| 1651 | [Hopper Company Queries III](https://leetcode.com/problems/hopper-company-queries-iii) 🔒 | [MySQL](problems/hopper-company-queries-iii) | Hard | -| 1650 | [Lowest Common Ancestor of a Binary Tree III](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii "二叉树的最近公共祖先 III") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iii) | Medium | -| 1649 | [Create Sorted Array through Instructions](https://leetcode.com/problems/create-sorted-array-through-instructions "通过指令创建有序数组") | [Go](problems/create-sorted-array-through-instructions) | Hard | -| 1648 | [Sell Diminishing-Valued Colored Balls](https://leetcode.com/problems/sell-diminishing-valued-colored-balls "销售价值减少的颜色球") | [Go](problems/sell-diminishing-valued-colored-balls) | Medium | -| 1647 | [Minimum Deletions to Make Character Frequencies Unique](https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique "字符频次唯一的最小删除次数") | [Go](problems/minimum-deletions-to-make-character-frequencies-unique) | Medium | -| 1646 | [Get Maximum in Generated Array](https://leetcode.com/problems/get-maximum-in-generated-array "获取生成数组中的最大值") | [Go](problems/get-maximum-in-generated-array) | Easy | -| 1645 | [Hopper Company Queries II](https://leetcode.com/problems/hopper-company-queries-ii) 🔒 | [MySQL](problems/hopper-company-queries-ii) | Hard | -| 1644 | [Lowest Common Ancestor of a Binary Tree II](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii "二叉树的最近公共祖先 II") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-ii) | Medium | -| 1643 | [Kth Smallest Instructions](https://leetcode.com/problems/kth-smallest-instructions "第 K 条最小指令") | [Go](problems/kth-smallest-instructions) | Hard | -| 1642 | [Furthest Building You Can Reach](https://leetcode.com/problems/furthest-building-you-can-reach "可以到达的最远建筑") | [Go](problems/furthest-building-you-can-reach) | Medium | -| 1641 | [Count Sorted Vowel Strings](https://leetcode.com/problems/count-sorted-vowel-strings "统计字典序元音字符串的数目") | [Go](problems/count-sorted-vowel-strings) | Medium | -| 1640 | [Check Array Formation Through Concatenation](https://leetcode.com/problems/check-array-formation-through-concatenation "能否连接形成数组") | [Go](problems/check-array-formation-through-concatenation) | Easy | -| 1639 | [Number of Ways to Form a Target String Given a Dictionary](https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary "通过给定词典构造目标字符串的方案数") | [Go](problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | Hard | -| 1638 | [Count Substrings That Differ by One Character](https://leetcode.com/problems/count-substrings-that-differ-by-one-character "统计只差一个字符的子串数目") | [Go](problems/count-substrings-that-differ-by-one-character) | Medium | -| 1637 | [Widest Vertical Area Between Two Points Containing No Points](https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points "两点之间不包含任何点的最宽垂直面积") | [Go](problems/widest-vertical-area-between-two-points-containing-no-points) | Medium | -| 1636 | [Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency "按照频率将数组升序排序") | [Go](problems/sort-array-by-increasing-frequency) | Easy | -| 1635 | [Hopper Company Queries I](https://leetcode.com/problems/hopper-company-queries-i "Hopper 公司查询 I") 🔒 | [MySQL](problems/hopper-company-queries-i) | Hard | -| 1634 | [Add Two Polynomials Represented as Linked Lists](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists "求两个多项式链表的和") 🔒 | [Go](problems/add-two-polynomials-represented-as-linked-lists) | Medium | -| 1633 | [Percentage of Users Attended a Contest](https://leetcode.com/problems/percentage-of-users-attended-a-contest "各赛事的用户注册率") 🔒 | [MySQL](problems/percentage-of-users-attended-a-contest) | Easy | -| 1632 | [Rank Transform of a Matrix](https://leetcode.com/problems/rank-transform-of-a-matrix "矩阵转换后的秩") | [Go](problems/rank-transform-of-a-matrix) | Hard | -| 1631 | [Path With Minimum Effort](https://leetcode.com/problems/path-with-minimum-effort "最小体力消耗路径") | [Go](problems/path-with-minimum-effort) | Medium | -| 1630 | [Arithmetic Subarrays](https://leetcode.com/problems/arithmetic-subarrays "等差子数组") | [Go](problems/arithmetic-subarrays) | Medium | -| 1629 | [Slowest Key](https://leetcode.com/problems/slowest-key "按键持续时间最长的键") | [Go](problems/slowest-key) | Easy | -| 1628 | [Design an Expression Tree With Evaluate Function](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function "设计带解析函数的表达式树") 🔒 | [Go](problems/design-an-expression-tree-with-evaluate-function) | Medium | -| 1627 | [Graph Connectivity With Threshold](https://leetcode.com/problems/graph-connectivity-with-threshold "带阈值的图连通性") | [Go](problems/graph-connectivity-with-threshold) | Hard | -| 1626 | [Best Team With No Conflicts](https://leetcode.com/problems/best-team-with-no-conflicts "无矛盾的最佳球队") | [Go](problems/best-team-with-no-conflicts) | Medium | -| 1625 | [Lexicographically Smallest String After Applying Operations](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations "执行操作后字典序最小的字符串") | [Go](problems/lexicographically-smallest-string-after-applying-operations) | Medium | -| 1624 | [Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters "两个相同字符之间的最长子字符串") | [Go](problems/largest-substring-between-two-equal-characters) | Easy | -| 1623 | [All Valid Triplets That Can Represent a Country](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "三人国家代表队") 🔒 | [MySQL](problems/all-valid-triplets-that-can-represent-a-country) | Easy | -| 1622 | [Fancy Sequence](https://leetcode.com/problems/fancy-sequence "奇妙序列") | [Go](problems/fancy-sequence) | Hard | -| 1621 | [Number of Sets of K Non-Overlapping Line Segments](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments "大小为 K 的不重叠线段的数目") | [Go](problems/number-of-sets-of-k-non-overlapping-line-segments) | Medium | -| 1620 | [Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") | [Go](problems/coordinate-with-maximum-network-quality) | Medium | -| 1619 | [Mean of Array After Removing Some Elements](https://leetcode.com/problems/mean-of-array-after-removing-some-elements "删除某些元素后的数组均值") | [Go](problems/mean-of-array-after-removing-some-elements) | Easy | -| 1618 | [Maximum Font to Fit a Sentence in a Screen](https://leetcode.com/problems/maximum-font-to-fit-a-sentence-in-a-screen "找出适应屏幕的最大字号") 🔒 | [Go](problems/maximum-font-to-fit-a-sentence-in-a-screen) | Medium | -| 1617 | [Count Subtrees With Max Distance Between Cities](https://leetcode.com/problems/count-subtrees-with-max-distance-between-cities "统计子树中城市之间最大距离") | [Go](problems/count-subtrees-with-max-distance-between-cities) | Hard | -| 1616 | [Split Two Strings to Make Palindrome](https://leetcode.com/problems/split-two-strings-to-make-palindrome "分割两个字符串得到回文串") | [Go](problems/split-two-strings-to-make-palindrome) | Medium | -| 1615 | [Maximal Network Rank](https://leetcode.com/problems/maximal-network-rank "最大网络秩") | [Go](problems/maximal-network-rank) | Medium | -| 1614 | [Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses "括号的最大嵌套深度") | [Go](problems/maximum-nesting-depth-of-the-parentheses) | Easy | -| 1613 | [Find the Missing IDs](https://leetcode.com/problems/find-the-missing-ids "找到遗失的ID") 🔒 | [MySQL](problems/find-the-missing-ids) | Medium | -| 1612 | [Check If Two Expression Trees are Equivalent](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent "检查两棵二叉表达式树是否等价") 🔒 | [Go](problems/check-if-two-expression-trees-are-equivalent) | Medium | -| 1611 | [Minimum One Bit Operations to Make Integers Zero](https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero "使整数变为 0 的最少操作次数") | [Go](problems/minimum-one-bit-operations-to-make-integers-zero) | Hard | -| 1610 | [Maximum Number of Visible Points](https://leetcode.com/problems/maximum-number-of-visible-points "可见点的最大数目") | [Go](problems/maximum-number-of-visible-points) | Hard | -| 1609 | [Even Odd Tree](https://leetcode.com/problems/even-odd-tree "奇偶树") | [Go](problems/even-odd-tree) | Medium | -| 1608 | [Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x "特殊数组的特征值") | [Go](problems/special-array-with-x-elements-greater-than-or-equal-x) | Easy | -| 1607 | [Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales "没有卖出的卖家") 🔒 | [MySQL](problems/sellers-with-no-sales) | Easy | -| 1606 | [Find Servers That Handled Most Number of Requests](https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests "找到处理最多请求的服务器") | [Go](problems/find-servers-that-handled-most-number-of-requests) | Hard | -| 1605 | [Find Valid Matrix Given Row and Column Sums](https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums "给定行和列的和求可行矩阵") | [Go](problems/find-valid-matrix-given-row-and-column-sums) | Medium | -| 1604 | [Alert Using Same Key-Card Three or More Times in a One Hour Period](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "警告一小时内使用相同员工卡大于等于三次的人") | [Go](problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | Medium | -| 1603 | [Design Parking System](https://leetcode.com/problems/design-parking-system "设计停车系统") | [Go](problems/design-parking-system) | Easy | -| 1602 | [Find Nearest Right Node in Binary Tree](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree "找到二叉树中最近的右侧节点") 🔒 | [Go](problems/find-nearest-right-node-in-binary-tree) | Medium | -| 1601 | [Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") | [Go](problems/maximum-number-of-achievable-transfer-requests) | Hard | -| 1600 | [Throne Inheritance](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") | [Go](problems/throne-inheritance) | Medium | -| 1599 | [Maximum Profit of Operating a Centennial Wheel](https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel "经营摩天轮的最大利润") | [Go](problems/maximum-profit-of-operating-a-centennial-wheel) | Medium | -| 1598 | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") | [Go](problems/crawler-log-folder) | Easy | -| 1597 | [Build Binary Expression Tree From Infix Expression](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression "根据中缀表达式构造二叉表达式树") 🔒 | [Go](problems/build-binary-expression-tree-from-infix-expression) | Hard | -| 1596 | [The Most Frequently Ordered Products for Each Customer](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer "每位顾客最经常订购的商品") 🔒 | [MySQL](problems/the-most-frequently-ordered-products-for-each-customer) | Medium | -| 1595 | [Minimum Cost to Connect Two Groups of Points](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") | [Go](problems/minimum-cost-to-connect-two-groups-of-points) | Hard | -| 1594 | [Maximum Non Negative Product in a Matrix](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") | [Go](problems/maximum-non-negative-product-in-a-matrix) | Medium | -| 1593 | [Split a String Into the Max Number of Unique Substrings](https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings "拆分字符串使唯一子字符串的数目最大") | [Go](problems/split-a-string-into-the-max-number-of-unique-substrings) | Medium | -| 1592 | [Rearrange Spaces Between Words](https://leetcode.com/problems/rearrange-spaces-between-words "重新排列单词间的空格") | [Go](problems/rearrange-spaces-between-words) | Easy | -| 1591 | [Strange Printer II](https://leetcode.com/problems/strange-printer-ii "奇怪的打印机 II") | [Go](problems/strange-printer-ii) | Hard | -| 1590 | [Make Sum Divisible by P](https://leetcode.com/problems/make-sum-divisible-by-p "使数组和能被 P 整除") | [Go](problems/make-sum-divisible-by-p) | Medium | -| 1589 | [Maximum Sum Obtained of Any Permutation](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation "所有排列中的最大和") | [Go](problems/maximum-sum-obtained-of-any-permutation) | Medium | -| 1588 | [Sum of All Odd Length Subarrays](https://leetcode.com/problems/sum-of-all-odd-length-subarrays "所有奇数长度子数组的和") | [Go](problems/sum-of-all-odd-length-subarrays) | Easy | -| 1587 | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii "银行账户概要 II") 🔒 | [MySQL](problems/bank-account-summary-ii) | Easy | -| 1586 | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii "二叉搜索树迭代器 II") 🔒 | [Go](problems/binary-search-tree-iterator-ii) | Medium | -| 1585 | [Check If String Is Transformable With Substring Sort Operations](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") | [Go](problems/check-if-string-is-transformable-with-substring-sort-operations) | Hard | -| 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](problems/min-cost-to-connect-all-points) | Medium | -| 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](problems/count-unhappy-friends) | Medium | -| 1582 | [Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") | [Go](problems/special-positions-in-a-binary-matrix) | Easy | -| 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客") 🔒 | [MySQL](problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | -| 1580 | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii "把箱子放进仓库里 II") 🔒 | [Go](problems/put-boxes-into-the-warehouse-ii) | Medium | -| 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | -| 1578 | [Minimum Deletion Cost to Avoid Repeating Letters](https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters "避免重复字母的最小删除成本") | [Go](problems/minimum-deletion-cost-to-avoid-repeating-letters) | Medium | -| 1577 | [Number of Ways Where Square of Number Is Equal to Product of Two Numbers](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") | [Go](problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | Medium | -| 1576 | [Replace All ?'s to Avoid Consecutive Repeating Characters](https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters "替换所有的问号") | [Go](problems/replace-all-s-to-avoid-consecutive-repeating-characters) | Easy | -| 1575 | [Count All Possible Routes](https://leetcode.com/problems/count-all-possible-routes "统计所有可行路径") | [Go](problems/count-all-possible-routes) | Hard | -| 1574 | [Shortest Subarray to be Removed to Make Array Sorted](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") | [Go](problems/shortest-subarray-to-be-removed-to-make-array-sorted) | Medium | -| 1573 | [Number of Ways to Split a String](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") | [Go](problems/number-of-ways-to-split-a-string) | Medium | -| 1572 | [Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum "矩阵对角线元素的和") | [Go](problems/matrix-diagonal-sum) | Easy | -| 1571 | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager "仓库经理") 🔒 | [MySQL](problems/warehouse-manager) | Easy | -| 1570 | [Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors "两个稀疏向量的点积") 🔒 | [Go](problems/dot-product-of-two-sparse-vectors) | Medium | -| 1569 | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard | -| 1568 | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](problems/minimum-number-of-days-to-disconnect-island) | Hard | -| 1567 | [Maximum Length of Subarray With Positive Product](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") | [Go](problems/maximum-length-of-subarray-with-positive-product) | Medium | -| 1566 | [Detect Pattern of Length M Repeated K or More Times](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") | [Go](problems/detect-pattern-of-length-m-repeated-k-or-more-times) | Easy | -| 1565 | [Unique Orders and Customers Per Month](https://leetcode.com/problems/unique-orders-and-customers-per-month "按月统计订单数与顾客数") 🔒 | [MySQL](problems/unique-orders-and-customers-per-month) | Easy | -| 1564 | [Put Boxes Into the Warehouse I](https://leetcode.com/problems/put-boxes-into-the-warehouse-i "把箱子放进仓库里 I") 🔒 | [Go](problems/put-boxes-into-the-warehouse-i) | Medium | -| 1563 | [Stone Game V](https://leetcode.com/problems/stone-game-v "石子游戏 V") | [Go](problems/stone-game-v) | Hard | -| 1562 | [Find Latest Group of Size M](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") | [Go](problems/find-latest-group-of-size-m) | Medium | -| 1561 | [Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") | [Go](problems/maximum-number-of-coins-you-can-get) | Medium | -| 1560 | [Most Visited Sector in a Circular Track](https://leetcode.com/problems/most-visited-sector-in-a-circular-track "圆形赛道上经过次数最多的扇区") | [Go](problems/most-visited-sector-in-a-circular-track) | Easy | -| 1559 | [Detect Cycles in 2D Grid](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") | [Go](problems/detect-cycles-in-2d-grid) | Medium | -| 1558 | [Minimum Numbers of Function Calls to Make Target Array](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") | [Go](problems/minimum-numbers-of-function-calls-to-make-target-array) | Medium | -| 1557 | [Minimum Number of Vertices to Reach All Nodes](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes "可以到达所有点的最少点数目") | [Go](problems/minimum-number-of-vertices-to-reach-all-nodes) | Medium | -| 1556 | [Thousand Separator](https://leetcode.com/problems/thousand-separator "千位分隔数") | [Go](problems/thousand-separator) | Easy | -| 1555 | [Bank Account Summary](https://leetcode.com/problems/bank-account-summary "银行账户概要") 🔒 | [MySQL](problems/bank-account-summary) | Medium | -| 1554 | [Strings Differ by One Character](https://leetcode.com/problems/strings-differ-by-one-character "只有一个不同字符的字符串") 🔒 | [Go](problems/strings-differ-by-one-character) | Medium | -| 1553 | [Minimum Number of Days to Eat N Oranges](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") | [Go](problems/minimum-number-of-days-to-eat-n-oranges) | Hard | -| 1552 | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](problems/magnetic-force-between-two-balls) | Medium | -| 1551 | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](problems/minimum-operations-to-make-array-equal) | Medium | -| 1550 | [Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds "存在连续三个奇数的数组") | [Go](problems/three-consecutive-odds) | Easy | -| 1549 | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product "每件商品的最新订单") 🔒 | [MySQL](problems/the-most-recent-orders-for-each-product) | Medium | -| 1548 | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph "图中最相似的路径") 🔒 | [Go](problems/the-most-similar-path-in-a-graph) | Hard | -| 1547 | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](problems/minimum-cost-to-cut-a-stick) | Hard | -| 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值且不重叠的非空子数组的最大数目") | [Go](problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | -| 1545 | [Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") | [Go](problems/find-kth-bit-in-nth-binary-string) | Medium | -| 1544 | [Make The String Great](https://leetcode.com/problems/make-the-string-great "整理字符串") | [Go](problems/make-the-string-great) | Easy | -| 1543 | [Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format "产品名称格式修复") 🔒 | [MySQL](problems/fix-product-name-format) | Easy | -| 1542 | [Find Longest Awesome Substring](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") | [Go](problems/find-longest-awesome-substring) | Hard | -| 1541 | [Minimum Insertions to Balance a Parentheses String](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string "平衡括号字符串的最少插入次数") | [Go](problems/minimum-insertions-to-balance-a-parentheses-string) | Medium | -| 1540 | [Can Convert String in K Moves](https://leetcode.com/problems/can-convert-string-in-k-moves "K 次操作转变字符串") | [Go](problems/can-convert-string-in-k-moves) | Medium | -| 1539 | [Kth Missing Positive Number](https://leetcode.com/problems/kth-missing-positive-number "第 k 个缺失的正整数") | [Go](problems/kth-missing-positive-number) | Easy | -| 1538 | [Guess the Majority in a Hidden Array](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array "找出隐藏数组中出现次数最多的元素") 🔒 | [Go](problems/guess-the-majority-in-a-hidden-array) | Medium | -| 1537 | [Get the Maximum Score](https://leetcode.com/problems/get-the-maximum-score "最大得分") | [Go](problems/get-the-maximum-score) | Hard | -| 1536 | [Minimum Swaps to Arrange a Binary Grid](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") | [Go](problems/minimum-swaps-to-arrange-a-binary-grid) | Medium | -| 1535 | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](problems/find-the-winner-of-an-array-game) | Medium | -| 1534 | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets "统计好三元组") | [Go](problems/count-good-triplets) | Easy | -| 1533 | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer "找到最大整数的索引") 🔒 | [Go](problems/find-the-index-of-the-large-integer) | Medium | -| 1532 | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") 🔒 | [MySQL](problems/the-most-recent-three-orders) | Medium | -| 1531 | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](problems/string-compression-ii) | Hard | -| 1530 | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](problems/number-of-good-leaf-nodes-pairs) | Medium | -| 1529 | [Bulb Switcher IV](https://leetcode.com/problems/bulb-switcher-iv "灯泡开关 IV") | [Go](problems/bulb-switcher-iv) | Medium | -| 1528 | [Shuffle String](https://leetcode.com/problems/shuffle-string "重新排列字符串") | [Go](problems/shuffle-string) | Easy | -| 1527 | [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition "患某种疾病的患者") 🔒 | [MySQL](problems/patients-with-a-condition) | Easy | -| 1526 | [Minimum Number of Increments on Subarrays to Form a Target Array](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") | [Go](problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | Hard | -| 1525 | [Number of Good Ways to Split a String](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") | [Go](problems/number-of-good-ways-to-split-a-string) | Medium | -| 1524 | [Number of Sub-arrays With Odd Sum](https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum "和为奇数的子数组数目") | [Go](problems/number-of-sub-arrays-with-odd-sum) | Medium | -| 1523 | [Count Odd Numbers in an Interval Range](https://leetcode.com/problems/count-odd-numbers-in-an-interval-range "在区间范围内统计奇数数目") | [Go](problems/count-odd-numbers-in-an-interval-range) | Easy | -| 1522 | [Diameter of N-Ary Tree](https://leetcode.com/problems/diameter-of-n-ary-tree "N 叉树的直径") 🔒 | [Go](problems/diameter-of-n-ary-tree) | Medium | -| 1521 | [Find a Value of a Mysterious Function Closest to Target](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") | [Go](problems/find-a-value-of-a-mysterious-function-closest-to-target) | Hard | -| 1520 | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](problems/maximum-number-of-non-overlapping-substrings) | Hard | -| 1519 | [Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") | [Go](problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | Medium | -| 1518 | [Water Bottles](https://leetcode.com/problems/water-bottles "换酒问题") | [Go](problems/water-bottles) | Easy | -| 1517 | [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails "查找拥有有效邮箱的用户") 🔒 | [MySQL](problems/find-users-with-valid-e-mails) | Easy | -| 1516 | [Move Sub-Tree of N-Ary Tree](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree "移动 N 叉树的子树") 🔒 | [Go](problems/move-sub-tree-of-n-ary-tree) | Hard | -| 1515 | [Best Position for a Service Centre](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") | [Go](problems/best-position-for-a-service-centre) | Hard | -| 1514 | [Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability "概率最大的路径") | [Go](problems/path-with-maximum-probability) | Medium | -| 1513 | [Number of Substrings With Only 1s](https://leetcode.com/problems/number-of-substrings-with-only-1s "仅含 1 的子串数") | [Go](problems/number-of-substrings-with-only-1s) | Medium | -| 1512 | [Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs "好数对的数目") | [Go](problems/number-of-good-pairs) | Easy | -| 1511 | [Customer Order Frequency](https://leetcode.com/problems/customer-order-frequency "消费者下单频率") 🔒 | [MySQL](problems/customer-order-frequency) | Easy | -| 1510 | [Stone Game IV](https://leetcode.com/problems/stone-game-iv "石子游戏 IV") | [Go](problems/stone-game-iv) | Hard | -| 1509 | [Minimum Difference Between Largest and Smallest Value in Three Moves](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") | [Go](problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | Medium | -| 1508 | [Range Sum of Sorted Subarray Sums](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums "子数组和排序后的区间和") | [Go](problems/range-sum-of-sorted-subarray-sums) | Medium | -| 1507 | [Reformat Date](https://leetcode.com/problems/reformat-date "转变日期格式") | [Go](problems/reformat-date) | Easy | -| 1506 | [Find Root of N-Ary Tree](https://leetcode.com/problems/find-root-of-n-ary-tree "找到 N 叉树的根节点") 🔒 | [Go](problems/find-root-of-n-ary-tree) | Medium | -| 1505 | [Minimum Possible Integer After at Most K Adjacent Swaps On Digits](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") | [Go](problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | Hard | -| 1504 | [Count Submatrices With All Ones](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") | [Go](problems/count-submatrices-with-all-ones) | Medium | -| 1503 | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium | -| 1502 | [Can Make Arithmetic Progression From Sequence](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") | [Go](problems/can-make-arithmetic-progression-from-sequence) | Easy | -| 1501 | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") 🔒 | [MySQL](problems/countries-you-can-safely-invest-in) | Medium | diff --git a/problems/01-matrix/README.md b/problems/01-matrix/README.md index 35b6ca3e1..47aff04e7 100644 --- a/problems/01-matrix/README.md +++ b/problems/01-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-string-ii "Reverse String II") diff --git a/problems/a-number-after-a-double-reversal/README.md b/problems/a-number-after-a-double-reversal/README.md new file mode 100644 index 000000000..4fffcb4b3 --- /dev/null +++ b/problems/a-number-after-a-double-reversal/README.md @@ -0,0 +1,61 @@ + + + + + + + +[< Previous](../build-the-equation "Build the Equation") +                 +[Next >](../execution-of-all-suffix-instructions-staying-in-a-grid "Execution of All Suffix Instructions Staying in a Grid") + +## [2119. A Number After a Double Reversal (Easy)](https://leetcode.com/problems/a-number-after-a-double-reversal "反转两次的数字") + +

Reversing an integer means to reverse all its digits.

+ + + +

Given an integer num, reverse num to get reversed1, then reverse reversed1 to get reversed2. Return true if reversed2 equals num. Otherwise return false.

+ +

 

+

Example 1:

+ +
+Input: num = 526
+Output: true
+Explanation: Reverse num to get 625, then reverse 625 to get 526, which equals num.
+
+ +

Example 2:

+ +
+Input: num = 1800
+Output: false
+Explanation: Reverse num to get 81, then reverse 81 to get 18, which does not equal num.
+
+ +

Example 3:

+ +
+Input: num = 0
+Output: true
+Explanation: Reverse num to get 0, then reverse 0 to get 0, which equals num.
+
+ +

 

+

Constraints:

+ + + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
+Hint 1 +Other than the number 0 itself, any number that ends with 0 would lose some digits permanently when reversed. +
diff --git a/problems/abbreviating-the-product-of-a-range/README.md b/problems/abbreviating-the-product-of-a-range/README.md new file mode 100644 index 000000000..3ee8a1c74 --- /dev/null +++ b/problems/abbreviating-the-product-of-a-range/README.md @@ -0,0 +1,103 @@ + + + + + + + +[< Previous](../check-if-a-parentheses-string-can-be-valid "Check if a Parentheses String Can Be Valid") +                 +[Next >](../build-the-equation "Build the Equation") + +## [2117. Abbreviating the Product of a Range (Hard)](https://leetcode.com/problems/abbreviating-the-product-of-a-range "一个区间内所有数乘积的缩写") + +

You are given two positive integers left and right with left <= right. Calculate the product of all integers in the inclusive range [left, right].

+ +

Since the product may be very large, you will abbreviate it following these steps:

+ +
    +
  1. Count all trailing zeros in the product and remove them. Let us denote this count as C. +
      +
    • For example, there are 3 trailing zeros in 1000, and there are 0 trailing zeros in 546.
    • +
    +
  2. +
  3. Denote the remaining number of digits in the product as d. If d > 10, then express the product as <pre>...<suf> where <pre> denotes the first 5 digits of the product, and <suf> denotes the last 5 digits of the product after removing all trailing zeros. If d <= 10, we keep it unchanged. +
      +
    • For example, we express 1234567654321 as 12345...54321, but 1234567 is represented as 1234567.
    • +
    +
  4. +
  5. Finally, represent the product as a string "<pre>...<suf>eC". +
      +
    • For example, 12345678987600000 will be represented as "12345...89876e5".
    • +
    +
  6. +
+ +

Return a string denoting the abbreviated product of all integers in the inclusive range [left, right].

+ +

 

+

Example 1:

+ +
+Input: left = 1, right = 4
+Output: "24e0"
+Explanation: The product is 1 × 2 × 3 × 4 = 24.
+There are no trailing zeros, so 24 remains the same. The abbreviation will end with "e0".
+Since the number of digits is 2, which is less than 10, we do not have to abbreviate it further.
+Thus, the final representation is "24e0".
+
+ +

Example 2:

+ +
+Input: left = 2, right = 11
+Output: "399168e2"
+Explanation: The product is 39916800.
+There are 2 trailing zeros, which we remove to get 399168. The abbreviation will end with "e2".
+The number of digits after removing the trailing zeros is 6, so we do not abbreviate it further.
+Hence, the abbreviated product is "399168e2".
+
+ +

Example 3:

+ +
+Input: left = 371, right = 375
+Output: "7219856259e3"
+Explanation: The product is 7219856259000.
+
+ +

 

+

Constraints:

+ + + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
+Hint 1 +Calculating the number of trailing zeros, the last five digits, and the first five digits can all be done separately. +
+ +
+Hint 2 +Use a prime factorization property to find the number of trailing zeros. Use modulo to find the last 5 digits. Use a logarithm property to find the first 5 digits. +
+ +
+Hint 3 +The number of trailing zeros C is nothing but the number of times the product is completely divisible by 10. Since 2 and 5 are the only prime factors of 10, C will be equal to the minimum number of times 2 or 5 appear in the prime factorization of the product. +
+ +
+Hint 4 +Iterate through the integers from left to right. For every integer, keep dividing it by 2 as long as it is divisible by 2 and C occurrences of 2 haven't been removed in total. Repeat this process for 5. Finally, multiply the integer under modulo of 10^5 with the product obtained till now to obtain the last five digits. +
+ +
+Hint 5 +The product P can be represented as P=10^(x+y) where x is the integral part and y is the fractional part of x+y. Using the property "if S = A * B, then log(S) = log(A) + log(B)", we can write x+y = log_10(P) = sum(log_10(i)) for each integer i in [left, right]. Once we obtain the sum, the first five digits can be represented as floor(10^(y+4)). +
diff --git a/problems/accepted-candidates-from-the-interviews/README.md b/problems/accepted-candidates-from-the-interviews/README.md index 19d0072c0..b6aa925d5 100644 --- a/problems/accepted-candidates-from-the-interviews/README.md +++ b/problems/accepted-candidates-from-the-interviews/README.md @@ -9,7 +9,7 @@                  [Next >](../check-if-numbers-are-ascending-in-a-sentence "Check if Numbers Are Ascending in a Sentence") -## [2041. Accepted Candidates From the Interviews (Medium)](https://leetcode.com/problems/accepted-candidates-from-the-interviews "") +## [2041. Accepted Candidates From the Interviews (Medium)](https://leetcode.com/problems/accepted-candidates-from-the-interviews "面试中被录取的候选人") diff --git a/problems/account-balance/README.md b/problems/account-balance/README.md index ce0895597..a5dbfabc3 100644 --- a/problems/account-balance/README.md +++ b/problems/account-balance/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-equal-count-substrings "Number of Equal Count Substrings") -## [2066. Account Balance (Medium)](https://leetcode.com/problems/account-balance "") +## [2066. Account Balance (Medium)](https://leetcode.com/problems/account-balance "账户余额") diff --git a/problems/active-users/README.md b/problems/active-users/README.md index ba0038306..ef8762c21 100644 --- a/problems/active-users/README.md +++ b/problems/active-users/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-darts-inside-of-a-circular-dartboard "Maximum Number of Darts Inside of a Circular Dartboard") diff --git a/problems/add-minimum-number-of-rungs/README.md b/problems/add-minimum-number-of-rungs/README.md index a1e778ff4..75ced1a88 100644 --- a/problems/add-minimum-number-of-rungs/README.md +++ b/problems/add-minimum-number-of-rungs/README.md @@ -49,15 +49,6 @@ Add a rung at height 1 to climb this ladder. The ladder will now have rungs at [1,3,4,6,7]. -

Example 4:

- -
-Input: rungs = [5], dist = 10
-Output: 0
-Explanation:
-This ladder can be climbed without adding additional rungs.
-
-

 

Constraints:

@@ -68,6 +59,10 @@ This ladder can be climbed without adding additional rungs.
  • rungs is strictly increasing.
  • +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + ### Hints
    Hint 1 diff --git a/problems/add-two-numbers/README.md b/problems/add-two-numbers/README.md index 5d07d51cf..4b8b6c228 100644 --- a/problems/add-two-numbers/README.md +++ b/problems/add-two-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum "Two Sum") diff --git a/problems/adding-spaces-to-a-string/README.md b/problems/adding-spaces-to-a-string/README.md new file mode 100644 index 000000000..2239ba4fd --- /dev/null +++ b/problems/adding-spaces-to-a-string/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../find-first-palindromic-string-in-the-array "Find First Palindromic String in the Array") +                 +[Next >](../number-of-smooth-descent-periods-of-a-stock "Number of Smooth Descent Periods of a Stock") + +## [2109. Adding Spaces to a String (Medium)](https://leetcode.com/problems/adding-spaces-to-a-string "向字符串添加空格") + +

    You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index.

    + + + +

    Return the modified string after the spaces have been added.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "LeetcodeHelpsMeLearn", spaces = [8,13,15]
    +Output: "Leetcode Helps Me Learn"
    +Explanation: 
    +The indices 8, 13, and 15 correspond to the underlined characters in "LeetcodeHelpsMeLearn".
    +We then place spaces before those characters.
    +
    + +

    Example 2:

    + +
    +Input: s = "icodeinpython", spaces = [1,5,7,9]
    +Output: "i code in py thon"
    +Explanation:
    +The indices 1, 5, 7, and 9 correspond to the underlined characters in "icodeinpython".
    +We then place spaces before those characters.
    +
    + +

    Example 3:

    + +
    +Input: s = "spacing", spaces = [0,1,2,3,4,5,6]
    +Output: " s p a c i n g"
    +Explanation:
    +We are also able to place spaces before the first character of the string.
    +
    + +

     

    +

    Constraints:

    + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Create a new string, initially empty, as the modified string. Iterate through the original string and append each character of the original string to the new string. However, each time you reach a character that requires a space before it, append a space before appending the character. +
    + +
    +Hint 2 +Since the array of indices for the space locations is sorted, use a pointer to keep track of the next index to place a space. Only increment the pointer once a space has been appended. +
    + +
    +Hint 3 +Ensure that your append operation can be done in O(1). +
    diff --git a/problems/ads-performance/README.md b/problems/ads-performance/README.md index 021d8c49e..6ab077012 100644 --- a/problems/ads-performance/README.md +++ b/problems/ads-performance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../restaurant-growth "Restaurant Growth") diff --git a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md index e57869f6d..a91e1b097 100644 --- a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md +++ b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md @@ -38,27 +38,13 @@ Explanation: "bob" used the keycard 3 times in a one-hour period ("21:00","21:20", "21:30"). -

    Example 3:

    - -
    -Input: keyName = ["john","john","john"], keyTime = ["23:58","23:59","00:01"]
    -Output: []
    -
    - -

    Example 4:

    - -
    -Input: keyName = ["leslie","leslie","leslie","clare","clare","clare","clare"], keyTime = ["13:00","13:20","14:00","18:00","18:51","19:30","19:49"]
    -Output: ["clare","leslie"]
    -
    -

     

    Constraints:

    ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] diff --git a/problems/all-possible-full-binary-trees/README.md b/problems/all-possible-full-binary-trees/README.md index 7d2cba86f..663028786 100644 --- a/problems/all-possible-full-binary-trees/README.md +++ b/problems/all-possible-full-binary-trees/README.md @@ -40,8 +40,8 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Recursion](../../tag/recursion/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/allocate-mailboxes/README.md b/problems/allocate-mailboxes/README.md index 5d982f082..b0bd29e7e 100644 --- a/problems/allocate-mailboxes/README.md +++ b/problems/allocate-mailboxes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-two-non-overlapping-sub-arrays-each-with-target-sum "Find Two Non-overlapping Sub-arrays Each With Target Sum") @@ -11,58 +11,38 @@ ## [1478. Allocate Mailboxes (Hard)](https://leetcode.com/problems/allocate-mailboxes "安排邮筒") -

    Given the array houses and an integer k. where houses[i] is the location of the ith house along a street, your task is to allocate k mailboxes in the street.

    +

    Given the array houses where houses[i] is the location of the ith house along a street and an integer k, allocate k mailboxes in the street.

    -

    Return the minimum total distance between each house and its nearest mailbox.

    +

    Return the minimum total distance between each house and its nearest mailbox.

    -

    The answer is guaranteed to fit in a 32-bit signed integer.

    +

    The test cases are generated so that the answer fits in a 32-bit integer.

     

    Example 1:

    - -

    - +
     Input: houses = [1,4,8,10,20], k = 3
     Output: 5
    -Explanation: Allocate mailboxes in position 3, 9 and 20.
    +Explanation: Allocate mailboxes in position 3, 9 and 20.
     Minimum total distance from each houses to nearest mailboxes is |3-1| + |4-3| + |9-8| + |10-9| + |20-20| = 5 
     

    Example 2:

    - -

    - +
     Input: houses = [2,3,5,12,18], k = 2
     Output: 9
    -Explanation: Allocate mailboxes in position 3 and 14.
    +Explanation: Allocate mailboxes in position 3 and 14.
     Minimum total distance from each houses to nearest mailboxes is |2-3| + |3-3| + |5-3| + |12-14| + |18-14| = 9.
     
    -

    Example 3:

    - -
    -Input: houses = [7,4,6,1], k = 1
    -Output: 8
    -
    - -

    Example 4:

    - -
    -Input: houses = [3,6,14,10], k = 4
    -Output: 0
    -
    -

     

    Constraints:

    ### Related Topics diff --git a/problems/amount-of-new-area-painted-each-day/README.md b/problems/amount-of-new-area-painted-each-day/README.md new file mode 100644 index 000000000..7af517b36 --- /dev/null +++ b/problems/amount-of-new-area-painted-each-day/README.md @@ -0,0 +1,40 @@ + + + + + + + +[< Previous](../groups-of-strings "Groups of Strings") +                 +[Next >](../order-two-columns-independently "Order Two Columns Independently") + +## [2158. Amount of New Area Painted Each Day (Hard)](https://leetcode.com/problems/amount-of-new-area-painted-each-day "") + + + +### Related Topics + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + +### Hints +
    +Hint 1 +What’s a good way to keep track of intervals that you have already painted? +
    + +
    +Hint 2 +Create an array of all 1’s, and when you have painted an interval, set the values in that interval to 0. +
    + +
    +Hint 3 +Using this array, how can you quickly calculate the amount of new area that you paint on a given day? +
    + +
    +Hint 4 +Calculate the sum of the new array in the interval that you paint. +
    diff --git a/problems/android-unlock-patterns/README.md b/problems/android-unlock-patterns/README.md index 9d96cd889..681daf4dc 100644 --- a/problems/android-unlock-patterns/README.md +++ b/problems/android-unlock-patterns/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../intersection-of-two-arrays-ii "Intersection of Two Arrays II") diff --git a/problems/apples-oranges/README.md b/problems/apples-oranges/README.md index be80dd0cb..61bfaa61e 100644 --- a/problems/apples-oranges/README.md +++ b/problems/apples-oranges/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-of-cutting-a-pizza "Number of Ways of Cutting a Pizza") diff --git a/problems/arithmetic-subarrays/README.md b/problems/arithmetic-subarrays/README.md index 5c34778f3..e38ff7b32 100644 --- a/problems/arithmetic-subarrays/README.md +++ b/problems/arithmetic-subarrays/README.md @@ -64,10 +64,6 @@ In the 2nd query, the subarray is [5,9,3,7]. This can be [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Arithmetic Slices](../arithmetic-slices) (Medium) - 1. [Can Make Arithmetic Progression From Sequence](../can-make-arithmetic-progression-from-sequence) (Easy) - ### Hints
    Hint 1 diff --git a/problems/armstrong-number/README.md b/problems/armstrong-number/README.md index 2a5aef613..6393d60cd 100644 --- a/problems/armstrong-number/README.md +++ b/problems/armstrong-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-unique-number "Largest Unique Number") diff --git a/problems/available-captures-for-rook/README.md b/problems/available-captures-for-rook/README.md index 6c4c5b748..d1375f510 100644 --- a/problems/available-captures-for-rook/README.md +++ b/problems/available-captures-for-rook/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-binary-tree-ii "Maximum Binary Tree II") diff --git a/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md b/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md index 1dcd53d41..239269d1b 100644 --- a/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md +++ b/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clone-n-ary-tree "Clone N-ary Tree") @@ -11,9 +11,9 @@ ## [1491. Average Salary Excluding the Minimum and Maximum Salary (Easy)](https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary "去掉最低工资和最高工资后的工资平均值") -

    Given an array of unique integers salary where salary[i] is the salary of the employee i.

    +

    You are given an array of unique integers salary where salary[i] is the salary of the ith employee.

    -

    Return the average salary of employees excluding the minimum and maximum salary.

    +

    Return the average salary of employees excluding the minimum and maximum salary. Answers within 10-5 of the actual answer will be accepted.

     

    Example 1:

    @@ -21,8 +21,8 @@
     Input: salary = [4000,3000,1000,2000]
     Output: 2500.00000
    -Explanation: Minimum salary and maximum salary are 1000 and 4000 respectively.
    -Average salary excluding minimum and maximum salary is (2000+3000)/2= 2500
    +Explanation: Minimum salary and maximum salary are 1000 and 4000 respectively.
    +Average salary excluding minimum and maximum salary is (2000+3000) / 2 = 2500
     

    Example 2:

    @@ -30,22 +30,8 @@ Average salary excluding minimum and maximum salary is (2000+3000)/2= 2500
     Input: salary = [1000,2000,3000]
     Output: 2000.00000
    -Explanation: Minimum salary and maximum salary are 1000 and 3000 respectively.
    -Average salary excluding minimum and maximum salary is (2000)/1= 2000
    -
    - -

    Example 3:

    - -
    -Input: salary = [6000,5000,4000,3000,2000,1000]
    -Output: 3500.00000
    -
    - -

    Example 4:

    - -
    -Input: salary = [8000,9000,2000,3000,6000,1000]
    -Output: 4750.00000
    +Explanation: Minimum salary and maximum salary are 1000 and 3000 respectively.
    +Average salary excluding minimum and maximum salary is (2000) / 1 = 2000
     

     

    @@ -53,9 +39,8 @@ Average salary excluding minimum and maximum salary is (2000)/1= 2000
    • 3 <= salary.length <= 100
    • -
    • 10^3 <= salary[i] <= 10^6
    • -
    • salary[i] is unique.
    • -
    • Answers within 10^-5 of the actual value will be accepted as correct.
    • +
    • 1000 <= salary[i] <= 106
    • +
    • All the integers of salary are unique.
    ### Related Topics diff --git a/problems/average-waiting-time/README.md b/problems/average-waiting-time/README.md index ef5e69e93..d2cba9701 100644 --- a/problems/average-waiting-time/README.md +++ b/problems/average-waiting-time/README.md @@ -61,9 +61,6 @@ So the average waiting time = (2 + 6 + 4 + 1) / 4 = 3.25. [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] -### Similar Questions - 1. [Average Height of Buildings in Each Segment](../average-height-of-buildings-in-each-segment) (Medium) - ### Hints
    Hint 1 diff --git a/problems/avoid-flood-in-the-city/README.md b/problems/avoid-flood-in-the-city/README.md index a691b24b6..fdd8339ce 100644 --- a/problems/avoid-flood-in-the-city/README.md +++ b/problems/avoid-flood-in-the-city/README.md @@ -25,7 +25,7 @@
    • ans.length == rains.length
    • ans[i] == -1 if rains[i] > 0.
    • -
    • ans[i] is the lake you choose to dry in the ith day if rains[i] == 0.
    • +
    • ans[i] is the lake you choose to dry in the ith day if rains[i] == 0.

    If there are multiple valid answers return any of them. If it is impossible to avoid flood return an empty array.

    @@ -68,22 +68,6 @@ It is easy that this scenario is flood-free. [-1,-1,1,2,-1,-1] is another accept After that, it will rain over lakes [1,2]. It's easy to prove that no matter which lake you choose to dry in the 3rd day, the other one will flood. -

    Example 4:

    - -
    -Input: rains = [69,0,0,0,69]
    -Output: [-1,69,1,1,-1]
    -Explanation: Any solution on one of the forms [-1,69,x,y,-1], [-1,x,69,y,-1] or [-1,x,y,69,-1] is acceptable where 1 <= x,y <= 10^9
    -
    - -

    Example 5:

    - -
    -Input: rains = [10,20,20]
    -Output: []
    -Explanation: It will rain over lake 20 two consecutive days. There is no chance to dry any lake.
    -
    -

     

    Constraints:

    diff --git a/problems/backspace-string-compare/README.md b/problems/backspace-string-compare/README.md index d11ab235a..e5ba9c09d 100644 --- a/problems/backspace-string-compare/README.md +++ b/problems/backspace-string-compare/README.md @@ -34,14 +34,6 @@

    Example 3:

    -
    -Input: s = "a##c", t = "#a#c"
    -Output: true
    -Explanation: Both s and t become "c".
    -
    - -

    Example 4:

    -
     Input: s = "a#c", t = "b"
     Output: false
    @@ -53,7 +45,7 @@
     
     
    • 1 <= s.length, t.length <= 200
    • -
    • s and t only contain lowercase letters and '#' characters.
    • +
    • s and t only contain lowercase letters and '#' characters.

     

    diff --git a/problems/bag-of-tokens/README.md b/problems/bag-of-tokens/README.md index 8b1f6e747..e5400398d 100644 --- a/problems/bag-of-tokens/README.md +++ b/problems/bag-of-tokens/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../most-stones-removed-with-same-row-or-column "Most Stones Removed with Same Row or Column") @@ -63,7 +63,7 @@ There is no need to play the 1st token since you cannot play it face ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/battleships-in-a-board/README.md b/problems/battleships-in-a-board/README.md index 4fd781d03..0fd2ab0d2 100644 --- a/problems/battleships-in-a-board/README.md +++ b/problems/battleships-in-a-board/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sentence-screen-fitting "Sentence Screen Fitting") @@ -44,6 +44,6 @@

    Follow up: Could you do it in one-pass, using only O(1) extra memory and without modifying the values board?

    ### Related Topics - [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/beautiful-arrangement/README.md b/problems/beautiful-arrangement/README.md index e9a44b8fa..054a56581 100644 --- a/problems/beautiful-arrangement/README.md +++ b/problems/beautiful-arrangement/README.md @@ -50,10 +50,10 @@ The second beautiful arrangement is [2,1]: ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Similar Questions diff --git a/problems/best-position-for-a-service-centre/README.md b/problems/best-position-for-a-service-centre/README.md index 776cdd14f..224671215 100644 --- a/problems/best-position-for-a-service-centre/README.md +++ b/problems/best-position-for-a-service-centre/README.md @@ -11,13 +11,13 @@ ## [1515. Best Position for a Service Centre (Hard)](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") -

    A delivery company wants to build a new service centre in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new centre in a position such that the sum of the euclidean distances to all customers is minimum.

    +

    A delivery company wants to build a new service center in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new center in a position such that the sum of the euclidean distances to all customers is minimum.

    Given an array positions where positions[i] = [xi, yi] is the position of the ith customer on the map, return the minimum sum of the euclidean distances to all customers.

    -

    In other words, you need to choose the position of the service centre [xcentre, ycentre] such that the following formula is minimized:

    +

    In other words, you need to choose the position of the service center [xcentre, ycentre] such that the following formula is minimized:

    -

    Answers within 10^-5 of the actual value will be accepted.

    +

    Answers within 10-5 of the actual value will be accepted.

     

    Example 1:

    @@ -36,38 +36,13 @@ Explanation: The minimum possible sum of distances = sqrt(2) + sqrt(2) = 2.82843
    -

    Example 3:

    - -
    -Input: positions = [[1,1]]
    -Output: 0.00000
    -
    - -

    Example 4:

    - -
    -Input: positions = [[1,1],[0,0],[2,0]]
    -Output: 2.73205
    -Explanation: At the first glance, you may think that locating the centre at [1, 0] will achieve the minimum sum, but locating it at [1, 0] will make the sum of distances = 3.
    -Try to locate the centre at [1.0, 0.5773502711] you will see that the sum of distances is 2.73205.
    -Be careful with the precision!
    -
    - -

    Example 5:

    - -
    -Input: positions = [[0,1],[3,2],[4,5],[7,6],[8,9],[11,1],[2,12]]
    -Output: 32.94036
    -Explanation: You can use [4.3460852395, 4.9813795505] as the position of the centre.
    -
    -

     

    Constraints:

      -
    • 1 <= positions.length <= 50
    • +
    • 1 <= positions.length <= 50
    • positions[i].length == 2
    • -
    • 0 <= positions[i][0], positions[i][1] <= 100
    • +
    • 0 <= xi, yi <= 100
    ### Related Topics diff --git a/problems/best-time-to-buy-and-sell-stock-iii/README.md b/problems/best-time-to-buy-and-sell-stock-iii/README.md index 198700c20..aed420db4 100644 --- a/problems/best-time-to-buy-and-sell-stock-iii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iii/README.md @@ -43,13 +43,6 @@ Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are Explanation: In this case, no transaction is done, i.e. max profit = 0. -

    Example 4:

    - -
    -Input: prices = [1]
    -Output: 0
    -
    -

     

    Constraints:

    diff --git a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md index 654c0256f..199745595 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subarray-product-less-than-k "Subarray Product Less Than K") @@ -48,9 +48,9 @@ The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) = 8. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Medium) diff --git a/problems/binary-number-with-alternating-bits/README.md b/problems/binary-number-with-alternating-bits/README.md index e1a0fdba1..c4e00c4fe 100644 --- a/problems/binary-number-with-alternating-bits/README.md +++ b/problems/binary-number-with-alternating-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../top-k-frequent-words "Top K Frequent Words") @@ -36,20 +36,6 @@ Output: false Explanation: The binary representation of 11 is: 1011. -

    Example 4:

    - -
    -Input: n = 10
    -Output: true
    -Explanation: The binary representation of 10 is: 1010.
    - -

    Example 5:

    - -
    -Input: n = 3
    -Output: false
    -
    -

     

    Constraints:

    diff --git a/problems/binary-searchable-numbers-in-an-unsorted-array/README.md b/problems/binary-searchable-numbers-in-an-unsorted-array/README.md index 456b220f6..6bebaaf0d 100644 --- a/problems/binary-searchable-numbers-in-an-unsorted-array/README.md +++ b/problems/binary-searchable-numbers-in-an-unsorted-array/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-strings-that-appear-as-substrings-in-word "Number of Strings That Appear as Substrings in Word") -## [1966. Binary Searchable Numbers in an Unsorted Array (Medium)](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array "") +## [1966. Binary Searchable Numbers in an Unsorted Array (Medium)](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array "未排序数组中的可被二分搜索的数") diff --git a/problems/binary-string-with-substrings-representing-1-to-n/README.md b/problems/binary-string-with-substrings-representing-1-to-n/README.md index 442d0a730..86dfded8d 100644 --- a/problems/binary-string-with-substrings-representing-1-to-n/README.md +++ b/problems/binary-string-with-substrings-representing-1-to-n/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-integer-divisible-by-k "Smallest Integer Divisible by K") diff --git a/problems/binary-subarrays-with-sum/README.md b/problems/binary-subarrays-with-sum/README.md index a618aad06..775b0833f 100644 --- a/problems/binary-subarrays-with-sum/README.md +++ b/problems/binary-subarrays-with-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-email-addresses "Unique Email Addresses") @@ -47,5 +47,5 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/binary-tree-level-order-traversal/README.md b/problems/binary-tree-level-order-traversal/README.md index 31bcd1c24..60197a3e7 100644 --- a/problems/binary-tree-level-order-traversal/README.md +++ b/problems/binary-tree-level-order-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../symmetric-tree "Symmetric Tree") diff --git a/problems/binary-tree-right-side-view/README.md b/problems/binary-tree-right-side-view/README.md index 792501a62..d005f8380 100644 --- a/problems/binary-tree-right-side-view/README.md +++ b/problems/binary-tree-right-side-view/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../house-robber "House Robber") diff --git a/problems/binary-tree-upside-down/README.md b/problems/binary-tree-upside-down/README.md index a3bf356be..9e4be9643 100644 --- a/problems/binary-tree-upside-down/README.md +++ b/problems/binary-tree-upside-down/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../min-stack "Min Stack") diff --git a/problems/binary-tree-vertical-order-traversal/README.md b/problems/binary-tree-vertical-order-traversal/README.md index 860aab5be..a23002120 100644 --- a/problems/binary-tree-vertical-order-traversal/README.md +++ b/problems/binary-tree-vertical-order-traversal/README.md @@ -90,10 +90,10 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/break-a-palindrome/README.md b/problems/break-a-palindrome/README.md index a6d34289d..aaaae4da1 100644 --- a/problems/break-a-palindrome/README.md +++ b/problems/break-a-palindrome/README.md @@ -35,19 +35,6 @@ Of all the ways, "aaccba" is the lexicographically smallest. Explanation: There is no way to replace a single character to make "a" not a palindrome, so return an empty string. -

    Example 3:

    - -
    -Input: palindrome = "aa"
    -Output: "ab"
    - -

    Example 4:

    - -
    -Input: palindrome = "aba"
    -Output: "abb"
    -
    -

     

    Constraints:

    diff --git a/problems/brightest-position-on-street/README.md b/problems/brightest-position-on-street/README.md index cf9a10f81..0aaf7cc50 100644 --- a/problems/brightest-position-on-street/README.md +++ b/problems/brightest-position-on-street/README.md @@ -9,7 +9,7 @@                  [Next >](../convert-1d-array-into-2d-array "Convert 1D Array Into 2D Array") -## [2021. Brightest Position on Street (Medium)](https://leetcode.com/problems/brightest-position-on-street "") +## [2021. Brightest Position on Street (Medium)](https://leetcode.com/problems/brightest-position-on-street "街上最亮的位置") diff --git a/problems/build-an-array-with-stack-operations/README.md b/problems/build-an-array-with-stack-operations/README.md index 60dd71263..15700b124 100644 --- a/problems/build-an-array-with-stack-operations/README.md +++ b/problems/build-an-array-with-stack-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../evaluate-boolean-expression "Evaluate Boolean Expression") @@ -11,17 +11,19 @@ ## [1441. Build an Array With Stack Operations (Easy)](https://leetcode.com/problems/build-an-array-with-stack-operations "用栈操作构建数组") -

    Given an array target and an integer n. In each iteration, you will read a number from  list = {1,2,3..., n}.

    +

    You are given an array target and an integer n.

    -

    Build the target array using the following operations:

    +

    In each iteration, you will read a number from list = [1, 2, 3, ..., n].

    + +

    Build the target array using the following operations:

      -
    • Push: Read a new element from the beginning list, and push it in the array.
    • -
    • Pop: delete the last element of the array.
    • -
    • If the target array is already built, stop reading more elements.
    • +
    • "Push": Reads a new element from the beginning list, and pushes it in the array.
    • +
    • "Pop": Deletes the last element of the array.
    • +
    • If the target array is already built, stop reading more elements.
    -

    Return the operations to build the target array. You are guaranteed that the answer is unique.

    +

    Return a list of the operations needed to build target. The test cases are generated so that the answer is unique.

     

    Example 1:

    @@ -29,8 +31,8 @@
     Input: target = [1,3], n = 3
     Output: ["Push","Push","Pop","Push"]
    -Explanation: 
    -Read number 1 and automatically push in the array -> [1]
    +Explanation: 
    +Read number 1 and automatically push in the array -> [1]
     Read number 2 and automatically push in the array then Pop it -> [1]
     Read number 3 and automatically push in the array -> [1,3]
     
    @@ -47,14 +49,7 @@ Read number 3 and automatically push in the array -> [1,3]
     Input: target = [1,2], n = 4
     Output: ["Push","Push"]
    -Explanation: You only need to read the first 2 numbers and stop.
    -
    - -

    Example 4:

    - -
    -Input: target = [2,3,4], n = 4
    -Output: ["Push","Pop","Push","Push","Push"]
    +Explanation: You only need to read the first 2 numbers and stop.
     

     

    @@ -62,14 +57,14 @@ Read number 3 and automatically push in the array -> [1,3]
    • 1 <= target.length <= 100
    • -
    • 1 <= target[i] <= n
    • 1 <= n <= 100
    • -
    • target is strictly increasing.
    • +
    • 1 <= target[i] <= n
    • +
    • target is strictly increasing.
    ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] + [[Stack](../../tag/stack/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/build-binary-expression-tree-from-infix-expression/README.md b/problems/build-binary-expression-tree-from-infix-expression/README.md index fc0ee4558..ccb059a16 100644 --- a/problems/build-binary-expression-tree-from-infix-expression/README.md +++ b/problems/build-binary-expression-tree-from-infix-expression/README.md @@ -14,11 +14,15 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Basic Calculator III](../basic-calculator-iii) (Hard) + 1. [Check If Two Expression Trees are Equivalent](../check-if-two-expression-trees-are-equivalent) (Medium) + ### Hints
    Hint 1 diff --git a/problems/build-the-equation/README.md b/problems/build-the-equation/README.md new file mode 100644 index 000000000..1a035a2c2 --- /dev/null +++ b/problems/build-the-equation/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../abbreviating-the-product-of-a-range "Abbreviating the Product of a Range") +                 +[Next >](../a-number-after-a-double-reversal "A Number After a Double Reversal") + +## [2118. Build the Equation (Hard)](https://leetcode.com/problems/build-the-equation "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/build-the-equation/mysql_schemas.sql b/problems/build-the-equation/mysql_schemas.sql new file mode 100644 index 000000000..9cb986611 --- /dev/null +++ b/problems/build-the-equation/mysql_schemas.sql @@ -0,0 +1,5 @@ +Create table If Not Exists Terms (power int, factor int); +Truncate table Terms; +insert into Terms (power, factor) values ('2', '1'); +insert into Terms (power, factor) values ('1', '-4'); +insert into Terms (power, factor) values ('0', '2'); diff --git a/problems/burst-balloons/README.md b/problems/burst-balloons/README.md index e2fb7335a..d8143c649 100644 --- a/problems/burst-balloons/README.md +++ b/problems/burst-balloons/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sparse-matrix-multiplication "Sparse Matrix Multiplication") @@ -39,7 +39,7 @@ coins = 3*1*5 + 3*5*8 + 1*3*8 + 1*8*1 = 167
    • n == nums.length
    • -
    • 1 <= n <= 500
    • +
    • 1 <= n <= 300
    • 0 <= nums[i] <= 100
    diff --git a/problems/calculate-salaries/README.md b/problems/calculate-salaries/README.md index 23f8246eb..9f0654cc5 100644 --- a/problems/calculate-salaries/README.md +++ b/problems/calculate-salaries/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "Probability of a Two Boxes Having The Same Number of Distinct Balls") diff --git a/problems/campus-bikes/README.md b/problems/campus-bikes/README.md index ea7457295..6e99c5415 100644 --- a/problems/campus-bikes/README.md +++ b/problems/campus-bikes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../confusing-number "Confusing Number") diff --git a/problems/can-make-arithmetic-progression-from-sequence/README.md b/problems/can-make-arithmetic-progression-from-sequence/README.md index 92f0cbc72..8ab8e871e 100644 --- a/problems/can-make-arithmetic-progression-from-sequence/README.md +++ b/problems/can-make-arithmetic-progression-from-sequence/README.md @@ -44,6 +44,9 @@ [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Arithmetic Subarrays](../arithmetic-subarrays) (Medium) + ### Hints
    Hint 1 diff --git a/problems/can-make-palindrome-from-substring/README.md b/problems/can-make-palindrome-from-substring/README.md index e8a95283e..20ea8a9eb 100644 --- a/problems/can-make-palindrome-from-substring/README.md +++ b/problems/can-make-palindrome-from-substring/README.md @@ -51,14 +51,11 @@ queries[4]: substring = "abcda", could be changed to "abcba" ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] -### Similar Questions - 1. [Plates Between Candles](../plates-between-candles) (Medium) - ### Hints
    Hint 1 diff --git a/problems/capacity-to-ship-packages-within-d-days/README.md b/problems/capacity-to-ship-packages-within-d-days/README.md index b2df14c7d..7bb5aba1c 100644 --- a/problems/capacity-to-ship-packages-within-d-days/README.md +++ b/problems/capacity-to-ship-packages-within-d-days/README.md @@ -65,15 +65,9 @@ Note that the cargo must be shipped in the order given, so using a ship of capac ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Greedy](../../tag/greedy/README.md)] - -### Similar Questions - 1. [Split Array Largest Sum](../split-array-largest-sum) (Hard) - 1. [Divide Chocolate](../divide-chocolate) (Hard) - 1. [Cutting Ribbons](../cutting-ribbons) (Medium) - 1. [Minimized Maximum of Products Distributed to Any Store](../minimized-maximum-of-products-distributed-to-any-store) (Medium) ### Hints
    diff --git a/problems/capital-gainloss/README.md b/problems/capital-gainloss/README.md index 0529c1234..df3815de0 100644 --- a/problems/capital-gainloss/README.md +++ b/problems/capital-gainloss/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-happy-prefix "Longest Happy Prefix") diff --git a/problems/capitalize-the-title/README.md b/problems/capitalize-the-title/README.md new file mode 100644 index 000000000..390a33635 --- /dev/null +++ b/problems/capitalize-the-title/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../remove-all-ones-with-row-and-column-flips "Remove All Ones With Row and Column Flips") +                 +[Next >](../maximum-twin-sum-of-a-linked-list "Maximum Twin Sum of a Linked List") + +## [2129. Capitalize the Title (Easy)](https://leetcode.com/problems/capitalize-the-title "将标题首字母大写") + +

    You are given a string title consisting of one or more words separated by a single space, where each word consists of English letters. Capitalize the string by changing the capitalization of each word such that:

    + +
      +
    • If the length of the word is 1 or 2 letters, change all letters to lowercase.
    • +
    • Otherwise, change the first letter to uppercase and the remaining letters to lowercase.
    • +
    + +

    Return the capitalized title.

    + +

     

    +

    Example 1:

    + +
    +Input: title = "capiTalIze tHe titLe"
    +Output: "Capitalize The Title"
    +Explanation:
    +Since all the words have a length of at least 3, the first letter of each word is uppercase, and the remaining letters are lowercase.
    +
    + +

    Example 2:

    + +
    +Input: title = "First leTTeR of EACH Word"
    +Output: "First Letter of Each Word"
    +Explanation:
    +The word "of" has length 2, so it is all lowercase.
    +The remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.
    +
    + +

    Example 3:

    + +
    +Input: title = "i lOve leetcode"
    +Output: "i Love Leetcode"
    +Explanation:
    +The word "i" has length 1, so it is lowercase.
    +The remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= title.length <= 100
    • +
    • title consists of words separated by a single space without any leading or trailing spaces.
    • +
    • Each word consists of uppercase and lowercase English letters and is non-empty.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Firstly, try to find all the words present in the string. +
    + +
    +Hint 2 +On the basis of each word's lengths, simulate the process explained in Problem. +
    diff --git a/problems/car-fleet-ii/README.md b/problems/car-fleet-ii/README.md index dda2040c2..49ff94884 100644 --- a/problems/car-fleet-ii/README.md +++ b/problems/car-fleet-ii/README.md @@ -48,11 +48,14 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + [[Stack](../../tag/stack/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + +### Similar Questions + 1. [Car Fleet](../car-fleet) (Medium) ### Hints
    diff --git a/problems/car-pooling/README.md b/problems/car-pooling/README.md index 18852963e..ee4665fef 100644 --- a/problems/car-pooling/README.md +++ b/problems/car-pooling/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../statistics-from-a-large-sample "Statistics from a Large Sample") @@ -13,7 +13,7 @@

    There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).

    -

    You are given the integer capacity and an array trips where trip[i] = [numPassengersi, fromi, toi] indicates that the ith trip has numPassengersi passengers and the locations to pick them up and drop them off are fromi and toi respectively. The locations are given as the number of kilometers due east from the car's initial location.

    +

    You are given the integer capacity and an array trips where trips[i] = [numPassengersi, fromi, toi] indicates that the ith trip has numPassengersi passengers and the locations to pick them up and drop them off are fromi and toi respectively. The locations are given as the number of kilometers due east from the car's initial location.

    Return true if it is possible to pick up and drop off all passengers for all the given trips, or false otherwise.

    @@ -32,20 +32,6 @@ Output: true -

    Example 3:

    - -
    -Input: trips = [[2,1,5],[3,5,7]], capacity = 3
    -Output: true
    -
    - -

    Example 4:

    - -
    -Input: trips = [[3,2,7],[3,7,9],[8,3,9]], capacity = 11
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/cat-and-mouse-ii/README.md b/problems/cat-and-mouse-ii/README.md index 1163fd2b3..87c97a15a 100644 --- a/problems/cat-and-mouse-ii/README.md +++ b/problems/cat-and-mouse-ii/README.md @@ -46,9 +46,7 @@

     

    Example 1:

    - -

    - +
     Input: grid = ["####F","#C...","M...."], catJump = 1, mouseJump = 2
     Output: true
    @@ -56,9 +54,7 @@
     

    Example 2:

    - -

    - +
     Input: grid = ["M.C...F"], catJump = 1, mouseJump = 4
     Output: true
    @@ -71,20 +67,6 @@
     Output: false
     
    -

    Example 4:

    - -
    -Input: grid = ["C...#","...#F","....#","M...."], catJump = 2, mouseJump = 5
    -Output: false
    -
    - -

    Example 5:

    - -
    -Input: grid = [".M...","..#..","#..#.","C#.#.","...#F"], catJump = 3, mouseJump = 1
    -Output: true
    -
    -

     

    Constraints:

    @@ -98,13 +80,17 @@ ### Related Topics + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Math](../../tag/math/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] +### Similar Questions + 1. [Escape The Ghosts](../escape-the-ghosts) (Medium) + 1. [Cat and Mouse](../cat-and-mouse) (Hard) + ### Hints
    Hint 1 diff --git a/problems/cheapest-flights-within-k-stops/README.md b/problems/cheapest-flights-within-k-stops/README.md index b2cd7e7b3..04469ee9c 100644 --- a/problems/cheapest-flights-within-k-stops/README.md +++ b/problems/cheapest-flights-within-k-stops/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../k-th-smallest-prime-fraction "K-th Smallest Prime Fraction") diff --git a/problems/check-array-formation-through-concatenation/README.md b/problems/check-array-formation-through-concatenation/README.md index d010e77ab..21e3f6946 100644 --- a/problems/check-array-formation-through-concatenation/README.md +++ b/problems/check-array-formation-through-concatenation/README.md @@ -18,20 +18,13 @@

     

    Example 1:

    -
    -Input: arr = [85], pieces = [[85]]
    -Output: true
    -
    - -

    Example 2:

    -
     Input: arr = [15,88], pieces = [[88],[15]]
     Output: true
    -Explanation: Concatenate [15] then [88]
    +Explanation: Concatenate [15] then [88]
     
    -

    Example 3:

    +

    Example 2:

     Input: arr = [49,18,16], pieces = [[16,18,49]]
    @@ -39,18 +32,12 @@
     Explanation: Even though the numbers match, we cannot reorder pieces[0].
     
    -

    Example 4:

    +

    Example 3:

     Input: arr = [91,4,64,78], pieces = [[78],[4,64],[91]]
     Output: true
    -Explanation: Concatenate [91] then [4,64] then [78]
    - -

    Example 5:

    - -
    -Input: arr = [1,3,5,7], pieces = [[2,4,6,8]]
    -Output: false
    +Explanation: Concatenate [91] then [4,64] then [78]
     

     

    @@ -61,8 +48,8 @@
  • sum(pieces[i].length) == arr.length
  • 1 <= pieces[i].length <= arr.length
  • 1 <= arr[i], pieces[i][j] <= 100
  • -
  • The integers in arr are distinct.
  • -
  • The integers in pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).
  • +
  • The integers in arr are distinct.
  • +
  • The integers in pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).
  • ### Related Topics diff --git a/problems/check-if-a-parentheses-string-can-be-valid/README.md b/problems/check-if-a-parentheses-string-can-be-valid/README.md new file mode 100644 index 000000000..9145e429f --- /dev/null +++ b/problems/check-if-a-parentheses-string-can-be-valid/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../find-all-possible-recipes-from-given-supplies "Find All Possible Recipes from Given Supplies") +                 +[Next >](../abbreviating-the-product-of-a-range "Abbreviating the Product of a Range") + +## [2116. Check if a Parentheses String Can Be Valid (Medium)](https://leetcode.com/problems/check-if-a-parentheses-string-can-be-valid "判断一个括号字符串是否有效") + +

    A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true:

    + +
      +
    • It is ().
    • +
    • It can be written as AB (A concatenated with B), where A and B are valid parentheses strings.
    • +
    • It can be written as (A), where A is a valid parentheses string.
    • +
    + +

    You are given a parentheses string s and a string locked, both of length n. locked is a binary string consisting only of '0's and '1's. For each index i of locked,

    + +
      +
    • If locked[i] is '1', you cannot change s[i].
    • +
    • But if locked[i] is '0', you can change s[i] to either '(' or ')'.
    • +
    + +

    Return true if you can make s a valid parentheses string. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "))()))", locked = "010100"
    +Output: true
    +Explanation: locked[1] == '1' and locked[3] == '1', so we cannot change s[1] or s[3].
    +We change s[0] and s[4] to '(' while leaving s[2] and s[5] unchanged to make s valid.
    + +

    Example 2:

    + +
    +Input: s = "()()", locked = "0000"
    +Output: true
    +Explanation: We do not need to make any changes because s is already valid.
    +
    + +

    Example 3:

    + +
    +Input: s = ")", locked = "0"
    +Output: false
    +Explanation: locked permits us to change s[0]. 
    +Changing s[0] to either '(' or ')' will not make s valid.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == s.length == locked.length
    • +
    • 1 <= n <= 105
    • +
    • s[i] is either '(' or ')'.
    • +
    • locked[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Can an odd length string ever be valid? +
    + +
    +Hint 2 +From left to right, if a locked ')' is encountered, it must be balanced with either a locked '(' or an unlocked index on its left. If neither exist, what conclusion can be drawn? If both exist, which one is more preferable to use? +
    + +
    +Hint 3 +After the above, we may have locked indices of '(' and additional unlocked indices. How can you balance out the locked '(' now? What if you cannot balance any locked '('? +
    diff --git a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md index 9a2188d97..1e1302333 100644 --- a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md +++ b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../make-two-arrays-equal-by-reversing-sub-arrays "Make Two Arrays Equal by Reversing Sub-arrays") @@ -11,9 +11,7 @@ ## [1461. Check If a String Contains All Binary Codes of Size K (Medium)](https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k "检查一个字符串是否包含所有长度为 K 的二进制子串") -

    Given a binary string s and an integer k.

    - -

    Return true if every binary code of length k is a substring of s. Otherwise, return false.

    +

    Given a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.

     

    Example 1:

    @@ -21,37 +19,23 @@
     Input: s = "00110110", k = 2
     Output: true
    -Explanation: The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indicies 0, 1, 3 and 2 respectively.
    +Explanation: The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indices 0, 1, 3 and 2 respectively.
     

    Example 2:

    -
    -Input: s = "00110", k = 2
    -Output: true
    -
    - -

    Example 3:

    -
     Input: s = "0110", k = 1
     Output: true
     Explanation: The binary codes of length 1 are "0" and "1", it is clear that both exist as a substring. 
     
    -

    Example 4:

    +

    Example 3:

     Input: s = "0110", k = 2
     Output: false
    -Explanation: The binary code "00" is of length 2 and doesn't exist in the array.
    -
    - -

    Example 5:

    - -
    -Input: s = "0000000001011100", k = 4
    -Output: false
    +Explanation: The binary code "00" is of length 2 and does not exist in the array.
     

     

    @@ -64,11 +48,11 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md index 68d50de68..95c2506ca 100644 --- a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md +++ b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../active-users "Active Users") @@ -42,20 +42,6 @@ Explanation: "you" is not a prefix of any word in the sentence. -

    Example 4:

    - -
    -Input: sentence = "i use triple pillow", searchWord = "pill"
    -Output: 4
    -
    - -

    Example 5:

    - -
    -Input: sentence = "hello from the other side", searchWord = "they"
    -Output: -1
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-all-as-appears-before-all-bs/README.md b/problems/check-if-all-as-appears-before-all-bs/README.md new file mode 100644 index 000000000..a5c03bdf8 --- /dev/null +++ b/problems/check-if-all-as-appears-before-all-bs/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../minimum-operations-to-remove-adjacent-ones-in-matrix "Minimum Operations to Remove Adjacent Ones in Matrix") +                 +[Next >](../number-of-laser-beams-in-a-bank "Number of Laser Beams in a Bank") + +## [2124. Check if All A's Appears Before All B's (Easy)](https://leetcode.com/problems/check-if-all-as-appears-before-all-bs "检查是否所有 A 都在 B 之前") + +

    Given a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "aaabbb"
    +Output: true
    +Explanation:
    +The 'a's are at indices 0, 1, and 2, while the 'b's are at indices 3, 4, and 5.
    +Hence, every 'a' appears before every 'b' and we return true.
    +
    + +

    Example 2:

    + +
    +Input: s = "abab"
    +Output: false
    +Explanation:
    +There is an 'a' at index 2 and a 'b' at index 1.
    +Hence, not every 'a' appears before every 'b' and we return false.
    +
    + +

    Example 3:

    + +
    +Input: s = "bbb"
    +Output: true
    +Explanation:
    +There are no 'a's, hence, every 'a' appears before every 'b' and we return true.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s[i] is either 'a' or 'b'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +You can check the opposite: check if there is a ‘b’ before an ‘a’. Then, negate and return that answer. +
    + +
    +Hint 2 +s should not have any occurrences of “ba” as a substring. +
    diff --git a/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md b/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md index d33963e44..aacdbbaa9 100644 --- a/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md +++ b/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md @@ -46,6 +46,9 @@ [[String](../../tag/string/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Rings and Rods](../rings-and-rods) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md b/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md index ce29c124c..caeebf97b 100644 --- a/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md +++ b/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md @@ -74,32 +74,6 @@ - The original string encoded as s2 must start with the letter 'c'. -

    Example 4:

    - -
    -Input: s1 = "112s", s2 = "g841"
    -Output: true
    -Explanation: It is possible that "gaaaaaaaaaaaas" was the original string
    -- "gaaaaaaaaaaaas"
    -  -> Split:      ["g", "aaaaaaaaaaaa", "s"]
    -  -> Replace:    ["1", "12",           "s"]
    -  -> Concatenate: "112s", which is s1.
    -- "gaaaaaaaaaaaas"
    -  -> Split:      ["g", "aaaaaaaa", "aaaa", "s"]
    -  -> Replace:    ["g", "8",        "4",    "1"]
    -  -> Concatenate: "g841", which is s2.
    -
    - -

    Example 5:

    - -
    -Input: s1 = "ab", s2 = "a2"
    -Output: false
    -Explanation: It is impossible.
    -- The original string encoded as s1 has two letters.
    -- The original string encoded as s2 has three letters.
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-array-is-sorted-and-rotated/README.md b/problems/check-if-array-is-sorted-and-rotated/README.md index f10753e75..0db6947c5 100644 --- a/problems/check-if-array-is-sorted-and-rotated/README.md +++ b/problems/check-if-array-is-sorted-and-rotated/README.md @@ -44,24 +44,6 @@ You can rotate the array by x = 3 positions to begin on the the element of value You can rotate the array by x = 0 positions (i.e. no rotation) to make nums. -

    Example 4:

    - -
    -Input: nums = [1,1,1]
    -Output: true
    -Explanation: [1,1,1] is the original sorted array.
    -You can rotate any number of positions to make nums.
    -
    - -

    Example 5:

    - -
    -Input: nums = [2,1]
    -Output: true
    -Explanation: [1,2] is the original sorted array.
    -You can rotate the array by x = 5 positions to begin on the element of value 2: [2,1].
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-array-pairs-are-divisible-by-k/README.md b/problems/check-if-array-pairs-are-divisible-by-k/README.md index 729dfd51c..2eeb96e92 100644 --- a/problems/check-if-array-pairs-are-divisible-by-k/README.md +++ b/problems/check-if-array-pairs-are-divisible-by-k/README.md @@ -13,9 +13,9 @@

    Given an array of integers arr of even length n and an integer k.

    -

    We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.

    +

    We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.

    -

    Return True If you can find a way to do that or False otherwise.

    +

    Return true If you can find a way to do that or false otherwise.

     

    Example 1:

    @@ -42,20 +42,6 @@ Explanation: You can try all possible pairs to see that there is no way to divide arr into 3 pairs each with sum divisible by 10. -

    Example 4:

    - -
    -Input: arr = [-10,10], k = 2
    -Output: true
    -
    - -

    Example 5:

    - -
    -Input: arr = [-1,1,-2,2,-3,3,-4,4], k = 3
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md index 1306dc3e1..60756572a 100644 --- a/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md +++ b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md @@ -40,6 +40,9 @@ ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Longer Contiguous Segments of Ones than Zeros](../longer-contiguous-segments-of-ones-than-zeros) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-every-row-and-column-contains-all-numbers/README.md b/problems/check-if-every-row-and-column-contains-all-numbers/README.md new file mode 100644 index 000000000..b3597801f --- /dev/null +++ b/problems/check-if-every-row-and-column-contains-all-numbers/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../stamping-the-grid "Stamping the Grid") +                 +[Next >](../minimum-swaps-to-group-all-1s-together-ii "Minimum Swaps to Group All 1's Together II") + +## [2133. Check if Every Row and Column Contains All Numbers (Easy)](https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers "检查是否每一行每一列都包含全部整数") + +

    An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive).

    + +

    Given an n x n integer matrix matrix, return true if the matrix is valid. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: matrix = [[1,2,3],[3,1,2],[2,3,1]]
    +Output: true
    +Explanation: In this case, n = 3, and every row and column contains the numbers 1, 2, and 3.
    +Hence, we return true.
    +
    + +

    Example 2:

    + +
    +Input: matrix = [[1,1,1],[1,2,3],[1,2,3]]
    +Output: false
    +Explanation: In this case, n = 3, but the first row and the first column do not contain the numbers 2 or 3.
    +Hence, we return false.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == matrix.length == matrix[i].length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= matrix[i][j] <= n
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Use for loops to check each row for every number from 1 to n. Similarly, do the same for each column. +
    + +
    +Hint 2 +For each check, you can keep a set of the unique elements in the checked row/col. By the end of the check, the size of the set should be n. +
    diff --git a/problems/check-if-n-and-its-double-exist/README.md b/problems/check-if-n-and-its-double-exist/README.md index 5eead7909..c54a20cf5 100644 --- a/problems/check-if-n-and-its-double-exist/README.md +++ b/problems/check-if-n-and-its-double-exist/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game-iv "Jump Game IV") @@ -61,6 +61,9 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Keep Multiplying Found Values by Two](../keep-multiplying-found-values-by-two) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-numbers-are-ascending-in-a-sentence/README.md b/problems/check-if-numbers-are-ascending-in-a-sentence/README.md index 7c77fe501..f23398623 100644 --- a/problems/check-if-numbers-are-ascending-in-a-sentence/README.md +++ b/problems/check-if-numbers-are-ascending-in-a-sentence/README.md @@ -47,15 +47,6 @@ They are strictly increasing from left to right: 1 < 3 < 4 < 6 < 12. Explanation: The numbers in s are: 7, 51, 50, 60. They are not strictly increasing. -

    Example 4:

    - -
    -Input: s = "4 5 11 26"
    -Output: true
    -Explanation: The numbers in s are: 4, 5, 11, 26.
    -They are strictly increasing from left to right: 4 < 5 < 11 < 26.
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-one-string-swap-can-make-strings-equal/README.md b/problems/check-if-one-string-swap-can-make-strings-equal/README.md index d278fdcd0..97904c0b9 100644 --- a/problems/check-if-one-string-swap-can-make-strings-equal/README.md +++ b/problems/check-if-one-string-swap-can-make-strings-equal/README.md @@ -40,13 +40,6 @@ Explanation: The two strings are already equal, so no string swap operation is required. -

    Example 4:

    - -
    -Input: s1 = "abcd", s2 = "dcba"
    -Output: false
    -
    -

     

    Constraints:

    @@ -61,6 +54,9 @@ [[String](../../tag/string/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Buddy Strings](../buddy-strings) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md index 439964b1e..59a65dbb5 100644 --- a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md +++ b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md @@ -11,17 +11,19 @@ ## [1585. Check If String Is Transformable With Substring Sort Operations (Hard)](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") -

    Given two strings s and t, you want to transform string s into string t using the following operation any number of times:

    +

    Given two strings s and t, transform string s into string t using the following operation any number of times:

      -
    • Choose a non-empty substring in s and sort it in-place so the characters are in ascending order.
    • +
    • Choose a non-empty substring in s and sort it in place so the characters are in ascending order. +
        +
      • For example, applying the operation on the underlined substring in "14234" results in "12344".
      • +
      +
    -

    For example, applying the operation on the underlined substring in "14234" results in "12344".

    +

    Return true if it is possible to transform s into t. Otherwise, return false.

    -

    Return true if it is possible to transform string s into string t. Otherwise, return false.

    - -

    A substring is a contiguous sequence of characters within a string.

    +

    A substring is a contiguous sequence of characters within a string.

     

    Example 1:

    @@ -51,20 +53,13 @@ Output: false -

    Example 4:

    - -
    -Input: s = "1", t = "2"
    -Output: false
    -
    -

     

    Constraints:

    • s.length == t.length
    • 1 <= s.length <= 105
    • -
    • s and t only contain digits from '0' to '9'.
    • +
    • s and t consist of only digits.
    ### Related Topics diff --git a/problems/checking-existence-of-edge-length-limited-paths/README.md b/problems/checking-existence-of-edge-length-limited-paths/README.md index 86f617a92..cb9115df3 100644 --- a/problems/checking-existence-of-edge-length-limited-paths/README.md +++ b/problems/checking-existence-of-edge-length-limited-paths/README.md @@ -52,14 +52,11 @@ For the second query, there is a path (0 -> 1 -> 2) of two edges with dist ### Related Topics - [[Array](../../tag/array/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Checking Existence of Edge Length Limited Paths II](../checking-existence-of-edge-length-limited-paths-ii) (Hard) - ### Hints
    Hint 1 diff --git a/problems/cherry-pickup-ii/README.md b/problems/cherry-pickup-ii/README.md index 0dac251a8..e44b8c7f0 100644 --- a/problems/cherry-pickup-ii/README.md +++ b/problems/cherry-pickup-ii/README.md @@ -11,61 +11,48 @@ ## [1463. Cherry Pickup II (Hard)](https://leetcode.com/problems/cherry-pickup-ii "摘樱桃 II") -

    Given a rows x cols matrix grid representing a field of cherries. Each cell in grid represents the number of cherries that you can collect.

    +

    You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell.

    -

    You have two robots that can collect cherries for you, Robot #1 is located at the top-left corner (0,0) , and Robot #2 is located at the top-right corner (0, cols-1) of the grid.

    +

    You have two robots that can collect cherries for you:

    -

    Return the maximum number of cherries collection using both robots  by following the rules below:

    +
      +
    • Robot #1 is located at the top-left corner (0, 0), and
    • +
    • Robot #2 is located at the top-right corner (0, cols - 1).
    • +
    + +

    Return the maximum number of cherries collection using both robots by following the rules below:

      -
    • From a cell (i,j), robots can move to cell (i+1, j-1) , (i+1, j) or (i+1, j+1).
    • -
    • When any robot is passing through a cell, It picks it up all cherries, and the cell becomes an empty cell (0).
    • -
    • When both robots stay on the same cell, only one of them takes the cherries.
    • -
    • Both robots cannot move outside of the grid at any moment.
    • -
    • Both robots should reach the bottom row in the grid.
    • +
    • From a cell (i, j), robots can move to cell (i + 1, j - 1), (i + 1, j), or (i + 1, j + 1).
    • +
    • When any robot passes through a cell, It picks up all cherries, and the cell becomes an empty cell.
    • +
    • When both robots stay in the same cell, only one takes the cherries.
    • +
    • Both robots cannot move outside of the grid at any moment.
    • +
    • Both robots should reach the bottom row in grid.

     

    Example 1:

    - -

    - +
     Input: grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]
     Output: 24
    -Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
    +Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
     Cherries taken by Robot #1, (3 + 2 + 5 + 2) = 12.
     Cherries taken by Robot #2, (1 + 5 + 5 + 1) = 12.
     Total of cherries: 12 + 12 = 24.
     

    Example 2:

    - -

    - +
     Input: grid = [[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]
     Output: 28
    -Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
    +Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
     Cherries taken by Robot #1, (1 + 9 + 5 + 2) = 17.
     Cherries taken by Robot #2, (1 + 3 + 4 + 3) = 11.
     Total of cherries: 17 + 11 = 28.
     
    -

    Example 3:

    - -
    -Input: grid = [[1,0,0,3],[0,0,0,3],[0,0,3,3],[9,0,3,3]]
    -Output: 22
    -
    - -

    Example 4:

    - -
    -Input: grid = [[1,1],[1,1]]
    -Output: 4
    -
    -

     

    Constraints:

    @@ -73,7 +60,7 @@ Total of cherries: 17 + 11 = 28.
  • rows == grid.length
  • cols == grid[i].length
  • 2 <= rows, cols <= 70
  • -
  • 0 <= grid[i][j] <= 100 
  • +
  • 0 <= grid[i][j] <= 100
  • ### Related Topics diff --git a/problems/cherry-pickup/README.md b/problems/cherry-pickup/README.md index 25337a3d5..07f1b153f 100644 --- a/problems/cherry-pickup/README.md +++ b/problems/cherry-pickup/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-and-earn "Delete and Earn") diff --git a/problems/choose-numbers-from-two-arrays-in-range/README.md b/problems/choose-numbers-from-two-arrays-in-range/README.md new file mode 100644 index 000000000..d35ea7619 --- /dev/null +++ b/problems/choose-numbers-from-two-arrays-in-range/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../the-number-of-passengers-in-each-bus-i "The Number of Passengers in Each Bus I") +                 +[Next >](../minimum-cost-of-buying-candies-with-discount "Minimum Cost of Buying Candies With Discount") + +## [2143. Choose Numbers From Two Arrays in Range (Hard)](https://leetcode.com/problems/choose-numbers-from-two-arrays-in-range "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +If you know the possible sums you can get for a range [l, r], how can you use this information to calculate the possible sums you can get for a range [l, r + 1]? +
    + +
    +Hint 2 +For the range [l, r], if it is possible to choose elements such that the sum of elements you picked from nums1 is x and the sum of elements you picked from nums2 is y, then (x + nums1[r + 1], y) and (x, y + nums2[r + 1]) are possible sums you can get in the range [l, r + 1]. +
    + +
    +Hint 3 +How can we save the possible sums obtainable at a given index so that we can reuse this information later? +
    diff --git a/problems/cinema-seat-allocation/README.md b/problems/cinema-seat-allocation/README.md index b08c37802..2a9094e0f 100644 --- a/problems/cinema-seat-allocation/README.md +++ b/problems/cinema-seat-allocation/README.md @@ -57,10 +57,10 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/circle-and-rectangle-overlapping/README.md b/problems/circle-and-rectangle-overlapping/README.md index 3f115e148..546cedeb1 100644 --- a/problems/circle-and-rectangle-overlapping/README.md +++ b/problems/circle-and-rectangle-overlapping/README.md @@ -11,61 +11,46 @@ ## [1401. Circle and Rectangle Overlapping (Medium)](https://leetcode.com/problems/circle-and-rectangle-overlapping "圆和矩形是否有重叠") -

    Given a circle represented as (radius, x_center, y_center) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.

    +

    You are given a circle represented as (radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.

    -

    Return True if the circle and rectangle are overlapped otherwise return False.

    - -

    In other words, check if there are any point (xi, yi) such that belongs to the circle and the rectangle at the same time.

    +

    Return true if the circle and rectangle are overlapped otherwise return false. In other words, check if there is any point (xi, yi) that belongs to the circle and the rectangle at the same time.

     

    Example 1:

    - -

    - +
    -Input: radius = 1, x_center = 0, y_center = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
    +Input: radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
     Output: true
    -Explanation: Circle and rectangle share the point (1,0) 
    +Explanation: Circle and rectangle share the point (1,0).
     

    Example 2:

    -

    -
    -Input: radius = 1, x_center = 0, y_center = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
    -Output: true
    +Input: radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1
    +Output: false
     

    Example 3:

    - -

    - +
    -Input: radius = 1, x_center = 1, y_center = 1, x1 = -3, y1 = -3, x2 = 3, y2 = 3
    +Input: radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
     Output: true
     
    -

    Example 4:

    - -
    -Input: radius = 1, x_center = 1, y_center = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1
    -Output: false
    -
    -

     

    Constraints:

    • 1 <= radius <= 2000
    • -
    • -10^4 <= x_center, y_center, x1, y1, x2, y2 <= 10^4
    • -
    • x1 < x2
    • -
    • y1 < y2
    • +
    • -104 <= xCenter, yCenter <= 104
    • +
    • -104 <= x1 < x2 <= 104
    • +
    • -104 <= y1 < y2 <= 104
    ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Hints
    diff --git a/problems/clone-binary-tree-with-random-pointer/README.md b/problems/clone-binary-tree-with-random-pointer/README.md index dac353e67..e50978b09 100644 --- a/problems/clone-binary-tree-with-random-pointer/README.md +++ b/problems/clone-binary-tree-with-random-pointer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../group-sold-products-by-the-date "Group Sold Products By The Date") diff --git a/problems/clone-n-ary-tree/README.md b/problems/clone-n-ary-tree/README.md index 7ef16942f..d1d37b8bd 100644 --- a/problems/clone-n-ary-tree/README.md +++ b/problems/clone-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree") diff --git a/problems/closest-binary-search-tree-value/README.md b/problems/closest-binary-search-tree-value/README.md index e1c3da73f..6178001ff 100644 --- a/problems/closest-binary-search-tree-value/README.md +++ b/problems/closest-binary-search-tree-value/README.md @@ -35,10 +35,10 @@ ### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/closest-dessert-cost/README.md b/problems/closest-dessert-cost/README.md index 82b8f7617..876fe6d2c 100644 --- a/problems/closest-dessert-cost/README.md +++ b/problems/closest-dessert-cost/README.md @@ -65,13 +65,6 @@ Total: 3 + 4 + 10 + 0 = 17. You cannot make a dessert with a total cost of 18. Explanation: It is possible to make desserts with cost 8 and 10. Return 8 as it is the lower cost. -

    Example 4:

    - -
    -Input: baseCosts = [10], toppingCosts = [1], target = 1
    -Output: 10
    -Explanation: Notice that you don't have to have any toppings, but you must have exactly one base.
    -

     

    Constraints:

    diff --git a/problems/combination-sum-ii/README.md b/problems/combination-sum-ii/README.md index c99f3bcb8..fa8221b01 100644 --- a/problems/combination-sum-ii/README.md +++ b/problems/combination-sum-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../combination-sum "Combination Sum") diff --git a/problems/combination-sum/README.md b/problems/combination-sum/README.md index 9a823c811..14716ac29 100644 --- a/problems/combination-sum/README.md +++ b/problems/combination-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-and-say "Count and Say") @@ -43,20 +43,6 @@ These are the only two combinations. Output: [] -

    Example 4:

    - -
    -Input: candidates = [1], target = 1
    -Output: [[1]]
    -
    - -

    Example 5:

    - -
    -Input: candidates = [1], target = 2
    -Output: [[1,1]]
    -
    -

     

    Constraints:

    diff --git a/problems/complement-of-base-10-integer/README.md b/problems/complement-of-base-10-integer/README.md index ba166f6bd..8b3cbb658 100644 --- a/problems/complement-of-base-10-integer/README.md +++ b/problems/complement-of-base-10-integer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-search-tree-from-preorder-traversal "Construct Binary Search Tree from Preorder Traversal") diff --git a/problems/concatenation-of-consecutive-binary-numbers/README.md b/problems/concatenation-of-consecutive-binary-numbers/README.md index 1bd4d3bc7..c79a5b348 100644 --- a/problems/concatenation-of-consecutive-binary-numbers/README.md +++ b/problems/concatenation-of-consecutive-binary-numbers/README.md @@ -49,8 +49,8 @@ After modulo 109 + 7, the result is 505379714. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/consecutive-characters/README.md b/problems/consecutive-characters/README.md index 9ea25d484..c3ea0e124 100644 --- a/problems/consecutive-characters/README.md +++ b/problems/consecutive-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../apples-oranges "Apples & Oranges") @@ -32,27 +32,6 @@ Explanation: The substring "eeeee" is of length 5 with the character 'e' only. -

    Example 3:

    - -
    -Input: s = "triplepillooooow"
    -Output: 5
    -
    - -

    Example 4:

    - -
    -Input: s = "hooraaaaaaaaaaay"
    -Output: 11
    -
    - -

    Example 5:

    - -
    -Input: s = "tourist"
    -Output: 1
    -
    -

     

    Constraints:

    @@ -64,10 +43,6 @@ ### Related Topics [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) - 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) - ### Hints
    Hint 1 diff --git a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md index 5271b0d6f..f48710384 100644 --- a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-tree-from-preorder-and-inorder-traversal "Construct Binary Tree from Preorder and Inorder Traversal") @@ -42,10 +42,10 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Tree](../../tag/tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md index 37ae76162..eb1be2100 100644 --- a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fair-candy-swap "Fair Candy Swap") diff --git a/problems/construct-binary-tree-from-string/README.md b/problems/construct-binary-tree-from-string/README.md index 05bb73e4e..985211a95 100644 --- a/problems/construct-binary-tree-from-string/README.md +++ b/problems/construct-binary-tree-from-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../encode-and-decode-tinyurl "Encode and Decode TinyURL") @@ -38,9 +38,9 @@

    ### Related Topics + [[String](../../tag/string/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/container-with-most-water/README.md b/problems/container-with-most-water/README.md index edfe43eec..b3b25e052 100644 --- a/problems/container-with-most-water/README.md +++ b/problems/container-with-most-water/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../regular-expression-matching "Regular Expression Matching") @@ -11,7 +11,11 @@ ## [11. Container With Most Water (Medium)](https://leetcode.com/problems/container-with-most-water "盛最多水的容器") -

    Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.

    +

    You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).

    + +

    Find two lines that together with the x-axis form a container, such that the container contains the most water.

    + +

    Return the maximum amount of water a container can store.

    Notice that you may not slant the container.

    @@ -21,7 +25,7 @@
     Input: height = [1,8,6,2,5,4,8,3,7]
     Output: 49
    -Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.
    +Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.
     

    Example 2:

    @@ -31,20 +35,6 @@ Output: 1 -

    Example 3:

    - -
    -Input: height = [4,3,2,1,4]
    -Output: 16
    -
    - -

    Example 4:

    - -
    -Input: height = [1,2,1]
    -Output: 2
    -
    -

     

    Constraints:

    diff --git a/problems/contiguous-array/README.md b/problems/contiguous-array/README.md index b0b4dbc33..39dec4a3a 100644 --- a/problems/contiguous-array/README.md +++ b/problems/contiguous-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-word-in-dictionary-through-deleting "Longest Word in Dictionary through Deleting") diff --git a/problems/continuous-subarray-sum/README.md b/problems/continuous-subarray-sum/README.md index b70633b7c..f182bd82e 100644 --- a/problems/continuous-subarray-sum/README.md +++ b/problems/continuous-subarray-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-uncommon-subsequence-ii "Longest Uncommon Subsequence II") diff --git a/problems/convert-1d-array-into-2d-array/README.md b/problems/convert-1d-array-into-2d-array/README.md index 43070be5f..1a2c6e69f 100644 --- a/problems/convert-1d-array-into-2d-array/README.md +++ b/problems/convert-1d-array-into-2d-array/README.md @@ -23,8 +23,7 @@
     Input: original = [1,2,3,4], m = 2, n = 2
     Output: [[1,2],[3,4]]
    -Explanation:
    -The constructed 2D array should contain 2 rows and 2 columns.
    +Explanation: The constructed 2D array should contain 2 rows and 2 columns.
     The first group of n=2 elements in original, [1,2], becomes the first row in the constructed 2D array.
     The second group of n=2 elements in original, [3,4], becomes the second row in the constructed 2D array.
     
    @@ -34,8 +33,7 @@ The second group of n=2 elements in original, [3,4], becomes the second row in t
     Input: original = [1,2,3], m = 1, n = 3
     Output: [[1,2,3]]
    -Explanation:
    -The constructed 2D array should contain 1 row and 3 columns.
    +Explanation: The constructed 2D array should contain 1 row and 3 columns.
     Put all three elements in original into the first row of the constructed 2D array.
     
    @@ -44,21 +42,10 @@ Put all three elements in original into the first row of the constructed 2D arra
     Input: original = [1,2], m = 1, n = 1
     Output: []
    -Explanation:
    -There are 2 elements in original.
    +Explanation: There are 2 elements in original.
     It is impossible to fit 2 elements in a 1x1 2D array, so return an empty 2D array.
     
    -

    Example 4:

    - -
    -Input: original = [3], m = 1, n = 2
    -Output: []
    -Explanation:
    -There is 1 element in original.
    -It is impossible to make 1 element fill all the spots in a 1x2 2D array, so return an empty 2D array.
    -
    -

     

    Constraints:

    diff --git a/problems/convert-bst-to-greater-tree/README.md b/problems/convert-bst-to-greater-tree/README.md index 203b61449..d29540249 100644 --- a/problems/convert-bst-to-greater-tree/README.md +++ b/problems/convert-bst-to-greater-tree/README.md @@ -23,7 +23,7 @@

     

    Example 1:

    - +
     Input: root = [4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]
     Output: [30,36,21,36,35,26,15,null,null,null,33,null,null,null,8]
    @@ -36,20 +36,6 @@
     Output: [1,null,1]
     
    -

    Example 3:

    - -
    -Input: root = [1,0,2]
    -Output: [3,3,2]
    -
    - -

    Example 4:

    - -
    -Input: root = [3,2,4,1]
    -Output: [7,9,4,10]
    -
    -

     

    Constraints:

    diff --git a/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md b/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md index 7f0be835b..c06050fea 100644 --- a/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md +++ b/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md @@ -11,16 +11,16 @@ ## [1317. Convert Integer to the Sum of Two No-Zero Integers (Easy)](https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers "将整数转换为两个无零整数的和") -

    Given an integer n. No-Zero integer is a positive integer which doesn't contain any 0 in its decimal representation.

    +

    No-Zero integer is a positive integer that does not contain any 0 in its decimal representation.

    -

    Return a list of two integers [A, B] where:

    +

    Given an integer n, return a list of two integers [A, B] where:

      -
    • A and B are No-Zero integers.
    • +
    • A and B are No-Zero integers.
    • A + B = n
    -

    It's guarateed that there is at least one valid solution. If there are many valid solutions you can return any of them.

    +

    The test cases are generated so that there is at least one valid solution. If there are many valid solutions you can return any of them.

     

    Example 1:

    @@ -28,7 +28,7 @@
     Input: n = 2
     Output: [1,1]
    -Explanation: A = 1, B = 1. A + B = n and both A and B don't contain any 0 in their decimal representation.
    +Explanation: A = 1, B = 1. A + B = n and both A and B do not contain any 0 in their decimal representation.
     

    Example 2:

    @@ -38,32 +38,11 @@ Output: [2,9] -

    Example 3:

    - -
    -Input: n = 10000
    -Output: [1,9999]
    -
    - -

    Example 4:

    - -
    -Input: n = 69
    -Output: [1,68]
    -
    - -

    Example 5:

    - -
    -Input: n = 1010
    -Output: [11,999]
    -
    -

     

    Constraints:

      -
    • 2 <= n <= 10^4
    • +
    • 2 <= n <= 104
    ### Related Topics diff --git a/problems/convert-sorted-array-to-binary-search-tree/README.md b/problems/convert-sorted-array-to-binary-search-tree/README.md index 1a722bd23..83415f923 100644 --- a/problems/convert-sorted-array-to-binary-search-tree/README.md +++ b/problems/convert-sorted-array-to-binary-search-tree/README.md @@ -43,10 +43,10 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] - [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Array](../../tag/array/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/convert-sorted-list-to-binary-search-tree/README.md b/problems/convert-sorted-list-to-binary-search-tree/README.md index e3261f6d8..e91c9b31d 100644 --- a/problems/convert-sorted-list-to-binary-search-tree/README.md +++ b/problems/convert-sorted-list-to-binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-sorted-array-to-binary-search-tree "Convert Sorted Array to Binary Search Tree") @@ -17,7 +17,7 @@

     

    Example 1:

    - +
     Input: head = [-10,-3,0,5,9]
     Output: [0,-3,9,-10,null,5]
    @@ -31,20 +31,6 @@
     Output: []
     
    -

    Example 3:

    - -
    -Input: head = [0]
    -Output: [0]
    -
    - -

    Example 4:

    - -
    -Input: head = [1,3]
    -Output: [3,1]
    -
    -

     

    Constraints:

    diff --git a/problems/coordinate-with-maximum-network-quality/README.md b/problems/coordinate-with-maximum-network-quality/README.md index 91f1ce025..6ada4d259 100644 --- a/problems/coordinate-with-maximum-network-quality/README.md +++ b/problems/coordinate-with-maximum-network-quality/README.md @@ -59,23 +59,6 @@ No other coordinate has a higher network quality. Explanation: Coordinate (1, 2) has the highest network quality. -

    Example 4:

    - -
    -Input: towers = [[2,1,9],[0,1,9]], radius = 2
    -Output: [0,1]
    -Explanation: Both (0, 1) and (2, 1) are optimal in terms of quality, but (0, 1) is lexicographically minimal.
    -
    - -

    Example 5:

    - -
    -Input: towers = [[42,0,0]], radius = 7
    -Output: [0,0]
    -Explanation: The network quality is 0 at every coordinate, even at the tower's location.
    -Thus, the lexicographically minimum non-negative coordinate is (0, 0).
    -
    -

     

    Constraints:

    diff --git a/problems/corporate-flight-bookings/README.md b/problems/corporate-flight-bookings/README.md index e48e88b45..63e874b4c 100644 --- a/problems/corporate-flight-bookings/README.md +++ b/problems/corporate-flight-bookings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../defanging-an-ip-address "Defanging an IP Address") diff --git a/problems/count-all-possible-routes/README.md b/problems/count-all-possible-routes/README.md index 9dfddc3fe..5de9e8ec3 100644 --- a/problems/count-all-possible-routes/README.md +++ b/problems/count-all-possible-routes/README.md @@ -25,7 +25,7 @@
     Input: locations = [2,3,6,8,4], start = 1, finish = 3, fuel = 5
     Output: 4
    -Explanation: The following are all possible routes, each uses 5 units of fuel:
    +Explanation: The following are all possible routes, each uses 5 units of fuel:
     1 -> 3
     1 -> 2 -> 3
     1 -> 4 -> 3
    @@ -37,7 +37,7 @@
     
     Input: locations = [4,3,1], start = 1, finish = 0, fuel = 6
     Output: 5
    -Explanation: The following are all possible routes:
    +Explanation: The following are all possible routes:
     1 -> 0, used fuel = 1
     1 -> 2 -> 0, used fuel = 5
     1 -> 2 -> 1 -> 0, used fuel = 5
    @@ -50,21 +50,7 @@
     
     Input: locations = [5,2,1], start = 0, finish = 2, fuel = 3
     Output: 0
    -Explanation: It's impossible to get from 0 to 2 using only 3 units of fuel since the shortest route needs 4 units of fuel.
    - -

    Example 4:

    - -
    -Input: locations = [2,1,5], start = 0, finish = 0, fuel = 3
    -Output: 2
    -Explanation: There are two possible routes, 0 and 0 -> 1 -> 0.
    - -

    Example 5:

    - -
    -Input: locations = [1,2,3], start = 0, finish = 2, fuel = 40
    -Output: 615088286
    -Explanation: The total number of possible routes is 2615088300. Taking this number modulo 10^9 + 7 gives us 615088286.
    +Explanation: It is impossible to get from 0 to 2 using only 3 units of fuel since the shortest route needs 4 units of fuel.
     

     

    @@ -79,9 +65,9 @@ ### Related Topics - [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Memoization](../../tag/memoization/README.md)] ### Hints
    diff --git a/problems/count-all-valid-pickup-and-delivery-options/README.md b/problems/count-all-valid-pickup-and-delivery-options/README.md index 2ff24eb41..32cda0c3e 100644 --- a/problems/count-all-valid-pickup-and-delivery-options/README.md +++ b/problems/count-all-valid-pickup-and-delivery-options/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-substrings-containing-all-three-characters "Number of Substrings Containing All Three Characters") diff --git a/problems/count-binary-substrings/README.md b/problems/count-binary-substrings/README.md index 42e1f4151..de93a8d21 100644 --- a/problems/count-binary-substrings/README.md +++ b/problems/count-binary-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-area-of-island "Max Area of Island") diff --git a/problems/count-common-words-with-one-occurrence/README.md b/problems/count-common-words-with-one-occurrence/README.md new file mode 100644 index 000000000..776b6f8bc --- /dev/null +++ b/problems/count-common-words-with-one-occurrence/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../drop-type-1-orders-for-customers-with-type-0-orders "Drop Type 1 Orders for Customers With Type 0 Orders") +                 +[Next >](../minimum-number-of-buckets-required-to-collect-rainwater-from-houses "Minimum Number of Buckets Required to Collect Rainwater from Houses") + +## [2085. Count Common Words With One Occurrence (Easy)](https://leetcode.com/problems/count-common-words-with-one-occurrence "统计出现过一次的公共字符串") + +

    Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.

    + +

     

    +

    Example 1:

    + +
    +Input: words1 = ["leetcode","is","amazing","as","is"], words2 = ["amazing","leetcode","is"]
    +Output: 2
    +Explanation:
    +- "leetcode" appears exactly once in each of the two arrays. We count this string.
    +- "amazing" appears exactly once in each of the two arrays. We count this string.
    +- "is" appears in each of the two arrays, but there are 2 occurrences of it in words1. We do not count this string.
    +- "as" appears once in words1, but does not appear in words2. We do not count this string.
    +Thus, there are 2 strings that appear exactly once in each of the two arrays.
    +
    + +

    Example 2:

    + +
    +Input: words1 = ["b","bb","bbb"], words2 = ["a","aa","aaa"]
    +Output: 0
    +Explanation: There are no strings that appear in each of the two arrays.
    +
    + +

    Example 3:

    + +
    +Input: words1 = ["a","ab"], words2 = ["a","a","a","ab"]
    +Output: 1
    +Explanation: The only string that appears exactly once in each of the two arrays is "ab".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words1.length, words2.length <= 1000
    • +
    • 1 <= words1[i].length, words2[j].length <= 30
    • +
    • words1[i] and words2[j] consists only of lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +Could you try every word? +
    + +
    +Hint 2 +Could you use a hash map to achieve a good complexity? +
    diff --git a/problems/count-different-palindromic-subsequences/README.md b/problems/count-different-palindromic-subsequences/README.md index ffc4a31e6..c0d8334f8 100644 --- a/problems/count-different-palindromic-subsequences/README.md +++ b/problems/count-different-palindromic-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../my-calendar-i "My Calendar I") diff --git a/problems/count-elements-with-strictly-smaller-and-greater-elements/README.md b/problems/count-elements-with-strictly-smaller-and-greater-elements/README.md new file mode 100644 index 000000000..199267f0b --- /dev/null +++ b/problems/count-elements-with-strictly-smaller-and-greater-elements/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](../number-of-ways-to-divide-a-long-corridor "Number of Ways to Divide a Long Corridor") +                 +[Next >](../rearrange-array-elements-by-sign "Rearrange Array Elements by Sign") + +## [2148. Count Elements With Strictly Smaller and Greater Elements (Easy)](https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements "元素计数") + +

    Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [11,7,2,15]
    +Output: 2
    +Explanation: The element 7 has the element 2 strictly smaller than it and the element 11 strictly greater than it.
    +Element 11 has element 7 strictly smaller than it and element 15 strictly greater than it.
    +In total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.
    +
    + +

    Example 2:

    + +
    +Input: nums = [-3,3,3,90]
    +Output: 2
    +Explanation: The element 3 has the element -3 strictly smaller than it and the element 90 strictly greater than it.
    +Since there are two elements with the value 3, in total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • -105 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +All the elements in the array should be counted except for the minimum and maximum elements. +
    + +
    +Hint 2 +If the array has n elements, the answer will be n - count(min(nums)) - count(max(nums)) +
    + +
    +Hint 3 +This formula will not work in case the array has all the elements equal, why? +
    diff --git a/problems/count-fertile-pyramids-in-a-land/README.md b/problems/count-fertile-pyramids-in-a-land/README.md new file mode 100644 index 000000000..9e438e6a1 --- /dev/null +++ b/problems/count-fertile-pyramids-in-a-land/README.md @@ -0,0 +1,99 @@ + + + + + + + +[< Previous](../minimum-cost-homecoming-of-a-robot-in-a-grid "Minimum Cost Homecoming of a Robot in a Grid") +                 +[Next >](../find-target-indices-after-sorting-array "Find Target Indices After Sorting Array") + +## [2088. Count Fertile Pyramids in a Land (Hard)](https://leetcode.com/problems/count-fertile-pyramids-in-a-land "统计农场中肥沃金字塔的数目") + +

    A farmer has a rectangular grid of land with m rows and n columns that can be divided into unit cells. Each cell is either fertile (represented by a 1) or barren (represented by a 0). All cells outside the grid are considered barren.

    + +

    A pyramidal plot of land can be defined as a set of cells with the following criteria:

    + +
      +
    1. The number of cells in the set has to be greater than 1 and all cells must be fertile.
    2. +
    3. The apex of a pyramid is the topmost cell of the pyramid. The height of a pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r <= i <= r + h - 1 and c - (i - r) <= j <= c + (i - r).
    4. +
    + +

    An inverse pyramidal plot of land can be defined as a set of cells with similar criteria:

    + +
      +
    1. The number of cells in the set has to be greater than 1 and all cells must be fertile.
    2. +
    3. The apex of an inverse pyramid is the bottommost cell of the inverse pyramid. The height of an inverse pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r - h + 1 <= i <= r and c - (r - i) <= j <= c + (r - i).
    4. +
    + +

    Some examples of valid and invalid pyramidal (and inverse pyramidal) plots are shown below. Black cells indicate fertile cells.

    + +

    Given a 0-indexed m x n binary matrix grid representing the farmland, return the total number of pyramidal and inverse pyramidal plots that can be found in grid.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[0,1,1,0],[1,1,1,1]]
    +Output: 2
    +Explanation: The 2 possible pyramidal plots are shown in blue and red respectively.
    +There are no inverse pyramidal plots in this grid. 
    +Hence total number of pyramidal and inverse pyramidal plots is 2 + 0 = 2.
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,1,1],[1,1,1]]
    +Output: 2
    +Explanation: The pyramidal plot is shown in blue, and the inverse pyramidal plot is shown in red. 
    +Hence the total number of plots is 1 + 1 = 2.
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1,1,1,1,0],[1,1,1,1,1],[1,1,1,1,1],[0,1,0,0,1]]
    +Output: 13
    +Explanation: There are 7 pyramidal plots, 3 of which are shown in the 2nd and 3rd figures.
    +There are 6 inverse pyramidal plots, 2 of which are shown in the last figure.
    +The total number of plots is 7 + 6 = 13.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 1000
    • +
    • 1 <= m * n <= 105
    • +
    • grid[i][j] is either 0 or 1.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Think about how dynamic programming can help solve the problem. +
    + +
    +Hint 2 +For any fixed cell (r, c), can you calculate the maximum height of the pyramid for which it is the apex? Let us denote this value as dp[r][c]. +
    + +
    +Hint 3 +How will the values at dp[r+1][c-1] and dp[r+1][c+1] help in determining the value at dp[r][c]? +
    + +
    +Hint 4 +For the cell (r, c), is there a relation between the number of pyramids for which it serves as the apex and dp[r][c]? How does it help in calculating the answer? +
    diff --git a/problems/count-good-meals/README.md b/problems/count-good-meals/README.md index a79cf7106..472223138 100644 --- a/problems/count-good-meals/README.md +++ b/problems/count-good-meals/README.md @@ -48,6 +48,11 @@ Their respective sums are 4, 8, 8, and 16, all of which are powers of 2. [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] +### Similar Questions + 1. [Two Sum](../two-sum) (Easy) + 1. [Max Number of K-Sum Pairs](../max-number-of-k-sum-pairs) (Medium) + 1. [Find All Possible Recipes from Given Supplies](../find-all-possible-recipes-from-given-supplies) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-good-nodes-in-binary-tree/README.md b/problems/count-good-nodes-in-binary-tree/README.md index acab1defb..4a8baa459 100644 --- a/problems/count-good-nodes-in-binary-tree/README.md +++ b/problems/count-good-nodes-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../simplified-fractions "Simplified Fractions") diff --git a/problems/count-good-triplets/README.md b/problems/count-good-triplets/README.md index 782b76d51..10a302420 100644 --- a/problems/count-good-triplets/README.md +++ b/problems/count-good-triplets/README.md @@ -56,9 +56,6 @@ [[Array](../../tag/array/README.md)] [[Enumeration](../../tag/enumeration/README.md)] -### Similar Questions - 1. [Count Special Quadruplets](../count-special-quadruplets) (Easy) - ### Hints
    Hint 1 diff --git a/problems/count-largest-group/README.md b/problems/count-largest-group/README.md index 577545eae..38160b260 100644 --- a/problems/count-largest-group/README.md +++ b/problems/count-largest-group/README.md @@ -11,9 +11,11 @@ ## [1399. Count Largest Group (Easy)](https://leetcode.com/problems/count-largest-group "统计最大组的数目") -

    Given an integer n. Each number from 1 to n is grouped according to the sum of its digits. 

    +

    You are given an integer n.

    -

    Return how many groups have the largest size.

    +

    Each number from 1 to n is grouped according to the sum of its digits.

    + +

    Return the number of groups that have the largest size.

     

    Example 1:

    @@ -22,7 +24,8 @@ Input: n = 13 Output: 4 Explanation: There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13: -[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. There are 4 groups with largest size. +[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. +There are 4 groups with largest size.

    Example 2:

    @@ -33,25 +36,11 @@ Explanation: There are 2 groups [1], [2] of size 1.
    -

    Example 3:

    - -
    -Input: n = 15
    -Output: 6
    -
    - -

    Example 4:

    - -
    -Input: n = 24
    -Output: 5
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^4
    • +
    • 1 <= n <= 104
    ### Related Topics diff --git a/problems/count-negative-numbers-in-a-sorted-matrix/README.md b/problems/count-negative-numbers-in-a-sorted-matrix/README.md index b9aac1ed8..7bfda52f4 100644 --- a/problems/count-negative-numbers-in-a-sorted-matrix/README.md +++ b/problems/count-negative-numbers-in-a-sorted-matrix/README.md @@ -29,20 +29,6 @@ Output: 0 -

    Example 3:

    - -
    -Input: grid = [[1,-1],[-1,-1]]
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: grid = [[-1]]
    -Output: 1
    -
    -

     

    Constraints:

    diff --git a/problems/count-nice-pairs-in-an-array/README.md b/problems/count-nice-pairs-in-an-array/README.md index ce79ee89e..5cc54e815 100644 --- a/problems/count-nice-pairs-in-an-array/README.md +++ b/problems/count-nice-pairs-in-an-array/README.md @@ -52,6 +52,9 @@ [[Math](../../tag/math/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Number of Pairs of Interchangeable Rectangles](../number-of-pairs-of-interchangeable-rectangles) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-nodes-equal-to-sum-of-descendants/README.md b/problems/count-nodes-equal-to-sum-of-descendants/README.md index 4edd6ed06..3008e7d1d 100644 --- a/problems/count-nodes-equal-to-sum-of-descendants/README.md +++ b/problems/count-nodes-equal-to-sum-of-descendants/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-time-to-type-word-using-special-typewriter "Minimum Time to Type Word Using Special Typewriter") -## [1973. Count Nodes Equal to Sum of Descendants (Medium)](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants "") +## [1973. Count Nodes Equal to Sum of Descendants (Medium)](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants "值等于子节点值之和的节点数量") diff --git a/problems/count-number-of-pairs-with-absolute-difference-k/README.md b/problems/count-number-of-pairs-with-absolute-difference-k/README.md index 29e70cae0..588fa71df 100644 --- a/problems/count-number-of-pairs-with-absolute-difference-k/README.md +++ b/problems/count-number-of-pairs-with-absolute-difference-k/README.md @@ -63,6 +63,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/count-number-of-teams/README.md b/problems/count-number-of-teams/README.md index 2f27f44d2..2fb55323d 100644 --- a/problems/count-number-of-teams/README.md +++ b/problems/count-number-of-teams/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-lucky-integer-in-an-array "Find Lucky Integer in an Array") @@ -57,9 +57,9 @@ ### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] ### Hints
    diff --git a/problems/count-of-smaller-numbers-after-self/README.md b/problems/count-of-smaller-numbers-after-self/README.md index 84bfffbb5..70e0604bd 100644 --- a/problems/count-of-smaller-numbers-after-self/README.md +++ b/problems/count-of-smaller-numbers-after-self/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-vertical-order-traversal "Binary Tree Vertical Order Traversal") @@ -49,16 +49,15 @@ To the right of 1 there is 0 smaller element. ### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] - [[Merge Sort](../../tag/merge-sort/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] + [[Merge Sort](../../tag/merge-sort/README.md)] ### Similar Questions 1. [Count of Range Sum](../count-of-range-sum) (Hard) 1. [Queue Reconstruction by Height](../queue-reconstruction-by-height) (Medium) 1. [Reverse Pairs](../reverse-pairs) (Hard) - 1. [How Many Numbers Are Smaller Than the Current Number](../how-many-numbers-are-smaller-than-the-current-number) (Easy) diff --git a/problems/count-operations-to-obtain-zero/README.md b/problems/count-operations-to-obtain-zero/README.md new file mode 100644 index 000000000..019bc3626 --- /dev/null +++ b/problems/count-operations-to-obtain-zero/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../unique-substrings-with-equal-digit-frequency "Unique Substrings With Equal Digit Frequency") +                 +[Next >](../minimum-operations-to-make-the-array-alternating "Minimum Operations to Make the Array Alternating") + +## [2169. Count Operations to Obtain Zero (Easy)](https://leetcode.com/problems/count-operations-to-obtain-zero "得到 0 的操作数") + +

    You are given two non-negative integers num1 and num2.

    + +

    In one operation, if num1 >= num2, you must subtract num2 from num1, otherwise subtract num1 from num2.

    + +
      +
    • For example, if num1 = 5 and num2 = 4, subtract num2 from num1, thus obtaining num1 = 1 and num2 = 4. However, if num1 = 4 and num2 = 5, after one operation, num1 = 4 and num2 = 1.
    • +
    + +

    Return the number of operations required to make either num1 = 0 or num2 = 0.

    + +

     

    +

    Example 1:

    + +
    +Input: num1 = 2, num2 = 3
    +Output: 3
    +Explanation: 
    +- Operation 1: num1 = 2, num2 = 3. Since num1 < num2, we subtract num1 from num2 and get num1 = 2, num2 = 3 - 2 = 1.
    +- Operation 2: num1 = 2, num2 = 1. Since num1 > num2, we subtract num2 from num1.
    +- Operation 3: num1 = 1, num2 = 1. Since num1 == num2, we subtract num2 from num1.
    +Now num1 = 0 and num2 = 1. Since num1 == 0, we do not need to perform any further operations.
    +So the total number of operations required is 3.
    +
    + +

    Example 2:

    + +
    +Input: num1 = 10, num2 = 10
    +Output: 1
    +Explanation: 
    +- Operation 1: num1 = 10, num2 = 10. Since num1 == num2, we subtract num2 from num1 and get num1 = 10 - 10 = 0.
    +Now num1 = 0 and num2 = 10. Since num1 == 0, we are done.
    +So the total number of operations required is 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= num1, num2 <= 105
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Try simulating the process until either of the two integers is zero. +
    + +
    +Hint 2 +Count the number of operations done. +
    diff --git a/problems/count-pairs-in-two-arrays/README.md b/problems/count-pairs-in-two-arrays/README.md index f7cdb43e0..82a198799 100644 --- a/problems/count-pairs-in-two-arrays/README.md +++ b/problems/count-pairs-in-two-arrays/README.md @@ -9,7 +9,7 @@                  [Next >](../determine-whether-matrix-can-be-obtained-by-rotation "Determine Whether Matrix Can Be Obtained By Rotation") -## [1885. Count Pairs in Two Arrays (Medium)](https://leetcode.com/problems/count-pairs-in-two-arrays "") +## [1885. Count Pairs in Two Arrays (Medium)](https://leetcode.com/problems/count-pairs-in-two-arrays "统计数对") diff --git a/problems/count-pairs-with-xor-in-a-range/README.md b/problems/count-pairs-with-xor-in-a-range/README.md index 8195188bb..1f7764e98 100644 --- a/problems/count-pairs-with-xor-in-a-range/README.md +++ b/problems/count-pairs-with-xor-in-a-range/README.md @@ -55,9 +55,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Trie](../../tag/trie/README.md)] - [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/count-servers-that-communicate/README.md b/problems/count-servers-that-communicate/README.md index b5454c4ec..5e4c3cca0 100644 --- a/problems/count-servers-that-communicate/README.md +++ b/problems/count-servers-that-communicate/README.md @@ -57,12 +57,12 @@ Return the number of servers that communicate with any other server.

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] - [[Counting](../../tag/counting/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/count-student-number-in-departments/README.md b/problems/count-student-number-in-departments/README.md index dc03eb901..089034b63 100644 --- a/problems/count-student-number-in-departments/README.md +++ b/problems/count-student-number-in-departments/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-cumulative-salary-of-an-employee "Find Cumulative Salary of an Employee") diff --git a/problems/count-student-number-in-departments/mysql_schemas.sql b/problems/count-student-number-in-departments/mysql_schemas.sql index e4e479904..618e4666d 100644 --- a/problems/count-student-number-in-departments/mysql_schemas.sql +++ b/problems/count-student-number-in-departments/mysql_schemas.sql @@ -1,10 +1,10 @@ -CREATE TABLE IF NOT EXISTS student (student_id INT,student_name VARCHAR(45), gender VARCHAR(6), dept_id INT); -CREATE TABLE IF NOT EXISTS department (dept_id INT, dept_name VARCHAR(255)); -Truncate table student; -insert into student (student_id, student_name, gender, dept_id) values ('1', 'Jack', 'M', '1'); -insert into student (student_id, student_name, gender, dept_id) values ('2', 'Jane', 'F', '1'); -insert into student (student_id, student_name, gender, dept_id) values ('3', 'Mark', 'M', '2'); -Truncate table department; -insert into department (dept_id, dept_name) values ('1', 'Engineering'); -insert into department (dept_id, dept_name) values ('2', 'Science'); -insert into department (dept_id, dept_name) values ('3', 'Law'); +Create table If Not Exists Student (student_id int,student_name varchar(45), gender varchar(6), dept_id int); +Create table If Not Exists Department (dept_id int, dept_name varchar(255)); +Truncate table Student; +insert into Student (student_id, student_name, gender, dept_id) values ('1', 'Jack', 'M', '1'); +insert into Student (student_id, student_name, gender, dept_id) values ('2', 'Jane', 'F', '1'); +insert into Student (student_id, student_name, gender, dept_id) values ('3', 'Mark', 'M', '2'); +Truncate table Department; +insert into Department (dept_id, dept_name) values ('1', 'Engineering'); +insert into Department (dept_id, dept_name) values ('2', 'Science'); +insert into Department (dept_id, dept_name) values ('3', 'Law'); diff --git a/problems/count-sub-islands/README.md b/problems/count-sub-islands/README.md index 3bc57c1ed..03d87c466 100644 --- a/problems/count-sub-islands/README.md +++ b/problems/count-sub-islands/README.md @@ -47,12 +47,17 @@ The 1s colored red in grid2 are those considered to be part of a sub-island. The ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Number of Islands](../number-of-islands) (Medium) + 1. [Number of Distinct Islands](../number-of-distinct-islands) (Medium) + 1. [Find All Groups of Farmland](../find-all-groups-of-farmland) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-subarrays-with-more-ones-than-zeros/README.md b/problems/count-subarrays-with-more-ones-than-zeros/README.md index 6b4eea3b1..e91e1a9cf 100644 --- a/problems/count-subarrays-with-more-ones-than-zeros/README.md +++ b/problems/count-subarrays-with-more-ones-than-zeros/README.md @@ -9,7 +9,7 @@                  [Next >](../two-out-of-three "Two Out of Three") -## [2031. Count Subarrays With More Ones Than Zeros (Medium)](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros "") +## [2031. Count Subarrays With More Ones Than Zeros (Medium)](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros "1 比 0 多的子数组个数") diff --git a/problems/count-substrings-that-differ-by-one-character/README.md b/problems/count-substrings-that-differ-by-one-character/README.md index dc837a236..4250e2fc0 100644 --- a/problems/count-substrings-that-differ-by-one-character/README.md +++ b/problems/count-substrings-that-differ-by-one-character/README.md @@ -25,7 +25,7 @@
     Input: s = "aba", t = "baba"
     Output: 6
    -Explanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:
    +Explanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:
     ("aba", "baba")
     ("aba", "baba")
     ("aba", "baba")
    @@ -39,25 +39,12 @@ The underlined portions are the substrings that are chosen from s and t.
     
     Input: s = "ab", t = "bb"
     Output: 3
    -Explanation: The following are the pairs of substrings from s and t that differ by 1 character:
    +Explanation: The following are the pairs of substrings from s and t that differ by 1 character:
     ("ab", "bb")
     ("ab", "bb")
     ("ab", "bb")
     ​​​​The underlined portions are the substrings that are chosen from s and t.
     
    -Example 3: - -
    -Input: s = "a", t = "a"
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: s = "abe", t = "bbc"
    -Output: 10
    -

     

    Constraints:

    @@ -72,6 +59,9 @@ The underlined portions are the substrings that are chosen from s and t. [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Count Words Obtained After Adding a Letter](../count-words-obtained-after-adding-a-letter) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-subtrees-with-max-distance-between-cities/README.md b/problems/count-subtrees-with-max-distance-between-cities/README.md index b2fafe331..4b8a8e661 100644 --- a/problems/count-subtrees-with-max-distance-between-cities/README.md +++ b/problems/count-subtrees-with-max-distance-between-cities/README.md @@ -61,14 +61,11 @@ No subtree has two nodes where the max distance between them is 3. ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Tree](../../tag/tree/README.md)] - [[Enumeration](../../tag/enumeration/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bitmask](../../tag/bitmask/README.md)] - -### Similar Questions - 1. [Tree Diameter](../tree-diameter) (Medium) + [[Enumeration](../../tag/enumeration/README.md)] ### Hints
    diff --git a/problems/count-the-hidden-sequences/README.md b/problems/count-the-hidden-sequences/README.md new file mode 100644 index 000000000..7b6dd0bc0 --- /dev/null +++ b/problems/count-the-hidden-sequences/README.md @@ -0,0 +1,96 @@ + + + + + + + +[< Previous](../minimum-cost-of-buying-candies-with-discount "Minimum Cost of Buying Candies With Discount") +                 +[Next >](../k-highest-ranked-items-within-a-price-range "K Highest Ranked Items Within a Price Range") + +## [2145. Count the Hidden Sequences (Medium)](https://leetcode.com/problems/count-the-hidden-sequences "统计隐藏数组数目") + +

    You are given a 0-indexed array of n integers differences, which describes the differences between each pair of consecutive integers of a hidden sequence of length (n + 1). More formally, call the hidden sequence hidden, then we have that differences[i] = hidden[i + 1] - hidden[i].

    + +

    You are further given two integers lower and upper that describe the inclusive range of values [lower, upper] that the hidden sequence can contain.

    + +
      +
    • For example, given differences = [1, -3, 4], lower = 1, upper = 6, the hidden sequence is a sequence of length 4 whose elements are in between 1 and 6 (inclusive). +
        +
      • [3, 4, 1, 5] and [4, 5, 2, 6] are possible hidden sequences.
      • +
      • [5, 6, 3, 7] is not possible since it contains an element greater than 6.
      • +
      • [1, 2, 3, 4] is not possible since the differences are not correct.
      • +
      +
    • +
    + +

    Return the number of possible hidden sequences there are. If there are no possible sequences, return 0.

    + +

     

    +

    Example 1:

    + +
    +Input: differences = [1,-3,4], lower = 1, upper = 6
    +Output: 2
    +Explanation: The possible hidden sequences are:
    +- [3, 4, 1, 5]
    +- [4, 5, 2, 6]
    +Thus, we return 2.
    +
    + +

    Example 2:

    + +
    +Input: differences = [3,-4,5,1,-2], lower = -4, upper = 5
    +Output: 4
    +Explanation: The possible hidden sequences are:
    +- [-3, 0, -4, 1, 2, 0]
    +- [-2, 1, -3, 2, 3, 1]
    +- [-1, 2, -2, 3, 4, 2]
    +- [0, 3, -1, 4, 5, 3]
    +Thus, we return 4.
    +
    + +

    Example 3:

    + +
    +Input: differences = [4,-7,2], lower = 3, upper = 6
    +Output: 0
    +Explanation: There are no possible hidden sequences. Thus, we return 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == differences.length
    • +
    • 1 <= n <= 105
    • +
    • -105 <= differences[i] <= 105
    • +
    • -105 <= lower <= upper <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +Fix the first element of the hidden sequence to any value x and ignore the given bounds. Notice that we can then determine all the other elements of the sequence by using the differences array. +
    + +
    +Hint 2 +We will also be able to determine the difference between the minimum and maximum elements of the sequence. Notice that the value of x does not affect this. +
    + +
    +Hint 3 +We now have the ‘range’ of the sequence (difference between min and max element), we can then calculate how many ways there are to fit this range into the given range of lower to upper. +
    + +
    +Hint 4 +Answer is (upper - lower + 1) - (range of sequence) +
    diff --git a/problems/count-the-number-of-consistent-strings/README.md b/problems/count-the-number-of-consistent-strings/README.md index e96a04d61..0149ed188 100644 --- a/problems/count-the-number-of-consistent-strings/README.md +++ b/problems/count-the-number-of-consistent-strings/README.md @@ -52,10 +52,10 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/count-the-number-of-experiments/README.md b/problems/count-the-number-of-experiments/README.md index 004d98070..32f1a9733 100644 --- a/problems/count-the-number-of-experiments/README.md +++ b/problems/count-the-number-of-experiments/README.md @@ -9,6 +9,6 @@                  [Next >](../find-the-middle-index-in-array "Find the Middle Index in Array") -## [1990. Count the Number of Experiments (Easy)](https://leetcode.com/problems/count-the-number-of-experiments "") +## [1990. Count the Number of Experiments (Easy)](https://leetcode.com/problems/count-the-number-of-experiments "统计实验的数量") diff --git a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md index db696b55f..54729a4f0 100644 --- a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md +++ b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md @@ -11,7 +11,7 @@ ## [1442. Count Triplets That Can Form Two Arrays of Equal XOR (Medium)](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目") -

    Given an array of integers arr.

    +

    Given an array of integers arr.

    We want to select three indices i, j and k where (0 <= i < j <= k < arr.length).

    @@ -42,33 +42,12 @@ Output: 10
    -

    Example 3:

    - -
    -Input: arr = [2,3]
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: arr = [1,3,5,7,9]
    -Output: 3
    -
    - -

    Example 5:

    - -
    -Input: arr = [7,11,12,9,5,2,7,17,22]
    -Output: 8
    -
    -

     

    Constraints:

    • 1 <= arr.length <= 300
    • -
    • 1 <= arr[i] <= 10^8
    • +
    • 1 <= arr[i] <= 108
    ### Related Topics diff --git a/problems/count-vowel-substrings-of-a-string/README.md b/problems/count-vowel-substrings-of-a-string/README.md index f66f9ed84..29a590805 100644 --- a/problems/count-vowel-substrings-of-a-string/README.md +++ b/problems/count-vowel-substrings-of-a-string/README.md @@ -48,14 +48,7 @@ - "cuaieuouac" - "cuaieuouac" - "cuaieuouac" -- "cuaieuouac" - -

    Example 4:

    - -
    -Input: word = "bbaeixoubb"
    -Output: 0
    -Explanation: The only substrings that contain all five vowels also contain consonants, so there are no vowel substrings.
    +- "cuaieuouac"
     

     

    diff --git a/problems/count-words-obtained-after-adding-a-letter/README.md b/problems/count-words-obtained-after-adding-a-letter/README.md new file mode 100644 index 000000000..b182d8fbc --- /dev/null +++ b/problems/count-words-obtained-after-adding-a-letter/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../minimum-swaps-to-group-all-1s-together-ii "Minimum Swaps to Group All 1's Together II") +                 +[Next >](../earliest-possible-day-of-full-bloom "Earliest Possible Day of Full Bloom") + +## [2135. Count Words Obtained After Adding a Letter (Medium)](https://leetcode.com/problems/count-words-obtained-after-adding-a-letter "统计追加字母可以获得的单词数") + +

    You are given two 0-indexed arrays of strings startWords and targetWords. Each string consists of lowercase English letters only.

    + +

    For each string in targetWords, check if it is possible to choose a string from startWords and perform a conversion operation on it to be equal to that from targetWords.

    + +

    The conversion operation is described in the following two steps:

    + +
      +
    1. Append any lowercase letter that is not present in the string to its end. +
        +
      • For example, if the string is "abc", the letters 'd', 'e', or 'y' can be added to it, but not 'a'. If 'd' is added, the resulting string will be "abcd".
      • +
      +
    2. +
    3. Rearrange the letters of the new string in any arbitrary order. +
        +
      • For example, "abcd" can be rearranged to "acbd", "bacd", "cbda", and so on. Note that it can also be rearranged to "abcd" itself.
      • +
      +
    4. +
    + +

    Return the number of strings in targetWords that can be obtained by performing the operations on any string of startWords.

    + +

    Note that you will only be verifying if the string in targetWords can be obtained from a string in startWords by performing the operations. The strings in startWords do not actually change during this process.

    + +

     

    +

    Example 1:

    + +
    +Input: startWords = ["ant","act","tack"], targetWords = ["tack","act","acti"]
    +Output: 2
    +Explanation:
    +- In order to form targetWords[0] = "tack", we use startWords[1] = "act", append 'k' to it, and rearrange "actk" to "tack".
    +- There is no string in startWords that can be used to obtain targetWords[1] = "act".
    +  Note that "act" does exist in startWords, but we must append one letter to the string before rearranging it.
    +- In order to form targetWords[2] = "acti", we use startWords[1] = "act", append 'i' to it, and rearrange "acti" to "acti" itself.
    +
    + +

    Example 2:

    + +
    +Input: startWords = ["ab","a"], targetWords = ["abc","abcd"]
    +Output: 1
    +Explanation:
    +- In order to form targetWords[0] = "abc", we use startWords[0] = "ab", add 'c' to it, and rearrange it to "abc".
    +- There is no string in startWords that can be used to obtain targetWords[1] = "abcd".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= startWords.length, targetWords.length <= 5 * 104
    • +
    • 1 <= startWords[i].length, targetWords[j].length <= 26
    • +
    • Each string of startWords and targetWords consists of lowercase English letters only.
    • +
    • No letter occurs more than once in any string of startWords or targetWords.
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Which data structure can be used to efficiently check if a string exists in startWords? +
    + +
    +Hint 2 +After appending a letter, all letters of a string can be rearranged in any possible way. How can we use this to reduce our search space while checking if a string in targetWords can be obtained from a string in startWords? +
    diff --git a/problems/counting-bits/README.md b/problems/counting-bits/README.md index 52e02d477..edcd0c085 100644 --- a/problems/counting-bits/README.md +++ b/problems/counting-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../house-robber-iii "House Robber III") @@ -55,8 +55,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/countries-you-can-safely-invest-in/README.md b/problems/countries-you-can-safely-invest-in/README.md index 0450b8cee..75a1ea51b 100644 --- a/problems/countries-you-can-safely-invest-in/README.md +++ b/problems/countries-you-can-safely-invest-in/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Average Salary: Departments VS Company](../average-salary-departments-vs-company) (Hard) diff --git a/problems/create-a-session-bar-chart/README.md b/problems/create-a-session-bar-chart/README.md index 9bf7444db..2d98529f9 100644 --- a/problems/create-a-session-bar-chart/README.md +++ b/problems/create-a-session-bar-chart/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-wear-different-hats-to-each-other "Number of Ways to Wear Different Hats to Each Other") diff --git a/problems/create-target-array-in-the-given-order/README.md b/problems/create-target-array-in-the-given-order/README.md index 26cc2be14..ed80d4212 100644 --- a/problems/create-target-array-in-the-given-order/README.md +++ b/problems/create-target-array-in-the-given-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../pizza-with-3n-slices "Pizza With 3n Slices") diff --git a/problems/decode-the-slanted-ciphertext/README.md b/problems/decode-the-slanted-ciphertext/README.md index 413cba302..b6fac51a5 100644 --- a/problems/decode-the-slanted-ciphertext/README.md +++ b/problems/decode-the-slanted-ciphertext/README.md @@ -55,14 +55,6 @@ The blue arrows show how we can find originalText from encodedText. Explanation: Since there is only 1 row, both originalText and encodedText are the same. -

    Example 4:

    - -
    -Input: encodedText = " b  ac", rows = 2
    -Output: " abc"
    -Explanation: originalText cannot have trailing spaces, but it may be preceded by one or more spaces.
    -
    -

     

    Constraints:

    diff --git a/problems/decode-ways-ii/README.md b/problems/decode-ways-ii/README.md index d8a78212b..7e825db0d 100644 --- a/problems/decode-ways-ii/README.md +++ b/problems/decode-ways-ii/README.md @@ -81,3 +81,4 @@ Hence, there are a total of (6 * 2) + (3 * 1) = 12 + 3 = 15 ways to decode " ### Similar Questions 1. [Decode Ways](../decode-ways) (Medium) 1. [Number of Ways to Separate Numbers](../number-of-ways-to-separate-numbers) (Hard) + 1. [Number of Ways to Divide a Long Corridor](../number-of-ways-to-divide-a-long-corridor) (Hard) diff --git a/problems/decode-xored-permutation/README.md b/problems/decode-xored-permutation/README.md index c848d7942..f1782835e 100644 --- a/problems/decode-xored-permutation/README.md +++ b/problems/decode-xored-permutation/README.md @@ -43,8 +43,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md b/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md index e7eb154e6..51121f55c 100644 --- a/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md +++ b/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md @@ -11,16 +11,16 @@ ## [1309. Decrypt String from Alphabet to Integer Mapping (Easy)](https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping "解码字母到整数映射") -

    Given a string s formed by digits ('0' - '9') and '#' . We want to map s to English lowercase characters as follows:

    +

    You are given a string s formed by digits and '#'. We want to map s to English lowercase characters as follows:

      -
    • Characters ('a' to 'i') are represented by ('1' to '9') respectively.
    • -
    • Characters ('j' to 'z') are represented by ('10#' to '26#') respectively. 
    • +
    • Characters ('a' to 'i') are represented by ('1' to '9') respectively.
    • +
    • Characters ('j' to 'z') are represented by ('10#' to '26#') respectively.
    -

    Return the string formed after mapping.

    +

    Return the string formed after mapping.

    -

    It's guaranteed that a unique mapping will always exist.

    +

    The test cases are generated so that a unique mapping will always exist.

     

    Example 1:

    @@ -38,27 +38,13 @@ Output: "acz" -

    Example 3:

    - -
    -Input: s = "25#"
    -Output: "y"
    -
    - -

    Example 4:

    - -
    -Input: s = "12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#"
    -Output: "abcdefghijklmnopqrstuvwxyz"
    -
    -

     

    Constraints:

    • 1 <= s.length <= 1000
    • -
    • s[i] only contains digits letters ('0'-'9') and '#' letter.
    • -
    • s will be valid string such that mapping is always possible.
    • +
    • s consists of digits and the '#' letter.
    • +
    • s will be a valid string such that mapping is always possible.
    ### Related Topics diff --git a/problems/deepest-leaves-sum/README.md b/problems/deepest-leaves-sum/README.md index 91cae7c59..82c34bc7f 100644 --- a/problems/deepest-leaves-sum/README.md +++ b/problems/deepest-leaves-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-paths-with-max-score "Number of Paths with Max Score") diff --git a/problems/degree-of-an-array/README.md b/problems/degree-of-an-array/README.md index 691229adc..46abd362f 100644 --- a/problems/degree-of-an-array/README.md +++ b/problems/degree-of-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-binary-substrings "Count Binary Substrings") diff --git a/problems/delete-duplicate-emails/README.md b/problems/delete-duplicate-emails/README.md index b3669d52c..f2ba686fb 100644 --- a/problems/delete-duplicate-emails/README.md +++ b/problems/delete-duplicate-emails/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tenth-line "Tenth Line") @@ -11,33 +11,49 @@ ## [196. Delete Duplicate Emails (Easy)](https://leetcode.com/problems/delete-duplicate-emails "删除重复的电子邮箱") -

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.

    +

    Table: Person

    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| id          | int     |
    +| email       | varchar |
    ++-------------+---------+
    +id is the primary key column for this table.
    +Each row of this table contains an email. The emails will not contain uppercase letters.
    +
    + +

     

    + +

    Write an SQL query to delete all the duplicate emails, keeping only one unique email with the smallest id. Note that you are supposed to write a DELETE statement and not a SELECT one.

    + +

    Return the result table in any order.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    + +
    +Input: 
    +Person table:
     +----+------------------+
    -| Id | Email            |
    +| id | email            |
     +----+------------------+
     | 1  | john@example.com |
     | 2  | bob@example.com  |
     | 3  | john@example.com |
     +----+------------------+
    -Id is the primary key column for this table.
    -
    - -

    For example, after running your query, the above Person table should have the following rows:

    - -
    +Output: 
     +----+------------------+
    -| Id | Email            |
    +| id | email            |
     +----+------------------+
     | 1  | john@example.com |
     | 2  | bob@example.com  |
     +----+------------------+
    +Explanation: john@example.com is repeated two times. We keep the row with the smallest Id = 1.
     
    -

    Note:

    - -

    Your output is the whole Person table after executing your sql. Use delete statement.

    - ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/delete-duplicate-emails/mysql_schemas.sql b/problems/delete-duplicate-emails/mysql_schemas.sql index 89062100e..6ee53bdfa 100644 --- a/problems/delete-duplicate-emails/mysql_schemas.sql +++ b/problems/delete-duplicate-emails/mysql_schemas.sql @@ -1,4 +1,5 @@ +Create table If Not Exists Person (Id int, Email varchar(255)); Truncate table Person; -insert into Person (Id, Email) values ('1', 'john@example.com'); -insert into Person (Id, Email) values ('2', 'bob@example.com'); -insert into Person (Id, Email) values ('3', 'john@example.com'); +insert into Person (id, email) values ('1', 'john@example.com'); +insert into Person (id, email) values ('2', 'bob@example.com'); +insert into Person (id, email) values ('3', 'john@example.com'); diff --git a/problems/delete-duplicate-folders-in-system/README.md b/problems/delete-duplicate-folders-in-system/README.md index 4bb81e72f..7e5d89477 100644 --- a/problems/delete-duplicate-folders-in-system/README.md +++ b/problems/delete-duplicate-folders-in-system/README.md @@ -69,29 +69,6 @@ Note that folders "/a" and "/c" are identical after the dele Note that the returned array can be in a different order as the order does not matter. -

    Example 4:

    - -
    -Input: paths = [["a"],["a","x"],["a","x","y"],["a","z"],["b"],["b","x"],["b","x","y"],["b","z"]]
    -Output: []
    -Explanation: The file structure is as shown.
    -Folders "/a/x" and "/b/x" (and their subfolders) are marked for deletion because they both contain an
    -empty folder named "y".
    -Folders "/a" and "/b" (and their subfolders) are marked for deletion because they both contain an empty
    -folder "z" and the folder "x" described above.
    -
    - -

    Example 5:

    - -
    -Input: paths = [["a"],["a","x"],["a","x","y"],["a","z"],["b"],["b","x"],["b","x","y"],["b","z"],["b","w"]]
    -Output: [["b"],["b","w"],["b","z"],["a"],["a","z"]]
    -Explanation: This has the same structure as the previous example, except with the added "/b/w".
    -Folders "/a/x" and "/b/x" are still marked, but "/a" and "/b" are no longer marked because "/b" has the
    -empty folder named "w" and "/a" does not.
    -Note that "/a/z" and "/b/z" are not marked because the set of identical subfolders must be non-empty, but these folders are empty.
    -
    -

     

    Constraints:

    diff --git a/problems/delete-leaves-with-a-given-value/README.md b/problems/delete-leaves-with-a-given-value/README.md index d581caa4a..1b4d423df 100644 --- a/problems/delete-leaves-with-a-given-value/README.md +++ b/problems/delete-leaves-with-a-given-value/README.md @@ -11,14 +11,14 @@ ## [1325. Delete Leaves With a Given Value (Medium)](https://leetcode.com/problems/delete-leaves-with-a-given-value "删除给定值的叶子节点") -

    Given a binary tree root and an integer target, delete all the leaf nodes with value target.

    +

    Given a binary tree root and an integer target, delete all the leaf nodes with value target.

    -

    Note that once you delete a leaf node with value targetif it's parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you can't).

    +

    Note that once you delete a leaf node with value target, if its parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you cannot).

     

    Example 1:

    -

    +

     Input: root = [1,2,3,2,null,2,4], target = 2
    @@ -29,7 +29,7 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in
     
     

    Example 2:

    -

    +

     Input: root = [1,3,3,3,2], target = 3
    @@ -38,7 +38,7 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in
     
     

    Example 3:

    -

    +

     Input: root = [1,2,null,2,null,2], target = 2
    @@ -46,34 +46,19 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in
     Explanation: Leaf nodes in green with value (target = 2) are removed at each step.
     
    -

    Example 4:

    - -
    -Input: root = [1,1,1], target = 1
    -Output: []
    -
    - -

    Example 5:

    - -
    -Input: root = [1,2,3], target = 1
    -Output: [1,2,3]
    -
    -

     

    Constraints:

      -
    • 1 <= target <= 1000
    • -
    • The given binary tree will have between 1 and 3000 nodes.
    • -
    • Each node's value is between [1, 1000].
    • +
    • The number of nodes in the tree is in the range [1, 3000].
    • +
    • 1 <= Node.val, target <= 1000
    ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md index e73b8b5f1..9c97fa0c3 100644 --- a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md +++ b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../paint-house-iii "Paint House III") diff --git a/problems/delete-the-middle-node-of-a-linked-list/README.md b/problems/delete-the-middle-node-of-a-linked-list/README.md new file mode 100644 index 000000000..e88e98744 --- /dev/null +++ b/problems/delete-the-middle-node-of-a-linked-list/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../finding-3-digit-even-numbers "Finding 3-Digit Even Numbers") +                 +[Next >](../step-by-step-directions-from-a-binary-tree-node-to-another "Step-By-Step Directions From a Binary Tree Node to Another") + +## [2095. Delete the Middle Node of a Linked List (Medium)](https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list "删除链表的中间节点") + +

    You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list.

    + +

    The middle node of a linked list of size n is the ⌊n / 2⌋th node from the start using 0-based indexing, where ⌊x⌋ denotes the largest integer less than or equal to x.

    + +
      +
    • For n = 1, 2, 3, 4, and 5, the middle nodes are 0, 1, 1, 2, and 2, respectively.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: head = [1,3,4,7,1,2,6]
    +Output: [1,3,4,1,2,6]
    +Explanation:
    +The above figure represents the given linked list. The indices of the nodes are written below.
    +Since n = 7, node 3 with value 7 is the middle node, which is marked in red.
    +We return the new list after removing this node. 
    +
    + +

    Example 2:

    + +
    +Input: head = [1,2,3,4]
    +Output: [1,2,4]
    +Explanation:
    +The above figure represents the given linked list.
    +For n = 4, node 2 with value 3 is the middle node, which is marked in red.
    +
    + +

    Example 3:

    + +
    +Input: head = [2,1]
    +Output: [2]
    +Explanation:
    +The above figure represents the given linked list.
    +For n = 2, node 1 with value 1 is the middle node, which is marked in red.
    +Node 0 with value 2 is the only node remaining after removing node 1.
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [1, 105].
    • +
    • 1 <= Node.val <= 105
    • +
    + +### Related Topics + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +If a point with a speed s moves n units in a given time, a point with speed 2 * s will move 2 * n units at the same time. Can you use this to find the middle node of a linked list? +
    + +
    +Hint 2 +If you are given the middle node, the node before it, and the node after it, how can you modify the linked list? +
    diff --git a/problems/delivering-boxes-from-storage-to-ports/README.md b/problems/delivering-boxes-from-storage-to-ports/README.md index a282ef700..a72e47f52 100644 --- a/problems/delivering-boxes-from-storage-to-ports/README.md +++ b/problems/delivering-boxes-from-storage-to-ports/README.md @@ -69,21 +69,6 @@ So the total number of trips is 2 + 2 + 2 = 6. So the total number of trips is 2 + 2 + 2 = 6.
    -

    Example 4:

    - -
    -Input: boxes = [[2,4],[2,5],[3,1],[3,2],[3,7],[3,1],[4,4],[1,3],[5,2]], portsCount = 5, maxBoxes = 5, maxWeight = 7
    -Output: 14
    -Explanation: The optimal strategy is as follows:
    -- The ship takes the first box, goes to port 2, then storage. 2 trips.
    -- The ship takes the second box, goes to port 2, then storage. 2 trips.
    -- The ship takes the third and fourth boxes, goes to port 3, then storage. 2 trips.
    -- The ship takes the fifth box, goes to port 3, then storage. 2 trips.
    -- The ship takes the sixth and seventh boxes, goes to port 3, then port 4, then storage. 3 trips. 
    -- The ship takes the eighth and ninth boxes, goes to port 1, then port 5, then storage. 3 trips.
    -So the total number of trips is 2 + 2 + 2 + 2 + 3 + 3 = 14.
    -
    -

     

    Constraints:

    diff --git a/problems/depth-of-bst-given-insertion-order/README.md b/problems/depth-of-bst-given-insertion-order/README.md index 87f0d6196..ecf971b20 100644 --- a/problems/depth-of-bst-given-insertion-order/README.md +++ b/problems/depth-of-bst-given-insertion-order/README.md @@ -9,7 +9,7 @@                  [Next >](../largest-odd-number-in-string "Largest Odd Number in String") -## [1902. Depth of BST Given Insertion Order (Medium)](https://leetcode.com/problems/depth-of-bst-given-insertion-order "") +## [1902. Depth of BST Given Insertion Order (Medium)](https://leetcode.com/problems/depth-of-bst-given-insertion-order "给定二叉搜索树的插入顺序求深度") diff --git a/problems/describe-the-painting/README.md b/problems/describe-the-painting/README.md index edda7d60e..ac2cbbea4 100644 --- a/problems/describe-the-painting/README.md +++ b/problems/describe-the-painting/README.md @@ -85,6 +85,10 @@ Note that returning a single segment [1,7) is incorrect because the mixed color [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Average Height of Buildings in Each Segment](../average-height-of-buildings-in-each-segment) (Medium) + 1. [Amount of New Area Painted Each Day](../amount-of-new-area-painted-each-day) (Hard) + ### Hints
    Hint 1 diff --git a/problems/design-a-file-sharing-system/README.md b/problems/design-a-file-sharing-system/README.md index 0eee8641a..ff0ae03e8 100644 --- a/problems/design-a-file-sharing-system/README.md +++ b/problems/design-a-file-sharing-system/README.md @@ -14,10 +14,13 @@ ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Data Stream](../../tag/data-stream/README.md)] + [[Design](../../tag/design/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] + +### Similar Questions + 1. [Design Twitter](../design-twitter) (Medium) ### Hints
    diff --git a/problems/design-bitset/README.md b/problems/design-bitset/README.md new file mode 100644 index 000000000..2cbd3a0ed --- /dev/null +++ b/problems/design-bitset/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../smallest-value-of-the-rearranged-number "Smallest Value of the Rearranged Number") +                 +[Next >](../minimum-time-to-remove-all-cars-containing-illegal-goods "Minimum Time to Remove All Cars Containing Illegal Goods") + +## [2166. Design Bitset (Medium)](https://leetcode.com/problems/design-bitset "设计位集") + +

    A Bitset is a data structure that compactly stores bits.

    + +

    Implement the Bitset class:

    + +
      +
    • Bitset(int size) Initializes the Bitset with size bits, all of which are 0.
    • +
    • void fix(int idx) Updates the value of the bit at the index idx to 1. If the value was already 1, no change occurs.
    • +
    • void unfix(int idx) Updates the value of the bit at the index idx to 0. If the value was already 0, no change occurs.
    • +
    • void flip() Flips the values of each bit in the Bitset. In other words, all bits with value 0 will now have value 1 and vice versa.
    • +
    • boolean all() Checks if the value of each bit in the Bitset is 1. Returns true if it satisfies the condition, false otherwise.
    • +
    • boolean one() Checks if there is at least one bit in the Bitset with value 1. Returns true if it satisfies the condition, false otherwise.
    • +
    • int count() Returns the total number of bits in the Bitset which have value 1.
    • +
    • String toString() Returns the current composition of the Bitset. Note that in the resultant string, the character at the ith index should coincide with the value at the ith bit of the Bitset.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["Bitset", "fix", "fix", "flip", "all", "unfix", "flip", "one", "unfix", "count", "toString"]
    +[[5], [3], [1], [], [], [0], [], [], [0], [], []]
    +Output
    +[null, null, null, null, false, null, null, true, null, 2, "01010"]
    +
    +Explanation
    +Bitset bs = new Bitset(5); // bitset = "00000".
    +bs.fix(3);     // the value at idx = 3 is updated to 1, so bitset = "00010".
    +bs.fix(1);     // the value at idx = 1 is updated to 1, so bitset = "01010". 
    +bs.flip();     // the value of each bit is flipped, so bitset = "10101". 
    +bs.all();      // return False, as not all values of the bitset are 1.
    +bs.unfix(0);   // the value at idx = 0 is updated to 0, so bitset = "00101".
    +bs.flip();     // the value of each bit is flipped, so bitset = "11010". 
    +bs.one();      // return True, as there is at least 1 index with value 1.
    +bs.unfix(0);   // the value at idx = 0 is updated to 0, so bitset = "01010".
    +bs.count();    // return 2, as there are 2 bits with value 1.
    +bs.toString(); // return "01010", which is the composition of bitset.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= size <= 105
    • +
    • 0 <= idx <= size - 1
    • +
    • At most 105 calls will be made in total to fix, unfix, flip, all, one, count, and toString.
    • +
    • At least one call will be made to all, one, count, or toString.
    • +
    • At most 5 calls will be made to toString.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Note that flipping a bit twice does nothing. +
    + +
    +Hint 2 +In order to determine the value of a bit, consider how you can efficiently count the number of flips made on the bit since its latest update. +
    diff --git a/problems/design-excel-sum-formula/README.md b/problems/design-excel-sum-formula/README.md index aa80932d7..367ed9cca 100644 --- a/problems/design-excel-sum-formula/README.md +++ b/problems/design-excel-sum-formula/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../course-schedule-iii "Course Schedule III") diff --git a/problems/design-file-system/README.md b/problems/design-file-system/README.md index 5d8630e7f..c37500d85 100644 --- a/problems/design-file-system/README.md +++ b/problems/design-file-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../single-row-keyboard "Single-Row Keyboard") diff --git a/problems/design-hashmap/README.md b/problems/design-hashmap/README.md index 14ef975d5..ede07f6c4 100644 --- a/problems/design-hashmap/README.md +++ b/problems/design-hashmap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-hashset "Design HashSet") @@ -53,11 +53,12 @@ myHashMap.get(2); // return -1 (i.e., not found), The map is now [[1,1]] ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] [[Hash Function](../../tag/hash-function/README.md)] ### Similar Questions 1. [Design HashSet](../design-hashset) (Easy) + 1. [Design Skiplist](../design-skiplist) (Hard) diff --git a/problems/design-log-storage-system/README.md b/problems/design-log-storage-system/README.md index 1560bb852..9f35d631e 100644 --- a/problems/design-log-storage-system/README.md +++ b/problems/design-log-storage-system/README.md @@ -38,9 +38,9 @@ retrieve("2016:01:01:01:01:01","2017:01:01:23:00:00","Hour"); // return [1,2], b

    ### Related Topics + [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Design](../../tag/design/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions diff --git a/problems/design-movie-rental-system/README.md b/problems/design-movie-rental-system/README.md index 7d30137c7..8f579b4f1 100644 --- a/problems/design-movie-rental-system/README.md +++ b/problems/design-movie-rental-system/README.md @@ -69,11 +69,11 @@ movieRentingSystem.search(2); // return [0, 1]. Movies of ID 2 are unrented at ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Design](../../tag/design/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Hints
    diff --git a/problems/design-parking-system/README.md b/problems/design-parking-system/README.md index c3e886f43..3b78047ab 100644 --- a/problems/design-parking-system/README.md +++ b/problems/design-parking-system/README.md @@ -49,8 +49,8 @@ parkingSystem.addCar(1); // return false because there is no available slot for ### Related Topics [[Design](../../tag/design/README.md)] - [[Counting](../../tag/counting/README.md)] [[Simulation](../../tag/simulation/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/design-skiplist/README.md b/problems/design-skiplist/README.md index c4e2f39fa..07f2933c2 100644 --- a/problems/design-skiplist/README.md +++ b/problems/design-skiplist/README.md @@ -66,5 +66,10 @@ skiplist.search(1); // return False, 1 has already been erased.
    ### Related Topics - [[Design](../../tag/design/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] + +### Similar Questions + 1. [Design HashSet](../design-hashset) (Easy) + 1. [Design HashMap](../design-hashmap) (Easy) + 1. [Design Linked List](../design-linked-list) (Medium) diff --git a/problems/design-snake-game/README.md b/problems/design-snake-game/README.md index 16eb867f5..d4a133824 100644 --- a/problems/design-snake-game/README.md +++ b/problems/design-snake-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../data-stream-as-disjoint-intervals "Data Stream as Disjoint Intervals") diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index 3c3d61dd4..07d725874 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -101,9 +101,12 @@ undergroundSystem.getAverageTime("Leyton", "Paradise"); // r ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] + +### Similar Questions + 1. [Design Bitset](../design-bitset) (Medium) ### Hints
    diff --git a/problems/destroying-asteroids/README.md b/problems/destroying-asteroids/README.md new file mode 100644 index 000000000..f1ff813bf --- /dev/null +++ b/problems/destroying-asteroids/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../number-of-laser-beams-in-a-bank "Number of Laser Beams in a Bank") +                 +[Next >](../maximum-employees-to-be-invited-to-a-meeting "Maximum Employees to Be Invited to a Meeting") + +## [2126. Destroying Asteroids (Medium)](https://leetcode.com/problems/destroying-asteroids "摧毁小行星") + +

    You are given an integer mass, which represents the original mass of a planet. You are further given an integer array asteroids, where asteroids[i] is the mass of the ith asteroid.

    + +

    You can arrange for the planet to collide with the asteroids in any arbitrary order. If the mass of the planet is greater than or equal to the mass of the asteroid, the asteroid is destroyed and the planet gains the mass of the asteroid. Otherwise, the planet is destroyed.

    + +

    Return true if all asteroids can be destroyed. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: mass = 10, asteroids = [3,9,19,5,21]
    +Output: true
    +Explanation: One way to order the asteroids is [9,19,5,3,21]:
    +- The planet collides with the asteroid with a mass of 9. New planet mass: 10 + 9 = 19
    +- The planet collides with the asteroid with a mass of 19. New planet mass: 19 + 19 = 38
    +- The planet collides with the asteroid with a mass of 5. New planet mass: 38 + 5 = 43
    +- The planet collides with the asteroid with a mass of 3. New planet mass: 43 + 3 = 46
    +- The planet collides with the asteroid with a mass of 21. New planet mass: 46 + 21 = 67
    +All asteroids are destroyed.
    +
    + +

    Example 2:

    + +
    +Input: mass = 5, asteroids = [4,9,23,4]
    +Output: false
    +Explanation: 
    +The planet cannot ever gain enough mass to destroy the asteroid with a mass of 23.
    +After the planet destroys the other asteroids, it will have a mass of 5 + 4 + 9 + 4 = 22.
    +This is less than 23, so a collision would not destroy the last asteroid.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= mass <= 105
    • +
    • 1 <= asteroids.length <= 105
    • +
    • 1 <= asteroids[i] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Choosing the asteroid to collide with can be done greedily. +
    + +
    +Hint 2 +If an asteroid will destroy the planet, then every bigger asteroid will also destroy the planet. +
    + +
    +Hint 3 +You only need to check the smallest asteroid at each collision. If it will destroy the planet, then every other asteroid will also destroy the planet. +
    + +
    +Hint 4 +Sort the asteroids in non-decreasing order by mass, then greedily try to collide with the asteroids in that order. +
    diff --git a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md index e154bfa69..6f2fcdace 100644 --- a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md +++ b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md @@ -11,11 +11,11 @@ ## [1566. Detect Pattern of Length M Repeated K or More Times (Easy)](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") -

    Given an array of positive integers arr,  find a pattern of length m that is repeated k or more times.

    +

    Given an array of positive integers arr, find a pattern of length m that is repeated k or more times.

    A pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length and the number of repetitions.

    -

    Return true if there exists a pattern of length m that is repeated k or more times, otherwise return false.

    +

    Return true if there exists a pattern of length m that is repeated k or more times, otherwise return false.

     

    Example 1:

    @@ -42,36 +42,23 @@ Explanation: The pattern (1,2) is of length 2 but is repeated only 2 times. There is no pattern of length 2 that is repeated 3 or more times. -

    Example 4:

    - -
    -Input: arr = [1,2,3,1,2], m = 2, k = 2
    -Output: false
    -Explanation: Notice that the pattern (1,2) exists twice but not consecutively, so it doesn't count.
    -
    - -

    Example 5:

    - -
    -Input: arr = [2,2,2,2], m = 2, k = 3
    -Output: false
    -Explanation: The only pattern of length 2 is (2,2) however it's repeated only twice. Notice that we do not count overlapping repetitions.
    -
    -

     

    Constraints:

    • 2 <= arr.length <= 100
    • 1 <= arr[i] <= 100
    • -
    • 1 <= m <= 100
    • -
    • 2 <= k <= 100
    • +
    • 1 <= m <= 100
    • +
    • 2 <= k <= 100
    ### Related Topics [[Array](../../tag/array/README.md)] [[Enumeration](../../tag/enumeration/README.md)] +### Similar Questions + 1. [Maximum Repeating Substring](../maximum-repeating-substring) (Easy) + ### Hints
    Hint 1 diff --git a/problems/determine-if-string-halves-are-alike/README.md b/problems/determine-if-string-halves-are-alike/README.md index c436e1ff8..8f0453b94 100644 --- a/problems/determine-if-string-halves-are-alike/README.md +++ b/problems/determine-if-string-halves-are-alike/README.md @@ -23,7 +23,7 @@
     Input: s = "book"
     Output: true
    -Explanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
    +Explanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
     

    Example 2:

    @@ -31,24 +31,10 @@
     Input: s = "textbook"
     Output: false
    -Explanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike.
    +Explanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike.
     Notice that the vowel o is counted twice.
     
    -

    Example 3:

    - -
    -Input: s = "MerryChristmas"
    -Output: false
    -
    - -

    Example 4:

    - -
    -Input: s = "AbCdEfGh"
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/determine-if-two-strings-are-close/README.md b/problems/determine-if-two-strings-are-close/README.md index 9da101df9..a6740f403 100644 --- a/problems/determine-if-two-strings-are-close/README.md +++ b/problems/determine-if-two-strings-are-close/README.md @@ -60,14 +60,6 @@ Apply Operation 1: "cabbba" -> "caabbb Apply Operation 2: "baaccc" -> "abbccc" -

    Example 4:

    - -
    -Input: word1 = "cabbba", word2 = "aabbss"
    -Output: false
    -Explanation: It is impossible to attain word2 from word1, or vice versa, in any amount of operations.
    -
    -

     

    Constraints:

    @@ -81,11 +73,6 @@ Apply Operation 2: "baaccc" -> "abbccc" [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Buddy Strings](../buddy-strings) (Easy) - 1. [Minimum Swaps to Make Strings Equal](../minimum-swaps-to-make-strings-equal) (Medium) - 1. [Minimum Number of Steps to Make Two Strings Anagram](../minimum-number-of-steps-to-make-two-strings-anagram) (Medium) - ### Hints
    Hint 1 diff --git a/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md b/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md index 3f86bc907..dc07d77be 100644 --- a/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md +++ b/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md @@ -52,6 +52,9 @@ [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Rotate Image](../rotate-image) (Medium) + ### Hints
    Hint 1 diff --git a/problems/detonate-the-maximum-bombs/README.md b/problems/detonate-the-maximum-bombs/README.md new file mode 100644 index 000000000..2a7ecfe4b --- /dev/null +++ b/problems/detonate-the-maximum-bombs/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../find-good-days-to-rob-the-bank "Find Good Days to Rob the Bank") +                 +[Next >](../sequentially-ordinal-rank-tracker "Sequentially Ordinal Rank Tracker") + +## [2101. Detonate the Maximum Bombs (Medium)](https://leetcode.com/problems/detonate-the-maximum-bombs "引爆最多的炸弹") + +

    You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.

    + +

    The bombs are represented by a 0-indexed 2D integer array bombs where bombs[i] = [xi, yi, ri]. xi and yi denote the X-coordinate and Y-coordinate of the location of the ith bomb, whereas ri denotes the radius of its range.

    + +

    You may choose to detonate a single bomb. When a bomb is detonated, it will detonate all bombs that lie in its range. These bombs will further detonate the bombs that lie in their ranges.

    + +

    Given the list of bombs, return the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb.

    + +

     

    +

    Example 1:

    + +
    +Input: bombs = [[2,1,3],[6,1,4]]
    +Output: 2
    +Explanation:
    +The above figure shows the positions and ranges of the 2 bombs.
    +If we detonate the left bomb, the right bomb will not be affected.
    +But if we detonate the right bomb, both bombs will be detonated.
    +So the maximum bombs that can be detonated is max(1, 2) = 2.
    +
    + +

    Example 2:

    + +
    +Input: bombs = [[1,1,5],[10,10,5]]
    +Output: 1
    +Explanation:
    +Detonating either bomb will not detonate the other bomb, so the maximum number of bombs that can be detonated is 1.
    +
    + +

    Example 3:

    + +
    +Input: bombs = [[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]]
    +Output: 5
    +Explanation:
    +The best bomb to detonate is bomb 0 because:
    +- Bomb 0 detonates bombs 1 and 2. The red circle denotes the range of bomb 0.
    +- Bomb 2 detonates bomb 3. The blue circle denotes the range of bomb 2.
    +- Bomb 3 detonates bomb 4. The green circle denotes the range of bomb 3.
    +Thus all 5 bombs are detonated.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= bombs.length <= 100
    • +
    • bombs[i].length == 3
    • +
    • 1 <= xi, yi, ri <= 105
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +How can we model the relationship between different bombs? Can "graphs" help us? +
    + +
    +Hint 2 +Bombs are nodes and are connected to other bombs in their range by directed edges. +
    + +
    +Hint 3 +If we know which bombs will be affected when any bomb is detonated, how can we find the total number of bombs that will be detonated if we start from a fixed bomb? +
    + +
    +Hint 4 +Run a Depth First Search (DFS) from every node, and all the nodes it reaches are the bombs that will be detonated. +
    diff --git a/problems/diagonal-traverse-ii/README.md b/problems/diagonal-traverse-ii/README.md index 89e88c505..f0f505c37 100644 --- a/problems/diagonal-traverse-ii/README.md +++ b/problems/diagonal-traverse-ii/README.md @@ -11,48 +11,31 @@ ## [1424. Diagonal Traverse II (Medium)](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") -Given a list of lists of integers, nums, return all elements of nums in diagonal order as shown in the below images. +

    Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.

    +

     

    Example 1:

    - -

    - +
     Input: nums = [[1,2,3],[4,5,6],[7,8,9]]
     Output: [1,4,2,7,5,3,8,6,9]
     

    Example 2:

    - -

    - +
     Input: nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]
     Output: [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]
     
    -

    Example 3:

    - -
    -Input: nums = [[1,2,3],[4],[5,6,7],[8],[9,10,11]]
    -Output: [1,4,2,5,3,8,6,9,7,10,11]
    -
    - -

    Example 4:

    - -
    -Input: nums = [[1,2,3,4,5,6]]
    -Output: [1,2,3,4,5,6]
    -
    -

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • 1 <= nums[i].length <= 10^5
    • -
    • 1 <= nums[i][j] <= 10^9
    • -
    • There at most 10^5 elements in nums.
    • +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i].length <= 105
    • +
    • 1 <= sum(nums[i].length) <= 105
    • +
    • 1 <= nums[i][j] <= 105
    ### Related Topics diff --git a/problems/diameter-of-binary-tree/README.md b/problems/diameter-of-binary-tree/README.md index 2af34eb9c..afe2198fb 100644 --- a/problems/diameter-of-binary-tree/README.md +++ b/problems/diameter-of-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../01-matrix "01 Matrix") @@ -45,3 +45,6 @@ [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] + +### Similar Questions + 1. [Diameter of N-Ary Tree](../diameter-of-n-ary-tree) (Medium) diff --git a/problems/distant-barcodes/README.md b/problems/distant-barcodes/README.md index cf6019f5a..dc8ebc8b1 100644 --- a/problems/distant-barcodes/README.md +++ b/problems/distant-barcodes/README.md @@ -32,12 +32,12 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Counting](../../tag/counting/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/distinct-echo-substrings/README.md b/problems/distinct-echo-substrings/README.md index de3a4e081..e27254199 100644 --- a/problems/distinct-echo-substrings/README.md +++ b/problems/distinct-echo-substrings/README.md @@ -39,12 +39,12 @@ ### Related Topics + [[Trie](../../tag/trie/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Trie](../../tag/trie/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/distribute-coins-in-binary-tree/README.md b/problems/distribute-coins-in-binary-tree/README.md index bca1db8a7..fe77331b2 100644 --- a/problems/distribute-coins-in-binary-tree/README.md +++ b/problems/distribute-coins-in-binary-tree/README.md @@ -19,7 +19,7 @@

     

    Example 1:

    - +
     Input: root = [3,0,0]
     Output: 2
    @@ -27,27 +27,13 @@
     

    Example 2:

    - +
     Input: root = [0,3,0]
     Output: 3
     Explanation: From the left child of the root, we move two coins to the root [taking two moves]. Then, we move one coin from the root of the tree to the right child.
     
    -

    Example 3:

    - -
    -Input: root = [1,0,2]
    -Output: 2
    -
    - -

    Example 4:

    - -
    -Input: root = [1,0,0,null,3]
    -Output: 4
    -
    -

     

    Constraints:

    diff --git a/problems/distribute-repeating-integers/README.md b/problems/distribute-repeating-integers/README.md index aa9699270..c9c238bd3 100644 --- a/problems/distribute-repeating-integers/README.md +++ b/problems/distribute-repeating-integers/README.md @@ -27,7 +27,7 @@
     Input: nums = [1,2,3,4], quantity = [2]
     Output: false
    -Explanation: The 0th customer cannot be given two different integers.
    +Explanation: The 0th customer cannot be given two different integers.
     

    Example 2:

    @@ -35,7 +35,7 @@
     Input: nums = [1,2,3,3], quantity = [2]
     Output: true
    -Explanation: The 0th customer is given [3,3]. The integers [1,2] are not used.
    +Explanation: The 0th customer is given [3,3]. The integers [1,2] are not used.
     

    Example 3:

    @@ -43,22 +43,7 @@
     Input: nums = [1,1,2,2], quantity = [2,2]
     Output: true
    -Explanation: The 0th customer is given [1,1], and the 1st customer is given [2,2].
    -
    - -

    Example 4:

    - -
    -Input: nums = [1,1,2,3], quantity = [2,2]
    -Output: false
    -Explanation: Although the 0th customer could be given [1,1], the 1st customer cannot be satisfied.
    - -

    Example 5:

    - -
    -Input: nums = [1,1,1,1,1], quantity = [2,3]
    -Output: true
    -Explanation: The 0th customer is given [1,1], and the 1st customer is given [1,1,1].
    +Explanation: The 0th customer is given [1,1], and the 1st customer is given [2,2].
     

     

    diff --git a/problems/divide-a-string-into-groups-of-size-k/README.md b/problems/divide-a-string-into-groups-of-size-k/README.md new file mode 100644 index 000000000..f7fc58e35 --- /dev/null +++ b/problems/divide-a-string-into-groups-of-size-k/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../pour-water-between-buckets-to-make-water-levels-equal "Pour Water Between Buckets to Make Water Levels Equal") +                 +[Next >](../minimum-moves-to-reach-target-score "Minimum Moves to Reach Target Score") + +## [2138. Divide a String Into Groups of Size k (Easy)](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k "将字符串拆分为若干长度为 k 的组") + +

    A string s can be partitioned into groups of size k using the following procedure:

    + +
      +
    • The first group consists of the first k characters of the string, the second group consists of the next k characters of the string, and so on. Each character can be a part of exactly one group.
    • +
    • For the last group, if the string does not have k characters remaining, a character fill is used to complete the group.
    • +
    + +

    Note that the partition is done so that after removing the fill character from the last group (if it exists) and concatenating all the groups in order, the resultant string should be s.

    + +

    Given the string s, the size of each group k and the character fill, return a string array denoting the composition of every group s has been divided into, using the above procedure.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "abcdefghi", k = 3, fill = "x"
    +Output: ["abc","def","ghi"]
    +Explanation:
    +The first 3 characters "abc" form the first group.
    +The next 3 characters "def" form the second group.
    +The last 3 characters "ghi" form the third group.
    +Since all groups can be completely filled by characters from the string, we do not need to use fill.
    +Thus, the groups formed are "abc", "def", and "ghi".
    +
    + +

    Example 2:

    + +
    +Input: s = "abcdefghij", k = 3, fill = "x"
    +Output: ["abc","def","ghi","jxx"]
    +Explanation:
    +Similar to the previous example, we are forming the first three groups "abc", "def", and "ghi".
    +For the last group, we can only use the character 'j' from the string. To complete this group, we add 'x' twice.
    +Thus, the 4 groups formed are "abc", "def", "ghi", and "jxx".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s consists of lowercase English letters only.
    • +
    • 1 <= k <= 100
    • +
    • fill is a lowercase English letter.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Using the length of the string and k, can you count the number of groups the string can be divided into? +
    + +
    +Hint 2 +Try completing each group using characters from the string. If there aren’t enough characters for the last group, use the fill character to complete the group. +
    diff --git a/problems/dot-product-of-two-sparse-vectors/README.md b/problems/dot-product-of-two-sparse-vectors/README.md index 0c36b471c..4dd93440a 100644 --- a/problems/dot-product-of-two-sparse-vectors/README.md +++ b/problems/dot-product-of-two-sparse-vectors/README.md @@ -14,10 +14,10 @@ ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Design](../../tag/design/README.md)] ### Hints
    diff --git a/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md b/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md index 1a73e08ea..015d77373 100644 --- a/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md +++ b/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md @@ -7,8 +7,11 @@ [< Previous](../substrings-that-begin-and-end-with-the-same-letter "Substrings That Begin and End With the Same Letter")                  -Next > +[Next >](../count-common-words-with-one-occurrence "Count Common Words With One Occurrence") -## [2084. Drop Type 1 Orders for Customers With Type 0 Orders (Medium)](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders "") +## [2084. Drop Type 1 Orders for Customers With Type 0 Orders (Medium)](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders "为订单类型为 0 的客户删除类型为 1 的订单") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/earliest-possible-day-of-full-bloom/README.md b/problems/earliest-possible-day-of-full-bloom/README.md new file mode 100644 index 000000000..ac699a6ed --- /dev/null +++ b/problems/earliest-possible-day-of-full-bloom/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../count-words-obtained-after-adding-a-letter "Count Words Obtained After Adding a Letter") +                 +[Next >](../pour-water-between-buckets-to-make-water-levels-equal "Pour Water Between Buckets to Make Water Levels Equal") + +## [2136. Earliest Possible Day of Full Bloom (Hard)](https://leetcode.com/problems/earliest-possible-day-of-full-bloom "全部开花的最早一天") + +

    You have n flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two 0-indexed integer arrays plantTime and growTime, of length n each:

    + +
      +
    • plantTime[i] is the number of full days it takes you to plant the ith seed. Every day, you can work on planting exactly one seed. You do not have to work on planting the same seed on consecutive days, but the planting of a seed is not complete until you have worked plantTime[i] days on planting it in total.
    • +
    • growTime[i] is the number of full days it takes the ith seed to grow after being completely planted. After the last day of its growth, the flower blooms and stays bloomed forever.
    • +
    + +

    From the beginning of day 0, you can plant the seeds in any order.

    + +

    Return the earliest possible day where all seeds are blooming.

    + +

     

    +

    Example 1:

    + +
    +Input: plantTime = [1,4,3], growTime = [2,3,1]
    +Output: 9
    +Explanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.
    +One optimal way is:
    +On day 0, plant the 0th seed. The seed grows for 2 full days and blooms on day 3.
    +On days 1, 2, 3, and 4, plant the 1st seed. The seed grows for 3 full days and blooms on day 8.
    +On days 5, 6, and 7, plant the 2nd seed. The seed grows for 1 full day and blooms on day 9.
    +Thus, on day 9, all the seeds are blooming.
    +
    + +

    Example 2:

    + +
    +Input: plantTime = [1,2,3,2], growTime = [2,1,2,1]
    +Output: 9
    +Explanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.
    +One optimal way is:
    +On day 1, plant the 0th seed. The seed grows for 2 full days and blooms on day 4.
    +On days 0 and 3, plant the 1st seed. The seed grows for 1 full day and blooms on day 5.
    +On days 2, 4, and 5, plant the 2nd seed. The seed grows for 2 full days and blooms on day 8.
    +On days 6 and 7, plant the 3rd seed. The seed grows for 1 full day and blooms on day 9.
    +Thus, on day 9, all the seeds are blooming.
    +
    + +

    Example 3:

    + +
    +Input: plantTime = [1], growTime = [1]
    +Output: 2
    +Explanation: On day 0, plant the 0th seed. The seed grows for 1 full day and blooms on day 2.
    +Thus, on day 2, all the seeds are blooming.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == plantTime.length == growTime.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= plantTime[i], growTime[i] <= 104
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +List the planting like the diagram above shows, where a row represents the timeline of a seed. A row i is above another row j if the last day planting seed i is ahead of the last day for seed j. Does it have any advantage to spend some days to plant seed j before completely planting seed i? +
    + +
    +Hint 2 +No. It does not help seed j but could potentially delay the completion of seed i, resulting in a worse final answer. Remaining focused is a part of the optimal solution. +
    + +
    +Hint 3 +Sort the seeds by their growTime in descending order. Can you prove why this strategy is the other part of the optimal solution? Note the bloom time of a seed is the sum of plantTime of all seeds preceding this seed plus the growTime of this seed. +
    + +
    +Hint 4 +There is no way to improve this strategy. The seed to bloom last dominates the final answer. Exchanging the planting of this seed with another seed with either a larger or smaller growTime will result in a potentially worse answer. +
    diff --git a/problems/egg-drop-with-2-eggs-and-n-floors/README.md b/problems/egg-drop-with-2-eggs-and-n-floors/README.md index b8408e61b..fb4e7cc26 100644 --- a/problems/egg-drop-with-2-eggs-and-n-floors/README.md +++ b/problems/egg-drop-with-2-eggs-and-n-floors/README.md @@ -54,6 +54,9 @@ Regardless of the outcome, it takes at most 14 drops to determine f. [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Super Egg Drop](../super-egg-drop) (Hard) + ### Hints
    Hint 1 diff --git a/problems/elements-in-array-after-removing-and-replacing-elements/README.md b/problems/elements-in-array-after-removing-and-replacing-elements/README.md new file mode 100644 index 000000000..745729049 --- /dev/null +++ b/problems/elements-in-array-after-removing-and-replacing-elements/README.md @@ -0,0 +1,33 @@ + + + + + + + +[< Previous](../the-airport-with-the-most-traffic "The Airport With the Most Traffic") +                 +[Next >](../maximum-number-of-words-found-in-sentences "Maximum Number of Words Found in Sentences") + +## [2113. Elements in Array After Removing and Replacing Elements (Medium)](https://leetcode.com/problems/elements-in-array-after-removing-and-replacing-elements "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Try to find a pattern in how nums changes. +
    + +
    +Hint 2 +Let m be the original length of nums. If time_i / m (integer division) is even, then nums is at its original size or decreasing in size. If it is odd, then it is empty, or increasing in size. +
    + +
    +Hint 3 +time_i % m can be used to find how many elements are in nums at minute time_i. +
    diff --git a/problems/eliminate-maximum-number-of-monsters/README.md b/problems/eliminate-maximum-number-of-monsters/README.md index 6a752338f..96c3ed4ba 100644 --- a/problems/eliminate-maximum-number-of-monsters/README.md +++ b/problems/eliminate-maximum-number-of-monsters/README.md @@ -65,8 +65,8 @@ You can only eliminate 1 monster. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/elimination-game/README.md b/problems/elimination-game/README.md index 276a8e60b..2368ac99f 100644 --- a/problems/elimination-game/README.md +++ b/problems/elimination-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-difference "Find the Difference") diff --git a/problems/employees-whose-manager-left-the-company/README.md b/problems/employees-whose-manager-left-the-company/README.md index 56eee226f..f6c3b1350 100644 --- a/problems/employees-whose-manager-left-the-company/README.md +++ b/problems/employees-whose-manager-left-the-company/README.md @@ -9,6 +9,6 @@                  [Next >](../find-greatest-common-divisor-of-array "Find Greatest Common Divisor of Array") -## [1978. Employees Whose Manager Left the Company (Easy)](https://leetcode.com/problems/employees-whose-manager-left-the-company "") +## [1978. Employees Whose Manager Left the Company (Easy)](https://leetcode.com/problems/employees-whose-manager-left-the-company "上级经理已离职的公司员工") diff --git a/problems/encode-and-decode-strings/README.md b/problems/encode-and-decode-strings/README.md index b24f694f4..b1676d0e4 100644 --- a/problems/encode-and-decode-strings/README.md +++ b/problems/encode-and-decode-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-binary-search-tree-value "Closest Binary Search Tree Value") @@ -56,9 +56,9 @@ vector<string> strs2 = decode(encoded_string); ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions 1. [Count and Say](../count-and-say) (Medium) diff --git a/problems/encode-and-decode-tinyurl/README.md b/problems/encode-and-decode-tinyurl/README.md index 66c905748..da7d5d6bd 100644 --- a/problems/encode-and-decode-tinyurl/README.md +++ b/problems/encode-and-decode-tinyurl/README.md @@ -47,7 +47,7 @@ string ans = obj.decode(tiny); // returns the original url after deconding it. ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] [[Hash Function](../../tag/hash-function/README.md)] diff --git a/problems/encode-n-ary-tree-to-binary-tree/README.md b/problems/encode-n-ary-tree-to-binary-tree/README.md index 22250ebe7..4ed404913 100644 --- a/problems/encode-n-ary-tree-to-binary-tree/README.md +++ b/problems/encode-n-ary-tree-to-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flatten-a-multilevel-doubly-linked-list "Flatten a Multilevel Doubly Linked List") diff --git a/problems/equal-rational-numbers/README.md b/problems/equal-rational-numbers/README.md index 6bf83eb5e..c11e97a3a 100644 --- a/problems/equal-rational-numbers/README.md +++ b/problems/equal-rational-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flip-binary-tree-to-match-preorder-traversal "Flip Binary Tree To Match Preorder Traversal") diff --git a/problems/erect-the-fence-ii/README.md b/problems/erect-the-fence-ii/README.md index 4ca218a50..dcc541793 100644 --- a/problems/erect-the-fence-ii/README.md +++ b/problems/erect-the-fence-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../count-square-sum-triples "Count Square Sum Triples") -## [1924. Erect the Fence II (Hard)](https://leetcode.com/problems/erect-the-fence-ii "") +## [1924. Erect the Fence II (Hard)](https://leetcode.com/problems/erect-the-fence-ii "安装栅栏 II") diff --git a/problems/escape-a-large-maze/README.md b/problems/escape-a-large-maze/README.md index d8546cb79..94f65508f 100644 --- a/problems/escape-a-large-maze/README.md +++ b/problems/escape-a-large-maze/README.md @@ -52,10 +52,10 @@ We cannot move south or west because we cannot go outside of the grid. ### Related Topics - [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/evaluate-reverse-polish-notation/README.md b/problems/evaluate-reverse-polish-notation/README.md index 9db4857d2..43faff9a6 100644 --- a/problems/evaluate-reverse-polish-notation/README.md +++ b/problems/evaluate-reverse-polish-notation/README.md @@ -59,9 +59,9 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Stack](../../tag/stack/README.md)] ### Similar Questions 1. [Basic Calculator](../basic-calculator) (Hard) diff --git a/problems/evaluate-the-bracket-pairs-of-a-string/README.md b/problems/evaluate-the-bracket-pairs-of-a-string/README.md index 5e9c0c85e..dc2c9de26 100644 --- a/problems/evaluate-the-bracket-pairs-of-a-string/README.md +++ b/problems/evaluate-the-bracket-pairs-of-a-string/README.md @@ -59,12 +59,6 @@ The key "a" has a value of "yes", so replace all occurrences Notice that the "a"s not in a bracket pair are not evaluated. -

    Example 4:

    - -
    -Input: s = "(a)(b)", knowledge = [["a","b"],["b","a"]]
    -Output: "ba"
    -

     

    Constraints:

    diff --git a/problems/even-odd-tree/README.md b/problems/even-odd-tree/README.md index 2cbc1f3a2..733b0e483 100644 --- a/problems/even-odd-tree/README.md +++ b/problems/even-odd-tree/README.md @@ -23,9 +23,7 @@

     

    Example 1:

    - -

    - +
     Input: root = [1,10,4,3,null,7,9,12,8,6,null,null,2]
     Output: true
    @@ -34,13 +32,11 @@ Level 0: [1]
     Level 1: [10,4]
     Level 2: [3,7,9]
     Level 3: [12,8,6,2]
    -Since levels 0 and 2 are all odd and increasing, and levels 1 and 3 are all even and decreasing, the tree is Even-Odd.
    +Since levels 0 and 2 are all odd and increasing and levels 1 and 3 are all even and decreasing, the tree is Even-Odd.
     

    Example 2:

    - -

    - +
     Input: root = [5,4,2,3,3,7]
     Output: false
    @@ -48,33 +44,17 @@ Since levels 0 and 2 are all odd and increasing, and levels 1 and 3 are all even
     Level 0: [5]
     Level 1: [4,2]
     Level 2: [3,3,7]
    -Node values in the level 2 must be in strictly increasing order, so the tree is not Even-Odd.
    +Node values in level 2 must be in strictly increasing order, so the tree is not Even-Odd.
     

    Example 3:

    - -

    - +
     Input: root = [5,9,1,3,5,7]
     Output: false
     Explanation: Node values in the level 1 should be even integers.
     
    -

    Example 4:

    - -
    -Input: root = [1]
    -Output: true
    -
    - -

    Example 5:

    - -
    -Input: root = [11,8,6,1,3,9,11,30,20,18,16,12,10,4,2,17]
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/excel-sheet-column-number/README.md b/problems/excel-sheet-column-number/README.md index 2db81257f..dad535777 100644 --- a/problems/excel-sheet-column-number/README.md +++ b/problems/excel-sheet-column-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum-iii-data-structure-design "Two Sum III - Data structure design") @@ -48,13 +48,6 @@ AB -> 28 Output: 701 -

    Example 4:

    - -
    -Input: columnTitle = "FXSHRXW"
    -Output: 2147483647
    -
    -

     

    Constraints:

    diff --git a/problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md b/problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md new file mode 100644 index 000000000..b462fe8ea --- /dev/null +++ b/problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../a-number-after-a-double-reversal "A Number After a Double Reversal") +                 +[Next >](../intervals-between-identical-elements "Intervals Between Identical Elements") + +## [2120. Execution of All Suffix Instructions Staying in a Grid (Medium)](https://leetcode.com/problems/execution-of-all-suffix-instructions-staying-in-a-grid "执行所有后缀指令") + +

    There is an n x n grid, with the top-left cell at (0, 0) and the bottom-right cell at (n - 1, n - 1). You are given the integer n and an integer array startPos where startPos = [startrow, startcol] indicates that a robot is initially at cell (startrow, startcol).

    + +

    You are also given a 0-indexed string s of length m where s[i] is the ith instruction for the robot: 'L' (move left), 'R' (move right), 'U' (move up), and 'D' (move down).

    + +

    The robot can begin executing from any ith instruction in s. It executes the instructions one by one towards the end of s but it stops if either of these conditions is met:

    + +
      +
    • The next instruction will move the robot off the grid.
    • +
    • There are no more instructions left to execute.
    • +
    + +

    Return an array answer of length m where answer[i] is the number of instructions the robot can execute if the robot begins executing from the ith instruction in s.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 3, startPos = [0,1], s = "RRDDLU"
    +Output: [1,5,4,3,1,0]
    +Explanation: Starting from startPos and beginning execution from the ith instruction:
    +- 0th: "RRDDLU". Only one instruction "R" can be executed before it moves off the grid.
    +- 1st:  "RDDLU". All five instructions can be executed while it stays in the grid and ends at (1, 1).
    +- 2nd:   "DDLU". All four instructions can be executed while it stays in the grid and ends at (1, 0).
    +- 3rd:    "DLU". All three instructions can be executed while it stays in the grid and ends at (0, 0).
    +- 4th:     "LU". Only one instruction "L" can be executed before it moves off the grid.
    +- 5th:      "U". If moving up, it would move off the grid.
    +
    + +

    Example 2:

    + +
    +Input: n = 2, startPos = [1,1], s = "LURD"
    +Output: [4,1,0,0]
    +Explanation:
    +- 0th: "LURD".
    +- 1st:  "URD".
    +- 2nd:   "RD".
    +- 3rd:    "D".
    +
    + +

    Example 3:

    + +
    +Input: n = 1, startPos = [0,0], s = "LRUD"
    +Output: [0,0,0,0]
    +Explanation: No matter which instruction the robot begins execution from, it would move off the grid.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == s.length
    • +
    • 1 <= n, m <= 500
    • +
    • startPos.length == 2
    • +
    • 0 <= startrow, startcol < n
    • +
    • s consists of 'L', 'R', 'U', and 'D'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +The constraints are not very large. Can we simulate the execution by starting from each index of s? +
    + +
    +Hint 2 +Before any of the stopping conditions is met, stop the simulation for that index and set the answer for that index. +
    diff --git a/problems/fair-candy-swap/README.md b/problems/fair-candy-swap/README.md index 65f8226b2..dbdc443d5 100644 --- a/problems/fair-candy-swap/README.md +++ b/problems/fair-candy-swap/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../super-egg-drop "Super Egg Drop")                  [Next >](../construct-binary-tree-from-preorder-and-postorder-traversal "Construct Binary Tree from Preorder and Postorder Traversal") -## [888. Fair Candy Swap (Easy)](https://leetcode.com/problems/fair-candy-swap "公平的糖果棒交换") +## [888. Fair Candy Swap (Easy)](https://leetcode.com/problems/fair-candy-swap "公平的糖果交换")

    Alice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of candies of the ith box of candy that Alice has and bobSizes[j] is the number of candies of the jth box of candy that Bob has.

    @@ -39,13 +39,6 @@ Output: [2,3] -

    Example 4:

    - -
    -Input: aliceSizes = [1,2,5], bobSizes = [2,4]
    -Output: [5,4]
    -
    -

     

    Constraints:

    diff --git a/problems/filling-bookcase-shelves/README.md b/problems/filling-bookcase-shelves/README.md index 7906d6302..c6cf32c76 100644 --- a/problems/filling-bookcase-shelves/README.md +++ b/problems/filling-bookcase-shelves/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-in-zigzag-labelled-binary-tree "Path In Zigzag Labelled Binary Tree") diff --git a/problems/final-prices-with-a-special-discount-in-a-shop/README.md b/problems/final-prices-with-a-special-discount-in-a-shop/README.md index 25c0fa2da..7c6538477 100644 --- a/problems/final-prices-with-a-special-discount-in-a-shop/README.md +++ b/problems/final-prices-with-a-special-discount-in-a-shop/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-n-nodes-after-m-nodes-of-a-linked-list "Delete N Nodes After M Nodes of a Linked List") diff --git a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md index 84e1c95e2..66b06bfd1 100644 --- a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md +++ b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-employee-id-with-the-unique-identifier "Replace Employee ID With The Unique Identifier") @@ -42,20 +42,6 @@ Output: 4 -

    Example 4:

    - -
    -Input: tree = [1,2,3,4,5,6,7,8,9,10], target = 5
    -Output: 5
    -
    - -

    Example 5:

    - -
    -Input: tree = [1,2,null,3], target = 2
    -Output: 2
    -
    -

     

    Constraints:

    diff --git a/problems/find-a-peak-element-ii/README.md b/problems/find-a-peak-element-ii/README.md index cdf0afb44..c47255627 100644 --- a/problems/find-a-peak-element-ii/README.md +++ b/problems/find-a-peak-element-ii/README.md @@ -57,6 +57,9 @@ [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Find Peak Element](../find-peak-element) (Medium) + ### Hints
    Hint 1 diff --git a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md index 93a511564..bf5dc8ff7 100644 --- a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md +++ b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md @@ -53,10 +53,10 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] ### Hints
    diff --git a/problems/find-all-duplicates-in-an-array/README.md b/problems/find-all-duplicates-in-an-array/README.md index c3651b409..56daee0c2 100644 --- a/problems/find-all-duplicates-in-an-array/README.md +++ b/problems/find-all-duplicates-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../arranging-coins "Arranging Coins") diff --git a/problems/find-all-lonely-numbers-in-the-array/README.md b/problems/find-all-lonely-numbers-in-the-array/README.md new file mode 100644 index 000000000..3ab667e3d --- /dev/null +++ b/problems/find-all-lonely-numbers-in-the-array/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../rearrange-array-elements-by-sign "Rearrange Array Elements by Sign") +                 +[Next >](../maximum-good-people-based-on-statements "Maximum Good People Based on Statements") + +## [2150. Find All Lonely Numbers in the Array (Medium)](https://leetcode.com/problems/find-all-lonely-numbers-in-the-array "找出数组中的所有孤独数字") + +

    You are given an integer array nums. A number x is lonely when it appears only once, and no adjacent numbers (i.e. x + 1 and x - 1) appear in the array.

    + +

    Return all lonely numbers in nums. You may return the answer in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [10,6,5,8]
    +Output: [10,8]
    +Explanation: 
    +- 10 is a lonely number since it appears exactly once and 9 and 11 does not appear in nums.
    +- 8 is a lonely number since it appears exactly once and 7 and 9 does not appear in nums.
    +- 5 is not a lonely number since 6 appears in nums and vice versa.
    +Hence, the lonely numbers in nums are [10, 8].
    +Note that [8, 10] may also be returned.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,3,5,3]
    +Output: [1,5]
    +Explanation: 
    +- 1 is a lonely number since it appears exactly once and 0 and 2 does not appear in nums.
    +- 5 is a lonely number since it appears exactly once and 4 and 6 does not appear in nums.
    +- 3 is not a lonely number since it appears twice.
    +Hence, the lonely numbers in nums are [1, 5].
    +Note that [5, 1] may also be returned.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 106
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +For a given element x, how can you quickly check if x - 1 and x + 1 are present in the array without reiterating through the entire array? +
    + +
    +Hint 2 +Use a set or a hash map. +
    diff --git a/problems/find-all-people-with-secret/README.md b/problems/find-all-people-with-secret/README.md new file mode 100644 index 000000000..0ff67d5f5 --- /dev/null +++ b/problems/find-all-people-with-secret/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../removing-minimum-and-maximum-from-array "Removing Minimum and Maximum From Array") +                 +[Next >](../minimum-cost-to-reach-city-with-discounts "Minimum Cost to Reach City With Discounts") + +## [2092. Find All People With Secret (Hard)](https://leetcode.com/problems/find-all-people-with-secret "找出知晓秘密的所有专家") + +

    You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [xi, yi, timei] indicates that person xi and person yi have a meeting at timei. A person may attend multiple meetings at the same time. Finally, you are given an integer firstPerson.

    + +

    Person 0 has a secret and initially shares the secret with a person firstPerson at time 0. This secret is then shared every time a meeting takes place with a person that has the secret. More formally, for every meeting, if a person xi has the secret at timei, then they will share the secret with person yi, and vice versa.

    + +

    The secrets are shared instantaneously. That is, a person may receive the secret and share it with people in other meetings within the same time frame.

    + +

    Return a list of all the people that have the secret after all the meetings have taken place. You may return the answer in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 6, meetings = [[1,2,5],[2,3,8],[1,5,10]], firstPerson = 1
    +Output: [0,1,2,3,5]
    +Explanation:
    +At time 0, person 0 shares the secret with person 1.
    +At time 5, person 1 shares the secret with person 2.
    +At time 8, person 2 shares the secret with person 3.
    +At time 10, person 1 shares the secret with person 5.​​​​
    +Thus, people 0, 1, 2, 3, and 5 know the secret after all the meetings.
    +
    + +

    Example 2:

    + +
    +Input: n = 4, meetings = [[3,1,3],[1,2,2],[0,3,3]], firstPerson = 3
    +Output: [0,1,3]
    +Explanation:
    +At time 0, person 0 shares the secret with person 3.
    +At time 2, neither person 1 nor person 2 know the secret.
    +At time 3, person 3 shares the secret with person 0 and person 1.
    +Thus, people 0, 1, and 3 know the secret after all the meetings.
    +
    + +

    Example 3:

    + +
    +Input: n = 5, meetings = [[3,4,2],[1,2,1],[2,3,1]], firstPerson = 1
    +Output: [0,1,2,3,4]
    +Explanation:
    +At time 0, person 0 shares the secret with person 1.
    +At time 1, person 1 shares the secret with person 2, and person 2 shares the secret with person 3.
    +Note that person 2 can share the secret at the same time as receiving it.
    +At time 2, person 3 shares the secret with person 4.
    +Thus, people 0, 1, 2, 3, and 4 know the secret after all the meetings.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 105
    • +
    • 1 <= meetings.length <= 105
    • +
    • meetings[i].length == 3
    • +
    • 0 <= xi, yi <= n - 1
    • +
    • xi != yi
    • +
    • 1 <= timei <= 105
    • +
    • 1 <= firstPerson <= n - 1
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Could you model all the meetings happening at the same time as a graph? +
    + +
    +Hint 2 +What data structure can you use to efficiently share the secret? +
    + +
    +Hint 3 +You can use the union-find data structure to quickly determine who knows the secret and share the secret. +
    diff --git a/problems/find-all-possible-recipes-from-given-supplies/README.md b/problems/find-all-possible-recipes-from-given-supplies/README.md new file mode 100644 index 000000000..a2dc609d4 --- /dev/null +++ b/problems/find-all-possible-recipes-from-given-supplies/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../maximum-number-of-words-found-in-sentences "Maximum Number of Words Found in Sentences") +                 +[Next >](../check-if-a-parentheses-string-can-be-valid "Check if a Parentheses String Can Be Valid") + +## [2115. Find All Possible Recipes from Given Supplies (Medium)](https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies "从给定原材料中找到所有可以做出的菜") + +

    You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i], and you can create it if you have all the needed ingredients from ingredients[i]. Ingredients to a recipe may need to be created from other recipes, i.e., ingredients[i] may contain a string that is in recipes.

    + +

    You are also given a string array supplies containing all the ingredients that you initially have, and you have an infinite supply of all of them.

    + +

    Return a list of all the recipes that you can create. You may return the answer in any order.

    + +

    Note that two recipes may contain each other in their ingredients.

    + +

     

    +

    Example 1:

    + +
    +Input: recipes = ["bread"], ingredients = [["yeast","flour"]], supplies = ["yeast","flour","corn"]
    +Output: ["bread"]
    +Explanation:
    +We can create "bread" since we have the ingredients "yeast" and "flour".
    +
    + +

    Example 2:

    + +
    +Input: recipes = ["bread","sandwich"], ingredients = [["yeast","flour"],["bread","meat"]], supplies = ["yeast","flour","meat"]
    +Output: ["bread","sandwich"]
    +Explanation:
    +We can create "bread" since we have the ingredients "yeast" and "flour".
    +We can create "sandwich" since we have the ingredient "meat" and can create the ingredient "bread".
    +
    + +

    Example 3:

    + +
    +Input: recipes = ["bread","sandwich","burger"], ingredients = [["yeast","flour"],["bread","meat"],["sandwich","meat","bread"]], supplies = ["yeast","flour","meat"]
    +Output: ["bread","sandwich","burger"]
    +Explanation:
    +We can create "bread" since we have the ingredients "yeast" and "flour".
    +We can create "sandwich" since we have the ingredient "meat" and can create the ingredient "bread".
    +We can create "burger" since we have the ingredient "meat" and can create the ingredients "bread" and "sandwich".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == recipes.length == ingredients.length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= ingredients[i].length, supplies.length <= 100
    • +
    • 1 <= recipes[i].length, ingredients[i][j].length, supplies[k].length <= 10
    • +
    • recipes[i], ingredients[i][j], and supplies[k] consist only of lowercase English letters.
    • +
    • All the values of recipes and supplies combined are unique.
    • +
    • Each ingredients[i] does not contain any duplicate values.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Can we use a data structure to quickly query whether we have a certain ingredient? +
    + +
    +Hint 2 +Once we verify that we can make a recipe, we can add it to our ingredient data structure. We can then check if we can make more recipes as a result of this. +
    diff --git a/problems/find-all-the-lonely-nodes/README.md b/problems/find-all-the-lonely-nodes/README.md index d0bb2cb6d..d7b5cec33 100644 --- a/problems/find-all-the-lonely-nodes/README.md +++ b/problems/find-all-the-lonely-nodes/README.md @@ -19,6 +19,10 @@ [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Binary Tree Tilt](../binary-tree-tilt) (Easy) + 1. [Univalued Binary Tree](../univalued-binary-tree) (Easy) + ### Hints
    Hint 1 diff --git a/problems/find-and-replace-in-string/README.md b/problems/find-and-replace-in-string/README.md index a7f371184..1d762c099 100644 --- a/problems/find-and-replace-in-string/README.md +++ b/problems/find-and-replace-in-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flipping-an-image "Flipping an Image") diff --git a/problems/find-and-replace-pattern/README.md b/problems/find-and-replace-pattern/README.md index f1d5c8d67..9dfda5196 100644 --- a/problems/find-and-replace-pattern/README.md +++ b/problems/find-and-replace-pattern/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-tree-from-preorder-and-postorder-traversal "Construct Binary Tree from Preorder and Postorder Traversal") diff --git a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md index d8036fa81..01117621a 100644 --- a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md +++ b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../avoid-flood-in-the-city "Avoid Flood in The City") diff --git a/problems/find-cutoff-score-for-each-school/README.md b/problems/find-cutoff-score-for-each-school/README.md index 5009be138..81a12ad5a 100644 --- a/problems/find-cutoff-score-for-each-school/README.md +++ b/problems/find-cutoff-score-for-each-school/README.md @@ -9,6 +9,6 @@                  [Next >](../maximum-number-of-people-that-can-be-caught-in-tag "Maximum Number of People That Can Be Caught in Tag") -## [1988. Find Cutoff Score for Each School (Medium)](https://leetcode.com/problems/find-cutoff-score-for-each-school "") +## [1988. Find Cutoff Score for Each School (Medium)](https://leetcode.com/problems/find-cutoff-score-for-each-school "找出每所学校的最低分数要求") diff --git a/problems/find-duplicate-subtrees/README.md b/problems/find-duplicate-subtrees/README.md index 13bb973a2..83c94b5a6 100644 --- a/problems/find-duplicate-subtrees/README.md +++ b/problems/find-duplicate-subtrees/README.md @@ -57,3 +57,4 @@ 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) 1. [Serialize and Deserialize BST](../serialize-and-deserialize-bst) (Medium) 1. [Construct String from Binary Tree](../construct-string-from-binary-tree) (Easy) + 1. [Delete Duplicate Folders in System](../delete-duplicate-folders-in-system) (Hard) diff --git a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md index fd35bab24..bc6e12886 100644 --- a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md +++ b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../search-in-rotated-sorted-array "Search in Rotated Sorted Array") @@ -11,7 +11,7 @@ ## [34. Find First and Last Position of Element in Sorted Array (Medium)](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array "在排序数组中查找元素的第一个和最后一个位置") -

    Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.

    +

    Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.

    If target is not found in the array, return [-1, -1].

    @@ -44,3 +44,5 @@ ### Similar Questions 1. [First Bad Version](../first-bad-version) (Easy) + 1. [Plates Between Candles](../plates-between-candles) (Medium) + 1. [Find Target Indices After Sorting Array](../find-target-indices-after-sorting-array) (Easy) diff --git a/problems/find-first-palindromic-string-in-the-array/README.md b/problems/find-first-palindromic-string-in-the-array/README.md new file mode 100644 index 000000000..d10defefd --- /dev/null +++ b/problems/find-first-palindromic-string-in-the-array/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../number-of-unique-flavors-after-sharing-k-candies "Number of Unique Flavors After Sharing K Candies") +                 +[Next >](../adding-spaces-to-a-string "Adding Spaces to a String") + +## [2108. Find First Palindromic String in the Array (Easy)](https://leetcode.com/problems/find-first-palindromic-string-in-the-array "找出数组中的第一个回文字符串") + +

    Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string "".

    + +

    A string is palindromic if it reads the same forward and backward.

    + +

     

    +

    Example 1:

    + +
    +Input: words = ["abc","car","ada","racecar","cool"]
    +Output: "ada"
    +Explanation: The first string that is palindromic is "ada".
    +Note that "racecar" is also palindromic, but it is not the first.
    +
    + +

    Example 2:

    + +
    +Input: words = ["notapalindrome","racecar"]
    +Output: "racecar"
    +Explanation: The first and only string that is palindromic is "racecar".
    +
    + +

    Example 3:

    + +
    +Input: words = ["def","ghi"]
    +Output: ""
    +Explanation: There are no palindromic strings, so the empty string is returned.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 100
    • +
    • 1 <= words[i].length <= 100
    • +
    • words[i] consists only of lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Iterate through the elements in order. As soon as the current element is a palindrome, return it. +
    + +
    +Hint 2 +To check if an element is a palindrome, can you reverse the string? +
    diff --git a/problems/find-good-days-to-rob-the-bank/README.md b/problems/find-good-days-to-rob-the-bank/README.md new file mode 100644 index 000000000..0f8c76b53 --- /dev/null +++ b/problems/find-good-days-to-rob-the-bank/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../find-subsequence-of-length-k-with-the-largest-sum "Find Subsequence of Length K With the Largest Sum") +                 +[Next >](../detonate-the-maximum-bombs "Detonate the Maximum Bombs") + +## [2100. Find Good Days to Rob the Bank (Medium)](https://leetcode.com/problems/find-good-days-to-rob-the-bank "适合打劫银行的日子") + +

    You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the ith day. The days are numbered starting from 0. You are also given an integer time.

    + +

    The ith day is a good day to rob the bank if:

    + +
      +
    • There are at least time days before and after the ith day,
    • +
    • The number of guards at the bank for the time days before i are non-increasing, and
    • +
    • The number of guards at the bank for the time days after i are non-decreasing.
    • +
    + +

    More formally, this means day i is a good day to rob the bank if and only if security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time].

    + +

    Return a list of all days (0-indexed) that are good days to rob the bank. The order that the days are returned in does not matter.

    + +

     

    +

    Example 1:

    + +
    +Input: security = [5,3,3,3,5,6,2], time = 2
    +Output: [2,3]
    +Explanation:
    +On day 2, we have security[0] >= security[1] >= security[2] <= security[3] <= security[4].
    +On day 3, we have security[1] >= security[2] >= security[3] <= security[4] <= security[5].
    +No other days satisfy this condition, so days 2 and 3 are the only good days to rob the bank.
    +
    + +

    Example 2:

    + +
    +Input: security = [1,1,1,1,1], time = 0
    +Output: [0,1,2,3,4]
    +Explanation:
    +Since time equals 0, every day is a good day to rob the bank, so return every day.
    +
    + +

    Example 3:

    + +
    +Input: security = [1,2,3,4,5,6], time = 2
    +Output: []
    +Explanation:
    +No day has 2 days before it that have a non-increasing number of guards.
    +Thus, no day is a good day to rob the bank, so return an empty list.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= security.length <= 105
    • +
    • 0 <= security[i], time <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +The trivial solution is to check the time days before and after each day. There are a lot of repeated operations using this solution. How could we optimize this solution? +
    + +
    +Hint 2 +We can use precomputation to make the solution faster. +
    + +
    +Hint 3 +Use an array to store the number of days before the ith day that is non-increasing, and another array to store the number of days after the ith day that is non-decreasing. +
    diff --git a/problems/find-if-path-exists-in-graph/README.md b/problems/find-if-path-exists-in-graph/README.md index 08b773042..f0623ec1c 100644 --- a/problems/find-if-path-exists-in-graph/README.md +++ b/problems/find-if-path-exists-in-graph/README.md @@ -13,15 +13,15 @@

    There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.

    -

    You want to determine if there is a valid path that exists from vertex start to vertex end.

    +

    You want to determine if there is a valid path that exists from vertex source to vertex destination.

    -

    Given edges and the integers n, start, and end, return true if there is a valid path from start to end, or false otherwise.

    +

    Given edges and the integers n, source, and destination, return true if there is a valid path from source to destination, or false otherwise.

     

    Example 1:

    -Input: n = 3, edges = [[0,1],[1,2],[2,0]], start = 0, end = 2
    +Input: n = 3, edges = [[0,1],[1,2],[2,0]], source = 0, destination = 2
     Output: true
     Explanation: There are two paths from vertex 0 to vertex 2:
     - 0 → 1 → 2
    @@ -31,7 +31,7 @@
     

    Example 2:

    -Input: n = 6, edges = [[0,1],[0,2],[3,5],[5,4],[4,3]], start = 0, end = 5
    +Input: n = 6, edges = [[0,1],[0,2],[3,5],[5,4],[4,3]], source = 0, destination = 5
     Output: false
     Explanation: There is no path from vertex 0 to vertex 5.
     
    @@ -45,7 +45,7 @@
  • edges[i].length == 2
  • 0 <= ui, vi <= n - 1
  • ui != vi
  • -
  • 0 <= start, end <= n - 1
  • +
  • 0 <= source, destination <= n - 1
  • There are no duplicate edges.
  • There are no self edges.
  • diff --git a/problems/find-k-closest-elements/README.md b/problems/find-k-closest-elements/README.md index db3d6d94d..3256c0ea8 100644 --- a/problems/find-k-closest-elements/README.md +++ b/problems/find-k-closest-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../robot-return-to-origin "Robot Return to Origin") diff --git a/problems/find-k-length-substrings-with-no-repeated-characters/README.md b/problems/find-k-length-substrings-with-no-repeated-characters/README.md index 8bbd4791a..2ffabda34 100644 --- a/problems/find-k-length-substrings-with-no-repeated-characters/README.md +++ b/problems/find-k-length-substrings-with-no-repeated-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum-less-than-k "Two Sum Less Than K") diff --git a/problems/find-kth-bit-in-nth-binary-string/README.md b/problems/find-kth-bit-in-nth-binary-string/README.md index c6deb7db6..a3be3ef9b 100644 --- a/problems/find-kth-bit-in-nth-binary-string/README.md +++ b/problems/find-kth-bit-in-nth-binary-string/README.md @@ -15,12 +15,12 @@
    • S1 = "0"
    • -
    • Si = Si-1 + "1" + reverse(invert(Si-1)) for i > 1
    • +
    • Si = Si - 1 + "1" + reverse(invert(Si - 1)) for i > 1
    -

    Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).

    +

    Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).

    -

    For example, the first 4 strings in the above sequence are:

    +

    For example, the first four strings in the above sequence are:

    • S1 = "0"
    • @@ -37,7 +37,8 @@
       Input: n = 3, k = 1
       Output: "0"
      -Explanation: S3 is "0111001". The first bit is "0".
      +Explanation: S3 is "0111001".
      +The 1st bit is "0".
       

      Example 2:

      @@ -45,21 +46,8 @@
       Input: n = 4, k = 11
       Output: "1"
      -Explanation: S4 is "011100110110001". The 11th bit is "1".
      -
      - -

      Example 3:

      - -
      -Input: n = 1, k = 1
      -Output: "0"
      -
      - -

      Example 4:

      - -
      -Input: n = 2, k = 3
      -Output: "1"
      +Explanation: S4 is "011100110110001".
      +The 11th bit is "1".
       

       

      diff --git a/problems/find-kth-largest-xor-coordinate-value/README.md b/problems/find-kth-largest-xor-coordinate-value/README.md index 09a8dc816..1e1e0f942 100644 --- a/problems/find-kth-largest-xor-coordinate-value/README.md +++ b/problems/find-kth-largest-xor-coordinate-value/README.md @@ -23,14 +23,16 @@
       Input: matrix = [[5,2],[1,6]], k = 1
       Output: 7
      -Explanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value.
      +Explanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value. +

    Example 2:

     Input: matrix = [[5,2],[1,6]], k = 2
     Output: 5
    -Explanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value.
    +Explanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value. +

    Example 3:

    @@ -39,13 +41,6 @@ Output: 4 Explanation: The value of coordinate (1,0) is 5 XOR 1 = 4, which is the 3rd largest value. -

    Example 4:

    - -
    -Input: matrix = [[5,2],[1,6]], k = 4
    -Output: 0
    -Explanation: The value of coordinate (1,1) is 5 XOR 2 XOR 1 XOR 6 = 0, which is the 4th largest value.
    -

     

    Constraints:

    diff --git a/problems/find-latest-group-of-size-m/README.md b/problems/find-latest-group-of-size-m/README.md index 7b8f9ad12..a9082fdad 100644 --- a/problems/find-latest-group-of-size-m/README.md +++ b/problems/find-latest-group-of-size-m/README.md @@ -25,21 +25,22 @@
     Input: arr = [3,5,1,2,4], m = 1
     Output: 4
    -Explanation:
    -Step 1: "00100", groups: ["1"]
    +Explanation: 
    +Step 1: "00100", groups: ["1"]
     Step 2: "00101", groups: ["1", "1"]
     Step 3: "10101", groups: ["1", "1", "1"]
     Step 4: "11101", groups: ["111", "1"]
     Step 5: "11111", groups: ["11111"]
    -The latest step at which there exists a group of size 1 is step 4.
    +The latest step at which there exists a group of size 1 is step 4. +

    Example 2:

     Input: arr = [3,1,5,4,2], m = 2
     Output: -1
    -Explanation:
    -Step 1: "00100", groups: ["1"]
    +Explanation: 
    +Step 1: "00100", groups: ["1"]
     Step 2: "10100", groups: ["1", "1"]
     Step 3: "10101", groups: ["1", "1", "1"]
     Step 4: "10111", groups: ["1", "111"]
    @@ -47,20 +48,6 @@ Step 5: "11111", groups: ["11111"]
     No group of size 2 exists during any step.
     
    -

    Example 3:

    - -
    -Input: arr = [1], m = 1
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: arr = [2,1], m = 2
    -Output: 2
    -
    -

     

    Constraints:

    diff --git a/problems/find-longest-awesome-substring/README.md b/problems/find-longest-awesome-substring/README.md index 35bff6ebc..b024ca96d 100644 --- a/problems/find-longest-awesome-substring/README.md +++ b/problems/find-longest-awesome-substring/README.md @@ -11,9 +11,9 @@ ## [1542. Find Longest Awesome Substring (Hard)](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") -

    Given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it palindrome.

    +

    You are given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it a palindrome.

    -

    Return the length of the maximum length awesome substring of s.

    +

    Return the length of the maximum length awesome substring of s.

     

    Example 1:

    @@ -39,13 +39,6 @@ Explanation: "213123" is the longest awesome substring, we can form the palindrome "231132" with some swaps. -

    Example 4:

    - -
    -Input: s = "00"
    -Output: 2
    -
    -

     

    Constraints:

    diff --git a/problems/find-lucky-integer-in-an-array/README.md b/problems/find-lucky-integer-in-an-array/README.md index 2308ca8e0..197c818bd 100644 --- a/problems/find-lucky-integer-in-an-array/README.md +++ b/problems/find-lucky-integer-in-an-array/README.md @@ -11,9 +11,9 @@ ## [1394. Find Lucky Integer in an Array (Easy)](https://leetcode.com/problems/find-lucky-integer-in-an-array "找出数组中的幸运数") -

    Given an array of integers arr, a lucky integer is an integer which has a frequency in the array equal to its value.

    +

    Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value.

    -

    Return a lucky integer in the array. If there are multiple lucky integers return the largest of them. If there is no lucky integer return -1.

    +

    Return the largest lucky integer in the array. If there is no lucky integer return -1.

     

    Example 1:

    @@ -40,20 +40,6 @@ Explanation: There are no lucky numbers in the array. -

    Example 4:

    - -
    -Input: arr = [5]
    -Output: -1
    -
    - -

    Example 5:

    - -
    -Input: arr = [7,7,7,7,7,7,7]
    -Output: 7
    -
    -

     

    Constraints:

    diff --git a/problems/find-minimum-in-rotated-sorted-array-ii/README.md b/problems/find-minimum-in-rotated-sorted-array-ii/README.md index d9cf6cda9..5fa38008e 100644 --- a/problems/find-minimum-in-rotated-sorted-array-ii/README.md +++ b/problems/find-minimum-in-rotated-sorted-array-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-minimum-in-rotated-sorted-array "Find Minimum in Rotated Sorted Array") diff --git a/problems/find-missing-observations/README.md b/problems/find-missing-observations/README.md index 7509a72d7..65ccb1f6d 100644 --- a/problems/find-missing-observations/README.md +++ b/problems/find-missing-observations/README.md @@ -46,14 +46,6 @@ Explanation: It is impossible for the mean to be 6 no matter what the 4 missing rolls are. -

    Example 4:

    - -
    -Input: rolls = [1], mean = 3, n = 1
    -Output: [5]
    -Explanation: The mean of all n + m rolls is (1 + 5) / 2 = 3.
    -
    -

     

    Constraints:

    diff --git a/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md index 428b9c620..f390364e6 100644 --- a/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md +++ b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md @@ -51,6 +51,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [K Closest Points to Origin](../k-closest-points-to-origin) (Medium) + ### Hints
    Hint 1 diff --git a/problems/find-numbers-with-even-number-of-digits/README.md b/problems/find-numbers-with-even-number-of-digits/README.md index b13bbff63..22abd4751 100644 --- a/problems/find-numbers-with-even-number-of-digits/README.md +++ b/problems/find-numbers-with-even-number-of-digits/README.md @@ -48,6 +48,9 @@ Only 1771 contains an even number of digits. ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [Finding 3-Digit Even Numbers](../finding-3-digit-even-numbers) (Easy) + ### Hints
    Hint 1 diff --git a/problems/find-root-of-n-ary-tree/README.md b/problems/find-root-of-n-ary-tree/README.md index 86d931298..1e76d79f4 100644 --- a/problems/find-root-of-n-ary-tree/README.md +++ b/problems/find-root-of-n-ary-tree/README.md @@ -14,13 +14,10 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - -### Similar Questions - 1. [Move Sub-Tree of N-Ary Tree](../move-sub-tree-of-n-ary-tree) (Hard) + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/find-servers-that-handled-most-number-of-requests/README.md b/problems/find-servers-that-handled-most-number-of-requests/README.md index c18b61cd2..ac8510ccd 100644 --- a/problems/find-servers-that-handled-most-number-of-requests/README.md +++ b/problems/find-servers-that-handled-most-number-of-requests/README.md @@ -30,7 +30,7 @@
     Input: k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] 
     Output: [1] 
    -Explanation:
    +Explanation: 
     All of the servers start out available.
     The first 3 requests are handled by the first 3 servers in order.
     Request 3 comes in. Server 0 is busy, so it's assigned to the next available server, which is 1.
    @@ -43,7 +43,7 @@ Servers 0 and 2 handled one request each, while server 1 handled two requests. H
     
     Input: k = 3, arrival = [1,2,3,4], load = [1,2,1,2]
     Output: [0]
    -Explanation:
    +Explanation: 
     The first 3 requests are handled by first 3 servers.
     Request 3 comes in. It is handled by server 0 since the server is available.
     Server 0 handled two requests, while servers 1 and 2 handled one request each. Hence server 0 is the busiest server.
    @@ -54,21 +54,7 @@ Server 0 handled two requests, while servers 1 and 2 handled one request each. H
     
     Input: k = 3, arrival = [1,2,3], load = [10,12,11]
     Output: [0,1,2]
    -Explanation: Each server handles a single request, so they are all considered the busiest.
    -
    - -

    Example 4:

    - -
    -Input: k = 3, arrival = [1,2,3,4,8,9,10], load = [5,2,10,3,1,2,2]
    -Output: [1]
    -
    - -

    Example 5:

    - -
    -Input: k = 1, arrival = [1], load = [1]
    -Output: [0]
    +Explanation: Each server handles a single request, so they are all considered the busiest.
     

     

    @@ -83,10 +69,10 @@ Server 0 handled two requests, while servers 1 and 2 handled one request each. H ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Hints
    diff --git a/problems/find-subsequence-of-length-k-with-the-largest-sum/README.md b/problems/find-subsequence-of-length-k-with-the-largest-sum/README.md new file mode 100644 index 000000000..dcdab30b2 --- /dev/null +++ b/problems/find-subsequence-of-length-k-with-the-largest-sum/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../subsequence-of-size-k-with-the-largest-even-sum "Subsequence of Size K With the Largest Even Sum") +                 +[Next >](../find-good-days-to-rob-the-bank "Find Good Days to Rob the Bank") + +## [2099. Find Subsequence of Length K With the Largest Sum (Easy)](https://leetcode.com/problems/find-subsequence-of-length-k-with-the-largest-sum "找到和最大的长度为 K 的子序列") + +

    You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum.

    + +

    Return any such subsequence as an integer array of length k.

    + +

    A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,1,3,3], k = 2
    +Output: [3,3]
    +Explanation:
    +The subsequence has the largest sum of 3 + 3 = 6.
    + +

    Example 2:

    + +
    +Input: nums = [-1,-2,3,4], k = 3
    +Output: [-1,3,4]
    +Explanation: 
    +The subsequence has the largest sum of -1 + 3 + 4 = 6.
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,4,3,3], k = 2
    +Output: [3,4]
    +Explanation:
    +The subsequence has the largest sum of 3 + 4 = 7. 
    +Another possible subsequence is [4, 3].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • -105 <= nums[i] <= 105
    • +
    • 1 <= k <= nums.length
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +From a greedy perspective, what k elements should you pick? +
    + +
    +Hint 2 +Could you sort the array while maintaining the index? +
    diff --git a/problems/find-substring-with-given-hash-value/README.md b/problems/find-substring-with-given-hash-value/README.md new file mode 100644 index 000000000..0c9182b7e --- /dev/null +++ b/problems/find-substring-with-given-hash-value/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../all-divisions-with-the-highest-score-of-a-binary-array "All Divisions With the Highest Score of a Binary Array") +                 +[Next >](../groups-of-strings "Groups of Strings") + +## [2156. Find Substring With Given Hash Value (Medium)](https://leetcode.com/problems/find-substring-with-given-hash-value "查找给定哈希值的子串") + +

    The hash of a 0-indexed string s of length k, given integers p and m, is computed using the following function:

    + +
      +
    • hash(s, p, m) = (val(s[0]) * p0 + val(s[1]) * p1 + ... + val(s[k-1]) * pk-1) mod m.
    • +
    + +

    Where val(s[i]) represents the index of s[i] in the alphabet from val('a') = 1 to val('z') = 26.

    + +

    You are given a string s and the integers power, modulo, k, and hashValue. Return sub, the first substring of s of length k such that hash(sub, power, modulo) == hashValue.

    + +

    The test cases will be generated such that an answer always exists.

    + +

    A substring is a contiguous non-empty sequence of characters within a string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "leetcode", power = 7, modulo = 20, k = 2, hashValue = 0
    +Output: "ee"
    +Explanation: The hash of "ee" can be computed to be hash("ee", 7, 20) = (5 * 1 + 5 * 7) mod 20 = 40 mod 20 = 0. 
    +"ee" is the first substring of length 2 with hashValue 0. Hence, we return "ee".
    +
    + +

    Example 2:

    + +
    +Input: s = "fbxzaad", power = 31, modulo = 100, k = 3, hashValue = 32
    +Output: "fbx"
    +Explanation: The hash of "fbx" can be computed to be hash("fbx", 31, 100) = (6 * 1 + 2 * 31 + 24 * 312) mod 100 = 23132 mod 100 = 32. 
    +The hash of "bxz" can be computed to be hash("bxz", 31, 100) = (2 * 1 + 24 * 31 + 26 * 312) mod 100 = 25732 mod 100 = 32. 
    +"fbx" is the first substring of length 3 with hashValue 32. Hence, we return "fbx".
    +Note that "bxz" also has a hash of 32 but it appears later than "fbx".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= s.length <= 2 * 104
    • +
    • 1 <= power, modulo <= 109
    • +
    • 0 <= hashValue < modulo
    • +
    • s consists of lowercase English letters only.
    • +
    • The test cases are generated such that an answer always exists.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] + +### Hints +
    +Hint 1 +How can we update the hash value efficiently while iterating instead of recalculating it each time? +
    + +
    +Hint 2 +Use the rolling hash method. +
    diff --git a/problems/find-target-indices-after-sorting-array/README.md b/problems/find-target-indices-after-sorting-array/README.md new file mode 100644 index 000000000..ef7f2708f --- /dev/null +++ b/problems/find-target-indices-after-sorting-array/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../count-fertile-pyramids-in-a-land "Count Fertile Pyramids in a Land") +                 +[Next >](../k-radius-subarray-averages "K Radius Subarray Averages") + +## [2089. Find Target Indices After Sorting Array (Easy)](https://leetcode.com/problems/find-target-indices-after-sorting-array "找出数组排序后的目标下标") + +

    You are given a 0-indexed integer array nums and a target element target.

    + +

    A target index is an index i such that nums[i] == target.

    + +

    Return a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,5,2,3], target = 2
    +Output: [1,2]
    +Explanation: After sorting, nums is [1,2,2,3,5].
    +The indices where nums[i] == 2 are 1 and 2.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,5,2,3], target = 3
    +Output: [3]
    +Explanation: After sorting, nums is [1,2,2,3,5].
    +The index where nums[i] == 3 is 3.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,5,2,3], target = 5
    +Output: [4]
    +Explanation: After sorting, nums is [1,2,2,3,5].
    +The index where nums[i] == 5 is 4.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 1 <= nums[i], target <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Try "sorting" the array first. +
    + +
    +Hint 2 +Now find all indices in the array whose values are equal to target. +
    diff --git a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md index 8a56a7c1b..fe8cd7fdf 100644 --- a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md +++ b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../filter-restaurants-by-vegan-friendly-price-and-distance "Filter Restaurants by Vegan-Friendly, Price and Distance") @@ -60,10 +60,13 @@ The city 0 has 1 neighboring city at a distanceThreshold = 2. ### Related Topics - [[Graph](../../tag/graph/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Graph](../../tag/graph/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] +### Similar Questions + 1. [Second Minimum Time to Reach Destination](../second-minimum-time-to-reach-destination) (Hard) + ### Hints
    Hint 1 diff --git a/problems/find-the-index-of-the-large-integer/README.md b/problems/find-the-index-of-the-large-integer/README.md index 57eb5c872..4206c138e 100644 --- a/problems/find-the-index-of-the-large-integer/README.md +++ b/problems/find-the-index-of-the-large-integer/README.md @@ -18,9 +18,6 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Interactive](../../tag/interactive/README.md)] -### Similar Questions - 1. [Search in a Sorted Array of Unknown Size](../search-in-a-sorted-array-of-unknown-size) (Medium) - ### Hints
    Hint 1 diff --git a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md index f115bd5f2..04ac15592 100644 --- a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md +++ b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit") @@ -11,9 +11,11 @@ ## [1439. Find the Kth Smallest Sum of a Matrix With Sorted Rows (Hard)](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") -

    You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing order.

    +

    You are given an m x n matrix mat that has its rows sorted in non-decreasing order and an integer k.

    -

    You are allowed to choose exactly 1 element from each row to form an array. Return the Kth smallest array sum among all possible arrays.

    +

    You are allowed to choose exactly one element from each row to form an array.

    + +

    Return the kth smallest array sum among all possible arrays.

     

    Example 1:

    @@ -21,8 +23,9 @@
     Input: mat = [[1,3,11],[2,4,6]], k = 5
     Output: 7
    -Explanation: Choosing one element from each row, the first k smallest sum are:
    -[1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7.  
    +Explanation: Choosing one element from each row, the first k smallest sum are: +[1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7. +

    Example 2:

    @@ -40,13 +43,6 @@ [1,1,2], [1,1,3], [1,4,2], [1,4,3], [1,1,6], [1,5,2], [1,5,3]. Where the 7th sum is 9.
    -

    Example 4:

    - -
    -Input: mat = [[1,1,10],[2,2,9]], k = 7
    -Output: 12
    -
    -

     

    Constraints:

    @@ -54,16 +50,16 @@
  • m == mat.length
  • n == mat.length[i]
  • 1 <= m, n <= 40
  • -
  • 1 <= k <= min(200, n ^ m)
  • 1 <= mat[i][j] <= 5000
  • -
  • mat[i] is a non decreasing array.
  • +
  • 1 <= k <= min(200, nm)
  • +
  • mat[i] is a non-decreasing array.
  • ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/find-the-middle-index-in-array/README.md b/problems/find-the-middle-index-in-array/README.md index c9372d3c6..5a9991797 100644 --- a/problems/find-the-middle-index-in-array/README.md +++ b/problems/find-the-middle-index-in-array/README.md @@ -25,8 +25,7 @@
     Input: nums = [2,3,-1,8,4]
     Output: 3
    -Explanation:
    -The sum of the numbers before index 3 is: 2 + 3 + -1 = 4
    +Explanation: The sum of the numbers before index 3 is: 2 + 3 + -1 = 4
     The sum of the numbers after index 3 is: 4 = 4
     
    @@ -35,8 +34,7 @@ The sum of the numbers after index 3 is: 4 = 4
     Input: nums = [1,-1,4]
     Output: 2
    -Explanation:
    -The sum of the numbers before index 2 is: 1 + -1 = 0
    +Explanation: The sum of the numbers before index 2 is: 1 + -1 = 0
     The sum of the numbers after index 2 is: 0
     
    @@ -45,18 +43,7 @@ The sum of the numbers after index 2 is: 0
     Input: nums = [2,5]
     Output: -1
    -Explanation:
    -There is no valid middleIndex.
    -
    - -

    Example 4:

    - -
    -Input: nums = [1]
    -Output: 0
    -Explantion:
    -The sum of the numbers before index 0 is: 0
    -The sum of the numbers after index 0 is: 0
    +Explanation: There is no valid middleIndex.
     

     

    diff --git a/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md b/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md index aa3940150..e614c8384 100644 --- a/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md +++ b/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md @@ -56,14 +56,6 @@ Thus, minDistance and maxDistance is 5 - 2 = 3. Note that the last node is not considered a local maxima because it does not have a next node. -

    Example 4:

    - -
    -Input: head = [2,3,3,2]
    -Output: [-1,-1]
    -Explanation: There are no critical points in [2,3,3,2].
    -
    -

     

    Constraints:

    diff --git a/problems/find-the-missing-ids/README.md b/problems/find-the-missing-ids/README.md index 493874513..ad3d152ac 100644 --- a/problems/find-the-missing-ids/README.md +++ b/problems/find-the-missing-ids/README.md @@ -15,3 +15,8 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Report Contiguous Dates](../report-contiguous-dates) (Hard) + 1. [Find the Start and End Number of Continuous Ranges](../find-the-start-and-end-number-of-continuous-ranges) (Medium) + 1. [Number of Transactions per Visit](../number-of-transactions-per-visit) (Hard) diff --git a/problems/find-the-most-competitive-subsequence/README.md b/problems/find-the-most-competitive-subsequence/README.md index 918cfd3ad..6f21e4840 100644 --- a/problems/find-the-most-competitive-subsequence/README.md +++ b/problems/find-the-most-competitive-subsequence/README.md @@ -43,15 +43,11 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] -### Similar Questions - 1. [Remove K Digits](../remove-k-digits) (Medium) - 1. [Smallest Subsequence of Distinct Characters](../smallest-subsequence-of-distinct-characters) (Medium) - ### Hints
    Hint 1 diff --git a/problems/find-the-smallest-divisor-given-a-threshold/README.md b/problems/find-the-smallest-divisor-given-a-threshold/README.md index ff3a0bece..45f02e814 100644 --- a/problems/find-the-smallest-divisor-given-a-threshold/README.md +++ b/problems/find-the-smallest-divisor-given-a-threshold/README.md @@ -15,7 +15,7 @@

    Each result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).

    -

    It is guaranteed that there will be an answer.

    +

    The test cases are generated so that there will be an answer.

     

    Example 1:

    @@ -34,20 +34,6 @@ If the divisor is 4 we can get a sum of 7 (1+1+2+3) and if the divisor is 5 the Output: 44 -

    Example 3:

    - -
    -Input: nums = [21212,10101,12121], threshold = 1000000
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: nums = [2,3,5,7,11], threshold = 11
    -Output: 3
    -
    -

     

    Constraints:

    diff --git a/problems/find-the-winner-of-an-array-game/README.md b/problems/find-the-winner-of-an-array-game/README.md index ab1c0c3a7..70bb38ceb 100644 --- a/problems/find-the-winner-of-an-array-game/README.md +++ b/problems/find-the-winner-of-an-array-game/README.md @@ -13,7 +13,7 @@

    Given an integer array arr of distinct integers and an integer k.

    -

    A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0 and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.

    +

    A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0, and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.

    Return the integer which will win the game.

    @@ -42,20 +42,6 @@ So we can see that 4 rounds will be played and 5 is the winner because it wins 2 Explanation: 3 will win the first 10 rounds consecutively. -

    Example 3:

    - -
    -Input: arr = [1,9,8,2,3,7,6,4,5], k = 7
    -Output: 9
    -
    - -

    Example 4:

    - -
    -Input: arr = [1,11,22,33,44,55,66,77,88,99], k = 1000000000
    -Output: 99
    -
    -

     

    Constraints:

    diff --git a/problems/find-the-winner-of-the-circular-game/README.md b/problems/find-the-winner-of-the-circular-game/README.md index 72592a8ab..f697c1c36 100644 --- a/problems/find-the-winner-of-the-circular-game/README.md +++ b/problems/find-the-winner-of-the-circular-game/README.md @@ -58,9 +58,10 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Queue](../../tag/queue/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md index 028421234..8f35b94cf 100644 --- a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md +++ b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subrectangle-queries "Subrectangle Queries") @@ -11,7 +11,7 @@ ## [1477. Find Two Non-overlapping Sub-arrays Each With Target Sum (Medium)](https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum "找两个和为目标值且不重叠的子数组") -

    Given an array of integers arr and an integer target.

    +

    You are given an array of integers arr and an integer target.

    You have to find two non-overlapping sub-arrays of arr each with a sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.

    @@ -42,22 +42,6 @@ Explanation: We have only one sub-array of sum = 6. -

    Example 4:

    - -
    -Input: arr = [5,5,4,4,5], target = 3
    -Output: -1
    -Explanation: We cannot find a sub-array of sum = 3.
    -
    - -

    Example 5:

    - -
    -Input: arr = [3,1,1,1,5,1,2,1], target = 3
    -Output: 3
    -Explanation: Note that sub-arrays [1,2] and [2,1] cannot be an answer because they overlap.
    -
    -

     

    Constraints:

    diff --git a/problems/find-valid-matrix-given-row-and-column-sums/README.md b/problems/find-valid-matrix-given-row-and-column-sums/README.md index 937b21680..1ca194f17 100644 --- a/problems/find-valid-matrix-given-row-and-column-sums/README.md +++ b/problems/find-valid-matrix-given-row-and-column-sums/README.md @@ -24,11 +24,11 @@ Input: rowSum = [3,8], colSum = [4,7] Output: [[3,0], [1,7]] -Explanation: -0th row: 3 + 0 = 3 == rowSum[0] -1st row: 1 + 7 = 8 == rowSum[1] -0th column: 3 + 1 = 4 == colSum[0] -1st column: 0 + 7 = 7 == colSum[1] +Explanation: +0th row: 3 + 0 = 3 == rowSum[0] +1st row: 1 + 7 = 8 == rowSum[1] +0th column: 3 + 1 = 4 == colSum[0] +1st column: 0 + 7 = 7 == colSum[1] The row and column sums match, and all matrix elements are non-negative. Another possible matrix is: [[1,2], [3,5]] @@ -43,29 +43,6 @@ Another possible matrix is: [[1,2], [2,0,8]] -

    Example 3:

    - -
    -Input: rowSum = [14,9], colSum = [6,9,8]
    -Output: [[0,9,5],
    -         [6,0,3]]
    -
    - -

    Example 4:

    - -
    -Input: rowSum = [1,0], colSum = [1]
    -Output: [[1],
    -         [0]]
    -
    - -

    Example 5:

    - -
    -Input: rowSum = [0], colSum = [0]
    -Output: [[0]]
    -
    -

     

    Constraints:

    diff --git a/problems/find-winner-on-a-tic-tac-toe-game/README.md b/problems/find-winner-on-a-tic-tac-toe-game/README.md index a9fb045d4..b92f461f3 100644 --- a/problems/find-winner-on-a-tic-tac-toe-game/README.md +++ b/problems/find-winner-on-a-tic-tac-toe-game/README.md @@ -51,14 +51,6 @@ Explanation: The game ends in a draw since there are no moves to make. -

    Example 4:

    - -
    -Input: moves = [[0,0],[1,1]]
    -Output: "Pending"
    -Explanation: The game has not finished yet.
    -
    -

     

    Constraints:

    diff --git a/problems/finding-3-digit-even-numbers/README.md b/problems/finding-3-digit-even-numbers/README.md new file mode 100644 index 000000000..b3b7cc928 --- /dev/null +++ b/problems/finding-3-digit-even-numbers/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../minimum-cost-to-reach-city-with-discounts "Minimum Cost to Reach City With Discounts") +                 +[Next >](../delete-the-middle-node-of-a-linked-list "Delete the Middle Node of a Linked List") + +## [2094. Finding 3-Digit Even Numbers (Easy)](https://leetcode.com/problems/finding-3-digit-even-numbers "找出 3 位偶数") + +

    You are given an integer array digits, where each element is a digit. The array may contain duplicates.

    + +

    You need to find all the unique integers that follow the given requirements:

    + +
      +
    • The integer consists of the concatenation of three elements from digits in any arbitrary order.
    • +
    • The integer does not have leading zeros.
    • +
    • The integer is even.
    • +
    + +

    For example, if the given digits were [1, 2, 3], integers 132 and 312 follow the requirements.

    + +

    Return a sorted array of the unique integers.

    + +

     

    +

    Example 1:

    + +
    +Input: digits = [2,1,3,0]
    +Output: [102,120,130,132,210,230,302,310,312,320]
    +Explanation: All the possible integers that follow the requirements are in the output array. 
    +Notice that there are no odd integers or integers with leading zeros.
    +
    + +

    Example 2:

    + +
    +Input: digits = [2,2,8,8,2]
    +Output: [222,228,282,288,822,828,882]
    +Explanation: The same digit can be used as many times as it appears in digits. 
    +In this example, the digit 8 is used twice each time in 288, 828, and 882. 
    +
    + +

    Example 3:

    + +
    +Input: digits = [3,7,5]
    +Output: []
    +Explanation: No even integers can be formed using the given digits.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= digits.length <= 100
    • +
    • 0 <= digits[i] <= 9
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +The range of possible answers includes all even numbers between 100 and 999 inclusive. Could you check each possible answer to see if it could be formed from the digits in the array? +
    diff --git a/problems/finding-mk-average/README.md b/problems/finding-mk-average/README.md index 17b35c582..8986cc95c 100644 --- a/problems/finding-mk-average/README.md +++ b/problems/finding-mk-average/README.md @@ -69,8 +69,13 @@ obj.calculateMKAverage(); // The last 3 elements are [5,5,5]. ### Related Topics [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + +### Similar Questions + 1. [Find Median from Data Stream](../find-median-from-data-stream) (Hard) + 1. [Kth Largest Element in a Stream](../kth-largest-element-in-a-stream) (Easy) + 1. [Sequentially Ordinal Rank Tracker](../sequentially-ordinal-rank-tracker) (Hard) ### Hints
    diff --git a/problems/finding-pairs-with-a-certain-sum/README.md b/problems/finding-pairs-with-a-certain-sum/README.md index db4adce8e..618963a92 100644 --- a/problems/finding-pairs-with-a-certain-sum/README.md +++ b/problems/finding-pairs-with-a-certain-sum/README.md @@ -62,9 +62,12 @@ findSumPairs.count(7); // return 11; pairs (2,1), (2,2), (2,4), (3,1), (3,2), ( ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + +### Similar Questions + 1. [Count Number of Pairs With Absolute Difference K](../count-number-of-pairs-with-absolute-difference-k) (Easy) ### Hints
    diff --git a/problems/first-and-last-call-on-the-same-day/README.md b/problems/first-and-last-call-on-the-same-day/README.md index b8f2de048..c8755953e 100644 --- a/problems/first-and-last-call-on-the-same-day/README.md +++ b/problems/first-and-last-call-on-the-same-day/README.md @@ -9,7 +9,7 @@                  [Next >](../count-nodes-equal-to-sum-of-descendants "Count Nodes Equal to Sum of Descendants") -## [1972. First and Last Call On the Same Day (Hard)](https://leetcode.com/problems/first-and-last-call-on-the-same-day "") +## [1972. First and Last Call On the Same Day (Hard)](https://leetcode.com/problems/first-and-last-call-on-the-same-day "同一天的第一个电话和最后一个电话") diff --git a/problems/first-unique-character-in-a-string/README.md b/problems/first-unique-character-in-a-string/README.md index 00f41ca4d..6935d8b35 100644 --- a/problems/first-unique-character-in-a-string/README.md +++ b/problems/first-unique-character-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lexicographical-numbers "Lexicographical Numbers") diff --git a/problems/fizz-buzz-multithreaded/README.md b/problems/fizz-buzz-multithreaded/README.md index 998449392..64187532e 100644 --- a/problems/fizz-buzz-multithreaded/README.md +++ b/problems/fizz-buzz-multithreaded/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tournament-winners "Tournament Winners") diff --git a/problems/flatten-binary-tree-to-linked-list/README.md b/problems/flatten-binary-tree-to-linked-list/README.md index 2fed5e2d1..3ec60780b 100644 --- a/problems/flatten-binary-tree-to-linked-list/README.md +++ b/problems/flatten-binary-tree-to-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-sum-ii "Path Sum II") diff --git a/problems/flip-game-ii/README.md b/problems/flip-game-ii/README.md index 1723aa64a..6814174ea 100644 --- a/problems/flip-game-ii/README.md +++ b/problems/flip-game-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flip-game "Flip Game") diff --git a/problems/flip-string-to-monotone-increasing/README.md b/problems/flip-string-to-monotone-increasing/README.md index 64b7a1358..1a4c257d1 100644 --- a/problems/flip-string-to-monotone-increasing/README.md +++ b/problems/flip-string-to-monotone-increasing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../long-pressed-name "Long Pressed Name") diff --git a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md index c79ccb267..939b93d2f 100644 --- a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md +++ b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md @@ -11,17 +11,15 @@ ## [1449. Form Largest Integer With Digits That Add up to Target (Hard)](https://leetcode.com/problems/form-largest-integer-with-digits-that-add-up-to-target "数位成本和为目标值的最大数字") -

    Given an array of integers cost and an integer target. Return the maximum integer you can paint under the following rules:

    +

    Given an array of integers cost and an integer target, return the maximum integer you can paint under the following rules:

      -
    • The cost of painting a digit (i+1) is given by cost[i] (0 indexed).
    • -
    • The total cost used must be equal to target.
    • -
    • Integer does not have digits 0.
    • +
    • The cost of painting a digit (i + 1) is given by cost[i] (0-indexed).
    • +
    • The total cost used must be equal to target.
    • +
    • The integer does not have 0 digits.
    -

    Since the answer may be too large, return it as string.

    - -

    If there is no way to paint any integer given the condition, return "0".

    +

    Since the answer may be very large, return it as a string. If there is no way to paint any integer given the condition, return "0".

     

    Example 1:

    @@ -29,7 +27,7 @@
     Input: cost = [4,3,2,5,6,7,2,5,5], target = 9
     Output: "7772"
    -Explanation:  The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost("7772") = 2*3+ 3*1 = 9. You could also paint "977", but "7772" is the largest number.
    +Explanation: The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost("7772") = 2*3+ 3*1 = 9. You could also paint "977", but "7772" is the largest number.
     Digit    cost
       1  ->   4
       2  ->   3
    @@ -55,14 +53,7 @@
     
     Input: cost = [2,4,6,2,4,6,4,4,4], target = 5
     Output: "0"
    -Explanation: It's not possible to paint any integer with total cost equal to target.
    -
    - -

    Example 4:

    - -
    -Input: cost = [6,10,15,40,40,40,40,40,40], target = 47
    -Output: "32211"
    +Explanation: It is impossible to paint any integer with total cost equal to target.
     

     

    @@ -70,8 +61,7 @@
    • cost.length == 9
    • -
    • 1 <= cost[i] <= 5000
    • -
    • 1 <= target <= 5000
    • +
    • 1 <= cost[i], target <= 5000
    ### Related Topics diff --git a/problems/four-divisors/README.md b/problems/four-divisors/README.md index c23fcc57b..0bdc98273 100644 --- a/problems/four-divisors/README.md +++ b/problems/four-divisors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../create-target-array-in-the-given-order "Create Target Array in the Given Order") diff --git a/problems/frog-position-after-t-seconds/README.md b/problems/frog-position-after-t-seconds/README.md index a47663936..1e6ecd7bf 100644 --- a/problems/frog-position-after-t-seconds/README.md +++ b/problems/frog-position-after-t-seconds/README.md @@ -15,22 +15,19 @@

    The edges of the undirected tree are given in the array edges, where edges[i] = [ai, bi] means that exists an edge connecting the vertices ai and bi.

    -

    Return the probability that after t seconds the frog is on the vertex target.

    +

    Return the probability that after t seconds the frog is on the vertex target. Answers within 10-5 of the actual answer will be accepted.

     

    Example 1:

    - -

    - +
     Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 2, target = 4
     Output: 0.16666666666666666 
    -Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666. 
    +Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666. 
     

    Example 2:

    - -

    +
     Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 1, target = 7
    @@ -38,13 +35,6 @@
     Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 = 0.3333333333333333 probability to the vertex 7 after second 1. 
     
    -

    Example 3:

    - -
    -Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 20, target = 6
    -Output: 0.16666666666666666
    -
    -

     

    Constraints:

    @@ -53,9 +43,8 @@
  • edges.length == n - 1
  • edges[i].length == 2
  • 1 <= ai, bi <= n
  • -
  • 1 <= t <= 50
  • -
  • 1 <= target <= n
  • -
  • Answers within 10-5 of the actual value will be accepted as correct.
  • +
  • 1 <= t <= 50
  • +
  • 1 <= target <= n
  • ### Related Topics diff --git a/problems/fruit-into-baskets/README.md b/problems/fruit-into-baskets/README.md index 5ddc874cb..e4961b828 100644 --- a/problems/fruit-into-baskets/README.md +++ b/problems/fruit-into-baskets/README.md @@ -50,14 +50,6 @@ If we had started at the first tree, we would only pick from trees [0,1]. If we had started at the first tree, we would only pick from trees [1,2].
    -

    Example 4:

    - -
    -Input: fruits = [3,3,3,1,2,1,1,2,3,3,4]
    -Output: 5
    -Explanation: We can pick from trees [1,2,1,1,2].
    -
    -

     

    Constraints:

    diff --git a/problems/game-play-analysis-i/README.md b/problems/game-play-analysis-i/README.md index eaa4b32f3..5fccd1c99 100644 --- a/problems/game-play-analysis-i/README.md +++ b/problems/game-play-analysis-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../inorder-successor-in-bst-ii "Inorder Successor in BST II") diff --git a/problems/get-the-maximum-score/README.md b/problems/get-the-maximum-score/README.md index 86d638303..26e258cc6 100644 --- a/problems/get-the-maximum-score/README.md +++ b/problems/get-the-maximum-score/README.md @@ -27,13 +27,11 @@

     

    Example 1:

    - -

    - +
     Input: nums1 = [2,4,5,8,10], nums2 = [4,6,8,9]
     Output: 30
    -Explanation: Valid paths:
    +Explanation: Valid paths:
     [2,4,5,8,10], [2,4,5,8,9], [2,4,6,8,9], [2,4,6,8,10],  (starting from nums1)
     [4,6,8,9], [4,5,8,10], [4,5,8,9], [4,6,8,10]    (starting from nums2)
     The maximum is obtained with the path in green [2,4,6,8,10].
    @@ -44,7 +42,7 @@ The maximum is obtained with the path in green [2,4,6,8,10].
     
     Input: nums1 = [1,3,5,7,9], nums2 = [3,5,100]
     Output: 109
    -Explanation: Maximum sum is obtained with the path [1,3,5,100].
    +Explanation: Maximum sum is obtained with the path [1,3,5,100].
     

    Example 3:

    @@ -52,17 +50,10 @@ The maximum is obtained with the path in green [2,4,6,8,10].
     Input: nums1 = [1,2,3,4,5], nums2 = [6,7,8,9,10]
     Output: 40
    -Explanation: There are no common elements between nums1 and nums2.
    +Explanation: There are no common elements between nums1 and nums2.
     Maximum sum is obtained with the path [6,7,8,9,10].
     
    -

    Example 4:

    - -
    -Input: nums1 = [1,4,5,8,9,11,19], nums2 = [2,3,4,11,12]
    -Output: 61
    -
    -

     

    Constraints:

    @@ -73,10 +64,10 @@ Maximum sum is obtained with the path [6,7,8,9,10]. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/get-the-second-most-recent-activity/README.md b/problems/get-the-second-most-recent-activity/README.md index 11682b2cc..60c83d6b0 100644 --- a/problems/get-the-second-most-recent-activity/README.md +++ b/problems/get-the-second-most-recent-activity/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-make-at-least-one-valid-path-in-a-grid "Minimum Cost to Make at Least One Valid Path in a Grid") diff --git a/problems/group-employees-of-the-same-salary/README.md b/problems/group-employees-of-the-same-salary/README.md index f221375de..0b2f7fc0a 100644 --- a/problems/group-employees-of-the-same-salary/README.md +++ b/problems/group-employees-of-the-same-salary/README.md @@ -9,7 +9,7 @@                  [Next >](../substrings-of-size-three-with-distinct-characters "Substrings of Size Three with Distinct Characters") -## [1875. Group Employees of the Same Salary (Medium)](https://leetcode.com/problems/group-employees-of-the-same-salary "") +## [1875. Group Employees of the Same Salary (Medium)](https://leetcode.com/problems/group-employees-of-the-same-salary "将工资相同的雇员分组") diff --git a/problems/group-sold-products-by-the-date/README.md b/problems/group-sold-products-by-the-date/README.md index f107e9cdc..6722eb2d8 100644 --- a/problems/group-sold-products-by-the-date/README.md +++ b/problems/group-sold-products-by-the-date/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-ancestor-of-a-tree-node "Kth Ancestor of a Tree Node") diff --git a/problems/groups-of-strings/README.md b/problems/groups-of-strings/README.md new file mode 100644 index 000000000..0cc7e7afb --- /dev/null +++ b/problems/groups-of-strings/README.md @@ -0,0 +1,96 @@ + + + + + + + +[< Previous](../find-substring-with-given-hash-value "Find Substring With Given Hash Value") +                 +[Next >](../amount-of-new-area-painted-each-day "Amount of New Area Painted Each Day") + +## [2157. Groups of Strings (Hard)](https://leetcode.com/problems/groups-of-strings "字符串分组") + +

    You are given a 0-indexed array of strings words. Each string consists of lowercase English letters only. No letter occurs more than once in any string of words.

    + +

    Two strings s1 and s2 are said to be connected if the set of letters of s2 can be obtained from the set of letters of s1 by any one of the following operations:

    + +
      +
    • Adding exactly one letter to the set of the letters of s1.
    • +
    • Deleting exactly one letter from the set of the letters of s1.
    • +
    • Replacing exactly one letter from the set of the letters of s1 with any letter, including itself.
    • +
    + +

    The array words can be divided into one or more non-intersecting groups. A string belongs to a group if any one of the following is true:

    + +
      +
    • It is connected to at least one other string of the group.
    • +
    • It is the only string present in the group.
    • +
    + +

    Note that the strings in words should be grouped in such a manner that a string belonging to a group cannot be connected to a string present in any other group. It can be proved that such an arrangement is always unique.

    + +

    Return an array ans of size 2 where:

    + +
      +
    • ans[0] is the maximum number of groups words can be divided into, and
    • +
    • ans[1] is the size of the largest group.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: words = ["a","b","ab","cde"]
    +Output: [2,3]
    +Explanation:
    +- words[0] can be used to obtain words[1] (by replacing 'a' with 'b'), and words[2] (by adding 'b'). So words[0] is connected to words[1] and words[2].
    +- words[1] can be used to obtain words[0] (by replacing 'b' with 'a'), and words[2] (by adding 'a'). So words[1] is connected to words[0] and words[2].
    +- words[2] can be used to obtain words[0] (by deleting 'b'), and words[1] (by deleting 'a'). So words[2] is connected to words[0] and words[1].
    +- words[3] is not connected to any string in words.
    +Thus, words can be divided into 2 groups ["a","b","ab"] and ["cde"]. The size of the largest group is 3.  
    +
    + +

    Example 2:

    + +
    +Input: words = ["a","ab","abc"]
    +Output: [1,3]
    +Explanation:
    +- words[0] is connected to words[1].
    +- words[1] is connected to words[0] and words[2].
    +- words[2] is connected to words[1].
    +Since all strings are connected to each other, they should be grouped together.
    +Thus, the size of the largest group is 3.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 2 * 104
    • +
    • 1 <= words[i].length <= 26
    • +
    • words[i] consists of lowercase English letters only.
    • +
    • No letter occurs more than once in words[i].
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Can we build a graph from words, where there exists an edge between nodes i and j if words[i] and words[j] are connected? +
    + +
    +Hint 2 +The problem now boils down to finding the total number of components and the size of the largest component in the graph. +
    + +
    +Hint 3 +How can we use bit masking to reduce the search space while adding edges to node i? +
    diff --git a/problems/guess-number-higher-or-lower/README.md b/problems/guess-number-higher-or-lower/README.md index c09647967..52aa4fcb3 100644 --- a/problems/guess-number-higher-or-lower/README.md +++ b/problems/guess-number-higher-or-lower/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-k-pairs-with-smallest-sums "Find K Pairs with Smallest Sums") @@ -17,30 +17,38 @@

    Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess.

    -

    You call a pre-defined API int guess(int num), which returns 3 possible results:

    +

    You call a pre-defined API int guess(int num), which returns three possible results:

      -
    • -1: The number I picked is lower than your guess (i.e. pick < num).
    • -
    • 1: The number I picked is higher than your guess (i.e. pick > num).
    • -
    • 0: The number I picked is equal to your guess (i.e. pick == num).
    • +
    • -1: Your guess is higher than the number I picked (i.e. num > pick).
    • +
    • 1: Your guess is lower than the number I picked (i.e. num < pick).
    • +
    • 0: your guess is equal to the number I picked (i.e. num == pick).

    Return the number that I picked.

     

    Example 1:

    -
    Input: n = 10, pick = 6
    +
    +
    +Input: n = 10, pick = 6
     Output: 6
    -

    Example 2:

    -
    Input: n = 1, pick = 1
    +
    + +

    Example 2:

    + +
    +Input: n = 1, pick = 1
     Output: 1
    -

    Example 3:

    -
    Input: n = 2, pick = 1
    +
    + +

    Example 3:

    + +
    +Input: n = 2, pick = 1
     Output: 1
    -

    Example 4:

    -
    Input: n = 2, pick = 2
    -Output: 2
     
    +

     

    Constraints:

    diff --git a/problems/guess-the-word/README.md b/problems/guess-the-word/README.md index 488ba5ca4..97fb5c1ad 100644 --- a/problems/guess-the-word/README.md +++ b/problems/guess-the-word/README.md @@ -59,5 +59,5 @@ We made 5 calls to master.guess and one of them was the secret, so we pass the t [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] - [[Interactive](../../tag/interactive/README.md)] [[Game Theory](../../tag/game-theory/README.md)] + [[Interactive](../../tag/interactive/README.md)] diff --git a/problems/hexspeak/README.md b/problems/hexspeak/README.md index 9813d663b..a1b971d22 100644 --- a/problems/hexspeak/README.md +++ b/problems/hexspeak/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-people-report-to-the-given-manager "All People Report to the Given Manager") diff --git a/problems/hopper-company-queries-i/README.md b/problems/hopper-company-queries-i/README.md index da53acdea..c436e61f3 100644 --- a/problems/hopper-company-queries-i/README.md +++ b/problems/hopper-company-queries-i/README.md @@ -15,8 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Trips and Users](../trips-and-users) (Hard) - 1. [Hopper Company Queries II](../hopper-company-queries-ii) (Hard) - 1. [Hopper Company Queries III](../hopper-company-queries-iii) (Hard) diff --git a/problems/hopper-company-queries-iii/README.md b/problems/hopper-company-queries-iii/README.md index 62a14af70..5424cf7fb 100644 --- a/problems/hopper-company-queries-iii/README.md +++ b/problems/hopper-company-queries-iii/README.md @@ -15,8 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Trips and Users](../trips-and-users) (Hard) - 1. [Hopper Company Queries I](../hopper-company-queries-i) (Hard) - 1. [Hopper Company Queries II](../hopper-company-queries-ii) (Hard) diff --git a/problems/house-robber-iii/README.md b/problems/house-robber-iii/README.md index 4f3e1613f..350409147 100644 --- a/problems/house-robber-iii/README.md +++ b/problems/house-robber-iii/README.md @@ -43,9 +43,9 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/house-robber/README.md b/problems/house-robber/README.md index 572ab037c..a37cd0a07 100644 --- a/problems/house-robber/README.md +++ b/problems/house-robber/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rising-temperature "Rising Temperature") diff --git a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md index 1418fd842..2b291471d 100644 --- a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md +++ b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-trusted-contacts-of-a-customer "Number of Trusted Contacts of a Customer") diff --git a/problems/html-entity-parser/README.md b/problems/html-entity-parser/README.md index 87d42149e..5201de90f 100644 --- a/problems/html-entity-parser/README.md +++ b/problems/html-entity-parser/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../queries-on-a-permutation-with-key "Queries on a Permutation With Key") @@ -16,17 +16,17 @@

    The special characters and their entities for HTML are:

      -
    • Quotation Mark: the entity is &quot; and symbol character is ".
    • -
    • Single Quote Mark: the entity is &apos; and symbol character is '.
    • -
    • Ampersand: the entity is &amp; and symbol character is &.
    • -
    • Greater Than Sign: the entity is &gt; and symbol character is >.
    • -
    • Less Than Sign: the entity is &lt; and symbol character is <.
    • -
    • Slash: the entity is &frasl; and symbol character is /.
    • +
    • Quotation Mark: the entity is &quot; and symbol character is ".
    • +
    • Single Quote Mark: the entity is &apos; and symbol character is '.
    • +
    • Ampersand: the entity is &amp; and symbol character is &.
    • +
    • Greater Than Sign: the entity is &gt; and symbol character is >.
    • +
    • Less Than Sign: the entity is &lt; and symbol character is <.
    • +
    • Slash: the entity is &frasl; and symbol character is /.

    Given the input text string to the HTML parser, you have to implement the entity parser.

    -

    Return the text after replacing the entities by the special characters.

    +

    Return the text after replacing the entities by the special characters.

     

    Example 1:

    @@ -44,33 +44,12 @@ Output: "and I quote: \"...\""
    -

    Example 3:

    - -
    -Input: text = "Stay home! Practice on Leetcode :)"
    -Output: "Stay home! Practice on Leetcode :)"
    -
    - -

    Example 4:

    - -
    -Input: text = "x &gt; y &amp;&amp; x &lt; y is always false"
    -Output: "x > y && x < y is always false"
    -
    - -

    Example 5:

    - -
    -Input: text = "leetcode.com&frasl;problemset&frasl;all"
    -Output: "leetcode.com/problemset/all"
    -
    -

     

    Constraints:

      -
    • 1 <= text.length <= 10^5
    • -
    • The string may contain any possible characters out of all the 256 ASCII characters.
    • +
    • 1 <= text.length <= 105
    • +
    • The string may contain any possible characters out of all the 256 ASCII characters.
    ### Related Topics diff --git a/problems/image-overlap/README.md b/problems/image-overlap/README.md index 692a184da..808a96906 100644 --- a/problems/image-overlap/README.md +++ b/problems/image-overlap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-distances-in-tree "Sum of Distances in Tree") diff --git a/problems/immediate-food-delivery-i/README.md b/problems/immediate-food-delivery-i/README.md index 857bf4d63..446d674e7 100644 --- a/problems/immediate-food-delivery-i/README.md +++ b/problems/immediate-food-delivery-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../dinner-plate-stacks "Dinner Plate Stacks") diff --git a/problems/immediate-food-delivery-ii/README.md b/problems/immediate-food-delivery-ii/README.md index 65fcea5cf..69aa37ffd 100644 --- a/problems/immediate-food-delivery-ii/README.md +++ b/problems/immediate-food-delivery-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../immediate-food-delivery-i "Immediate Food Delivery I") diff --git a/problems/implement-rand10-using-rand7/README.md b/problems/implement-rand10-using-rand7/README.md index 5ae0a32f1..9a1d23cdc 100644 --- a/problems/implement-rand10-using-rand7/README.md +++ b/problems/implement-rand10-using-rand7/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convex-polygon "Convex Polygon") diff --git a/problems/implement-strstr/README.md b/problems/implement-strstr/README.md index eaaae77cc..a744c0b83 100644 --- a/problems/implement-strstr/README.md +++ b/problems/implement-strstr/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-element "Remove Element") diff --git a/problems/increasing-decreasing-string/README.md b/problems/increasing-decreasing-string/README.md index a64f532bd..8a62e65a2 100644 --- a/problems/increasing-decreasing-string/README.md +++ b/problems/increasing-decreasing-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../get-the-second-most-recent-activity "Get the Second Most Recent Activity") @@ -11,21 +11,21 @@ ## [1370. Increasing Decreasing String (Easy)](https://leetcode.com/problems/increasing-decreasing-string "上升下降字符串") -

    Given a string s. You should re-order the string using the following algorithm:

    +

    You are given a string s. Reorder the string using the following algorithm:

    1. Pick the smallest character from s and append it to the result.
    2. Pick the smallest character from s which is greater than the last appended character to the result and append it.
    3. Repeat step 2 until you cannot pick more characters.
    4. -
    5. Pick the largest character from s and append it to the result.
    6. -
    7. Pick the largest character from s which is smaller than the last appended character to the result and append it.
    8. +
    9. Pick the largest character from s and append it to the result.
    10. +
    11. Pick the largest character from s which is smaller than the last appended character to the result and append it.
    12. Repeat step 5 until you cannot pick more characters.
    13. Repeat the steps from 1 to 6 until you pick all characters from s.

    In each step, If the smallest or the largest character appears more than once you can choose any occurrence and append it to the result.

    -

    Return the result string after sorting s with this algorithm.

    +

    Return the result string after sorting s with this algorithm.

     

    Example 1:

    @@ -48,33 +48,12 @@ After steps 4, 5 and 6 of the second iteration, result = "abccbaabccba" Explanation: The word "rat" becomes "art" after re-ordering it with the mentioned algorithm.
    -

    Example 3:

    - -
    -Input: s = "leetcode"
    -Output: "cdelotee"
    -
    - -

    Example 4:

    - -
    -Input: s = "ggggggg"
    -Output: "ggggggg"
    -
    - -

    Example 5:

    - -
    -Input: s = "spo"
    -Output: "ops"
    -
    -

     

    Constraints:

    • 1 <= s.length <= 500
    • -
    • s contains only lower-case English letters.
    • +
    • s consists of only lowercase English letters.
    ### Related Topics diff --git a/problems/integer-replacement/README.md b/problems/integer-replacement/README.md index ca7535ef4..6e163430d 100644 --- a/problems/integer-replacement/README.md +++ b/problems/integer-replacement/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rotate-function "Rotate Function") diff --git a/problems/integer-to-english-words/README.md b/problems/integer-to-english-words/README.md index a79d587c3..4bc0037c2 100644 --- a/problems/integer-to-english-words/README.md +++ b/problems/integer-to-english-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-binary-search-tree-value-ii "Closest Binary Search Tree Value II") @@ -15,18 +15,26 @@

     

    Example 1:

    -
    Input: num = 123
    -Output: "One Hundred Twenty Three"
    -

    Example 2:

    -
    Input: num = 12345
    -Output: "Twelve Thousand Three Hundred Forty Five"
    -

    Example 3:

    -
    Input: num = 1234567
    -Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"
    -

    Example 4:

    -
    Input: num = 1234567891
    -Output: "One Billion Two Hundred Thirty Four Million Five Hundred Sixty Seven Thousand Eight Hundred Ninety One"
    +
    +
    +Input: num = 123
    +Output: "One Hundred Twenty Three"
    +
    + +

    Example 2:

    + +
    +Input: num = 12345
    +Output: "Twelve Thousand Three Hundred Forty Five"
     
    + +

    Example 3:

    + +
    +Input: num = 1234567
    +Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"
    +
    +

     

    Constraints:

    diff --git a/problems/intervals-between-identical-elements/README.md b/problems/intervals-between-identical-elements/README.md new file mode 100644 index 000000000..8b689aeac --- /dev/null +++ b/problems/intervals-between-identical-elements/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../execution-of-all-suffix-instructions-staying-in-a-grid "Execution of All Suffix Instructions Staying in a Grid") +                 +[Next >](../recover-the-original-array "Recover the Original Array") + +## [2121. Intervals Between Identical Elements (Medium)](https://leetcode.com/problems/intervals-between-identical-elements "相同元素的间隔之和") + +

    You are given a 0-indexed array of n integers arr.

    + +

    The interval between two elements in arr is defined as the absolute difference between their indices. More formally, the interval between arr[i] and arr[j] is |i - j|.

    + +

    Return an array intervals of length n where intervals[i] is the sum of intervals between arr[i] and each element in arr with the same value as arr[i].

    + +

    Note: |x| is the absolute value of x.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [2,1,3,1,2,3,3]
    +Output: [4,2,7,2,4,4,5]
    +Explanation:
    +- Index 0: Another 2 is found at index 4. |0 - 4| = 4
    +- Index 1: Another 1 is found at index 3. |1 - 3| = 2
    +- Index 2: Two more 3s are found at indices 5 and 6. |2 - 5| + |2 - 6| = 7
    +- Index 3: Another 1 is found at index 1. |3 - 1| = 2
    +- Index 4: Another 2 is found at index 0. |4 - 0| = 4
    +- Index 5: Two more 3s are found at indices 2 and 6. |5 - 2| + |5 - 6| = 4
    +- Index 6: Two more 3s are found at indices 2 and 5. |6 - 2| + |6 - 5| = 5
    +
    + +

    Example 2:

    + +
    +Input: arr = [10,5,10,10]
    +Output: [5,0,3,4]
    +Explanation:
    +- Index 0: Two more 10s are found at indices 2 and 3. |0 - 2| + |0 - 3| = 5
    +- Index 1: There is only one 5 in the array, so its sum of intervals to identical elements is 0.
    +- Index 2: Two more 10s are found at indices 0 and 3. |2 - 0| + |2 - 3| = 3
    +- Index 3: Two more 10s are found at indices 0 and 2. |3 - 0| + |3 - 2| = 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == arr.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= arr[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +For each unique value found in the array, store a sorted list of indices of elements that have this value in the array. +
    + +
    +Hint 2 +One way of doing this is to use a HashMap that maps the values to their list of indices. Update this mapping as you iterate through the array. +
    + +
    +Hint 3 +Process each list of indices separately and get the sum of intervals for the elements of that value by utilizing prefix sums. +
    + +
    +Hint 4 +For each element, keep track of the sum of indices of the identical elements that have come before and that will come after respectively. Use this to calculate the sum of intervals for that element to the rest of the elements with identical values. +
    diff --git a/problems/is-graph-bipartite/README.md b/problems/is-graph-bipartite/README.md index dd7928a28..fa8efd94f 100644 --- a/problems/is-graph-bipartite/README.md +++ b/problems/is-graph-bipartite/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../letter-case-permutation "Letter Case Permutation") diff --git a/problems/jump-game-iii/README.md b/problems/jump-game-iii/README.md index a8063e365..876cb75b2 100644 --- a/problems/jump-game-iii/README.md +++ b/problems/jump-game-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-elements-in-two-binary-search-trees "All Elements in Two Binary Search Trees") diff --git a/problems/jump-game-v/README.md b/problems/jump-game-v/README.md index ed8f8ea0c..5c5e3730c 100644 --- a/problems/jump-game-v/README.md +++ b/problems/jump-game-v/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-of-splitted-binary-tree "Maximum Product of Splitted Binary Tree") @@ -51,26 +51,12 @@ Similarly You cannot jump from index 3 to index 2 or index 1. Explanation: Start at index 0. You can visit all the indicies.
    -

    Example 4:

    - -
    -Input: arr = [7,1,7,1,7,1], d = 2
    -Output: 2
    -
    - -

    Example 5:

    - -
    -Input: arr = [66], d = 1
    -Output: 1
    -
    -

     

    Constraints:

    • 1 <= arr.length <= 1000
    • -
    • 1 <= arr[i] <= 10^5
    • +
    • 1 <= arr[i] <= 105
    • 1 <= d <= arr.length
    @@ -79,9 +65,6 @@ Similarly You cannot jump from index 3 to index 2 or index 1. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Jump Game VII](../jump-game-vii) (Medium) - ### Hints
    Hint 1 diff --git a/problems/jump-game-vi/README.md b/problems/jump-game-vi/README.md index e18bac1d8..80cd600af 100644 --- a/problems/jump-game-vi/README.md +++ b/problems/jump-game-vi/README.md @@ -52,16 +52,12 @@ ### Related Topics + [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Monotonic Queue](../../tag/monotonic-queue/README.md)] - -### Similar Questions - 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) - 1. [Jump Game VII](../jump-game-vii) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/k-highest-ranked-items-within-a-price-range/README.md b/problems/k-highest-ranked-items-within-a-price-range/README.md new file mode 100644 index 000000000..85a214e2c --- /dev/null +++ b/problems/k-highest-ranked-items-within-a-price-range/README.md @@ -0,0 +1,121 @@ + + + + + + + +[< Previous](../count-the-hidden-sequences "Count the Hidden Sequences") +                 +[Next >](../number-of-ways-to-divide-a-long-corridor "Number of Ways to Divide a Long Corridor") + +## [2146. K Highest Ranked Items Within a Price Range (Medium)](https://leetcode.com/problems/k-highest-ranked-items-within-a-price-range "价格范围内最高排名的 K 样物品") + +

    You are given a 0-indexed 2D integer array grid of size m x n that represents a map of the items in a shop. The integers in the grid represent the following:

    + +
      +
    • 0 represents a wall that you cannot pass through.
    • +
    • 1 represents an empty cell that you can freely move to and from.
    • +
    • All other positive integers represent the price of an item in that cell. You may also freely move to and from these item cells.
    • +
    + +

    It takes 1 step to travel between adjacent grid cells.

    + +

    You are also given integer arrays pricing and start where pricing = [low, high] and start = [row, col] indicates that you start at the position (row, col) and are interested only in items with a price in the range of [low, high] (inclusive). You are further given an integer k.

    + +

    You are interested in the positions of the k highest-ranked items whose prices are within the given price range. The rank is determined by the first of these criteria that is different:

    + +
      +
    1. Distance, defined as the length of the shortest path from the start (shorter distance has a higher rank).
    2. +
    3. Price (lower price has a higher rank, but it must be in the price range).
    4. +
    5. The row number (smaller row number has a higher rank).
    6. +
    7. The column number (smaller column number has a higher rank).
    8. +
    + +

    Return the k highest-ranked items within the price range sorted by their rank (highest to lowest). If there are fewer than k reachable items within the price range, return all of them.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[1,2,0,1],[1,3,0,1],[0,2,5,1]], pricing = [2,5], start = [0,0], k = 3
    +Output: [[0,1],[1,1],[2,1]]
    +Explanation: You start at (0,0).
    +With a price range of [2,5], we can take items from (0,1), (1,1), (2,1) and (2,2).
    +The ranks of these items are:
    +- (0,1) with distance 1
    +- (1,1) with distance 2
    +- (2,1) with distance 3
    +- (2,2) with distance 4
    +Thus, the 3 highest ranked items in the price range are (0,1), (1,1), and (2,1).
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,2,0,1],[1,3,3,1],[0,2,5,1]], pricing = [2,3], start = [2,3], k = 2
    +Output: [[2,1],[1,2]]
    +Explanation: You start at (2,3).
    +With a price range of [2,3], we can take items from (0,1), (1,1), (1,2) and (2,1).
    +The ranks of these items are:
    +- (2,1) with distance 2, price 2
    +- (1,2) with distance 2, price 3
    +- (1,1) with distance 3
    +- (0,1) with distance 4
    +Thus, the 2 highest ranked items in the price range are (2,1) and (1,2).
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1,1,1],[0,0,1],[2,3,4]], pricing = [2,3], start = [0,0], k = 3
    +Output: [[2,1],[2,0]]
    +Explanation: You start at (0,0).
    +With a price range of [2,3], we can take items from (2,0) and (2,1). 
    +The ranks of these items are: 
    +- (2,1) with distance 5
    +- (2,0) with distance 6
    +Thus, the 2 highest ranked items in the price range are (2,1) and (2,0). 
    +Note that k = 3 but there are only 2 reachable items within the price range.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 105
    • +
    • 1 <= m * n <= 105
    • +
    • 0 <= grid[i][j] <= 105
    • +
    • pricing.length == 2
    • +
    • 2 <= low <= high <= 105
    • +
    • start.length == 2
    • +
    • 0 <= row <= m - 1
    • +
    • 0 <= col <= n - 1
    • +
    • grid[row][col] > 0
    • +
    • 1 <= k <= m * n
    • +
    + +### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +Could you determine the rank of every item efficiently? +
    + +
    +Hint 2 +We can perform a breadth-first search from the starting position and know the length of the shortest path from start to every item. +
    + +
    +Hint 3 +Sort all the items according to the conditions listed in the problem, and return the first k (or all if less than k exist) items as the answer. +
    diff --git a/problems/k-radius-subarray-averages/README.md b/problems/k-radius-subarray-averages/README.md new file mode 100644 index 000000000..f062f0a12 --- /dev/null +++ b/problems/k-radius-subarray-averages/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../find-target-indices-after-sorting-array "Find Target Indices After Sorting Array") +                 +[Next >](../removing-minimum-and-maximum-from-array "Removing Minimum and Maximum From Array") + +## [2090. K Radius Subarray Averages (Medium)](https://leetcode.com/problems/k-radius-subarray-averages "半径为 k 的子数组平均值") + +

    You are given a 0-indexed array nums of n integers, and an integer k.

    + +

    The k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elements in nums between the indices i - k and i + k (inclusive). If there are less than k elements before or after the index i, then the k-radius average is -1.

    + +

    Build and return an array avgs of length n where avgs[i] is the k-radius average for the subarray centered at index i.

    + +

    The average of x elements is the sum of the x elements divided by x, using integer division. The integer division truncates toward zero, which means losing its fractional part.

    + +
      +
    • For example, the average of four elements 2, 3, 1, and 5 is (2 + 3 + 1 + 5) / 4 = 11 / 4 = 2.75, which truncates to 2.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: nums = [7,4,3,9,1,8,5,2,6], k = 3
    +Output: [-1,-1,-1,5,4,4,-1,-1,-1]
    +Explanation:
    +- avg[0], avg[1], and avg[2] are -1 because there are less than k elements before each index.
    +- The sum of the subarray centered at index 3 with radius 3 is: 7 + 4 + 3 + 9 + 1 + 8 + 5 = 37.
    +  Using integer division, avg[3] = 37 / 7 = 5.
    +- For the subarray centered at index 4, avg[4] = (4 + 3 + 9 + 1 + 8 + 5 + 2) / 7 = 4.
    +- For the subarray centered at index 5, avg[5] = (3 + 9 + 1 + 8 + 5 + 2 + 6) / 7 = 4.
    +- avg[6], avg[7], and avg[8] are -1 because there are less than k elements after each index.
    +
    + +

    Example 2:

    + +
    +Input: nums = [100000], k = 0
    +Output: [100000]
    +Explanation:
    +- The sum of the subarray centered at index 0 with radius 0 is: 100000.
    +  avg[0] = 100000 / 1 = 100000.
    +
    + +

    Example 3:

    + +
    +Input: nums = [8], k = 100000
    +Output: [-1]
    +Explanation: 
    +- avg[0] is -1 because there are less than k elements before and after index 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 105
    • +
    • 0 <= nums[i], k <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +To calculate the average of a subarray, you need the sum and the K. K is already given. How could you quickly calculate the sum of a subarray? +
    + +
    +Hint 2 +Use the Prefix Sums method to calculate the subarray sums. +
    + +
    +Hint 3 +It is possible that the sum of all the elements does not fit in a 32-bit integer type. Be sure to use a 64-bit integer type for the prefix sum array. +
    diff --git a/problems/k-th-smallest-in-lexicographical-order/README.md b/problems/k-th-smallest-in-lexicographical-order/README.md index 00ede0949..b5ef1c26b 100644 --- a/problems/k-th-smallest-in-lexicographical-order/README.md +++ b/problems/k-th-smallest-in-lexicographical-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ternary-expression-parser "Ternary Expression Parser") diff --git a/problems/keep-multiplying-found-values-by-two/README.md b/problems/keep-multiplying-found-values-by-two/README.md new file mode 100644 index 000000000..bb4be6ff6 --- /dev/null +++ b/problems/keep-multiplying-found-values-by-two/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../the-number-of-passengers-in-each-bus-ii "The Number of Passengers in Each Bus II") +                 +[Next >](../all-divisions-with-the-highest-score-of-a-binary-array "All Divisions With the Highest Score of a Binary Array") + +## [2154. Keep Multiplying Found Values by Two (Easy)](https://leetcode.com/problems/keep-multiplying-found-values-by-two "将找到的值乘以 2") + +

    You are given an array of integers nums. You are also given an integer original which is the first number that needs to be searched for in nums.

    + +

    You then do the following steps:

    + +
      +
    1. If original is found in nums, multiply it by two (i.e., set original = 2 * original).
    2. +
    3. Otherwise, stop the process.
    4. +
    5. Repeat this process with the new number as long as you keep finding the number.
    6. +
    + +

    Return the final value of original.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [5,3,6,1,12], original = 3
    +Output: 24
    +Explanation: 
    +- 3 is found in nums. 3 is multiplied by 2 to obtain 6.
    +- 6 is found in nums. 6 is multiplied by 2 to obtain 12.
    +- 12 is found in nums. 12 is multiplied by 2 to obtain 24.
    +- 24 is not found in nums. Thus, 24 is returned.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,7,9], original = 4
    +Output: 4
    +Explanation:
    +- 4 is not found in nums. Thus, 4 is returned.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 1 <= nums[i], original <= 1000
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Repeatedly iterate through the array and check if the current value of original is in the array. +
    + +
    +Hint 2 +If original is not found, stop and return its current value. +
    + +
    +Hint 3 +Otherwise, multiply original by 2 and repeat the process. +
    + +
    +Hint 4 +Use set data structure to check the existence faster. +
    diff --git a/problems/kill-process/README.md b/problems/kill-process/README.md index 7e5c758ca..bd317f457 100644 --- a/problems/kill-process/README.md +++ b/problems/kill-process/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-unsorted-continuous-subarray "Shortest Unsorted Continuous Subarray") diff --git a/problems/koko-eating-bananas/README.md b/problems/koko-eating-bananas/README.md index 89ee52e14..1a72a6186 100644 --- a/problems/koko-eating-bananas/README.md +++ b/problems/koko-eating-bananas/README.md @@ -56,3 +56,4 @@ ### Similar Questions 1. [Minimize Max Distance to Gas Station](../minimize-max-distance-to-gas-station) (Hard) + 1. [Minimized Maximum of Products Distributed to Any Store](../minimized-maximum-of-products-distributed-to-any-store) (Medium) diff --git a/problems/kth-largest-element-in-a-stream/README.md b/problems/kth-largest-element-in-a-stream/README.md index 100e1cf78..5c9061b41 100644 --- a/problems/kth-largest-element-in-a-stream/README.md +++ b/problems/kth-largest-element-in-a-stream/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../search-in-a-sorted-array-of-unknown-size "Search in a Sorted Array of Unknown Size") diff --git a/problems/largest-1-bordered-square/README.md b/problems/largest-1-bordered-square/README.md index 35359c6e7..b2e11e036 100644 --- a/problems/largest-1-bordered-square/README.md +++ b/problems/largest-1-bordered-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../alphabet-board-path "Alphabet Board Path") diff --git a/problems/largest-magic-square/README.md b/problems/largest-magic-square/README.md index d0553679e..c13ed708f 100644 --- a/problems/largest-magic-square/README.md +++ b/problems/largest-magic-square/README.md @@ -50,9 +50,6 @@ Every row sum, column sum, and diagonal sum of this magic square is equal to 12. [[Matrix](../../tag/matrix/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] -### Similar Questions - 1. [Magic Squares In Grid](../magic-squares-in-grid) (Medium) - ### Hints
    Hint 1 diff --git a/problems/largest-multiple-of-three/README.md b/problems/largest-multiple-of-three/README.md index 3995859b7..91ce76469 100644 --- a/problems/largest-multiple-of-three/README.md +++ b/problems/largest-multiple-of-three/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-divisors "Closest Divisors") @@ -37,13 +37,6 @@ Output: "" -

    Example 4:

    - -
    -Input: digits = [0,0,0,0,0,0]
    -Output: "0"
    -
    -

     

    Constraints:

    @@ -53,9 +46,9 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/largest-number/README.md b/problems/largest-number/README.md index de24d869a..308b5ad2c 100644 --- a/problems/largest-number/README.md +++ b/problems/largest-number/README.md @@ -11,9 +11,9 @@ ## [179. Largest Number (Medium)](https://leetcode.com/problems/largest-number "最大数") -

    Given a list of non-negative integers nums, arrange them such that they form the largest number.

    +

    Given a list of non-negative integers nums, arrange them such that they form the largest number and return it.

    -

    Note: The result may be very large, so you need to return a string instead of an integer.

    +

    Since the result may be very large, so you need to return a string instead of an integer.

     

    Example 1:

    @@ -30,20 +30,6 @@ Output: "9534330" -

    Example 3:

    - -
    -Input: nums = [1]
    -Output: "1"
    -
    - -

    Example 4:

    - -
    -Input: nums = [10]
    -Output: "10"
    -
    -

     

    Constraints:

    diff --git a/problems/largest-odd-number-in-string/README.md b/problems/largest-odd-number-in-string/README.md index 71116c391..433ce9589 100644 --- a/problems/largest-odd-number-in-string/README.md +++ b/problems/largest-odd-number-in-string/README.md @@ -49,9 +49,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/largest-perimeter-triangle/README.md b/problems/largest-perimeter-triangle/README.md index 924d7001a..0bc3e6422 100644 --- a/problems/largest-perimeter-triangle/README.md +++ b/problems/largest-perimeter-triangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../odd-even-jump "Odd Even Jump") @@ -15,18 +15,19 @@

     

    Example 1:

    -
    Input: nums = [2,1,2]
    +
    +
    +Input: nums = [2,1,2]
     Output: 5
    -

    Example 2:

    -
    Input: nums = [1,2,1]
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,1]
     Output: 0
    -

    Example 3:

    -
    Input: nums = [3,2,3,4]
    -Output: 10
    -

    Example 4:

    -
    Input: nums = [3,6,2,3]
    -Output: 8
     
    +

     

    Constraints:

    diff --git a/problems/largest-subarray-length-k/README.md b/problems/largest-subarray-length-k/README.md index f4590c82e..29371e2c9 100644 --- a/problems/largest-subarray-length-k/README.md +++ b/problems/largest-subarray-length-k/README.md @@ -14,8 +14,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/largest-submatrix-with-rearrangements/README.md b/problems/largest-submatrix-with-rearrangements/README.md index 6c614e375..fd5ac277b 100644 --- a/problems/largest-submatrix-with-rearrangements/README.md +++ b/problems/largest-submatrix-with-rearrangements/README.md @@ -17,9 +17,7 @@

     

    Example 1:

    - -

    - +
     Input: matrix = [[0,0,1],[1,1,1],[1,0,1]]
     Output: 4
    @@ -28,9 +26,7 @@ The largest submatrix of 1s, in bold, has an area of 4.
     

    Example 2:

    - -

    - +
     Input: matrix = [[1,0,1,0,1]]
     Output: 3
    @@ -43,14 +39,8 @@ The largest submatrix of 1s, in bold, has an area of 3.
     
     Input: matrix = [[1,1,0],[1,0,1]]
     Output: 2
    -Explanation: Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2.
    - -

    Example 4:

    - -
    -Input: matrix = [[0,0],[0,0]]
    -Output: 0
    -Explanation: As there are no 1s, no submatrix of 1s can be formed and the area is 0.
    +Explanation: Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2. +

     

    Constraints:

    @@ -59,7 +49,7 @@ The largest submatrix of 1s, in bold, has an area of 3.
  • m == matrix.length
  • n == matrix[i].length
  • 1 <= m * n <= 105
  • -
  • matrix[i][j] is 0 or 1.
  • +
  • matrix[i][j] is either 0 or 1.
  • ### Related Topics diff --git a/problems/largest-substring-between-two-equal-characters/README.md b/problems/largest-substring-between-two-equal-characters/README.md index c707c3506..46a160a10 100644 --- a/problems/largest-substring-between-two-equal-characters/README.md +++ b/problems/largest-substring-between-two-equal-characters/README.md @@ -39,14 +39,6 @@ Explanation: There are no characters that appear twice in s.
    -

    Example 4:

    - -
    -Input: s = "cabbac"
    -Output: 4
    -Explanation: The optimal substring here is "abba". Other non-optimal substrings include "bb" and "".
    -
    -

     

    Constraints:

    diff --git a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md index 2cd2780b0..4c259e38a 100644 --- a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md +++ b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md @@ -11,13 +11,13 @@ ## [1503. Last Moment Before All Ants Fall Out of a Plank (Medium)](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") -

    We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with speed 1 unit per second. Some of the ants move to the left, the other move to the right.

    +

    We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with a speed of 1 unit per second. Some of the ants move to the left, the other move to the right.

    -

    When two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions doesn't take any additional time.

    +

    When two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions does not take any additional time.

    -

    When an ant reaches one end of the plank at a time t, it falls out of the plank imediately.

    +

    When an ant reaches one end of the plank at a time t, it falls out of the plank immediately.

    -

    Given an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right. Return the moment when the last ant(s) fall out of the plank.

    +

    Given an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right, return the moment when the last ant(s) fall out of the plank.

     

    Example 1:

    @@ -30,7 +30,7 @@ -The ant at index 1 is named B and going to the right. -The ant at index 3 is named C and going to the left. -The ant at index 4 is named D and going to the left. -Note that the last moment when an ant was on the plank is t = 4 second, after that it falls imediately out of the plank. (i.e. We can say that at t = 4.0000000001, there is no ants on the plank). +The last moment when an ant was on the plank is t = 4 seconds. After that, it falls immediately out of the plank. (i.e., We can say that at t = 4.0000000001, there are no ants on the plank).

    Example 2:

    @@ -49,26 +49,11 @@ Note that the last moment when an ant was on the plank is t = 4 second, after th Explanation: All ants are going to the left, the ant at index 7 needs 7 seconds to fall. -

    Example 4:

    - -
    -Input: n = 9, left = [5], right = [4]
    -Output: 5
    -Explanation: At t = 1 second, both ants will be at the same intial position but with different direction.
    -
    - -

    Example 5:

    - -
    -Input: n = 6, left = [6], right = [0]
    -Output: 6
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^4
    • +
    • 1 <= n <= 104
    • 0 <= left.length <= n + 1
    • 0 <= left[i] <= n
    • 0 <= right.length <= n + 1
    • @@ -78,8 +63,8 @@ Note that the last moment when an ant was on the plank is t = 4 second, after th
    ### Related Topics - [[Array](../../tag/array/README.md)] [[Brainteaser](../../tag/brainteaser/README.md)] + [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/least-number-of-unique-integers-after-k-removals/README.md b/problems/least-number-of-unique-integers-after-k-removals/README.md index e31706f4f..07b4b71a6 100644 --- a/problems/least-number-of-unique-integers-after-k-removals/README.md +++ b/problems/least-number-of-unique-integers-after-k-removals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../running-sum-of-1d-array "Running Sum of 1d Array") diff --git a/problems/leetcodify-friends-recommendations/README.md b/problems/leetcodify-friends-recommendations/README.md index cb786fb0e..dcc682953 100644 --- a/problems/leetcodify-friends-recommendations/README.md +++ b/problems/leetcodify-friends-recommendations/README.md @@ -9,7 +9,7 @@                  [Next >](../kth-smallest-subarray-sum "Kth Smallest Subarray Sum") -## [1917. Leetcodify Friends Recommendations (Hard)](https://leetcode.com/problems/leetcodify-friends-recommendations "") +## [1917. Leetcodify Friends Recommendations (Hard)](https://leetcode.com/problems/leetcodify-friends-recommendations "Leetcodify 好友推荐") diff --git a/problems/leetcodify-similar-friends/README.md b/problems/leetcodify-similar-friends/README.md index f7168514e..3d20773a3 100644 --- a/problems/leetcodify-similar-friends/README.md +++ b/problems/leetcodify-similar-friends/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Leetcodify Friends Recommendations](../leetcodify-friends-recommendations) (Hard) diff --git a/problems/leftmost-column-with-at-least-a-one/README.md b/problems/leftmost-column-with-at-least-a-one/README.md index 52434c5cc..da3d04af4 100644 --- a/problems/leftmost-column-with-at-least-a-one/README.md +++ b/problems/leftmost-column-with-at-least-a-one/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../perform-string-shifts "Perform String Shifts") @@ -16,8 +16,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Interactive](../../tag/interactive/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Hints
    diff --git a/problems/letter-case-permutation/README.md b/problems/letter-case-permutation/README.md index 1599aa88b..975c5da62 100644 --- a/problems/letter-case-permutation/README.md +++ b/problems/letter-case-permutation/README.md @@ -11,9 +11,9 @@ ## [784. Letter Case Permutation (Medium)](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列") -

    Given a string s, we can transform every letter individually to be lowercase or uppercase to create another string.

    +

    Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string.

    -

    Return a list of all possible strings we could create. You can return the output in any order.

    +

    Return a list of all possible strings we could create. Return the output in any order.

     

    Example 1:

    @@ -30,32 +30,18 @@ Output: ["3z4","3Z4"] -

    Example 3:

    - -
    -Input: s = "12345"
    -Output: ["12345"]
    -
    - -

    Example 4:

    - -
    -Input: s = "0"
    -Output: ["0"]
    -
    -

     

    Constraints:

      -
    • s will be a string with length between 1 and 12.
    • -
    • s will consist only of letters or digits.
    • +
    • 1 <= s.length <= 12
    • +
    • s consists of lowercase English letters, uppercase English letters, and digits.
    ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Subsets](../subsets) (Medium) diff --git a/problems/lexicographically-smallest-string-after-applying-operations/README.md b/problems/lexicographically-smallest-string-after-applying-operations/README.md index d0c943cb6..09ea81db8 100644 --- a/problems/lexicographically-smallest-string-after-applying-operations/README.md +++ b/problems/lexicographically-smallest-string-after-applying-operations/README.md @@ -30,15 +30,15 @@
     Input: s = "5525", a = 9, b = 2
     Output: "2050"
    -Explanation: We can apply the following operations:
    +Explanation: We can apply the following operations:
     Start:  "5525"
     Rotate: "2555"
     Add:    "2454"
     Add:    "2353"
     Rotate: "5323"
     Add:    "5222"
    -​​​​​​​Add:    "5121"
    -​​​​​​​Rotate: "2151"
    +Add:    "5121"
    +Rotate: "2151"
     ​​​​​​​Add:    "2050"​​​​​​​​​​​​
     There is no way to obtain a string that is lexicographically smaller then "2050".
     
    @@ -48,7 +48,7 @@ There is no way to obtain a string that is lexicographically smaller then "
     Input: s = "74", a = 5, b = 1
     Output: "24"
    -Explanation: We can apply the following operations:
    +Explanation: We can apply the following operations:
     Start:  "74"
     Rotate: "47"
     ​​​​​​​Add:    "42"
    @@ -61,14 +61,7 @@ There is no way to obtain a string that is lexicographically smaller then "
     
     Input: s = "0011", a = 4, b = 2
     Output: "0011"
    -Explanation: There are no sequence of operations that will give us a lexicographically smaller string than "0011".
    -
    - -

    Example 4:

    - -
    -Input: s = "43987654", a = 7, b = 3
    -Output: "00553311"
    +Explanation: There are no sequence of operations that will give us a lexicographically smaller string than "0011".
     

     

    @@ -83,8 +76,8 @@ There is no way to obtain a string that is lexicographically smaller then " ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[String](../../tag/string/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/line-reflection/README.md b/problems/line-reflection/README.md index e102b042a..ba950f01d 100644 --- a/problems/line-reflection/README.md +++ b/problems/line-reflection/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-twitter "Design Twitter") diff --git a/problems/linked-list-in-binary-tree/README.md b/problems/linked-list-in-binary-tree/README.md index bd5ccf805..9b1a71dfe 100644 --- a/problems/linked-list-in-binary-tree/README.md +++ b/problems/linked-list-in-binary-tree/README.md @@ -55,10 +55,10 @@ ### Related Topics + [[Linked List](../../tag/linked-list/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Linked List](../../tag/linked-list/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/logger-rate-limiter/README.md b/problems/logger-rate-limiter/README.md index 20267a79e..52a6f01b0 100644 --- a/problems/logger-rate-limiter/README.md +++ b/problems/logger-rate-limiter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rearrange-string-k-distance-apart "Rearrange String k Distance Apart") diff --git a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md index ea4ae8c81..a95dfe168 100644 --- a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md +++ b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md @@ -64,6 +64,11 @@ The segment of 1s is not longer, so return false. ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) + 1. [Count Subarrays With More Ones Than Zeros](../count-subarrays-with-more-ones-than-zeros) (Medium) + 1. [Check if Binary String Has at Most One Segment of Ones](../check-if-binary-string-has-at-most-one-segment-of-ones) (Easy) + ### Hints
    Hint 1 diff --git a/problems/longest-arithmetic-subsequence-of-given-difference/README.md b/problems/longest-arithmetic-subsequence-of-given-difference/README.md index 4158fbe84..dc350155e 100644 --- a/problems/longest-arithmetic-subsequence-of-given-difference/README.md +++ b/problems/longest-arithmetic-subsequence-of-given-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-move-chips-to-the-same-position "Minimum Cost to Move Chips to The Same Position") diff --git a/problems/longest-arithmetic-subsequence/README.md b/problems/longest-arithmetic-subsequence/README.md index a11e3f40c..33b7de800 100644 --- a/problems/longest-arithmetic-subsequence/README.md +++ b/problems/longest-arithmetic-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-difference-between-node-and-ancestor "Maximum Difference Between Node and Ancestor") diff --git a/problems/longest-chunked-palindrome-decomposition/README.md b/problems/longest-chunked-palindrome-decomposition/README.md index 6c7f56e26..6e555f50b 100644 --- a/problems/longest-chunked-palindrome-decomposition/README.md +++ b/problems/longest-chunked-palindrome-decomposition/README.md @@ -46,14 +46,6 @@ Explanation: We can split the string on "(a)(nt)(a)(pre)(za)(tpe)(za)(pre)(a)(nt)(a)".
    -

    Example 4:

    - -
    -Input: text = "aaa"
    -Output: 3
    -Explanation: We can split the string on "(a)(a)(a)".
    -
    -

     

    Constraints:

    diff --git a/problems/longest-common-subsequence-between-sorted-arrays/README.md b/problems/longest-common-subsequence-between-sorted-arrays/README.md index 3f9f604dc..1477353b8 100644 --- a/problems/longest-common-subsequence-between-sorted-arrays/README.md +++ b/problems/longest-common-subsequence-between-sorted-arrays/README.md @@ -18,6 +18,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) + ### Hints
    Hint 1 diff --git a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md index 66c810ef5..ae7344147 100644 --- a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md +++ b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-all-1s-are-at-least-length-k-places-away "Check If All 1's Are at Least Length K Places Away") @@ -58,12 +58,12 @@ Therefore, the size of the longest subarray is 2. ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] ### Hints
    diff --git a/problems/longest-duplicate-substring/README.md b/problems/longest-duplicate-substring/README.md index b40016fef..e3a41f9d7 100644 --- a/problems/longest-duplicate-substring/README.md +++ b/problems/longest-duplicate-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-array-for-maximum-sum "Partition Array for Maximum Sum") @@ -34,10 +34,10 @@ ### Related Topics [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Suffix Array](../../tag/suffix-array/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Suffix Array](../../tag/suffix-array/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/longest-happy-prefix/README.md b/problems/longest-happy-prefix/README.md index 673083037..7fa67f4df 100644 --- a/problems/longest-happy-prefix/README.md +++ b/problems/longest-happy-prefix/README.md @@ -32,20 +32,6 @@ Explanation: "abab" is the largest prefix which is also suffix. They can overlap in the original string. -

    Example 3:

    - -
    -Input: s = "leetcodeleet"
    -Output: "leet"
    -
    - -

    Example 4:

    - -
    -Input: s = "a"
    -Output: ""
    -
    -

     

    Constraints:

    @@ -56,9 +42,9 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] [[String Matching](../../tag/string-matching/README.md)] [[Hash Function](../../tag/hash-function/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/longest-happy-string/README.md b/problems/longest-happy-string/README.md index bd6c6c74d..a07549769 100644 --- a/problems/longest-happy-string/README.md +++ b/problems/longest-happy-string/README.md @@ -11,17 +11,19 @@ ## [1405. Longest Happy String (Medium)](https://leetcode.com/problems/longest-happy-string "最长快乐字符串") -

    A string is called happy if it does not have any of the strings 'aaa', 'bbb' or 'ccc' as a substring.

    - -

    Given three integers a, b and c, return any string s, which satisfies following conditions:

    +

    A string s is called happy if it satisfies the following conditions:

      -
    • s is happy and longest possible.
    • -
    • s contains at most a occurrences of the letter 'a', at most b occurrences of the letter 'b' and at most c occurrences of the letter 'c'.
    • -
    • will only contain 'a', 'b' and 'c' letters.
    • +
    • s only contains the letters 'a', 'b', and 'c'.
    • +
    • s does not contain any of "aaa", "bbb", or "ccc" as a substring.
    • +
    • s contains at most a occurrences of the letter 'a'.
    • +
    • s contains at most b occurrences of the letter 'b'.
    • +
    • s contains at most c occurrences of the letter 'c'.
    -

    If there is no such string s return the empty string "".

    +

    Given three integers a, b, and c, return the longest possible happy string. If there are multiple longest happy strings, return any of them. If there is no such string, return the empty string "".

    + +

    A substring is a contiguous sequence of characters within a string.

     

    Example 1:

    @@ -34,17 +36,10 @@

    Example 2:

    -
    -Input: a = 2, b = 2, c = 1
    -Output: "aabbc"
    -
    - -

    Example 3:

    -
     Input: a = 7, b = 1, c = 0
     Output: "aabaa"
    -Explanation: It's the only correct answer in this case.
    +Explanation: It is the only correct answer in this case.
     

     

    @@ -60,6 +55,9 @@ [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] +### Similar Questions + 1. [Reorganize String](../reorganize-string) (Medium) + ### Hints
    Hint 1 diff --git a/problems/longest-harmonious-subsequence/README.md b/problems/longest-harmonious-subsequence/README.md index 61d1605f2..a965eb210 100644 --- a/problems/longest-harmonious-subsequence/README.md +++ b/problems/longest-harmonious-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-square "Valid Square") diff --git a/problems/longest-increasing-path-in-a-matrix/README.md b/problems/longest-increasing-path-in-a-matrix/README.md index 2561b5543..e03319e78 100644 --- a/problems/longest-increasing-path-in-a-matrix/README.md +++ b/problems/longest-increasing-path-in-a-matrix/README.md @@ -50,9 +50,9 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-mountain-in-array/README.md b/problems/longest-mountain-in-array/README.md index 275d9a58e..c391abf44 100644 --- a/problems/longest-mountain-in-array/README.md +++ b/problems/longest-mountain-in-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../backspace-string-compare "Backspace String Compare") diff --git a/problems/longest-nice-substring/README.md b/problems/longest-nice-substring/README.md index 8d3fc5369..20b09a0f5 100644 --- a/problems/longest-nice-substring/README.md +++ b/problems/longest-nice-substring/README.md @@ -30,22 +30,16 @@
     Input: s = "Bb"
     Output: "Bb"
    -Explanation: "Bb" is a nice string because both 'B' and 'b' appear. The whole string is a substring.
    +Explanation: "Bb" is a nice string because both 'B' and 'b' appear. The whole string is a substring. +

    Example 3:

     Input: s = "c"
     Output: ""
    -Explanation: There are no nice substrings.
    - -

    Example 4:

    - -
    -Input: s = "dDzeE"
    -Output: "dD"
    -Explanation: Both "dD" and "eE" are the longest nice substrings.
    -As there are multiple longest nice substrings, return "dD" since it occurs earlier.
    +Explanation: There are no nice substrings. +

     

    Constraints:

    diff --git a/problems/longest-palindrome-by-concatenating-two-letter-words/README.md b/problems/longest-palindrome-by-concatenating-two-letter-words/README.md new file mode 100644 index 000000000..3efa72307 --- /dev/null +++ b/problems/longest-palindrome-by-concatenating-two-letter-words/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../maximum-twin-sum-of-a-linked-list "Maximum Twin Sum of a Linked List") +                 +[Next >](../stamping-the-grid "Stamping the Grid") + +## [2131. Longest Palindrome by Concatenating Two Letter Words (Medium)](https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words "连接两字母单词得到的最长回文串") + +

    You are given an array of strings words. Each element of words consists of two lowercase English letters.

    + +

    Create the longest possible palindrome by selecting some elements from words and concatenating them in any order. Each element can be selected at most once.

    + +

    Return the length of the longest palindrome that you can create. If it is impossible to create any palindrome, return 0.

    + +

    A palindrome is a string that reads the same forward and backward.

    + +

     

    +

    Example 1:

    + +
    +Input: words = ["lc","cl","gg"]
    +Output: 6
    +Explanation: One longest palindrome is "lc" + "gg" + "cl" = "lcggcl", of length 6.
    +Note that "clgglc" is another longest palindrome that can be created.
    +
    + +

    Example 2:

    + +
    +Input: words = ["ab","ty","yt","lc","cl","ab"]
    +Output: 8
    +Explanation: One longest palindrome is "ty" + "lc" + "cl" + "yt" = "tylcclyt", of length 8.
    +Note that "lcyttycl" is another longest palindrome that can be created.
    +
    + +

    Example 3:

    + +
    +Input: words = ["cc","ll","xx"]
    +Output: 2
    +Explanation: One longest palindrome is "cc", of length 2.
    +Note that "ll" is another longest palindrome that can be created, and so is "xx".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 105
    • +
    • words[i].length == 2
    • +
    • words[i] consists of lowercase English letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +A palindrome must be mirrored over the center. Suppose we have a palindrome. If we prepend the word "ab" on the left, what must we append on the right to keep it a palindrome? +
    + +
    +Hint 2 +We must append "ba" on the right. The number of times we can do this is the minimum of (occurrences of "ab") and (occurrences of "ba"). +
    + +
    +Hint 3 +For words that are already palindromes, e.g. "aa", we can prepend and append these in pairs as described in the previous hint. We can also use exactly one in the middle to form an even longer palindrome. +
    diff --git a/problems/longest-palindromic-subsequence-ii/README.md b/problems/longest-palindromic-subsequence-ii/README.md index 7e5d73629..7f8a858a1 100644 --- a/problems/longest-palindromic-subsequence-ii/README.md +++ b/problems/longest-palindromic-subsequence-ii/README.md @@ -17,6 +17,9 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Longest Palindromic Subsequence](../longest-palindromic-subsequence) (Medium) + ### Hints
    Hint 1 diff --git a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md index 6da0a32b4..4c5892b99 100644 --- a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md +++ b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md @@ -21,34 +21,23 @@
     Input: nums = [1,1,0,1]
     Output: 3
    -Explanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's.
    +Explanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's. +

    Example 2:

     Input: nums = [0,1,1,1,0,1,1,0,1]
     Output: 5
    -Explanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1].
    +Explanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1]. +

    Example 3:

     Input: nums = [1,1,1]
     Output: 2
    -Explanation: You must delete one element.
    - -

    Example 4:

    - -
    -Input: nums = [1,1,0,0,1,1,1,0,1]
    -Output: 4
    -
    - -

    Example 5:

    - -
    -Input: nums = [0,0,0]
    -Output: 0
    +Explanation: You must delete one element.
     

     

    diff --git a/problems/longest-subsequence-repeated-k-times/README.md b/problems/longest-subsequence-repeated-k-times/README.md index eb18b2de0..2879b957e 100644 --- a/problems/longest-subsequence-repeated-k-times/README.md +++ b/problems/longest-subsequence-repeated-k-times/README.md @@ -49,14 +49,6 @@ Explanation: There is no subsequence repeated 2 times. Empty string is returned. -

    Example 4:

    - -
    -Input: s = "bbabbabbbbabaababab", k = 3
    -Output: "bbbb"
    -Explanation: The longest subsequence "bbbb" is repeated 3 times in "bbabbabbbbabaababab".
    -
    -

     

    Constraints:

    diff --git a/problems/longest-uncommon-subsequence-ii/README.md b/problems/longest-uncommon-subsequence-ii/README.md index 218b3d5fd..be9dd896a 100644 --- a/problems/longest-uncommon-subsequence-ii/README.md +++ b/problems/longest-uncommon-subsequence-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-uncommon-subsequence-i "Longest Uncommon Subsequence I") diff --git a/problems/longest-univalue-path/README.md b/problems/longest-univalue-path/README.md index de2efc274..87333d2cc 100644 --- a/problems/longest-univalue-path/README.md +++ b/problems/longest-univalue-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../repeated-string-match "Repeated String Match") diff --git a/problems/longest-winning-streak/README.md b/problems/longest-winning-streak/README.md new file mode 100644 index 000000000..d136c15df --- /dev/null +++ b/problems/longest-winning-streak/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../maximum-and-sum-of-array "Maximum AND Sum of Array") +                 +Next > + +## [2173. Longest Winning Streak (Hard)](https://leetcode.com/problems/longest-winning-streak "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/longest-winning-streak/mysql_schemas.sql b/problems/longest-winning-streak/mysql_schemas.sql new file mode 100644 index 000000000..6da5cb0fb --- /dev/null +++ b/problems/longest-winning-streak/mysql_schemas.sql @@ -0,0 +1,10 @@ +Create table If Not Exists Matches (player_id int, match_day date, result ENUM('Win', 'Draw', 'Lose')); +Truncate table Matches; +insert into Matches (player_id, match_day, result) values ('1', '2022-01-17', 'Win'); +insert into Matches (player_id, match_day, result) values ('1', '2022-01-18', 'Win'); +insert into Matches (player_id, match_day, result) values ('1', '2022-01-25', 'Win'); +insert into Matches (player_id, match_day, result) values ('1', '2022-01-31', 'Draw'); +insert into Matches (player_id, match_day, result) values ('1', '2022-02-08', 'Win'); +insert into Matches (player_id, match_day, result) values ('2', '2022-02-06', 'Lose'); +insert into Matches (player_id, match_day, result) values ('2', '2022-02-08', 'Lose'); +insert into Matches (player_id, match_day, result) values ('3', '2022-03-30', 'Win'); diff --git a/problems/low-quality-problems/README.md b/problems/low-quality-problems/README.md index 9daaf212c..09b5a0c7a 100644 --- a/problems/low-quality-problems/README.md +++ b/problems/low-quality-problems/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-moves-to-convert-string "Minimum Moves to Convert String") -## [2026. Low-Quality Problems (Easy)](https://leetcode.com/problems/low-quality-problems "") +## [2026. Low-Quality Problems (Easy)](https://leetcode.com/problems/low-quality-problems "低质量的问题") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md index 026487e5f..a616f79c8 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md @@ -18,6 +18,14 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) + 1. [Lowest Common Ancestor of a Binary Tree](../lowest-common-ancestor-of-a-binary-tree) (Medium) + 1. [Lowest Common Ancestor of Deepest Leaves](../lowest-common-ancestor-of-deepest-leaves) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree II](../lowest-common-ancestor-of-a-binary-tree-ii) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree III](../lowest-common-ancestor-of-a-binary-tree-iii) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree IV](../lowest-common-ancestor-of-a-binary-tree-iv) (Medium) + ### Hints
    Hint 1 diff --git a/problems/lowest-common-ancestor-of-a-binary-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-tree/README.md index 6baf04ac6..bd54f479f 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-a-binary-search-tree "Lowest Common Ancestor of a Binary Search Tree") diff --git a/problems/majority-element-ii/README.md b/problems/majority-element-ii/README.md index 8fe8073d6..07c9879d8 100644 --- a/problems/majority-element-ii/README.md +++ b/problems/majority-element-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../summary-ranges "Summary Ranges") @@ -13,8 +13,6 @@

    Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.

    -

    Follow-up: Could you solve the problem in linear time and in O(1) space?

    -

     

    Example 1:

    @@ -45,11 +43,14 @@
  • -109 <= nums[i] <= 109
  • +

     

    +

    Follow up: Could you solve the problem in linear time and in O(1) space?

    + ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Counting](../../tag/counting/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Counting](../../tag/counting/README.md)] ### Similar Questions 1. [Majority Element](../majority-element) (Easy) diff --git a/problems/majority-element/README.md b/problems/majority-element/README.md index ae8eb9d3d..0e1ec3228 100644 --- a/problems/majority-element/README.md +++ b/problems/majority-element/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../excel-sheet-column-title "Excel Sheet Column Title") diff --git a/problems/make-sum-divisible-by-p/README.md b/problems/make-sum-divisible-by-p/README.md index ecef87f72..bcdc0d891 100644 --- a/problems/make-sum-divisible-by-p/README.md +++ b/problems/make-sum-divisible-by-p/README.md @@ -42,21 +42,6 @@ Explanation: Here the sum is 6. which is already divisible by 3. Thus we do not need to remove anything. -

    Example 4:

    - -
    -Input: nums = [1,2,3], p = 7
    -Output: -1
    -Explanation: There is no way to remove a subarray in order to get a sum divisible by 7.
    -
    - -

    Example 5:

    - -
    -Input: nums = [1000000000,1000000000,1000000000], p = 3
    -Output: 0
    -
    -

     

    Constraints:

    diff --git a/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md b/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md index 7ccaa9fe5..3f98c203d 100644 --- a/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md +++ b/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rectangles-area "Rectangles Area") @@ -11,11 +11,9 @@ ## [1460. Make Two Arrays Equal by Reversing Sub-arrays (Easy)](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays "通过翻转子数组使两个数组相等") -

    Given two integer arrays of equal length target and arr.

    +

    You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any number of steps.

    -

    In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any number of steps.

    - -

    Return True if you can make arr equal to target, or False otherwise.

    +

    Return true if you can make arr equal to target or false otherwise.

     

    Example 1:

    @@ -40,24 +38,10 @@ There are multiple ways to convert arr to target, this is not the only way to do

    Example 3:

    -
    -Input: target = [1,12], arr = [12,1]
    -Output: true
    -
    - -

    Example 4:

    -
     Input: target = [3,7,9], arr = [3,7,11]
     Output: false
    -Explanation: arr doesn't have value 9 and it can never be converted to target.
    -
    - -

    Example 5:

    - -
    -Input: target = [1,1,1,1,1], arr = [1,1,1,1,1]
    -Output: true
    +Explanation: arr does not have value 9 and it can never be converted to target.
     

     

    diff --git a/problems/making-file-names-unique/README.md b/problems/making-file-names-unique/README.md index dc950449f..0b8995d41 100644 --- a/problems/making-file-names-unique/README.md +++ b/problems/making-file-names-unique/README.md @@ -11,11 +11,11 @@ ## [1487. Making File Names Unique (Medium)](https://leetcode.com/problems/making-file-names-unique "保证文件名唯一") -

    Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i].

    +

    Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i].

    -

    Since two files cannot have the same name, if you enter a folder name which is previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.

    +

    Since two files cannot have the same name, if you enter a folder name that was previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.

    -

    Return an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.

    +

    Return an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.

     

    Example 1:

    @@ -50,29 +50,13 @@ Explanation: When the last folder is created, the smallest positive valid k is 4, and it becomes "onepiece(4)". -

    Example 4:

    - -
    -Input: names = ["wano","wano","wano","wano"]
    -Output: ["wano","wano(1)","wano(2)","wano(3)"]
    -Explanation: Just increase the value of k each time you create folder "wano".
    -
    - -

    Example 5:

    - -
    -Input: names = ["kaido","kaido(1)","kaido","kaido(1)"]
    -Output: ["kaido","kaido(1)","kaido(2)","kaido(1)(1)"]
    -Explanation: Please note that system adds the suffix (k) to current name even it contained the same suffix before.
    -
    -

     

    Constraints:

      -
    • 1 <= names.length <= 5 * 10^4
    • +
    • 1 <= names.length <= 5 * 104
    • 1 <= names[i].length <= 20
    • -
    • names[i] consists of lower case English letters, digits and/or round brackets.
    • +
    • names[i] consists of lowercase English letters, digits, and/or round brackets.
    ### Related Topics diff --git a/problems/map-sum-pairs/README.md b/problems/map-sum-pairs/README.md index 2332b6706..ffca94185 100644 --- a/problems/map-sum-pairs/README.md +++ b/problems/map-sum-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../implement-magic-dictionary "Implement Magic Dictionary") @@ -55,7 +55,7 @@ mapSum.sum("ap"); // return 5 (apple + app = 3 ### Related Topics - [[Design](../../tag/design/README.md)] - [[Trie](../../tag/trie/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] diff --git a/problems/matrix-block-sum/README.md b/problems/matrix-block-sum/README.md index 91ae8977a..9fe7fe48f 100644 --- a/problems/matrix-block-sum/README.md +++ b/problems/matrix-block-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decompress-run-length-encoded-list "Decompress Run-Length Encoded List") @@ -49,6 +49,9 @@ [[Matrix](../../tag/matrix/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Stamping the Grid](../stamping-the-grid) (Hard) + ### Hints
    Hint 1 diff --git a/problems/matrix-cells-in-distance-order/README.md b/problems/matrix-cells-in-distance-order/README.md index 3e26821f3..9fa55ff71 100644 --- a/problems/matrix-cells-in-distance-order/README.md +++ b/problems/matrix-cells-in-distance-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-city-scheduling "Two City Scheduling") @@ -54,8 +54,8 @@ There are other answers that would also be accepted as correct, such as [[1,2],[ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Matrix](../../tag/matrix/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/matrix-diagonal-sum/README.md b/problems/matrix-diagonal-sum/README.md index f45ad0315..ea3934e05 100644 --- a/problems/matrix-diagonal-sum/README.md +++ b/problems/matrix-diagonal-sum/README.md @@ -57,6 +57,9 @@ Notice that element mat[1][1] = 5 is counted only once. [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Check if Every Row and Column Contains All Numbers](../check-if-every-row-and-column-contains-all-numbers) (Easy) + ### Hints
    Hint 1 diff --git a/problems/max-consecutive-ones-iii/README.md b/problems/max-consecutive-ones-iii/README.md index 543968e6c..2d8260401 100644 --- a/problems/max-consecutive-ones-iii/README.md +++ b/problems/max-consecutive-ones-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-word-is-valid-after-substitutions "Check If Word Is Valid After Substitutions") @@ -43,15 +43,14 @@ Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Medium) 1. [Longest Repeating Character Replacement](../longest-repeating-character-replacement) (Medium) 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) 1. [Max Consecutive Ones II](../max-consecutive-ones-ii) (Medium) - 1. [Maximize the Confusion of an Exam](../maximize-the-confusion-of-an-exam) (Medium) ### Hints
    diff --git a/problems/max-dot-product-of-two-subsequences/README.md b/problems/max-dot-product-of-two-subsequences/README.md index 7e4087e25..87cfbc3c3 100644 --- a/problems/max-dot-product-of-two-subsequences/README.md +++ b/problems/max-dot-product-of-two-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../pseudo-palindromic-paths-in-a-binary-tree "Pseudo-Palindromic Paths in a Binary Tree") diff --git a/problems/max-value-of-equation/README.md b/problems/max-value-of-equation/README.md index 485de6f96..4acc64f7b 100644 --- a/problems/max-value-of-equation/README.md +++ b/problems/max-value-of-equation/README.md @@ -48,11 +48,14 @@ No other pairs satisfy the condition, so we return the max of 4 and 1. ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] + [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + +### Similar Questions + 1. [Count Pairs in Two Arrays](../count-pairs-in-two-arrays) (Medium) ### Hints
    diff --git a/problems/maximal-rectangle/README.md b/problems/maximal-rectangle/README.md index 0a5485bb9..78ebdca14 100644 --- a/problems/maximal-rectangle/README.md +++ b/problems/maximal-rectangle/README.md @@ -24,46 +24,32 @@

    Example 2:

    -
    -Input: matrix = []
    -Output: 0
    -
    - -

    Example 3:

    -
     Input: matrix = [["0"]]
     Output: 0
     
    -

    Example 4:

    +

    Example 3:

     Input: matrix = [["1"]]
     Output: 1
     
    -

    Example 5:

    - -
    -Input: matrix = [["0","0"]]
    -Output: 0
    -
    -

     

    Constraints:

    • rows == matrix.length
    • cols == matrix[i].length
    • -
    • 0 <= row, cols <= 200
    • +
    • 1 <= row, cols <= 200
    • matrix[i][j] is '0' or '1'.
    ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Stack](../../tag/stack/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/maximize-number-of-nice-divisors/README.md b/problems/maximize-number-of-nice-divisors/README.md index b325bd1cf..69b41c77f 100644 --- a/problems/maximize-number-of-nice-divisors/README.md +++ b/problems/maximize-number-of-nice-divisors/README.md @@ -48,8 +48,11 @@ There is not other value of n that has at most 5 prime factors and more nice div ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] + +### Similar Questions + 1. [Integer Break](../integer-break) (Medium) ### Hints
    diff --git a/problems/maximum-alternating-subarray-sum/README.md b/problems/maximum-alternating-subarray-sum/README.md index 0ae635e82..d761dc4d7 100644 --- a/problems/maximum-alternating-subarray-sum/README.md +++ b/problems/maximum-alternating-subarray-sum/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-number-of-moves-to-seat-everyone "Minimum Number of Moves to Seat Everyone") -## [2036. Maximum Alternating Subarray Sum (Medium)](https://leetcode.com/problems/maximum-alternating-subarray-sum "") +## [2036. Maximum Alternating Subarray Sum (Medium)](https://leetcode.com/problems/maximum-alternating-subarray-sum "最大交替子数组和") diff --git a/problems/maximum-alternating-subsequence-sum/README.md b/problems/maximum-alternating-subsequence-sum/README.md index 2265c28fd..340f9b788 100644 --- a/problems/maximum-alternating-subsequence-sum/README.md +++ b/problems/maximum-alternating-subsequence-sum/README.md @@ -61,6 +61,9 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Maximum Alternating Subarray Sum](../maximum-alternating-subarray-sum) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-and-sum-of-array/README.md b/problems/maximum-and-sum-of-array/README.md new file mode 100644 index 000000000..c3a632e65 --- /dev/null +++ b/problems/maximum-and-sum-of-array/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../removing-minimum-number-of-magic-beans "Removing Minimum Number of Magic Beans") +                 +[Next >](../longest-winning-streak "Longest Winning Streak") + +## [2172. Maximum AND Sum of Array (Hard)](https://leetcode.com/problems/maximum-and-sum-of-array "数组的最大与和") + +

    You are given an integer array nums of length n and an integer numSlots such that 2 * numSlots >= n. There are numSlots slots numbered from 1 to numSlots.

    + +

    You have to place all n integers into the slots such that each slot contains at most two numbers. The AND sum of a given placement is the sum of the bitwise AND of every number with its respective slot number.

    + +
      +
    • For example, the AND sum of placing the numbers [1, 3] into slot 1 and [4, 6] into slot 2 is equal to (1 AND 1) + (3 AND 1) + (4 AND 2) + (6 AND 2) = 1 + 1 + 0 + 2 = 4.
    • +
    + +

    Return the maximum possible AND sum of nums given numSlots slots.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,4,5,6], numSlots = 3
    +Output: 9
    +Explanation: One possible placement is [1, 4] into slot 1, [2, 6] into slot 2, and [3, 5] into slot 3. 
    +This gives the maximum AND sum of (1 AND 1) + (4 AND 1) + (2 AND 2) + (6 AND 2) + (3 AND 3) + (5 AND 3) = 1 + 0 + 2 + 2 + 3 + 1 = 9.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,3,10,4,7,1], numSlots = 9
    +Output: 24
    +Explanation: One possible placement is [1, 1] into slot 1, [3] into slot 3, [4] into slot 4, [7] into slot 7, and [10] into slot 9.
    +This gives the maximum AND sum of (1 AND 1) + (1 AND 1) + (3 AND 3) + (4 AND 4) + (7 AND 7) + (10 AND 9) = 1 + 1 + 3 + 4 + 7 + 8 = 24.
    +Note that slots 2, 5, 6, and 8 are empty which is permitted.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= numSlots <= 9
    • +
    • 1 <= n <= 2 * numSlots
    • +
    • 1 <= nums[i] <= 15
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + +### Hints +
    +Hint 1 +Can you think of a dynamic programming solution to this problem? +
    + +
    +Hint 2 +Can you use a bitmask to represent the state of the slots? +
    diff --git a/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md b/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md index c1efb356e..43b1a9eeb 100644 --- a/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md +++ b/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-of-two-elements-in-an-array "Maximum Product of Two Elements in an Array") @@ -58,8 +58,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/maximum-ascending-subarray-sum/README.md b/problems/maximum-ascending-subarray-sum/README.md index 33dd72404..349c6752a 100644 --- a/problems/maximum-ascending-subarray-sum/README.md +++ b/problems/maximum-ascending-subarray-sum/README.md @@ -42,13 +42,6 @@ Explanation: [10,11,12] is the ascending subarray with the maximum sum of 33. -

    Example 4:

    - -
    -Input: nums = [100,10,1]
    -Output: 100
    -
    -

     

    Constraints:

    @@ -60,6 +53,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [Find Good Days to Rob the Bank](../find-good-days-to-rob-the-bank) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-binary-string-after-change/README.md b/problems/maximum-binary-string-after-change/README.md index 07af7eb1a..8f105f46c 100644 --- a/problems/maximum-binary-string-after-change/README.md +++ b/problems/maximum-binary-string-after-change/README.md @@ -59,8 +59,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-candies-you-can-get-from-boxes/README.md b/problems/maximum-candies-you-can-get-from-boxes/README.md index 7977327ee..d714a6c5d 100644 --- a/problems/maximum-candies-you-can-get-from-boxes/README.md +++ b/problems/maximum-candies-you-can-get-from-boxes/README.md @@ -11,18 +11,18 @@ ## [1298. Maximum Candies You Can Get from Boxes (Hard)](https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes "你能从盒子里获得的最大糖果数") -

    Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:

    +

    You have n boxes labeled from 0 to n - 1. You are given four arrays: status, candies, keys, and containedBoxes where:

      -
    • status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
    • -
    • candies[i]: an integer representing the number of candies in box[i].
    • -
    • keys[i]: an array contains the indices of the boxes you can open with the key in box[i].
    • -
    • containedBoxes[i]: an array contains the indices of the boxes found in box[i].
    • +
    • status[i] is 1 if the ith box is open and 0 if the ith box is closed,
    • +
    • candies[i] is the number of candies in the ith box,
    • +
    • keys[i] is a list of the labels of the boxes you can open after opening the ith box.
    • +
    • containedBoxes[i] is a list of the boxes you found inside the ith box.
    -

    You will start with some boxes given in initialBoxes array. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.

    +

    You are given an integer array initialBoxes that contains the labels of the boxes you initially have. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.

    -

    Return the maximum number of candies you can get following the rules above.

    +

    Return the maximum number of candies you can get following the rules above.

     

    Example 1:

    @@ -30,7 +30,8 @@
     Input: status = [1,0,1,0], candies = [7,5,4,100], keys = [[],[],[1],[]], containedBoxes = [[1,2],[3],[],[]], initialBoxes = [0]
     Output: 16
    -Explanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2. Box 1 is closed and you don't have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2.
    +Explanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2.
    +Box 1 is closed and you do not have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2.
     In box 1, you will find 5 candies and box 3 but you will not find a key to box 3 so box 3 will remain closed.
     Total number of candies collected = 7 + 4 + 5 = 16 candy.
     
    @@ -40,52 +41,32 @@ Total number of candies collected = 7 + 4 + 5 = 16 candy.
     Input: status = [1,0,0,0,0,0], candies = [1,1,1,1,1,1], keys = [[1,2,3,4,5],[],[],[],[],[]], containedBoxes = [[1,2,3,4,5],[],[],[],[],[]], initialBoxes = [0]
     Output: 6
    -Explanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys. The total number of candies will be 6.
    -
    - -

    Example 3:

    - -
    -Input: status = [1,1,1], candies = [100,1,100], keys = [[],[0,2],[]], containedBoxes = [[],[],[]], initialBoxes = [1]
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: status = [1], candies = [100], keys = [[]], containedBoxes = [[]], initialBoxes = []
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: status = [1,1,1], candies = [2,3,2], keys = [[],[],[]], containedBoxes = [[],[],[]], initialBoxes = [2,1,0]
    -Output: 7
    +Explanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys.
    +The total number of candies will be 6.
     

     

    Constraints:

      -
    • 1 <= status.length <= 1000
    • -
    • status.length == candies.length == keys.length == containedBoxes.length == n
    • -
    • status[i] is 0 or 1.
    • +
    • n == status.length == candies.length == keys.length == containedBoxes.length
    • +
    • 1 <= n <= 1000
    • +
    • status[i] is either 0 or 1.
    • 1 <= candies[i] <= 1000
    • -
    • 0 <= keys[i].length <= status.length
    • -
    • 0 <= keys[i][j] < status.length
    • -
    • All values in keys[i] are unique.
    • -
    • 0 <= containedBoxes[i].length <= status.length
    • -
    • 0 <= containedBoxes[i][j] < status.length
    • -
    • All values in containedBoxes[i] are unique.
    • +
    • 0 <= keys[i].length <= n
    • +
    • 0 <= keys[i][j] < n
    • +
    • All values of keys[i] are unique.
    • +
    • 0 <= containedBoxes[i].length <= n
    • +
    • 0 <= containedBoxes[i][j] < n
    • +
    • All values of containedBoxes[i] are unique.
    • Each box is contained in one box at most.
    • -
    • 0 <= initialBoxes.length <= status.length
    • -
    • 0 <= initialBoxes[i] < status.length
    • +
    • 0 <= initialBoxes.length <= n
    • +
    • 0 <= initialBoxes[i] < n
    ### Related Topics - [[Array](../../tag/array/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/maximum-difference-between-node-and-ancestor/README.md b/problems/maximum-difference-between-node-and-ancestor/README.md index 0b9b3cbd1..d8ad9af3b 100644 --- a/problems/maximum-difference-between-node-and-ancestor/README.md +++ b/problems/maximum-difference-between-node-and-ancestor/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../divisor-game "Divisor Game") diff --git a/problems/maximum-distance-between-a-pair-of-values/README.md b/problems/maximum-distance-between-a-pair-of-values/README.md index 6303a4c38..e88895f23 100644 --- a/problems/maximum-distance-between-a-pair-of-values/README.md +++ b/problems/maximum-distance-between-a-pair-of-values/README.md @@ -47,14 +47,6 @@ The maximum distance is 1 with pair (0,1). The maximum distance is 2 with pair (2,4). -

    Example 4:

    - -
    -Input: nums1 = [5,4], nums2 = [3,2]
    -Output: 0
    -Explanation: There are no valid pairs, so return 0.
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-distance-in-arrays/README.md b/problems/maximum-distance-in-arrays/README.md index b9bcdb2a2..4190a9404 100644 --- a/problems/maximum-distance-in-arrays/README.md +++ b/problems/maximum-distance-in-arrays/README.md @@ -35,5 +35,5 @@ One way to reach the maximum distance 4 is to pick 1 in the first or third array

    ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-element-after-decreasing-and-rearranging/README.md b/problems/maximum-element-after-decreasing-and-rearranging/README.md index 2ec14e72a..b3c3ef248 100644 --- a/problems/maximum-element-after-decreasing-and-rearranging/README.md +++ b/problems/maximum-element-after-decreasing-and-rearranging/README.md @@ -69,8 +69,8 @@ The largest element in arr is 3. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/maximum-employees-to-be-invited-to-a-meeting/README.md b/problems/maximum-employees-to-be-invited-to-a-meeting/README.md new file mode 100644 index 000000000..b593c81e1 --- /dev/null +++ b/problems/maximum-employees-to-be-invited-to-a-meeting/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../destroying-asteroids "Destroying Asteroids") +                 +[Next >](../remove-all-ones-with-row-and-column-flips "Remove All Ones With Row and Column Flips") + +## [2127. Maximum Employees to Be Invited to a Meeting (Hard)](https://leetcode.com/problems/maximum-employees-to-be-invited-to-a-meeting "参加会议的最多员工数") + +

    A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seating any number of employees.

    + +

    The employees are numbered from 0 to n - 1. Each employee has a favorite person and they will attend the meeting only if they can sit next to their favorite person at the table. The favorite person of an employee is not themself.

    + +

    Given a 0-indexed integer array favorite, where favorite[i] denotes the favorite person of the ith employee, return the maximum number of employees that can be invited to the meeting.

    + +

     

    +

    Example 1:

    + +
    +Input: favorite = [2,2,1,2]
    +Output: 3
    +Explanation:
    +The above figure shows how the company can invite employees 0, 1, and 2, and seat them at the round table.
    +All employees cannot be invited because employee 2 cannot sit beside employees 0, 1, and 3, simultaneously.
    +Note that the company can also invite employees 1, 2, and 3, and give them their desired seats.
    +The maximum number of employees that can be invited to the meeting is 3. 
    +
    + +

    Example 2:

    + +
    +Input: favorite = [1,2,0]
    +Output: 3
    +Explanation: 
    +Each employee is the favorite person of at least one other employee, and the only way the company can invite them is if they invite every employee.
    +The seating arrangement will be the same as that in the figure given in example 1:
    +- Employee 0 will sit between employees 2 and 1.
    +- Employee 1 will sit between employees 0 and 2.
    +- Employee 2 will sit between employees 1 and 0.
    +The maximum number of employees that can be invited to the meeting is 3.
    +
    + +

    Example 3:

    + +
    +Input: favorite = [3,0,1,4,1]
    +Output: 4
    +Explanation:
    +The above figure shows how the company will invite employees 0, 1, 3, and 4, and seat them at the round table.
    +Employee 2 cannot be invited because the two spots next to their favorite employee 1 are taken.
    +So the company leaves them out of the meeting.
    +The maximum number of employees that can be invited to the meeting is 4.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == favorite.length
    • +
    • 2 <= n <= 105
    • +
    • 0 <= favorite[i] <= n - 1
    • +
    • favorite[i] != i
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + +### Hints +
    +Hint 1 +From the given array favorite, create a graph where for every index i, there is a directed edge from favorite[i] to i. The graph will be a combination of cycles and chains of acyclic edges. Now, what are the ways in which we can choose employees to sit at the table? +
    + +
    +Hint 2 +The first way by which we can choose employees is by selecting a cycle of the graph. It can be proven that in this case, the employees that do not lie in the cycle can never be seated at the table. +
    + +
    +Hint 3 +The second way is by combining acyclic chains. At most two chains can be combined by a cycle of length 2, where each chain ends on one of the employees in the cycle. +
    diff --git a/problems/maximum-fruits-harvested-after-at-most-k-steps/README.md b/problems/maximum-fruits-harvested-after-at-most-k-steps/README.md new file mode 100644 index 000000000..997d2537c --- /dev/null +++ b/problems/maximum-fruits-harvested-after-at-most-k-steps/README.md @@ -0,0 +1,99 @@ + + + + + + + +[< Previous](../watering-plants-ii "Watering Plants II") +                 +[Next >](../number-of-unique-flavors-after-sharing-k-candies "Number of Unique Flavors After Sharing K Candies") + +## [2106. Maximum Fruits Harvested After at Most K Steps (Hard)](https://leetcode.com/problems/maximum-fruits-harvested-after-at-most-k-steps "摘水果") + +

    Fruits are available at some positions on an infinite x-axis. You are given a 2D integer array fruits where fruits[i] = [positioni, amounti] depicts amounti fruits at the position positioni. fruits is already sorted by positioni in ascending order, and each positioni is unique.

    + +

    You are also given an integer startPos and an integer k. Initially, you are at the position startPos. From any position, you can either walk to the left or right. It takes one step to move one unit on the x-axis, and you can walk at most k steps in total. For every position you reach, you harvest all the fruits at that position, and the fruits will disappear from that position.

    + +

    Return the maximum total number of fruits you can harvest.

    + +

     

    +

    Example 1:

    + +
    +Input: fruits = [[2,8],[6,3],[8,6]], startPos = 5, k = 4
    +Output: 9
    +Explanation: 
    +The optimal way is to:
    +- Move right to position 6 and harvest 3 fruits
    +- Move right to position 8 and harvest 6 fruits
    +You moved 3 steps and harvested 3 + 6 = 9 fruits in total.
    +
    + +

    Example 2:

    + +
    +Input: fruits = [[0,9],[4,1],[5,7],[6,2],[7,4],[10,9]], startPos = 5, k = 4
    +Output: 14
    +Explanation: 
    +You can move at most k = 4 steps, so you cannot reach position 0 nor 10.
    +The optimal way is to:
    +- Harvest the 7 fruits at the starting position 5
    +- Move left to position 4 and harvest 1 fruit
    +- Move right to position 6 and harvest 2 fruits
    +- Move right to position 7 and harvest 4 fruits
    +You moved 1 + 3 = 4 steps and harvested 7 + 1 + 2 + 4 = 14 fruits in total.
    +
    + +

    Example 3:

    + +
    +Input: fruits = [[0,3],[6,4],[8,5]], startPos = 3, k = 2
    +Output: 0
    +Explanation:
    +You can move at most k = 2 steps and cannot reach any position with fruits.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= fruits.length <= 105
    • +
    • fruits[i].length == 2
    • +
    • 0 <= startPos, positioni <= 2 * 105
    • +
    • positioni-1 < positioni for any i > 0 (0-indexed)
    • +
    • 1 <= amounti <= 104
    • +
    • 0 <= k <= 2 * 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +Does an optimal path have very few patterns? For example, could a path that goes left, turns and goes right, then turns again and goes left be any better than a path that simply goes left, turns, and goes right? +
    + +
    +Hint 2 +The optimal path turns at most once. That is, the optimal path is one of these: to go left only; to go right only; to go left, turn and go right; or to go right, turn and go left. +
    + +
    +Hint 3 +Moving x steps left then k-x steps right gives you a range of positions that you can reach. +
    + +
    +Hint 4 +Use prefix sums to get the sum of all fruits for each possible range. +
    + +
    +Hint 5 +Use a similar strategy for all the paths that go right, then turn and go left. +
    diff --git a/problems/maximum-genetic-difference-query/README.md b/problems/maximum-genetic-difference-query/README.md index dbd84060c..1b13b9038 100644 --- a/problems/maximum-genetic-difference-query/README.md +++ b/problems/maximum-genetic-difference-query/README.md @@ -52,6 +52,14 @@
  • 0 <= vali <= 2 * 105
  • +### Related Topics + [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Trie](../../tag/trie/README.md)] + +### Similar Questions + 1. [Maximum XOR With an Element From Array](../maximum-xor-with-an-element-from-array) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-good-people-based-on-statements/README.md b/problems/maximum-good-people-based-on-statements/README.md new file mode 100644 index 000000000..9b0cf9661 --- /dev/null +++ b/problems/maximum-good-people-based-on-statements/README.md @@ -0,0 +1,114 @@ + + + + + + + +[< Previous](../find-all-lonely-numbers-in-the-array "Find All Lonely Numbers in the Array") +                 +[Next >](../minimum-number-of-lines-to-cover-points "Minimum Number of Lines to Cover Points") + +## [2151. Maximum Good People Based on Statements (Hard)](https://leetcode.com/problems/maximum-good-people-based-on-statements "基于陈述统计最多好人数") + +

    There are two types of persons:

    + +
      +
    • The good person: The person who always tells the truth.
    • +
    • The bad person: The person who might tell the truth and might lie.
    • +
    + +

    You are given a 0-indexed 2D integer array statements of size n x n that represents the statements made by n people about each other. More specifically, statements[i][j] could be one of the following:

    + +
      +
    • 0 which represents a statement made by person i that person j is a bad person.
    • +
    • 1 which represents a statement made by person i that person j is a good person.
    • +
    • 2 represents that no statement is made by person i about person j.
    • +
    + +

    Additionally, no person ever makes a statement about themselves. Formally, we have that statements[i][i] = 2 for all 0 <= i < n.

    + +

    Return the maximum number of people who can be good based on the statements made by the n people.

    + +

     

    +

    Example 1:

    + +
    +Input: statements = [[2,1,2],[1,2,2],[2,0,2]]
    +Output: 2
    +Explanation: Each person makes a single statement.
    +- Person 0 states that person 1 is good.
    +- Person 1 states that person 0 is good.
    +- Person 2 states that person 1 is bad.
    +Let's take person 2 as the key.
    +- Assuming that person 2 is a good person:
    +    - Based on the statement made by person 2, person 1 is a bad person.
    +    - Now we know for sure that person 1 is bad and person 2 is good.
    +    - Based on the statement made by person 1, and since person 1 is bad, they could be:
    +        - telling the truth. There will be a contradiction in this case and this assumption is invalid.
    +        - lying. In this case, person 0 is also a bad person and lied in their statement.
    +    - Following that person 2 is a good person, there will be only one good person in the group.
    +- Assuming that person 2 is a bad person:
    +    - Based on the statement made by person 2, and since person 2 is bad, they could be:
    +        - telling the truth. Following this scenario, person 0 and 1 are both bad as explained before.
    +            - Following that person 2 is bad but told the truth, there will be no good persons in the group.
    +        - lying. In this case person 1 is a good person.
    +            - Since person 1 is a good person, person 0 is also a good person.
    +            - Following that person 2 is bad and lied, there will be two good persons in the group.
    +We can see that at most 2 persons are good in the best case, so we return 2.
    +Note that there is more than one way to arrive at this conclusion.
    +
    + +

    Example 2:

    + +
    +Input: statements = [[2,0],[0,2]]
    +Output: 1
    +Explanation: Each person makes a single statement.
    +- Person 0 states that person 1 is bad.
    +- Person 1 states that person 0 is bad.
    +Let's take person 0 as the key.
    +- Assuming that person 0 is a good person:
    +    - Based on the statement made by person 0, person 1 is a bad person and was lying.
    +    - Following that person 0 is a good person, there will be only one good person in the group.
    +- Assuming that person 0 is a bad person:
    +    - Based on the statement made by person 0, and since person 0 is bad, they could be:
    +        - telling the truth. Following this scenario, person 0 and 1 are both bad.
    +            - Following that person 0 is bad but told the truth, there will be no good persons in the group.
    +        - lying. In this case person 1 is a good person.
    +            - Following that person 0 is bad and lied, there will be only one good person in the group.
    +We can see that at most, one person is good in the best case, so we return 1.
    +Note that there is more than one way to arrive at this conclusion.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == statements.length == statements[i].length
    • +
    • 2 <= n <= 15
    • +
    • statements[i][j] is either 0, 1, or 2.
    • +
    • statements[i][i] == 2
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + +### Hints +
    +Hint 1 +You should test every possible assignment of good and bad people, using a bitmask. +
    + +
    +Hint 2 +In each bitmask, if the person i is good, then his statements should be consistent with the bitmask in order for the assignment to be valid. +
    + +
    +Hint 3 +If the assignment is valid, count how many people are good and keep track of the maximum. +
    diff --git a/problems/maximum-ice-cream-bars/README.md b/problems/maximum-ice-cream-bars/README.md index 5fbc91a10..5b90aaafb 100644 --- a/problems/maximum-ice-cream-bars/README.md +++ b/problems/maximum-ice-cream-bars/README.md @@ -55,8 +55,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md index 7dd80565b..cc15cde53 100644 --- a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md +++ b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md @@ -49,14 +49,6 @@ Maximum length is 4. Explanation: The only string in arr has all 26 characters. -

    Example 4:

    - -
    -Input: arr = ["aa","bb"]
    -Output: 0
    -Explanation: Both strings in arr do not have unique characters, thus there are no valid concatenations.
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-length-of-subarray-with-positive-product/README.md b/problems/maximum-length-of-subarray-with-positive-product/README.md index 09559fc46..d1b1c444c 100644 --- a/problems/maximum-length-of-subarray-with-positive-product/README.md +++ b/problems/maximum-length-of-subarray-with-positive-product/README.md @@ -11,11 +11,11 @@ ## [1567. Maximum Length of Subarray With Positive Product (Medium)](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") -

    Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.

    +

    Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.

    A subarray of an array is a consecutive sequence of zero or more values taken out of that array.

    -

    Return the maximum length of a subarray with positive product.

    +

    Return the maximum length of a subarray with positive product.

     

    Example 1:

    @@ -23,7 +23,7 @@
     Input: nums = [1,-2,-3,4]
     Output: 4
    -Explanation: The array nums already has a positive product of 24.
    +Explanation: The array nums already has a positive product of 24.
     

    Example 2:

    @@ -31,7 +31,7 @@
     Input: nums = [0,1,-2,-3,-4]
     Output: 3
    -Explanation: The longest subarray with positive product is [1,-2,-3] which has a product of 6.
    +Explanation: The longest subarray with positive product is [1,-2,-3] which has a product of 6.
     Notice that we cannot include 0 in the subarray since that'll make the product 0 which is not positive.

    Example 3:

    @@ -39,35 +39,21 @@ Notice that we cannot include 0 in the subarray since that'll make the produ
     Input: nums = [-1,-2,-3,0,1]
     Output: 2
    -Explanation: The longest subarray with positive product is [-1,-2] or [-2,-3].
    -
    - -

    Example 4:

    - -
    -Input: nums = [-1,2]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: nums = [1,2,3,5,-6,4,0,10]
    -Output: 4
    +Explanation: The longest subarray with positive product is [-1,-2] or [-2,-3].
     

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • -10^9 <= nums[i] <= 10^9
    • +
    • 1 <= nums.length <= 105
    • +
    • -109 <= nums[i] <= 109
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-nesting-depth-of-the-parentheses/README.md b/problems/maximum-nesting-depth-of-the-parentheses/README.md index b4df75520..93c9ebc78 100644 --- a/problems/maximum-nesting-depth-of-the-parentheses/README.md +++ b/problems/maximum-nesting-depth-of-the-parentheses/README.md @@ -48,20 +48,6 @@ Output: 3 -

    Example 3:

    - -
    -Input: s = "1+(2*3)/(2-1)"
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: s = "1"
    -Output: 0
    -
    -

     

    Constraints:

    @@ -72,8 +58,11 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + +### Similar Questions + 1. [Maximum Nesting Depth of Two Valid Parentheses Strings](../maximum-nesting-depth-of-two-valid-parentheses-strings) (Medium) ### Hints
    diff --git a/problems/maximum-non-negative-product-in-a-matrix/README.md b/problems/maximum-non-negative-product-in-a-matrix/README.md index 0b1c73b57..061a705d5 100644 --- a/problems/maximum-non-negative-product-in-a-matrix/README.md +++ b/problems/maximum-non-negative-product-in-a-matrix/README.md @@ -11,59 +11,46 @@ ## [1594. Maximum Non Negative Product in a Matrix (Medium)](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") -

    You are given a rows x cols matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.

    +

    You are given a m x n matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.

    -

    Among all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (rows - 1, cols - 1), find the path with the maximum non-negative product. The product of a path is the product of all integers in the grid cells visited along the path.

    +

    Among all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (m - 1, n - 1), find the path with the maximum non-negative product. The product of a path is the product of all integers in the grid cells visited along the path.

    -

    Return the maximum non-negative product modulo 109 + 7If the maximum product is negative return -1.

    +

    Return the maximum non-negative product modulo 109 + 7. If the maximum product is negative, return -1.

    -

    Notice that the modulo is performed after getting the maximum product.

    +

    Notice that the modulo is performed after getting the maximum product.

     

    Example 1:

    - +
    -Input: grid = [[-1,-2,-3],
    -               [-2,-3,-3],
    -               [-3,-3,-2]]
    +Input: grid = [[-1,-2,-3],[-2,-3,-3],[-3,-3,-2]]
     Output: -1
    -Explanation: It's not possible to get non-negative product in the path from (0, 0) to (2, 2), so return -1.
    +Explanation: It is not possible to get non-negative product in the path from (0, 0) to (2, 2), so return -1.
     

    Example 2:

    - +
    -Input: grid = [[1,-2,1],
    -               [1,-2,1],
    -               [3,-4,1]]
    +Input: grid = [[1,-2,1],[1,-2,1],[3,-4,1]]
     Output: 8
    -Explanation: Maximum non-negative product is in bold (1 * 1 * -2 * -4 * 1 = 8).
    +Explanation: Maximum non-negative product is shown (1 * 1 * -2 * -4 * 1 = 8).
     

    Example 3:

    - +
    -Input: grid = [[1, 3],
    -               [0,-4]]
    +Input: grid = [[1,3],[0,-4]]
     Output: 0
    -Explanation: Maximum non-negative product is in bold (1 * 0 * -4 = 0).
    -
    - -

    Example 4:

    - -
    -Input: grid = [[ 1, 4,4,0],
    -               [-2, 0,0,1],
    -               [ 1,-1,1,1]]
    -Output: 2
    -Explanation: Maximum non-negative product is in bold (1 * -2 * 1 * -1 * 1 * 1 = 2).
    +Explanation: Maximum non-negative product is shown (1 * 0 * -4 = 0).
     

     

    Constraints:

      -
    • 1 <= rows, cols <= 15
    • +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 15
    • -4 <= grid[i][j] <= 4
    diff --git a/problems/maximum-number-of-achievable-transfer-requests/README.md b/problems/maximum-number-of-achievable-transfer-requests/README.md index 144c6a30e..8c9be33c7 100644 --- a/problems/maximum-number-of-achievable-transfer-requests/README.md +++ b/problems/maximum-number-of-achievable-transfer-requests/README.md @@ -64,6 +64,8 @@ We can achieve all the requests. ### Related Topics + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Enumeration](../../tag/enumeration/README.md)] diff --git a/problems/maximum-number-of-consecutive-values-you-can-make/README.md b/problems/maximum-number-of-consecutive-values-you-can-make/README.md index 7fdf0d08f..b0826514c 100644 --- a/problems/maximum-number-of-consecutive-values-you-can-make/README.md +++ b/problems/maximum-number-of-consecutive-values-you-can-make/README.md @@ -60,16 +60,24 @@ You can make 8 consecutive integer values starting from 0. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Patching Array](../patching-array) (Hard) ### Hints
    Hint 1 -Let's note that if you can make the first x values then you can and you have a value v≤x+1 then you can make all values ≤v+x +If you can make the first x values and you have a value v, then you can make all the values ≤ v + x
    Hint 2 -The smaller v is the smaller the x you need so it's optimal to process elements in a sorted order +Sort the array of coins. You can always make the value 0 so you can start with x = 0. +
    + +
    +Hint 3 +Process the values starting from the smallest and stop when there is a value that cannot be achieved with the current x.
    diff --git a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md index 03a0c1879..7767a3d0e 100644 --- a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md +++ b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md @@ -11,52 +11,36 @@ ## [1453. Maximum Number of Darts Inside of a Circular Dartboard (Hard)](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") -

    You have a very large square wall and a circular dartboard placed on the wall. You have been challenged to throw darts into the board blindfolded. Darts thrown at the wall are represented as an array of points on a 2D plane. 

    +

    Alice is throwing n darts on a very large wall. You are given an array darts where darts[i] = [xi, yi] is the position of the ith dart that Alice threw on the wall.

    -

    Return the maximum number of points that are within or lie on any circular dartboard of radius r.

    +

    Bob knows the positions of the n darts on the wall. He wants to place a dartboard of radius r on the wall so that the maximum number of darts that Alice throws lies on the dartboard.

    + +

    Given the integer r, return the maximum number of darts that can lie on the dartboard.

     

    Example 1:

    - -

    - +
    -Input: points = [[-2,0],[2,0],[0,2],[0,-2]], r = 2
    +Input: darts = [[-2,0],[2,0],[0,2],[0,-2]], r = 2
     Output: 4
     Explanation: Circle dartboard with center in (0,0) and radius = 2 contain all points.
     

    Example 2:

    - -

    - +
    -Input: points = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5
    +Input: darts = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5
     Output: 5
     Explanation: Circle dartboard with center in (0,4) and radius = 5 contain all points except the point (7,8).
     
    -

    Example 3:

    - -
    -Input: points = [[-2,0],[2,0],[0,2],[0,-2]], r = 1
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: points = [[1,2],[3,5],[1,-1],[2,3],[4,1],[1,3]], r = 2
    -Output: 4
    -
    -

     

    Constraints:

      -
    • 1 <= points.length <= 100
    • -
    • points[i].length == 2
    • -
    • -10^4 <= points[i][0], points[i][1] <= 10^4
    • +
    • 1 <= darts.length <= 100
    • +
    • darts[i].length == 2
    • +
    • -104 <= xi, yi <= 104
    • 1 <= r <= 5000
    diff --git a/problems/maximum-number-of-eaten-apples/README.md b/problems/maximum-number-of-eaten-apples/README.md index 2e29bdaa3..4d83aebe7 100644 --- a/problems/maximum-number-of-eaten-apples/README.md +++ b/problems/maximum-number-of-eaten-apples/README.md @@ -45,16 +45,15 @@

    Constraints:

      -
    • apples.length == n
    • -
    • days.length == n
    • +
    • n == apples.length == days.length
    • 1 <= n <= 2 * 104
    • 0 <= apples[i], days[i] <= 2 * 104
    • days[i] = 0 if and only if apples[i] = 0.
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/maximum-number-of-events-that-can-be-attended/README.md b/problems/maximum-number-of-events-that-can-be-attended/README.md index 4559f8e33..1db35bebc 100644 --- a/problems/maximum-number-of-events-that-can-be-attended/README.md +++ b/problems/maximum-number-of-events-that-can-be-attended/README.md @@ -11,15 +11,15 @@ ## [1353. Maximum Number of Events That Can Be Attended (Medium)](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended "最多可以参加的会议数目") -

    Given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.

    +

    You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.

    -

    You can attend an event i at any day d where startTimei <= d <= endTimei. Notice that you can only attend one event at any time d.

    +

    You can attend an event i at any day d where startTimei <= d <= endTimei. You can only attend one event at any time d.

    -

    Return the maximum number of events you can attend.

    +

    Return the maximum number of events you can attend.

     

    Example 1:

    - +
     Input: events = [[1,2],[2,3],[3,4]]
     Output: 3
    @@ -37,27 +37,6 @@ Attend the third event on day 3.
     Output: 4
     
    -

    Example 3:

    - -
    -Input: events = [[1,4],[4,4],[2,2],[3,4],[1,1]]
    -Output: 4
    -
    - -

    Example 4:

    - -
    -Input: events = [[1,100000]]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: events = [[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7]]
    -Output: 7
    -
    -

     

    Constraints:

    @@ -68,14 +47,10 @@ Attend the third event on day 3. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] -### Similar Questions - 1. [Maximum Number of Events That Can Be Attended II](../maximum-number-of-events-that-can-be-attended-ii) (Hard) - 1. [Maximum Earnings From Taxi](../maximum-earnings-from-taxi) (Medium) - ### Hints
    Hint 1 diff --git a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md index 6f963ba4b..e7e645d7d 100644 --- a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md +++ b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md @@ -11,9 +11,7 @@ ## [1546. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target (Medium)](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值且不重叠的非空子数组的最大数目") -

    Given an array nums and an integer target.

    - -

    Return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.

    +

    Given an array nums and an integer target, return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.

     

    Example 1:

    @@ -21,7 +19,7 @@
     Input: nums = [1,1,1,1,1], target = 2
     Output: 2
    -Explanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2).
    +Explanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2).
     

    Example 2:

    @@ -29,36 +27,23 @@
     Input: nums = [-1,3,5,1,4,2,-9], target = 6
     Output: 2
    -Explanation: There are 3 subarrays with sum equal to 6.
    -([5,1], [4,2], [3,5,1,4,2,-9]) but only the first 2 are non-overlapping.
    - -

    Example 3:

    - -
    -Input: nums = [-2,6,6,3,5,4,1,2,8], target = 10
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: nums = [0,0,0], target = 0
    -Output: 3
    +Explanation: There are 3 subarrays with sum equal to 6.
    +([5,1], [4,2], [3,5,1,4,2,-9]) but only the first 2 are non-overlapping.
     

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • -10^4 <= nums[i] <= 10^4
    • -
    • 0 <= target <= 10^6
    • +
    • 1 <= nums.length <= 105
    • +
    • -104 <= nums[i] <= 104
    • +
    • 0 <= target <= 106
    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/problems/maximum-number-of-non-overlapping-substrings/README.md b/problems/maximum-number-of-non-overlapping-substrings/README.md index 4c57eba84..2fb424741 100644 --- a/problems/maximum-number-of-non-overlapping-substrings/README.md +++ b/problems/maximum-number-of-non-overlapping-substrings/README.md @@ -57,8 +57,8 @@ If we choose the first string, we cannot choose anything else and we'd get o ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-occurrences-of-a-substring/README.md b/problems/maximum-number-of-occurrences-of-a-substring/README.md index 3634859c2..c8a0ba0fb 100644 --- a/problems/maximum-number-of-occurrences-of-a-substring/README.md +++ b/problems/maximum-number-of-occurrences-of-a-substring/README.md @@ -11,11 +11,11 @@ ## [1297. Maximum Number of Occurrences of a Substring (Medium)](https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring "子串的最大出现次数") -

    Given a string s, return the maximum number of ocurrences of any substring under the following rules:

    +

    Given a string s, return the maximum number of ocurrences of any substring under the following rules:

    • The number of unique characters in the substring must be less than or equal to maxLetters.
    • -
    • The substring size must be between minSize and maxSize inclusive.
    • +
    • The substring size must be between minSize and maxSize inclusive.

     

    @@ -36,28 +36,14 @@ It satisfies the conditions, 2 unique letters and size 3 (between minSize and ma Explanation: Substring "aaa" occur 2 times in the string. It can overlap. -

    Example 3:

    - -
    -Input: s = "aabcabcab", maxLetters = 2, minSize = 2, maxSize = 3
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: s = "abcde", maxLetters = 2, minSize = 3, maxSize = 3
    -Output: 0
    -
    -

     

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • 1 <= maxLetters <= 26
    • 1 <= minSize <= maxSize <= min(26, s.length)
    • -
    • s only contains lowercase English letters.
    • +
    • s consists of only lowercase English letters.
    ### Related Topics diff --git a/problems/maximum-number-of-tasks-you-can-assign/README.md b/problems/maximum-number-of-tasks-you-can-assign/README.md index a917e8956..03bd179c2 100644 --- a/problems/maximum-number-of-tasks-you-can-assign/README.md +++ b/problems/maximum-number-of-tasks-you-can-assign/README.md @@ -52,19 +52,7 @@ We can assign the magical pills and tasks as follows: - Give the magical pill to worker 0 and worker 1. - Assign worker 0 to task 0 (0 + 10 >= 10) - Assign worker 1 to task 1 (10 + 10 >= 15) - - -

    Example 4:

    - -
    -Input: tasks = [5,9,8,5,9], workers = [1,6,4,2,6], pills = 1, strength = 5
    -Output: 3
    -Explanation:
    -We can assign the magical pill and tasks as follows:
    -- Give the magical pill to worker 2.
    -- Assign worker 1 to task 0 (6 >= 5)
    -- Assign worker 2 to task 2 (4 + 5 >= 8)
    -- Assign worker 4 to task 3 (6 >= 5)
    +The last pill is not given because it will not make any worker strong enough for the last task.
     

     

    diff --git a/problems/maximum-number-of-visible-points/README.md b/problems/maximum-number-of-visible-points/README.md index 1dcf62a62..f9401d886 100644 --- a/problems/maximum-number-of-visible-points/README.md +++ b/problems/maximum-number-of-visible-points/README.md @@ -62,11 +62,11 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Sorting](../../tag/sorting/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md b/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md index 8bc9d9ffb..0222974a8 100644 --- a/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md +++ b/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md @@ -11,11 +11,9 @@ ## [1456. Maximum Number of Vowels in a Substring of Given Length (Medium)](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length "定长子串中元音的最大数目") -

    Given a string s and an integer k.

    +

    Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.

    -

    Return the maximum number of vowel letters in any substring of s with length k.

    - -

    Vowel letters in English are (a, e, i, o, u).

    +

    Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.

     

    Example 1:

    @@ -42,27 +40,12 @@ Explanation: "lee", "eet" and "ode" contain 2 vowels. -

    Example 4:

    - -
    -Input: s = "rhythms", k = 4
    -Output: 0
    -Explanation: We can see that s doesn't have any vowel letters.
    -
    - -

    Example 5:

    - -
    -Input: s = "tryhard", k = 4
    -Output: 1
    -
    -

     

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • -
    • s consists of lowercase English letters.
    • +
    • 1 <= s.length <= 105
    • +
    • s consists of lowercase English letters.
    • 1 <= k <= s.length
    diff --git a/problems/maximum-number-of-weeks-for-which-you-can-work/README.md b/problems/maximum-number-of-weeks-for-which-you-can-work/README.md index 60f444ba4..406210336 100644 --- a/problems/maximum-number-of-weeks-for-which-you-can-work/README.md +++ b/problems/maximum-number-of-weeks-for-which-you-can-work/README.md @@ -68,8 +68,11 @@ Thus, one milestone in project 0 will remain unfinished. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Task Scheduler](../task-scheduler) (Medium) ### Hints
    diff --git a/problems/maximum-number-of-words-found-in-sentences/README.md b/problems/maximum-number-of-words-found-in-sentences/README.md new file mode 100644 index 000000000..38e5c6b31 --- /dev/null +++ b/problems/maximum-number-of-words-found-in-sentences/README.md @@ -0,0 +1,61 @@ + + + + + + + +[< Previous](../elements-in-array-after-removing-and-replacing-elements "Elements in Array After Removing and Replacing Elements") +                 +[Next >](../find-all-possible-recipes-from-given-supplies "Find All Possible Recipes from Given Supplies") + +## [2114. Maximum Number of Words Found in Sentences (Easy)](https://leetcode.com/problems/maximum-number-of-words-found-in-sentences "句子中的最多单词数") + +

    A sentence is a list of words that are separated by a single space with no leading or trailing spaces.

    + +

    You are given an array of strings sentences, where each sentences[i] represents a single sentence.

    + +

    Return the maximum number of words that appear in a single sentence.

    + +

     

    +

    Example 1:

    + +
    +Input: sentences = ["alice and bob love leetcode", "i think so too", "this is great thanks very much"]
    +Output: 6
    +Explanation: 
    +- The first sentence, "alice and bob love leetcode", has 5 words in total.
    +- The second sentence, "i think so too", has 4 words in total.
    +- The third sentence, "this is great thanks very much", has 6 words in total.
    +Thus, the maximum number of words in a single sentence comes from the third sentence, which has 6 words.
    +
    + +

    Example 2:

    + +
    +Input: sentences = ["please wait", "continue to fight", "continue to win"]
    +Output: 3
    +Explanation: It is possible that multiple sentences contain the same number of words. 
    +In this example, the second and third sentences (underlined) have the same number of words.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= sentences.length <= 100
    • +
    • 1 <= sentences[i].length <= 100
    • +
    • sentences[i] consists only of lowercase English letters and ' ' only.
    • +
    • sentences[i] does not have leading or trailing spaces.
    • +
    • All the words in sentences[i] are separated by a single space.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Process each sentence separately and count the number of words by looking for the number of space characters in the sentence and adding it by 1. +
    diff --git a/problems/maximum-path-quality-of-a-graph/README.md b/problems/maximum-path-quality-of-a-graph/README.md index de1176b46..9e6c3bbfd 100644 --- a/problems/maximum-path-quality-of-a-graph/README.md +++ b/problems/maximum-path-quality-of-a-graph/README.md @@ -47,18 +47,7 @@ The nodes visited are 0 and 3, giving a maximal path quality of 5 + 20 = 25. Output: 7 Explanation: One possible path is 0 -> 1 -> 3 -> 1 -> 0. The total time taken is 10 + 13 + 13 + 10 = 46 <= 50. -The nodes visited are 0, 1, and 3, giving a maximal path quality of 1 + 2 + 4 = 7. - -

    Example 4:

    - -

    - -
    -Input: values = [0,1,2], edges = [[1,2,10]], maxTime = 10
    -Output: 0
    -Explanation: 
    -The only path is 0. The total time taken is 0.
    -The only node visited is 0, giving a maximal path quality of 0.
    +The nodes visited are 0, 1, and 3, giving a maximal path quality of 1 + 2 + 4 = 7.
     

     

    diff --git a/problems/maximum-performance-of-a-team/README.md b/problems/maximum-performance-of-a-team/README.md index 4bf572f41..875210e17 100644 --- a/problems/maximum-performance-of-a-team/README.md +++ b/problems/maximum-performance-of-a-team/README.md @@ -62,6 +62,9 @@ We have the maximum performance of the team by selecting engineer 2 (with speed= [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] +### Similar Questions + 1. [Maximum Fruits Harvested After at Most K Steps](../maximum-fruits-harvested-after-at-most-k-steps) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-points-you-can-obtain-from-cards/README.md b/problems/maximum-points-you-can-obtain-from-cards/README.md index c5c74b84a..d01d36990 100644 --- a/problems/maximum-points-you-can-obtain-from-cards/README.md +++ b/problems/maximum-points-you-can-obtain-from-cards/README.md @@ -44,21 +44,6 @@ Explanation: You have to take all the cards. Your score is the sum of points of all cards. -

    Example 4:

    - -
    -Input: cardPoints = [1,1000,1], k = 1
    -Output: 1
    -Explanation: You cannot take the card in the middle. Your best score is 1. 
    -
    - -

    Example 5:

    - -
    -Input: cardPoints = [1,79,80,1,1,1,200,1], k = 3
    -Output: 202
    -
    -

     

    Constraints:

    @@ -70,8 +55,12 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Similar Questions + 1. [Maximum Score from Performing Multiplication Operations](../maximum-score-from-performing-multiplication-operations) (Medium) + 1. [Removing Minimum and Maximum From Array](../removing-minimum-and-maximum-from-array) (Medium) ### Hints
    diff --git a/problems/maximum-product-of-splitted-binary-tree/README.md b/problems/maximum-product-of-splitted-binary-tree/README.md index 0d7bea15e..aad097cb2 100644 --- a/problems/maximum-product-of-splitted-binary-tree/README.md +++ b/problems/maximum-product-of-splitted-binary-tree/README.md @@ -34,20 +34,6 @@ Explanation: Remove the red edge and get 2 binary trees with sum 15 and 6.Their product is 90 (15*6) -

    Example 3:

    - -
    -Input: root = [2,3,9,10,7,8,6,5,4,11,1]
    -Output: 1025
    -
    - -

    Example 4:

    - -
    -Input: root = [1,1]
    -Output: 1
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-product-of-word-lengths/README.md b/problems/maximum-product-of-word-lengths/README.md index 32a3e74c8..40fec0598 100644 --- a/problems/maximum-product-of-word-lengths/README.md +++ b/problems/maximum-product-of-word-lengths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-distance-from-all-buildings "Shortest Distance from All Buildings") diff --git a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md index f638ef1e3..0ef854aa3 100644 --- a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md +++ b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md @@ -21,7 +21,7 @@

     

    Example 1:

    - +
     Input: customers = [8,3], boardingCost = 5, runningCost = 6
     Output: 3
    @@ -29,7 +29,8 @@
     1. 8 customers arrive, 4 board and 4 wait for the next gondola, the wheel rotates. Current profit is 4 * $5 - 1 * $6 = $14.
     2. 3 customers arrive, the 4 waiting board the wheel and the other 3 wait, the wheel rotates. Current profit is 8 * $5 - 2 * $6 = $28.
     3. The final 3 customers board the gondola, the wheel rotates. Current profit is 11 * $5 - 3 * $6 = $37.
    -The highest profit was $37 after rotating the wheel 3 times.
    +The highest profit was $37 after rotating the wheel 3 times. +

    Example 2:

    @@ -45,7 +46,6 @@ The highest profit was $37 after rotating the wheel 3 times. 6. 4 board and 1 waits, the wheel rotates. Current profit is 24 * $6 - 6 * $4 = $120. 7. 1 boards, the wheel rotates. Current profit is 25 * $6 - 7 * $4 = $122. The highest profit was $122 after rotating the wheel 7 times. -

    Example 3:

    @@ -62,25 +62,6 @@ The highest profit was $122 after rotating the wheel 7 times. The profit was never positive, so return -1. -

    Example 4:

    - -
    -Input: customers = [10,10,6,4,7], boardingCost = 3, runningCost = 8
    -Output: 9
    -Explanation:
    -1. 10 customers arrive, 4 board and 6 wait, the wheel rotates. Current profit is 4 * $3 - 1 * $8 = $4.
    -2. 10 customers arrive, 4 board and 12 wait, the wheel rotates. Current profit is 8 * $3 - 2 * $8 = $8.
    -3. 6 customers arrive, 4 board and 14 wait, the wheel rotates. Current profit is 12 * $3 - 3 * $8 = $12.
    -4. 4 customers arrive, 4 board and 14 wait, the wheel rotates. Current profit is 16 * $3 - 4 * $8 = $16.
    -5. 7 customers arrive, 4 board and 17 wait, the wheel rotates. Current profit is 20 * $3 - 5 * $8 = $20.
    -6. 4 board and 13 wait, the wheel rotates. Current profit is 24 * $3 - 6 * $8 = $24.
    -7. 4 board and 9 wait, the wheel rotates. Current profit is 28 * $3 - 7 * $8 = $28.
    -8. 4 board and 5 wait, the wheel rotates. Current profit is 32 * $3 - 8 * $8 = $32.
    -9. 4 board and 1 waits, the wheel rotates. Current profit is 36 * $3 - 9 * $8 = $36.
    -10. 1 board and 0 wait, the wheel rotates. Current profit is 37 * $3 - 10 * $8 = $31.
    -The highest profit was $36 after rotating the wheel 9 times.
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-repeating-substring/README.md b/problems/maximum-repeating-substring/README.md index 96fe3070b..708d69560 100644 --- a/problems/maximum-repeating-substring/README.md +++ b/problems/maximum-repeating-substring/README.md @@ -53,9 +53,6 @@ [[String](../../tag/string/README.md)] [[String Matching](../../tag/string-matching/README.md)] -### Similar Questions - 1. [Detect Pattern of Length M Repeated K or More Times](../detect-pattern-of-length-m-repeated-k-or-more-times) (Easy) - ### Hints
    Hint 1 diff --git a/problems/maximum-running-time-of-n-computers/README.md b/problems/maximum-running-time-of-n-computers/README.md new file mode 100644 index 000000000..671f8e340 --- /dev/null +++ b/problems/maximum-running-time-of-n-computers/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../solving-questions-with-brainpower "Solving Questions With Brainpower") +                 +[Next >](../the-number-of-passengers-in-each-bus-i "The Number of Passengers in Each Bus I") + +## [2141. Maximum Running Time of N Computers (Hard)](https://leetcode.com/problems/maximum-running-time-of-n-computers "同时运行 N 台电脑的最长时间") + +

    You have n computers. You are given the integer n and a 0-indexed integer array batteries where the ith battery can run a computer for batteries[i] minutes. You are interested in running all n computers simultaneously using the given batteries.

    + +

    Initially, you can insert at most one battery into each computer. After that and at any integer time moment, you can remove a battery from a computer and insert another battery any number of times. The inserted battery can be a totally new battery or a battery from another computer. You may assume that the removing and inserting processes take no time.

    + +

    Note that the batteries cannot be recharged.

    + +

    Return the maximum number of minutes you can run all the n computers simultaneously.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 2, batteries = [3,3,3]
    +Output: 4
    +Explanation: 
    +Initially, insert battery 0 into the first computer and battery 1 into the second computer.
    +After two minutes, remove battery 1 from the second computer and insert battery 2 instead. Note that battery 1 can still run for one minute.
    +At the end of the third minute, battery 0 is drained, and you need to remove it from the first computer and insert battery 1 instead.
    +By the end of the fourth minute, battery 1 is also drained, and the first computer is no longer running.
    +We can run the two computers simultaneously for at most 4 minutes, so we return 4.
    +
    +
    + +

    Example 2:

    + +
    +Input: n = 2, batteries = [1,1,1,1]
    +Output: 2
    +Explanation: 
    +Initially, insert battery 0 into the first computer and battery 2 into the second computer. 
    +After one minute, battery 0 and battery 2 are drained so you need to remove them and insert battery 1 into the first computer and battery 3 into the second computer. 
    +After another minute, battery 1 and battery 3 are also drained so the first and second computers are no longer running.
    +We can run the two computers simultaneously for at most 2 minutes, so we return 2.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= batteries.length <= 105
    • +
    • 1 <= batteries[i] <= 109
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +For a given running time, can you determine if it is possible to run all n computers simultaneously? +
    + +
    +Hint 2 +Try to use Binary Search to find the maximal running time +
    diff --git a/problems/maximum-score-from-performing-multiplication-operations/README.md b/problems/maximum-score-from-performing-multiplication-operations/README.md index bc78098df..31175d357 100644 --- a/problems/maximum-score-from-performing-multiplication-operations/README.md +++ b/problems/maximum-score-from-performing-multiplication-operations/README.md @@ -64,6 +64,10 @@ The total score is 50 + 15 - 9 + 4 + 42 = 102. [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Maximum Points You Can Obtain from Cards](../maximum-points-you-can-obtain-from-cards) (Medium) + 1. [Stone Game VII](../stone-game-vii) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-score-from-removing-substrings/README.md b/problems/maximum-score-from-removing-substrings/README.md index 17c71631f..7fca866cd 100644 --- a/problems/maximum-score-from-removing-substrings/README.md +++ b/problems/maximum-score-from-removing-substrings/README.md @@ -58,9 +58,12 @@ Total score = 5 + 4 + 5 + 5 = 19. ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[String](../../tag/string/README.md)] + +### Similar Questions + 1. [Count Words Obtained After Adding a Letter](../count-words-obtained-after-adding-a-letter) (Medium) ### Hints
    diff --git a/problems/maximum-score-of-a-good-subarray/README.md b/problems/maximum-score-of-a-good-subarray/README.md index edeb34460..46c3d4d84 100644 --- a/problems/maximum-score-of-a-good-subarray/README.md +++ b/problems/maximum-score-of-a-good-subarray/README.md @@ -44,12 +44,15 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Stack](../../tag/stack/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] +### Similar Questions + 1. [Largest Rectangle in Histogram](../largest-rectangle-in-histogram) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-score-words-formed-by-letters/README.md b/problems/maximum-score-words-formed-by-letters/README.md index 97452e4ff..f2d0288bb 100644 --- a/problems/maximum-score-words-formed-by-letters/README.md +++ b/problems/maximum-score-words-formed-by-letters/README.md @@ -67,6 +67,9 @@ Letter "e" can only be used once. [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] +### Similar Questions + 1. [Maximum Good People Based on Statements](../maximum-good-people-based-on-statements) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-students-taking-exam/README.md b/problems/maximum-students-taking-exam/README.md index 3e752af5f..5b38f2519 100644 --- a/problems/maximum-students-taking-exam/README.md +++ b/problems/maximum-students-taking-exam/README.md @@ -65,11 +65,11 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bitmask](../../tag/bitmask/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/maximum-sum-bst-in-binary-tree/README.md b/problems/maximum-sum-bst-in-binary-tree/README.md index e74dca556..2cdd3f82f 100644 --- a/problems/maximum-sum-bst-in-binary-tree/README.md +++ b/problems/maximum-sum-bst-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-zigzag-path-in-a-binary-tree "Longest ZigZag Path in a Binary Tree") @@ -50,20 +50,6 @@ Explanation: All values are negatives. Return an empty BST. -

    Example 4:

    - -
    -Input: root = [2,1,3]
    -Output: 6
    -
    - -

    Example 5:

    - -
    -Input: root = [5,4,8,3,null,6,3]
    -Output: 7
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md b/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md index bc2d40939..f29094169 100644 --- a/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md +++ b/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../knight-probability-in-chessboard "Knight Probability in Chessboard") diff --git a/problems/maximum-twin-sum-of-a-linked-list/README.md b/problems/maximum-twin-sum-of-a-linked-list/README.md new file mode 100644 index 000000000..03df5b91f --- /dev/null +++ b/problems/maximum-twin-sum-of-a-linked-list/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../capitalize-the-title "Capitalize the Title") +                 +[Next >](../longest-palindrome-by-concatenating-two-letter-words "Longest Palindrome by Concatenating Two Letter Words") + +## [2130. Maximum Twin Sum of a Linked List (Medium)](https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list "链表最大孪生和") + +

    In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / 2) - 1.

    + +
      +
    • For example, if n = 4, then node 0 is the twin of node 3, and node 1 is the twin of node 2. These are the only nodes with twins for n = 4.
    • +
    + +

    The twin sum is defined as the sum of a node and its twin.

    + +

    Given the head of a linked list with even length, return the maximum twin sum of the linked list.

    + +

     

    +

    Example 1:

    + +
    +Input: head = [5,4,2,1]
    +Output: 6
    +Explanation:
    +Nodes 0 and 1 are the twins of nodes 3 and 2, respectively. All have twin sum = 6.
    +There are no other nodes with twins in the linked list.
    +Thus, the maximum twin sum of the linked list is 6. 
    +
    + +

    Example 2:

    + +
    +Input: head = [4,2,2,3]
    +Output: 7
    +Explanation:
    +The nodes with twins present in this linked list are:
    +- Node 0 is the twin of node 3 having a twin sum of 4 + 3 = 7.
    +- Node 1 is the twin of node 2 having a twin sum of 2 + 2 = 4.
    +Thus, the maximum twin sum of the linked list is max(7, 4) = 7. 
    +
    + +

    Example 3:

    + +
    +Input: head = [1,100000]
    +Output: 100001
    +Explanation:
    +There is only one node with a twin in the linked list having twin sum of 1 + 100000 = 100001.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is an even integer in the range [2, 105].
    • +
    • 1 <= Node.val <= 105
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +How can "reversing" a part of the linked list help find the answer? +
    + +
    +Hint 2 +We know that the nodes of the first half are twins of nodes in the second half, so try dividing the linked list in half and reverse the second half. +
    + +
    +Hint 3 +How can two pointers be used to find every twin sum optimally? +
    + +
    +Hint 4 +Use two different pointers pointing to the first nodes of the two halves of the linked list. The second pointer will point to the first node of the reversed half, which is the (n-1-i)th node in the original linked list. By moving both pointers forward at the same time, we find all twin sums. +
    diff --git a/problems/maximum-units-on-a-truck/README.md b/problems/maximum-units-on-a-truck/README.md index 3ead65713..e08582c6e 100644 --- a/problems/maximum-units-on-a-truck/README.md +++ b/problems/maximum-units-on-a-truck/README.md @@ -53,8 +53,8 @@ The total number of units will be = (1 * 3) + (2 * 2) + (1 * 1) = 8. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md index b41ba72a4..885b19f5f 100644 --- a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md +++ b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md @@ -51,8 +51,8 @@ There are no arrays that satisfy all the conditions and have nums[2] == 3, so 2 ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/mean-of-array-after-removing-some-elements/README.md b/problems/mean-of-array-after-removing-some-elements/README.md index 82a728f5a..a3838f31b 100644 --- a/problems/mean-of-array-after-removing-some-elements/README.md +++ b/problems/mean-of-array-after-removing-some-elements/README.md @@ -38,20 +38,6 @@ Output: 4.77778 -

    Example 4:

    - -
    -Input: arr = [9,7,8,7,7,8,4,4,6,8,8,7,6,8,8,9,2,6,0,0,1,10,8,6,3,3,5,1,10,9,0,7,10,0,10,4,1,10,6,9,3,6,0,0,2,7,0,6,7,2,9,7,7,3,0,1,6,1,10,3]
    -Output: 5.27778
    -
    - -

    Example 5:

    - -
    -Input: arr = [4,8,4,10,0,7,1,3,7,8,8,3,4,1,6,2,1,1,8,0,9,8,0,3,9,10,3,10,1,10,7,3,2,1,4,9,10,7,6,4,0,8,5,1,2,1,6,2,5,0,7,10,9,10,3,7,10,5,8,5,7,6,7,6,10,9,5,10,5,5,7,2,10,7,7,8,2,0,1,1]
    -Output: 5.29167
    -
    -

     

    Constraints:

    diff --git a/problems/meeting-rooms-ii/README.md b/problems/meeting-rooms-ii/README.md index e08daae7c..03636b0e5 100644 --- a/problems/meeting-rooms-ii/README.md +++ b/problems/meeting-rooms-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../meeting-rooms "Meeting Rooms") @@ -28,9 +28,9 @@

    NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/merge-bsts-to-create-single-bst/README.md b/problems/merge-bsts-to-create-single-bst/README.md index 63d8f9678..f8271915c 100644 --- a/problems/merge-bsts-to-create-single-bst/README.md +++ b/problems/merge-bsts-to-create-single-bst/README.md @@ -65,14 +65,6 @@ The resulting tree is shown above. This is the only valid operation that can be Explanation: It is impossible to perform any operations. -

    Example 4:

    - -
    -Input: trees = [[2,1,3]]
    -Output: [2,1,3]
    -Explanation: There is only one tree, and it is already a valid BST, so return its root.
    -
    -

     

    Constraints:

    diff --git a/problems/merge-in-between-linked-lists/README.md b/problems/merge-in-between-linked-lists/README.md index 246908775..2206ccda2 100644 --- a/problems/merge-in-between-linked-lists/README.md +++ b/problems/merge-in-between-linked-lists/README.md @@ -15,7 +15,7 @@

    Remove list1's nodes from the ath node to the bth node, and put list2 in their place.

    -

    The blue edges and nodes in the following figure incidate the result:

    +

    The blue edges and nodes in the following figure indicate the result:

    Build the result list and return its head.

    diff --git a/problems/merge-intervals/README.md b/problems/merge-intervals/README.md index d474da066..9a94b715c 100644 --- a/problems/merge-intervals/README.md +++ b/problems/merge-intervals/README.md @@ -53,3 +53,4 @@ 1. [Employee Free Time](../employee-free-time) (Hard) 1. [Partition Labels](../partition-labels) (Medium) 1. [Interval List Intersections](../interval-list-intersections) (Medium) + 1. [Amount of New Area Painted Each Day](../amount-of-new-area-painted-each-day) (Hard) diff --git a/problems/merge-strings-alternately/README.md b/problems/merge-strings-alternately/README.md index fa3b9c32b..27cb88935 100644 --- a/problems/merge-strings-alternately/README.md +++ b/problems/merge-strings-alternately/README.md @@ -61,6 +61,9 @@ merged: a p b q c d [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Zigzag Iterator](../zigzag-iterator) (Medium) + ### Hints
    Hint 1 diff --git a/problems/merge-triplets-to-form-target-triplet/README.md b/problems/merge-triplets-to-form-target-triplet/README.md index a2105787a..cc1c8f67d 100644 --- a/problems/merge-triplets-to-form-target-triplet/README.md +++ b/problems/merge-triplets-to-form-target-triplet/README.md @@ -31,7 +31,7 @@
     Input: triplets = [[2,5,3],[1,8,4],[1,7,5]], target = [2,7,5]
     Output: true
    -Explanation: Perform the following operations:
    +Explanation: Perform the following operations:
     - Choose the first and last triplets [[2,5,3],[1,8,4],[1,7,5]]. Update the last triplet to be [max(2,1), max(5,7), max(3,5)] = [2,7,5]. triplets = [[2,5,3],[1,8,4],[2,7,5]]
     The target triplet [2,7,5] is now an element of triplets.
     
    @@ -39,9 +39,9 @@ The target triplet [2,7,5] is now an element of triplets.

    Example 2:

    -Input: triplets = [[1,3,4],[2,5,8]], target = [2,5,8]
    -Output: true
    -Explanation: The target triplet [2,5,8] is already an element of triplets.
    +Input: triplets = [[3,4,5],[4,5,6]], target = [3,2,5]
    +Output: false
    +Explanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets.
     

    Example 3:

    @@ -55,14 +55,6 @@ The target triplet [2,7,5] is now an element of triplets. The target triplet [5,5,5] is now an element of triplets. -

    Example 4:

    - -
    -Input: triplets = [[3,4,5],[4,5,6]], target = [3,2,5]
    -Output: false
    -Explanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets.
    -
    -

     

    Constraints:

    diff --git a/problems/min-cost-to-connect-all-points/README.md b/problems/min-cost-to-connect-all-points/README.md index 6ad6e59f7..7cb2c19ad 100644 --- a/problems/min-cost-to-connect-all-points/README.md +++ b/problems/min-cost-to-connect-all-points/README.md @@ -11,22 +11,20 @@ ## [1584. Min Cost to Connect All Points (Medium)](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") -

    You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].

    +

    You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].

    -

    The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val.

    +

    The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val.

    -

    Return the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points.

    +

    Return the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points.

     

    Example 1:

    - -

    - +
     Input: points = [[0,0],[2,2],[3,10],[5,2],[7,0]]
     Output: 20
    -Explanation:
    -
    +Explanation: 
    +
     We can connect the points as shown above to get the minimum cost of 20.
     Notice that there is a unique path between every pair of points.
     
    @@ -38,41 +36,23 @@ Notice that there is a unique path between every pair of points. Output: 18 -

    Example 3:

    - -
    -Input: points = [[0,0],[1,1],[1,0],[-1,1]]
    -Output: 4
    -
    - -

    Example 4:

    - -
    -Input: points = [[-1000000,-1000000],[1000000,1000000]]
    -Output: 4000000
    -
    - -

    Example 5:

    - -
    -Input: points = [[0,0]]
    -Output: 0
    -
    -

     

    Constraints:

    • 1 <= points.length <= 1000
    • -
    • -106 <= xi, yi <= 106
    • +
    • -106 <= xi, yi <= 106
    • All pairs (xi, yi) are distinct.
    ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] + [[Union Find](../../tag/union-find/README.md)] [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] +### Similar Questions + 1. [Minimum Number of Lines to Cover Points](../minimum-number-of-lines-to-cover-points) (Medium) + ### Hints
    Hint 1 diff --git a/problems/mini-parser/README.md b/problems/mini-parser/README.md index 35d1f45d1..2a2884145 100644 --- a/problems/mini-parser/README.md +++ b/problems/mini-parser/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shuffle-an-array "Shuffle an Array") diff --git a/problems/minimize-deviation-in-array/README.md b/problems/minimize-deviation-in-array/README.md index 67f25aefa..9b41e74d4 100644 --- a/problems/minimize-deviation-in-array/README.md +++ b/problems/minimize-deviation-in-array/README.md @@ -66,10 +66,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimize-hamming-distance-after-swap-operations/README.md b/problems/minimize-hamming-distance-after-swap-operations/README.md index 56ca147c2..9a9482090 100644 --- a/problems/minimize-hamming-distance-after-swap-operations/README.md +++ b/problems/minimize-hamming-distance-after-swap-operations/README.md @@ -59,9 +59,12 @@ The Hamming distance of source and target is 2 as they differ in 2 positions: in ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] + +### Similar Questions + 1. [Smallest String With Swaps](../smallest-string-with-swaps) (Medium) ### Hints
    diff --git a/problems/minimum-absolute-difference/README.md b/problems/minimum-absolute-difference/README.md index 58e0d2f6b..a2d9fe276 100644 --- a/problems/minimum-absolute-difference/README.md +++ b/problems/minimum-absolute-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-to-build-blocks "Minimum Time to Build Blocks") @@ -11,14 +11,14 @@ ## [1200. Minimum Absolute Difference (Easy)](https://leetcode.com/problems/minimum-absolute-difference "最小绝对差") -

    Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements. 

    +

    Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.

    Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows

    • a, b are from arr
    • a < b
    • -
    • b - a equals to the minimum absolute difference of any two elements in arr
    • +
    • b - a equals to the minimum absolute difference of any two elements in arr

     

    @@ -47,14 +47,17 @@

    Constraints:

      -
    • 2 <= arr.length <= 10^5
    • -
    • -10^6 <= arr[i] <= 10^6
    • +
    • 2 <= arr.length <= 105
    • +
    • -106 <= arr[i] <= 106
    ### Related Topics [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Minimum Cost of Buying Candies With Discount](../minimum-cost-of-buying-candies-with-discount) (Easy) + ### Hints
    Hint 1 diff --git a/problems/minimum-add-to-make-parentheses-valid/README.md b/problems/minimum-add-to-make-parentheses-valid/README.md index b03b231d9..f22abd1a7 100644 --- a/problems/minimum-add-to-make-parentheses-valid/README.md +++ b/problems/minimum-add-to-make-parentheses-valid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-music-playlists "Number of Music Playlists") @@ -42,20 +42,6 @@ Output: 3 -

    Example 3:

    - -
    -Input: s = "()"
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: s = "()))(("
    -Output: 4
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md index 94852b978..2f7a8dce0 100644 --- a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md +++ b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md @@ -50,10 +50,14 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Similar Questions + 1. [Minimum Swaps to Group All 1's Together](../minimum-swaps-to-group-all-1s-together) (Medium) + 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) ### Hints
    diff --git a/problems/minimum-area-rectangle-ii/README.md b/problems/minimum-area-rectangle-ii/README.md index c8fc5d698..c413480e8 100644 --- a/problems/minimum-area-rectangle-ii/README.md +++ b/problems/minimum-area-rectangle-ii/README.md @@ -19,7 +19,7 @@

     

    Example 1:

    - +
     Input: points = [[1,2],[2,1],[1,0],[0,1]]
     Output: 2.00000
    @@ -27,7 +27,7 @@
     

    Example 2:

    - +
     Input: points = [[0,1],[2,1],[1,1],[1,0],[2,0]]
     Output: 1.00000
    @@ -35,21 +35,13 @@
     

    Example 3:

    - +
     Input: points = [[0,3],[1,2],[3,1],[1,3],[2,1]]
     Output: 0
     Explanation: There is no possible rectangle to form from these points.
     
    -

    Example 4:

    - -
    -Input: points = [[3,1],[1,1],[0,1],[2,1],[3,3],[3,2],[0,2],[2,3]]
    -Output: 2.00000
    -Explanation: The minimum area rectangle occurs at [2,1],[2,3],[3,3],[3,1], with an area of 2.
    -
    -

     

    Constraints:

    @@ -61,6 +53,6 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md b/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md new file mode 100644 index 000000000..49d80e975 --- /dev/null +++ b/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../minimum-number-of-buckets-required-to-collect-rainwater-from-houses "Minimum Number of Buckets Required to Collect Rainwater from Houses") +                 +[Next >](../count-fertile-pyramids-in-a-land "Count Fertile Pyramids in a Land") + +## [2087. Minimum Cost Homecoming of a Robot in a Grid (Medium)](https://leetcode.com/problems/minimum-cost-homecoming-of-a-robot-in-a-grid "网格图中机器人回家的最小代价") + +

    There is an m x n grid, where (0, 0) is the top-left cell and (m - 1, n - 1) is the bottom-right cell. You are given an integer array startPos where startPos = [startrow, startcol] indicates that initially, a robot is at the cell (startrow, startcol). You are also given an integer array homePos where homePos = [homerow, homecol] indicates that its home is at the cell (homerow, homecol).

    + +

    The robot needs to go to its home. It can move one cell in four directions: left, right, up, or down, and it can not move outside the boundary. Every move incurs some cost. You are further given two 0-indexed integer arrays: rowCosts of length m and colCosts of length n.

    + +
      +
    • If the robot moves up or down into a cell whose row is r, then this move costs rowCosts[r].
    • +
    • If the robot moves left or right into a cell whose column is c, then this move costs colCosts[c].
    • +
    + +

    Return the minimum total cost for this robot to return home.

    + +

     

    +

    Example 1:

    + +
    +Input: startPos = [1, 0], homePos = [2, 3], rowCosts = [5, 4, 3], colCosts = [8, 2, 6, 7]
    +Output: 18
    +Explanation: One optimal path is that:
    +Starting from (1, 0)
    +-> It goes down to (2, 0). This move costs rowCosts[2] = 3.
    +-> It goes right to (2, 1). This move costs colCosts[1] = 2.
    +-> It goes right to (2, 2). This move costs colCosts[2] = 6.
    +-> It goes right to (2, 3). This move costs colCosts[3] = 7.
    +The total cost is 3 + 2 + 6 + 7 = 18
    + +

    Example 2:

    + +
    +Input: startPos = [0, 0], homePos = [0, 0], rowCosts = [5], colCosts = [26]
    +Output: 0
    +Explanation: The robot is already at its home. Since no moves occur, the total cost is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == rowCosts.length
    • +
    • n == colCosts.length
    • +
    • 1 <= m, n <= 105
    • +
    • 0 <= rowCosts[r], colCosts[c] <= 104
    • +
    • startPos.length == 2
    • +
    • homePos.length == 2
    • +
    • 0 <= startrow, homerow < m
    • +
    • 0 <= startcol, homecol < n
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Irrespective of what path the robot takes, it will have to traverse all the rows between startRow and homeRow and all the columns between startCol and homeCol. +
    + +
    +Hint 2 +Hence, making any other move other than traversing the required rows and columns will potentially incur more cost which can be avoided. +
    diff --git a/problems/minimum-cost-of-buying-candies-with-discount/README.md b/problems/minimum-cost-of-buying-candies-with-discount/README.md new file mode 100644 index 000000000..f1b686fbd --- /dev/null +++ b/problems/minimum-cost-of-buying-candies-with-discount/README.md @@ -0,0 +1,100 @@ + + + + + + + +[< Previous](../choose-numbers-from-two-arrays-in-range "Choose Numbers From Two Arrays in Range") +                 +[Next >](../count-the-hidden-sequences "Count the Hidden Sequences") + +## [2144. Minimum Cost of Buying Candies With Discount (Easy)](https://leetcode.com/problems/minimum-cost-of-buying-candies-with-discount "打折购买糖果的最小开销") + +

    A shop is selling candies at a discount. For every two candies sold, the shop gives a third candy for free.

    + +

    The customer can choose any candy to take away for free as long as the cost of the chosen candy is less than or equal to the minimum cost of the two candies bought.

    + +
      +
    • For example, if there are 4 candies with costs 1, 2, 3, and 4, and the customer buys candies with costs 2 and 3, they can take the candy with cost 1 for free, but not the candy with cost 4.
    • +
    + +

    Given a 0-indexed integer array cost, where cost[i] denotes the cost of the ith candy, return the minimum cost of buying all the candies.

    + +

     

    +

    Example 1:

    + +
    +Input: cost = [1,2,3]
    +Output: 5
    +Explanation: We buy the candies with costs 2 and 3, and take the candy with cost 1 for free.
    +The total cost of buying all candies is 2 + 3 = 5. This is the only way we can buy the candies.
    +Note that we cannot buy candies with costs 1 and 3, and then take the candy with cost 2 for free.
    +The cost of the free candy has to be less than or equal to the minimum cost of the purchased candies.
    +
    + +

    Example 2:

    + +
    +Input: cost = [6,5,7,9,2,2]
    +Output: 23
    +Explanation: The way in which we can get the minimum cost is described below:
    +- Buy candies with costs 9 and 7
    +- Take the candy with cost 6 for free
    +- We buy candies with costs 5 and 2
    +- Take the last remaining candy with cost 2 for free
    +Hence, the minimum cost to buy all candies is 9 + 7 + 5 + 2 = 23.
    +
    + +

    Example 3:

    + +
    +Input: cost = [5,5]
    +Output: 10
    +Explanation: Since there are only 2 candies, we buy both of them. There is not a third candy we can take for free.
    +Hence, the minimum cost to buy all candies is 5 + 5 = 10.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= cost.length <= 100
    • +
    • 1 <= cost[i] <= 100
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +If we consider costs from high to low, what is the maximum cost of a single candy that we can get for free? +
    + +
    +Hint 2 +How can we generalize this approach to maximize the costs of the candies we get for free? +
    + +
    +Hint 3 +Can “sorting” the array help us find the minimum cost? +
    + +
    +Hint 4 +If we consider costs from high to low, what is the maximum cost of a single candy that we can get for free? +
    + +
    +Hint 5 +How can we generalize this approach to maximize the costs of the candies we get for free? +
    + +
    +Hint 6 +Can “sorting” the array help us find the minimum cost? +
    diff --git a/problems/minimum-cost-to-connect-two-groups-of-points/README.md b/problems/minimum-cost-to-connect-two-groups-of-points/README.md index fa8b8b06d..64c0a7e2b 100644 --- a/problems/minimum-cost-to-connect-two-groups-of-points/README.md +++ b/problems/minimum-cost-to-connect-two-groups-of-points/README.md @@ -62,11 +62,11 @@ Note that there are multiple points connected to point 2 in the first group and ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bitmask](../../tag/bitmask/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/minimum-cost-to-cut-a-stick/README.md b/problems/minimum-cost-to-cut-a-stick/README.md index bd27a000b..232a331a8 100644 --- a/problems/minimum-cost-to-cut-a-stick/README.md +++ b/problems/minimum-cost-to-cut-a-stick/README.md @@ -55,6 +55,9 @@ There are much ordering with total cost <= 25, for example, the order [4, 6, [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Number of Ways to Divide a Long Corridor](../number-of-ways-to-divide-a-long-corridor) (Hard) + ### Hints
    Hint 1 diff --git a/problems/minimum-cost-to-merge-stones/README.md b/problems/minimum-cost-to-merge-stones/README.md index da1b34bf4..8efb726aa 100644 --- a/problems/minimum-cost-to-merge-stones/README.md +++ b/problems/minimum-cost-to-merge-stones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../available-captures-for-rook "Available Captures for Rook") diff --git a/problems/minimum-cost-to-reach-city-with-discounts/README.md b/problems/minimum-cost-to-reach-city-with-discounts/README.md new file mode 100644 index 000000000..873df6d98 --- /dev/null +++ b/problems/minimum-cost-to-reach-city-with-discounts/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../find-all-people-with-secret "Find All People With Secret") +                 +[Next >](../finding-3-digit-even-numbers "Finding 3-Digit Even Numbers") + +## [2093. Minimum Cost to Reach City With Discounts (Medium)](https://leetcode.com/problems/minimum-cost-to-reach-city-with-discounts "") + + + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + +### Hints +
    +Hint 1 +Try to construct a graph out of highways. What type of graph is this? +
    + +
    +Hint 2 +We essentially need to find the minimum distance to get from node 0 to node n - 1 in an undirected weighted graph. What algorithm should we use to do this? +
    + +
    +Hint 3 +Use Dijkstra's algorithm to find the minimum weight path. Keep track of the minimum distance to each vertex with d discounts left +
    diff --git a/problems/minimum-cost-to-reach-destination-in-time/README.md b/problems/minimum-cost-to-reach-destination-in-time/README.md index 73dbdb11c..d2bc9797e 100644 --- a/problems/minimum-cost-to-reach-destination-in-time/README.md +++ b/problems/minimum-cost-to-reach-destination-in-time/README.md @@ -65,8 +65,12 @@ You cannot take path 0 -> 1 -> 2 -> 5 since it would take too long. ### Related Topics - [[Graph](../../tag/graph/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Graph](../../tag/graph/README.md)] + +### Similar Questions + 1. [Maximum Path Quality of a Graph](../maximum-path-quality-of-a-graph) (Hard) + 1. [Minimum Cost to Reach City With Discounts](../minimum-cost-to-reach-city-with-discounts) (Medium) ### Hints
    diff --git a/problems/minimum-cost-to-separate-sentence-into-rows/README.md b/problems/minimum-cost-to-separate-sentence-into-rows/README.md index 36029ae69..559bc0df4 100644 --- a/problems/minimum-cost-to-separate-sentence-into-rows/README.md +++ b/problems/minimum-cost-to-separate-sentence-into-rows/README.md @@ -9,7 +9,7 @@                  [Next >](../kth-distinct-string-in-an-array "Kth Distinct String in an Array") -## [2052. Minimum Cost to Separate Sentence Into Rows (Medium)](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows "") +## [2052. Minimum Cost to Separate Sentence Into Rows (Medium)](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows "将句子分隔成行的最低成本") diff --git a/problems/minimum-cost-to-set-cooking-time/README.md b/problems/minimum-cost-to-set-cooking-time/README.md new file mode 100644 index 000000000..c3235cd38 --- /dev/null +++ b/problems/minimum-cost-to-set-cooking-time/README.md @@ -0,0 +1,98 @@ + + + + + + + +[< Previous](../partition-array-according-to-given-pivot "Partition Array According to Given Pivot") +                 +[Next >](../minimum-difference-in-sums-after-removal-of-elements "Minimum Difference in Sums After Removal of Elements") + +## [2162. Minimum Cost to Set Cooking Time (Medium)](https://leetcode.com/problems/minimum-cost-to-set-cooking-time "设置时间的最少代价") + +

    A generic microwave supports cooking times for:

    + +
      +
    • at least 1 second.
    • +
    • at most 99 minutes and 99 seconds.
    • +
    + +

    To set the cooking time, you push at most four digits. The microwave normalizes what you push as four digits by prepending zeroes. It interprets the first two digits as the minutes and the last two digits as the seconds. It then adds them up as the cooking time. For example,

    + +
      +
    • You push 9 5 4 (three digits). It is normalized as 0954 and interpreted as 9 minutes and 54 seconds.
    • +
    • You push 0 0 0 8 (four digits). It is interpreted as 0 minutes and 8 seconds.
    • +
    • You push 8 0 9 0. It is interpreted as 80 minutes and 90 seconds.
    • +
    • You push 8 1 3 0. It is interpreted as 81 minutes and 30 seconds.
    • +
    + +

    You are given integers startAt, moveCost, pushCost, and targetSeconds. Initially, your finger is on the digit startAt. Moving the finger above any specific digit costs moveCost units of fatigue. Pushing the digit below the finger once costs pushCost units of fatigue.

    + +

    There can be multiple ways to set the microwave to cook for targetSeconds seconds but you are interested in the way with the minimum cost.

    + +

    Return the minimum cost to set targetSeconds seconds of cooking time.

    + +

    Remember that one minute consists of 60 seconds.

    + +

     

    +

    Example 1:

    + +
    +Input: startAt = 1, moveCost = 2, pushCost = 1, targetSeconds = 600
    +Output: 6
    +Explanation: The following are the possible ways to set the cooking time.
    +- 1 0 0 0, interpreted as 10 minutes and 0 seconds.
    +  The finger is already on digit 1, pushes 1 (with cost 1), moves to 0 (with cost 2), pushes 0 (with cost 1), pushes 0 (with cost 1), and pushes 0 (with cost 1).
    +  The cost is: 1 + 2 + 1 + 1 + 1 = 6. This is the minimum cost.
    +- 0 9 6 0, interpreted as 9 minutes and 60 seconds. That is also 600 seconds.
    +  The finger moves to 0 (with cost 2), pushes 0 (with cost 1), moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1).
    +  The cost is: 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 = 12.
    +- 9 6 0, normalized as 0960 and interpreted as 9 minutes and 60 seconds.
    +  The finger moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1).
    +  The cost is: 2 + 1 + 2 + 1 + 2 + 1 = 9.
    +
    + +

    Example 2:

    + +
    +Input: startAt = 0, moveCost = 1, pushCost = 2, targetSeconds = 76
    +Output: 6
    +Explanation: The optimal way is to push two digits: 7 6, interpreted as 76 seconds.
    +The finger moves to 7 (with cost 1), pushes 7 (with cost 2), moves to 6 (with cost 1), and pushes 6 (with cost 2). The total cost is: 1 + 2 + 1 + 2 = 6
    +Note other possible ways are 0076, 076, 0116, and 116, but none of them produces the minimum cost.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= startAt <= 9
    • +
    • 1 <= moveCost, pushCost <= 105
    • +
    • 1 <= targetSeconds <= 6039
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + +### Hints +
    +Hint 1 +Define a separate function Cost(mm, ss) where 0 <= mm <= 99 and 0 <= ss <= 99. This function should calculate the cost of setting the cocking time to mm minutes and ss seconds +
    + +
    +Hint 2 +The range of the minutes is small (i.e., [0, 99]), how can you use that? +
    + +
    +Hint 3 +For every mm in [0, 99], calculate the needed ss to make mm:ss equal to targetSeconds and minimize the cost of setting the cocking time to mm:ss +
    + +
    +Hint 4 +Be careful in some cases when ss is not in the valid range [0, 99]. +
    diff --git a/problems/minimum-deletions-to-make-string-balanced/README.md b/problems/minimum-deletions-to-make-string-balanced/README.md index ced0f75da..32083314e 100644 --- a/problems/minimum-deletions-to-make-string-balanced/README.md +++ b/problems/minimum-deletions-to-make-string-balanced/README.md @@ -49,6 +49,9 @@ Delete the characters at 0-indexed positions 3 and 6 ("aababba Hint 1 diff --git a/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md b/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md index e33c271fd..f53074997 100644 --- a/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md +++ b/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md @@ -53,6 +53,7 @@ The minimum possible difference is 2. ### Related Topics [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md index b999215c1..4c51853a1 100644 --- a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md +++ b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md @@ -11,9 +11,9 @@ ## [1509. Minimum Difference Between Largest and Smallest Value in Three Moves (Medium)](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") -

    Given an array nums, you are allowed to choose one element of nums and change it by any value in one move.

    +

    You are given an integer array nums. In one move, you can choose one element of nums and change it by any value.

    -

    Return the minimum difference between the largest and smallest value of nums after perfoming at most 3 moves.

    +

    Return the minimum difference between the largest and smallest value of nums after performing at most three moves.

     

    Example 1:

    @@ -22,7 +22,8 @@ Input: nums = [5,3,2,4] Output: 0 Explanation: Change the array [5,3,2,4] to [2,2,2,2]. -The difference between the maximum and minimum is 2-2 = 0. +The difference between the maximum and minimum is 2-2 = 0. +

    Example 2:

    @@ -33,26 +34,12 @@ The difference between the maximum and minimum is 2-2 = 0. The difference between the maximum and minimum is 1-0 = 1. -

    Example 3:

    - -
    -Input: nums = [6,6,0,1,1,4,6]
    -Output: 2
    -
    - -

    Example 4:

    - -
    -Input: nums = [1,5,6,14,15]
    -Output: 1
    -
    -

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • -10^9 <= nums[i] <= 10^9
    • +
    • 1 <= nums.length <= 105
    • +
    • -109 <= nums[i] <= 109
    ### Related Topics diff --git a/problems/minimum-difference-in-sums-after-removal-of-elements/README.md b/problems/minimum-difference-in-sums-after-removal-of-elements/README.md new file mode 100644 index 000000000..9daf25991 --- /dev/null +++ b/problems/minimum-difference-in-sums-after-removal-of-elements/README.md @@ -0,0 +1,90 @@ + + + + + + + +[< Previous](../minimum-cost-to-set-cooking-time "Minimum Cost to Set Cooking Time") +                 +[Next >](../sort-even-and-odd-indices-independently "Sort Even and Odd Indices Independently") + +## [2163. Minimum Difference in Sums After Removal of Elements (Hard)](https://leetcode.com/problems/minimum-difference-in-sums-after-removal-of-elements "删除元素后和的最小差值") + +

    You are given a 0-indexed integer array nums consisting of 3 * n elements.

    + +

    You are allowed to remove any subsequence of elements of size exactly n from nums. The remaining 2 * n elements will be divided into two equal parts:

    + +
      +
    • The first n elements belonging to the first part and their sum is sumfirst.
    • +
    • The next n elements belonging to the second part and their sum is sumsecond.
    • +
    + +

    The difference in sums of the two parts is denoted as sumfirst - sumsecond.

    + +
      +
    • For example, if sumfirst = 3 and sumsecond = 2, their difference is 1.
    • +
    • Similarly, if sumfirst = 2 and sumsecond = 3, their difference is -1.
    • +
    + +

    Return the minimum difference possible between the sums of the two parts after the removal of n elements.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,1,2]
    +Output: -1
    +Explanation: Here, nums has 3 elements, so n = 1. 
    +Thus we have to remove 1 element from nums and divide the array into two equal parts.
    +- If we remove nums[0] = 3, the array will be [1,2]. The difference in sums of the two parts will be 1 - 2 = -1.
    +- If we remove nums[1] = 1, the array will be [3,2]. The difference in sums of the two parts will be 3 - 2 = 1.
    +- If we remove nums[2] = 2, the array will be [3,1]. The difference in sums of the two parts will be 3 - 1 = 2.
    +The minimum difference between sums of the two parts is min(-1,1,2) = -1. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [7,9,5,8,1,3]
    +Output: 1
    +Explanation: Here n = 2. So we must remove 2 elements and divide the remaining array into two parts containing two elements each.
    +If we remove nums[2] = 5 and nums[3] = 8, the resultant array will be [7,9,1,3]. The difference in sums will be (7+9) - (1+3) = 12.
    +To obtain the minimum difference, we should remove nums[1] = 9 and nums[4] = 1. The resultant array becomes [7,5,8,3]. The difference in sums of the two parts is (7+5) - (8+3) = 1.
    +It can be shown that it is not possible to obtain a difference smaller than 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • nums.length == 3 * n
    • +
    • 1 <= n <= 105
    • +
    • 1 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +The lowest possible difference can be obtained when the sum of the first n elements in the resultant array is minimum, and the sum of the next n elements is maximum. +
    + +
    +Hint 2 +For every index i, think about how you can find the minimum possible sum of n elements with indices lesser or equal to i, if possible. +
    + +
    +Hint 3 +Similarly, for every index i, try to find the maximum possible sum of n elements with indices greater or equal to i, if possible. +
    + +
    +Hint 4 +Now for all indices, check if we can consider it as the partitioning index and hence find the answer. +
    diff --git a/problems/minimum-difficulty-of-a-job-schedule/README.md b/problems/minimum-difficulty-of-a-job-schedule/README.md index 1dcb96035..7367d9f71 100644 --- a/problems/minimum-difficulty-of-a-job-schedule/README.md +++ b/problems/minimum-difficulty-of-a-job-schedule/README.md @@ -11,13 +11,13 @@ ## [1335. Minimum Difficulty of a Job Schedule (Hard)](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule "工作计划的最低难度") -

    You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the i-th job, you have to finish all the jobs j where 0 <= j < i).

    +

    You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the ith job, you have to finish all the jobs j where 0 <= j < i).

    -

    You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done in that day.

    +

    You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done on that day.

    -

    Given an array of integers jobDifficulty and an integer d. The difficulty of the i-th job is jobDifficulty[i].

    +

    You are given an integer array jobDifficulty and an integer d. The difficulty of the ith job is jobDifficulty[i].

    -

    Return the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.

    +

    Return the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.

     

    Example 1:

    @@ -46,20 +46,6 @@ The difficulty of the schedule = 6 + 1 = 7 Explanation: The schedule is one job per day. total difficulty will be 3. -

    Example 4:

    - -
    -Input: jobDifficulty = [7,1,7,1,7,1], d = 3
    -Output: 15
    -
    - -

    Example 5:

    - -
    -Input: jobDifficulty = [11,111,22,222,33,333,44,444], d = 6
    -Output: 843
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md index b519e4090..48841f1ad 100644 --- a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md +++ b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md @@ -30,8 +30,7 @@
     Input: word = "CAKE"
     Output: 3
    -Explanation: 
    -Using two fingers, one optimal way to type "CAKE" is: 
    +Explanation: Using two fingers, one optimal way to type "CAKE" is: 
     Finger 1 on letter 'C' -> cost = 0 
     Finger 1 on letter 'A' -> cost = Distance from letter 'C' to letter 'A' = 2 
     Finger 2 on letter 'K' -> cost = 0 
    @@ -44,8 +43,7 @@ Total distance = 3
     
     Input: word = "HAPPY"
     Output: 6
    -Explanation: 
    -Using two fingers, one optimal way to type "HAPPY" is:
    +Explanation: Using two fingers, one optimal way to type "HAPPY" is:
     Finger 1 on letter 'H' -> cost = 0
     Finger 1 on letter 'A' -> cost = Distance from letter 'H' to letter 'A' = 2
     Finger 2 on letter 'P' -> cost = 0
    @@ -54,20 +52,6 @@ Finger 1 on letter 'Y' -> cost = Distance from letter 'A' to
     Total distance = 6
     
    -

    Example 3:

    - -
    -Input: word = "NEW"
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: word = "YEAR"
    -Output: 7
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-domino-rotations-for-equal-row/README.md b/problems/minimum-domino-rotations-for-equal-row/README.md index 63b5a53a9..70e13dd34 100644 --- a/problems/minimum-domino-rotations-for-equal-row/README.md +++ b/problems/minimum-domino-rotations-for-equal-row/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clumsy-factorial "Clumsy Factorial") @@ -49,5 +49,5 @@ In this case, it is not possible to rotate the dominoes to make one row of value ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md index dfbb7e274..1bad5bcd5 100644 --- a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md +++ b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md @@ -44,8 +44,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-falling-path-sum-ii/README.md b/problems/minimum-falling-path-sum-ii/README.md index d0c06f521..446fbe15c 100644 --- a/problems/minimum-falling-path-sum-ii/README.md +++ b/problems/minimum-falling-path-sum-ii/README.md @@ -50,6 +50,9 @@ The falling path with the smallest sum is [1,5,7], so the answer is 13 [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Minimum Falling Path Sum](../minimum-falling-path-sum) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-falling-path-sum/README.md b/problems/minimum-falling-path-sum/README.md index 9e7856ffb..cbd4580c6 100644 --- a/problems/minimum-falling-path-sum/README.md +++ b/problems/minimum-falling-path-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-subarrays-with-sum "Binary Subarrays With Sum") diff --git a/problems/minimum-genetic-mutation/README.md b/problems/minimum-genetic-mutation/README.md index 906685cc7..464225609 100644 --- a/problems/minimum-genetic-mutation/README.md +++ b/problems/minimum-genetic-mutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-oone-data-structure "All O`one Data Structure") diff --git a/problems/minimum-incompatibility/README.md b/problems/minimum-incompatibility/README.md index cb789c363..8cce8ee4d 100644 --- a/problems/minimum-incompatibility/README.md +++ b/problems/minimum-incompatibility/README.md @@ -56,9 +56,9 @@ The incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Hints diff --git a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md index db3e86945..4dea8e463 100644 --- a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md +++ b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md @@ -42,26 +42,12 @@ Explanation: Inserting 5 characters the string becomes "leetcodocteel".
    -

    Example 4:

    - -
    -Input: s = "g"
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: s = "no"
    -Output: 1
    -
    -

     

    Constraints:

    • 1 <= s.length <= 500
    • -
    • All characters of s are lower case English letters.
    • +
    • s consists of lowercase English letters.
    ### Related Topics diff --git a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md index 3fd4fb5b2..ee880867b 100644 --- a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md +++ b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md @@ -14,13 +14,15 @@

    Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if:

      -
    • Any left parenthesis '(' must have a corresponding two consecutive right parenthesis '))'.
    • -
    • Left parenthesis '(' must go before the corresponding two consecutive right parenthesis '))'.
    • +
    • Any left parenthesis '(' must have a corresponding two consecutive right parenthesis '))'.
    • +
    • Left parenthesis '(' must go before the corresponding two consecutive right parenthesis '))'.
    -

    In other words, we treat '(' as openning parenthesis and '))' as closing parenthesis.

    +

    In other words, we treat '(' as an opening parenthesis and '))' as a closing parenthesis.

    -

    For example, "())", "())(())))" and "(())())))" are balanced, ")()", "()))" and "(()))" are not balanced.

    +
      +
    • For example, "())", "())(())))" and "(())())))" are balanced, ")()", "()))" and "(()))" are not balanced.
    • +

    You can insert the characters '(' and ')' at any position of the string to balance it if needed.

    @@ -51,27 +53,11 @@ Explanation: Add '(' to match the first '))', Add '))' to match the last '('. -

    Example 4:

    - -
    -Input: s = "(((((("
    -Output: 12
    -Explanation: Add 12 ')' to balance the string.
    -
    - -

    Example 5:

    - -
    -Input: s = ")))))))"
    -Output: 5
    -Explanation: Add 4 '(' at the beginning of the string and one ')' at the end. The string becomes "(((())))))))".
    -
    -

     

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • s consists of '(' and ')' only.
    diff --git a/problems/minimum-interval-to-include-each-query/README.md b/problems/minimum-interval-to-include-each-query/README.md index 4cfe2d11c..f9a6134b5 100644 --- a/problems/minimum-interval-to-include-each-query/README.md +++ b/problems/minimum-interval-to-include-each-query/README.md @@ -56,8 +56,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Sorting](../../tag/sorting/README.md)] [[Line Sweep](../../tag/line-sweep/README.md)] + [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/minimum-jumps-to-reach-home/README.md b/problems/minimum-jumps-to-reach-home/README.md index d9e52ef2a..5f74939af 100644 --- a/problems/minimum-jumps-to-reach-home/README.md +++ b/problems/minimum-jumps-to-reach-home/README.md @@ -62,9 +62,9 @@ ### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md index 486ed61bd..34b543908 100644 --- a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md +++ b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md @@ -30,26 +30,26 @@

     

    Example 1:

    - +
     Input: grid = [["#","#","#","#","#","#"],
                    ["#","T","#","#","#","#"],
    -               ["#",".",".","B",".","#"],
    -               ["#",".","#","#",".","#"],
    -               ["#",".",".",".","S","#"],
    -               ["#","#","#","#","#","#"]]
    +               ["#",".",".","B",".","#"],
    +               ["#",".","#","#",".","#"],
    +               ["#",".",".",".","S","#"],
    +               ["#","#","#","#","#","#"]]
     Output: 3
    -Explanation: We return only the number of times the box is pushed.
    +Explanation: We return only the number of times the box is pushed.

    Example 2:

     Input: grid = [["#","#","#","#","#","#"],
                    ["#","T","#","#","#","#"],
    -               ["#",".",".","B",".","#"],
    -               ["#","#","#","#",".","#"],
    -               ["#",".",".",".","S","#"],
    -               ["#","#","#","#","#","#"]]
    +               ["#",".",".","B",".","#"],
    +               ["#","#","#","#",".","#"],
    +               ["#",".",".",".","S","#"],
    +               ["#","#","#","#","#","#"]]
     Output: -1
     
    @@ -57,22 +57,13 @@
     Input: grid = [["#","#","#","#","#","#"],
    -               ["#","T",".",".","#","#"],
    -               ["#",".","#","B",".","#"],
    -               ["#",".",".",".",".","#"],
    -               ["#",".",".",".","S","#"],
    -               ["#","#","#","#","#","#"]]
    +               ["#","T",".",".","#","#"],
    +               ["#",".","#","B",".","#"],
    +               ["#",".",".",".",".","#"],
    +               ["#",".",".",".","S","#"],
    +               ["#","#","#","#","#","#"]]
     Output: 5
    -Explanation:  push the box down, left, left, up and up.
    -
    - -

    Example 4:

    - -
    -Input: grid = [["#","#","#","#","#","#","#"],
    -               ["#","S","#",".","B","T","#"],
    -               ["#","#","#","#","#","#","#"]]
    -Output: -1
    +Explanation: push the box down, left, left, up and up.
     

     

    diff --git a/problems/minimum-moves-to-reach-target-score/README.md b/problems/minimum-moves-to-reach-target-score/README.md new file mode 100644 index 000000000..03f9395f4 --- /dev/null +++ b/problems/minimum-moves-to-reach-target-score/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../divide-a-string-into-groups-of-size-k "Divide a String Into Groups of Size k") +                 +[Next >](../solving-questions-with-brainpower "Solving Questions With Brainpower") + +## [2139. Minimum Moves to Reach Target Score (Medium)](https://leetcode.com/problems/minimum-moves-to-reach-target-score "得到目标值的最少行动次数") + +

    You are playing a game with integers. You start with the integer 1 and you want to reach the integer target.

    + +

    In one move, you can either:

    + +
      +
    • Increment the current integer by one (i.e., x = x + 1).
    • +
    • Double the current integer (i.e., x = 2 * x).
    • +
    + +

    You can use the increment operation any number of times, however, you can only use the double operation at most maxDoubles times.

    + +

    Given the two integers target and maxDoubles, return the minimum number of moves needed to reach target starting with 1.

    + +

     

    +

    Example 1:

    + +
    +Input: target = 5, maxDoubles = 0
    +Output: 4
    +Explanation: Keep incrementing by 1 until you reach target.
    +
    + +

    Example 2:

    + +
    +Input: target = 19, maxDoubles = 2
    +Output: 7
    +Explanation: Initially, x = 1
    +Increment 3 times so x = 4
    +Double once so x = 8
    +Increment once so x = 9
    +Double again so x = 18
    +Increment once so x = 19
    +
    + +

    Example 3:

    + +
    +Input: target = 10, maxDoubles = 4
    +Output: 4
    +Explanation: Initially, x = 1
    +Increment once so x = 2
    +Double once so x = 4
    +Increment once so x = 5
    +Double again so x = 10
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= target <= 109
    • +
    • 0 <= maxDoubles <= 100
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Solve the opposite problem: start at the given score and move to 1. +
    + +
    +Hint 2 +It is better to use the move of the second type once we can to lose more scores fast. +
    diff --git a/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses/README.md b/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses/README.md new file mode 100644 index 000000000..8a0798f2f --- /dev/null +++ b/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../count-common-words-with-one-occurrence "Count Common Words With One Occurrence") +                 +[Next >](../minimum-cost-homecoming-of-a-robot-in-a-grid "Minimum Cost Homecoming of a Robot in a Grid") + +## [2086. Minimum Number of Buckets Required to Collect Rainwater from Houses (Medium)](https://leetcode.com/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses "从房屋收集雨水需要的最少水桶数") + +

    You are given a 0-indexed string street. Each character in street is either 'H' representing a house or '.' representing an empty space.

    + +

    You can place buckets on the empty spaces to collect rainwater that falls from the adjacent houses. The rainwater from a house at index i is collected if a bucket is placed at index i - 1 and/or index i + 1. A single bucket, if placed adjacent to two houses, can collect the rainwater from both houses.

    + +

    Return the minimum number of buckets needed so that for every house, there is at least one bucket collecting rainwater from it, or -1 if it is impossible.

    + +

     

    +

    Example 1:

    + +
    +Input: street = "H..H"
    +Output: 2
    +Explanation:
    +We can put buckets at index 1 and index 2.
    +"H..H" -> "HBBH" ('B' denotes where a bucket is placed).
    +The house at index 0 has a bucket to its right, and the house at index 3 has a bucket to its left.
    +Thus, for every house, there is at least one bucket collecting rainwater from it.
    +
    + +

    Example 2:

    + +
    +Input: street = ".H.H."
    +Output: 1
    +Explanation:
    +We can put a bucket at index 2.
    +".H.H." -> ".HBH." ('B' denotes where a bucket is placed).
    +The house at index 1 has a bucket to its right, and the house at index 3 has a bucket to its left.
    +Thus, for every house, there is at least one bucket collecting rainwater from it.
    +
    + +

    Example 3:

    + +
    +Input: street = ".HHH."
    +Output: -1
    +Explanation:
    +There is no empty space to place a bucket to collect the rainwater from the house at index 2.
    +Thus, it is impossible to collect the rainwater from all the houses.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= street.length <= 105
    • +
    • street[i] is either'H' or '.'.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +When is it impossible to collect the rainwater from all the houses? +
    + +
    +Hint 2 +When one or more houses do not have an empty space adjacent to it. +
    + +
    +Hint 3 +Assuming the rainwater from all previous houses is collected. If there is a house at index i and you are able to place a bucket at index i - 1 or i + 1, where should you put it? +
    + +
    +Hint 4 +It is always better to place a bucket at index i + 1 because it can collect the rainwater from the next house as well. +
    diff --git a/problems/minimum-number-of-days-to-disconnect-island/README.md b/problems/minimum-number-of-days-to-disconnect-island/README.md index 26163ef0f..2f96201d0 100644 --- a/problems/minimum-number-of-days-to-disconnect-island/README.md +++ b/problems/minimum-number-of-days-to-disconnect-island/README.md @@ -11,73 +11,47 @@ ## [1568. Minimum Number of Days to Disconnect Island (Hard)](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") -

    Given a 2D grid consisting of 1s (land) and 0s (water).  An island is a maximal 4-directionally (horizontal or vertical) connected group of 1s.

    +

    You are given an m x n binary grid grid where 1 represents land and 0 represents water. An island is a maximal 4-directionally (horizontal or vertical) connected group of 1's.

    -

    The grid is said to be connected if we have exactly one island, otherwise is said disconnected.

    +

    The grid is said to be connected if we have exactly one island, otherwise is said disconnected.

    In one day, we are allowed to change any single land cell (1) into a water cell (0).

    -

    Return the minimum number of days to disconnect the grid.

    +

    Return the minimum number of days to disconnect the grid.

     

    Example 1:

    - -

    - +
     Input: grid = [[0,1,1,0],[0,1,1,0],[0,0,0,0]]
    +
     Output: 2
     Explanation: We need at least 2 days to get a disconnected grid.
     Change land grid[1][1] and grid[0][2] to water and get 2 disconnected island.
     

    Example 2:

    - +
     Input: grid = [[1,1]]
     Output: 2
    -Explanation: Grid of full water is also disconnected ([[1,1]] -> [[0,0]]), 0 islands.
    -
    - -

    Example 3:

    - -
    -Input: grid = [[1,0,1,0]]
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: grid = [[1,1,0,1,1],
    -               [1,1,1,1,1],
    -               [1,1,0,1,1],
    -               [1,1,0,1,1]]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: grid = [[1,1,0,1,1],
    -               [1,1,1,1,1],
    -               [1,1,0,1,1],
    -               [1,1,1,1,1]]
    -Output: 2
    +Explanation: Grid of full water is also disconnected ([[1,1]] -> [[0,0]]), 0 islands.
     

     

    Constraints:

      -
    • 1 <= grid.length, grid[i].length <= 30
    • -
    • grid[i][j] is 0 or 1.
    • +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 30
    • +
    • grid[i][j] is either 0 or 1.
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Strongly Connected Component](../../tag/strongly-connected-component/README.md)] diff --git a/problems/minimum-number-of-days-to-eat-n-oranges/README.md b/problems/minimum-number-of-days-to-eat-n-oranges/README.md index 2f250b084..ef9a3d0c3 100644 --- a/problems/minimum-number-of-days-to-eat-n-oranges/README.md +++ b/problems/minimum-number-of-days-to-eat-n-oranges/README.md @@ -15,13 +15,13 @@
    • Eat one orange.
    • -
    • If the number of remaining oranges n is divisible by 2 then you can eat n / 2 oranges.
    • -
    • If the number of remaining oranges n is divisible by 3 then you can eat 2 * (n / 3) oranges.
    • +
    • If the number of remaining oranges n is divisible by 2 then you can eat n / 2 oranges.
    • +
    • If the number of remaining oranges n is divisible by 3 then you can eat 2 * (n / 3) oranges.

    You can only choose one of the actions per day.

    -

    Return the minimum number of days to eat n oranges.

    +

    Given the integer n, return the minimum number of days to eat n oranges.

     

    Example 1:

    @@ -49,20 +49,6 @@ Day 3: Eat the last orange 1 - 1 = 0. You need at least 3 days to eat the 6 oranges. -

    Example 3:

    - -
    -Input: n = 1
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: n = 56
    -Output: 6
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-number-of-days-to-make-m-bouquets/README.md b/problems/minimum-number-of-days-to-make-m-bouquets/README.md index 79478879e..23c7493b3 100644 --- a/problems/minimum-number-of-days-to-make-m-bouquets/README.md +++ b/problems/minimum-number-of-days-to-make-m-bouquets/README.md @@ -11,13 +11,13 @@ ## [1482. Minimum Number of Days to Make m Bouquets (Medium)](https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets "制作 m 束花所需的最少天数") -

    Given an integer array bloomDay, an integer m and an integer k.

    +

    You are given an integer array bloomDay, an integer m and an integer k.

    -

    We need to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.

    +

    You want to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.

    -

    The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.

    +

    The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.

    -

    Return the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.

    +

    Return the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.

     

    Example 1:

    @@ -25,7 +25,7 @@
     Input: bloomDay = [1,10,3,10,2], m = 3, k = 1
     Output: 3
    -Explanation: Let's see what happened in the first three days. x means flower bloomed and _ means flower didn't bloom in the garden.
    +Explanation: Let us see what happened in the first three days. x means flower bloomed and _ means flower did not bloom in the garden.
     We need 3 bouquets each should contain 1 flower.
     After day 1: [x, _, _, _, _]   // we can only make one bouquet.
     After day 2: [x, _, _, _, x]   // we can only make two bouquets.
    @@ -46,36 +46,21 @@ After day 3: [x, _, x, _, x]   // we can make 3 bouquets. The answer is 3.
     Input: bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3
     Output: 12
     Explanation: We need 2 bouquets each should have 3 flowers.
    -Here's the garden after the 7 and 12 days:
    +Here is the garden after the 7 and 12 days:
     After day 7: [x, x, x, x, _, x, x]
     We can make one bouquet of the first three flowers that bloomed. We cannot make another bouquet from the last three flowers that bloomed because they are not adjacent.
     After day 12: [x, x, x, x, x, x, x]
     It is obvious that we can make two bouquets in different ways.
     
    -

    Example 4:

    - -
    -Input: bloomDay = [1000000000,1000000000], m = 1, k = 1
    -Output: 1000000000
    -Explanation: You need to wait 1000000000 days to have a flower ready for a bouquet.
    -
    - -

    Example 5:

    - -
    -Input: bloomDay = [1,10,2,9,3,8,4,7,5,6], m = 4, k = 2
    -Output: 9
    -
    -

     

    Constraints:

    • bloomDay.length == n
    • -
    • 1 <= n <= 10^5
    • -
    • 1 <= bloomDay[i] <= 10^9
    • -
    • 1 <= m <= 10^6
    • +
    • 1 <= n <= 105
    • +
    • 1 <= bloomDay[i] <= 109
    • +
    • 1 <= m <= 106
    • 1 <= k <= n
    @@ -85,6 +70,7 @@ It is obvious that we can make two bouquets in different ways. ### Similar Questions 1. [Maximize the Confusion of an Exam](../maximize-the-confusion-of-an-exam) (Medium) + 1. [Earliest Possible Day of Full Bloom](../earliest-possible-day-of-full-bloom) (Hard) ### Hints
    diff --git a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md index 0dcbfe47e..1dc73d265 100644 --- a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md +++ b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md @@ -33,22 +33,15 @@
     Input: mat = [[0]]
     Output: 0
    -Explanation: Given matrix is a zero matrix. We don't need to change it.
    +Explanation: Given matrix is a zero matrix. We do not need to change it.
     

    Example 3:

    -
    -Input: mat = [[1,1,1],[1,0,1],[0,0,0]]
    -Output: 6
    -
    - -

    Example 4:

    -
     Input: mat = [[1,0,0],[1,0,0]]
     Output: -1
    -Explanation: Given matrix can't be a zero matrix
    +Explanation: Given matrix cannot be a zero matrix.
     

     

    @@ -67,6 +60,10 @@ [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Minimum Operations to Remove Adjacent Ones in Matrix](../minimum-operations-to-remove-adjacent-ones-in-matrix) (Hard) + 1. [Remove All Ones With Row and Column Flips](../remove-all-ones-with-row-and-column-flips) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md index d2ff2706f..48368b32a 100644 --- a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md +++ b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md @@ -11,24 +11,24 @@ ## [1526. Minimum Number of Increments on Subarrays to Form a Target Array (Hard)](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") -

    Given an array of positive integers target and an array initial of same size with all zeros.

    +

    You are given an integer array target. You have an integer array initial of the same size as target with all elements initially zeros.

    -

    Return the minimum number of operations to form a target array from initial if you are allowed to do the following operation:

    +

    In one operation you can choose any subarray from initial and increment each value by one.

    + +

    Return the minimum number of operations to form a target array from initial.

    + +

    The test cases are generated so that the answer fits in a 32-bit integer.

    -
      -
    • Choose any subarray from initial and increment each value by one.
    • -
    -The answer is guaranteed to fit within the range of a 32-bit signed integer.

     

    Example 1:

     Input: target = [1,2,3,2,1]
     Output: 3
    -Explanation: We need at least 3 operations to form the target array from the initial array.
    -[0,0,0,0,0] increment 1 from index 0 to 4 (inclusive).
    -[1,1,1,1,1] increment 1 from index 1 to 3 (inclusive).
    -[1,2,2,2,1] increment 1 at index 2.
    +Explanation: We need at least 3 operations to form the target array from the initial array.
    +[0,0,0,0,0] increment 1 from index 0 to 4 (inclusive).
    +[1,1,1,1,1] increment 1 from index 1 to 3 (inclusive).
    +[1,2,2,2,1] increment 1 at index 2.
     [1,2,3,2,1] target array is formed.
     
    @@ -37,7 +37,7 @@ The answer is guaranteed to fit within the range of a 32-bit signed integer.
     Input: target = [3,1,1,2]
     Output: 4
    -Explanation: (initial)[0,0,0,0] -> [1,1,1,1] -> [1,1,1,2] -> [2,1,1,2] -> [3,1,1,2] (target).
    +Explanation: [0,0,0,0] -> [1,1,1,1] -> [1,1,1,2] -> [2,1,1,2] -> [3,1,1,2]
     

    Example 3:

    @@ -45,23 +45,15 @@ The answer is guaranteed to fit within the range of a 32-bit signed integer.
     Input: target = [3,1,5,4,2]
     Output: 7
    -Explanation: (initial)[0,0,0,0,0] -> [1,1,1,1,1] -> [2,1,1,1,1] -> [3,1,1,1,1] 
    -                                  -> [3,1,2,2,2] -> [3,1,3,3,2] -> [3,1,4,4,2] -> [3,1,5,4,2] (target).
    -
    - -

    Example 4:

    - -
    -Input: target = [1,1,1,1]
    -Output: 1
    +Explanation: [0,0,0,0,0] -> [1,1,1,1,1] -> [2,1,1,1,1] -> [3,1,1,1,1] -> [3,1,2,2,2] -> [3,1,3,3,2] -> [3,1,4,4,2] -> [3,1,5,4,2].
     

     

    Constraints:

      -
    • 1 <= target.length <= 10^5
    • -
    • 1 <= target[i] <= 10^5
    • +
    • 1 <= target.length <= 105
    • +
    • 1 <= target[i] <= 105
    ### Related Topics diff --git a/problems/minimum-number-of-lines-to-cover-points/README.md b/problems/minimum-number-of-lines-to-cover-points/README.md new file mode 100644 index 000000000..582bba6e1 --- /dev/null +++ b/problems/minimum-number-of-lines-to-cover-points/README.md @@ -0,0 +1,45 @@ + + + + + + + +[< Previous](../maximum-good-people-based-on-statements "Maximum Good People Based on Statements") +                 +[Next >](../the-number-of-passengers-in-each-bus-ii "The Number of Passengers in Each Bus II") + +## [2152. Minimum Number of Lines to Cover Points (Medium)](https://leetcode.com/problems/minimum-number-of-lines-to-cover-points "") + + + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + +### Hints +
    +Hint 1 +What is the highest possible answer for a set of n points? +
    + +
    +Hint 2 +The highest possible answer is n / 2 (rounded up). This is because you can cover at least two points with a line, and if n is odd, you need to add one extra line to cover the last point. +
    + +
    +Hint 3 +Suppose you have a line covering two points, how can you quickly check if a third point is also covered by that line? +
    + +
    +Hint 4 +Calculate the slope from the first point to the second point. If the slope from the first point to the third point is the same, then it is also covered by that line. +
    diff --git a/problems/minimum-number-of-operations-to-make-string-sorted/README.md b/problems/minimum-number-of-operations-to-make-string-sorted/README.md index 7aa3e5a7d..60c4203fb 100644 --- a/problems/minimum-number-of-operations-to-make-string-sorted/README.md +++ b/problems/minimum-number-of-operations-to-make-string-sorted/README.md @@ -46,19 +46,6 @@ Operation 1: i=3, j=4. Swap s[2] and s[4] to get s="aaaab", then rever Operation 2: i=4, j=4. Swap s[3] and s[4] to get s="aaaab", then reverse the substring starting at 4. Now, s="aaaab". -

    Example 3:

    - -
    -Input: s = "cdbea"
    -Output: 63
    - -

    Example 4:

    - -
    -Input: s = "leetcodeleetcodeleetcode"
    -Output: 982157772
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md index 3f34200f4..42d3cc5e1 100644 --- a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md +++ b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md @@ -50,6 +50,9 @@ [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Minimum Cost to Move Chips to The Same Position](../minimum-cost-to-move-chips-to-the-same-position) (Easy) + ### Hints
    Hint 1 diff --git a/problems/minimum-number-of-refueling-stops/README.md b/problems/minimum-number-of-refueling-stops/README.md index c990e21b1..1cc8c8b1f 100644 --- a/problems/minimum-number-of-refueling-stops/README.md +++ b/problems/minimum-number-of-refueling-stops/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../advantage-shuffle "Advantage Shuffle") @@ -61,7 +61,7 @@ We made 2 refueling stops along the way, so we return 2. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/minimum-number-of-removals-to-make-mountain-array/README.md b/problems/minimum-number-of-removals-to-make-mountain-array/README.md index 7f2ca1d02..bfc45b56b 100644 --- a/problems/minimum-number-of-removals-to-make-mountain-array/README.md +++ b/problems/minimum-number-of-removals-to-make-mountain-array/README.md @@ -42,20 +42,6 @@ Explanation: One solution is to remove the elements at indices 0, 1, and 5, making the array nums = [1,5,6,3,1]. -

    Example 3:

    - -
    -Input: nums = [4,3,2,1,1,2,3,1]
    -Output: 4
    -
    - -

    Example 4:

    - -
    -Input: nums = [1,2,3,4,4,3,2,1]
    -Output: 1
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md index 5038dbee9..22618114e 100644 --- a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md +++ b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md @@ -11,11 +11,11 @@ ## [1347. Minimum Number of Steps to Make Two Strings Anagram (Medium)](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram "制造字母异位词的最小步骤数") -

    Given two equal-size strings s and t. In one step you can choose any character of t and replace it with another character.

    +

    You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.

    -

    Return the minimum number of steps to make t an anagram of s.

    +

    Return the minimum number of steps to make t an anagram of s.

    -

    An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.

    +

    An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.

     

    Example 1:

    @@ -42,27 +42,13 @@ Explanation: "anagram" and "mangaar" are anagrams. -

    Example 4:

    - -
    -Input: s = "xxyyzz", t = "xxyyzz"
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: s = "friend", t = "family"
    -Output: 4
    -
    -

     

    Constraints:

      -
    • 1 <= s.length <= 50000
    • +
    • 1 <= s.length <= 5 * 104
    • s.length == t.length
    • -
    • s and t contain lower-case English letters only.
    • +
    • s and t consist of lowercase English letters only.
    ### Related Topics diff --git a/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md b/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md index 179da70b9..51d236eaa 100644 --- a/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md +++ b/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md @@ -51,8 +51,8 @@ The string is now alternating. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md index 3f1157121..c44128242 100644 --- a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md +++ b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md @@ -42,27 +42,6 @@ Opening Only the second tap will water the whole garden [0,5] Explanation: Even if you activate all the four taps you cannot water the whole garden. -

    Example 3:

    - -
    -Input: n = 7, ranges = [1,2,1,0,2,1,0,1]
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: n = 8, ranges = [4,0,0,0,0,0,0,0,4]
    -Output: 2
    -
    - -

    Example 5:

    - -
    -Input: n = 8, ranges = [4,0,0,0,4,0,0,0,4]
    -Output: 1
    -
    -

     

    Constraints:

    @@ -73,9 +52,9 @@ Opening Only the second tap will water the whole garden [0,5] ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md index 9fcfb0f7e..78c2033c8 100644 --- a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md +++ b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md @@ -11,13 +11,13 @@ ## [1558. Minimum Numbers of Function Calls to Make Target Array (Medium)](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") -

    +

    You are given an integer array nums. You have an integer array arr of the same length with all values set to 0 initially. You also have the following modify function:

    + +

    You want to use the modify function to covert arr to nums using the minimum number of calls.

    -

    Your task is to form an integer array nums from an initial array of zeros arr that is the same size as nums.

    +

    Return the minimum number of function calls to make nums from arr.

    -

    Return the minimum number of function calls to make nums from arr.

    - -

    The answer is guaranteed to fit in a 32-bit signed integer.

    +

    The test cases are generated so that the answer fits in a 32-bit signed integer.

     

    Example 1:

    @@ -49,26 +49,12 @@ Total of operations: 2 + 1 = 3. Explanation: (initial)[0,0,0] -> [1,0,0] -> [1,0,1] -> [2,0,2] -> [2,1,2] -> [4,2,4] -> [4,2,5](nums). -

    Example 4:

    - -
    -Input: nums = [3,2,2,4]
    -Output: 7
    -
    - -

    Example 5:

    - -
    -Input: nums = [2,4,8,16]
    -Output: 8
    -
    -

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • 0 <= nums[i] <= 10^9
    • +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 109
    ### Related Topics diff --git a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md index 6daae4a00..8051fc22e 100644 --- a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md +++ b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md @@ -23,45 +23,24 @@

     

    Example 1:

    -
    -Input: n = 0
    -Output: 0
    -
    - -

    Example 2:

    -
     Input: n = 3
     Output: 2
     Explanation: The binary representation of 3 is "11".
    -"11" -> "01" with the 2nd operation since the 0th bit is 1.
    -"01" -> "00" with the 1st operation.
    +"11" -> "01" with the 2nd operation since the 0th bit is 1.
    +"01" -> "00" with the 1st operation.
     
    -

    Example 3:

    +

    Example 2:

     Input: n = 6
     Output: 4
     Explanation: The binary representation of 6 is "110".
    -"110" -> "010" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0.
    -"010" -> "011" with the 1st operation.
    -"011" -> "001" with the 2nd operation since the 0th bit is 1.
    -"001" -> "000" with the 1st operation.
    -
    - -

    Example 4:

    - -
    -Input: n = 9
    -Output: 14
    -
    - -

    Example 5:

    - -
    -Input: n = 333
    -Output: 393
    +"110" -> "010" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0.
    +"010" -> "011" with the 1st operation.
    +"011" -> "001" with the 2nd operation since the 0th bit is 1.
    +"001" -> "000" with the 1st operation.
     

     

    @@ -72,9 +51,12 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) ### Hints
    diff --git a/problems/minimum-operations-to-convert-number/README.md b/problems/minimum-operations-to-convert-number/README.md index 941b3a389..dbf649ccb 100644 --- a/problems/minimum-operations-to-convert-number/README.md +++ b/problems/minimum-operations-to-convert-number/README.md @@ -11,7 +11,7 @@ ## [2059. Minimum Operations to Convert Number (Medium)](https://leetcode.com/problems/minimum-operations-to-convert-number "转化数字的最小运算数") -

    You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:

    +

    You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:

    If 0 <= x <= 1000, then for any index i in the array (0 <= i < nums.length), you can set x to any of the following:

    @@ -28,56 +28,31 @@

     

    Example 1:

    -
    -Input: nums = [1,3], start = 6, goal = 4
    -Output: 2
    -Explanation:
    -We can go from 6 → 7 → 4 with the following 2 operations.
    -- 6 ^ 1 = 7
    -- 7 ^ 3 = 4
    -
    - -

    Example 2:

    -
     Input: nums = [2,4,12], start = 2, goal = 12
     Output: 2
    -Explanation:
    -We can go from 2 → 14 → 12 with the following 2 operations.
    +Explanation: We can go from 2 → 14 → 12 with the following 2 operations.
     - 2 + 12 = 14
     - 14 - 2 = 12
     
    -

    Example 3:

    +

    Example 2:

     Input: nums = [3,5,7], start = 0, goal = -4
     Output: 2
    -Explanation:
    -We can go from 0 → 3 → -4 with the following 2 operations. 
    +Explanation: We can go from 0 → 3 → -4 with the following 2 operations. 
     - 0 + 3 = 3
     - 3 - 7 = -4
     Note that the last operation sets x out of the range 0 <= x <= 1000, which is valid.
     
    -

    Example 4:

    +

    Example 3:

     Input: nums = [2,8,16], start = 0, goal = 1
     Output: -1
    -Explanation:
    -There is no way to convert 0 into 1.
    - -

    Example 5:

    - -
    -Input: nums = [1], start = 0, goal = 3
    -Output: 3
    -Explanation: 
    -We can go from 0 → 1 → 2 → 3 with the following 3 operations. 
    -- 0 + 1 = 1 
    -- 1 + 1 = 2
    -- 2 + 1 = 3
    +Explanation: There is no way to convert 0 into 1.
     

     

    diff --git a/problems/minimum-operations-to-make-the-array-alternating/README.md b/problems/minimum-operations-to-make-the-array-alternating/README.md new file mode 100644 index 000000000..8b1fec07d --- /dev/null +++ b/problems/minimum-operations-to-make-the-array-alternating/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../count-operations-to-obtain-zero "Count Operations to Obtain Zero") +                 +[Next >](../removing-minimum-number-of-magic-beans "Removing Minimum Number of Magic Beans") + +## [2170. Minimum Operations to Make the Array Alternating (Medium)](https://leetcode.com/problems/minimum-operations-to-make-the-array-alternating "使数组变成交替数组的最少操作数") + +

    You are given a 0-indexed array nums consisting of n positive integers.

    + +

    The array nums is called alternating if:

    + +
      +
    • nums[i - 2] == nums[i], where 2 <= i <= n - 1.
    • +
    • nums[i - 1] != nums[i], where 1 <= i <= n - 1.
    • +
    + +

    In one operation, you can choose an index i and change nums[i] into any positive integer.

    + +

    Return the minimum number of operations required to make the array alternating.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,1,3,2,4,3]
    +Output: 3
    +Explanation:
    +One way to make the array alternating is by converting it to [3,1,3,1,3,1].
    +The number of operations required in this case is 3.
    +It can be proven that it is not possible to make the array alternating in less than 3 operations. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,2,2,2]
    +Output: 2
    +Explanation:
    +One way to make the array alternating is by converting it to [1,2,1,2,1].
    +The number of operations required in this case is 2.
    +Note that the array cannot be converted to [2,2,2,2,2] because in this case nums[0] == nums[1] which violates the conditions of an alternating array.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +Count the frequency of each element in odd positions in the array. Do the same for elements in even positions. +
    + +
    +Hint 2 +To minimize the number of operations we need to maximize the number of elements we keep from the original array. +
    + +
    +Hint 3 +What are the possible combinations of elements we can choose from odd indices and even indices so that the number of unchanged elements is maximized? +
    diff --git a/problems/minimum-operations-to-make-the-array-k-increasing/README.md b/problems/minimum-operations-to-make-the-array-k-increasing/README.md new file mode 100644 index 000000000..3ecfaec2b --- /dev/null +++ b/problems/minimum-operations-to-make-the-array-k-increasing/README.md @@ -0,0 +1,100 @@ + + + + + + + +[< Previous](../number-of-smooth-descent-periods-of-a-stock "Number of Smooth Descent Periods of a Stock") +                 +[Next >](../the-airport-with-the-most-traffic "The Airport With the Most Traffic") + +## [2111. Minimum Operations to Make the Array K-Increasing (Hard)](https://leetcode.com/problems/minimum-operations-to-make-the-array-k-increasing "使数组 K 递增的最少操作次数") + +

    You are given a 0-indexed array arr consisting of n positive integers, and a positive integer k.

    + +

    The array arr is called K-increasing if arr[i-k] <= arr[i] holds for every index i, where k <= i <= n-1.

    + +
      +
    • For example, arr = [4, 1, 5, 2, 6, 2] is K-increasing for k = 2 because: +
        +
      • arr[0] <= arr[2] (4 <= 5)
      • +
      • arr[1] <= arr[3] (1 <= 2)
      • +
      • arr[2] <= arr[4] (5 <= 6)
      • +
      • arr[3] <= arr[5] (2 <= 2)
      • +
      +
    • +
    • However, the same arr is not K-increasing for k = 1 (because arr[0] > arr[1]) or k = 3 (because arr[0] > arr[3]).
    • +
    + +

    In one operation, you can choose an index i and change arr[i] into any positive integer.

    + +

    Return the minimum number of operations required to make the array K-increasing for the given k.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [5,4,3,2,1], k = 1
    +Output: 4
    +Explanation:
    +For k = 1, the resultant array has to be non-decreasing.
    +Some of the K-increasing arrays that can be formed are [5,6,7,8,9], [1,1,1,1,1], [2,2,3,4,4]. All of them require 4 operations.
    +It is suboptimal to change the array to, for example, [6,7,8,9,10] because it would take 5 operations.
    +It can be shown that we cannot make the array K-increasing in less than 4 operations.
    +
    + +

    Example 2:

    + +
    +Input: arr = [4,1,5,2,6,2], k = 2
    +Output: 0
    +Explanation:
    +This is the same example as the one in the problem description.
    +Here, for every index i where 2 <= i <= 5, arr[i-2] <= arr[i].
    +Since the given array is already K-increasing, we do not need to perform any operations.
    + +

    Example 3:

    + +
    +Input: arr = [4,1,5,2,6,2], k = 3
    +Output: 2
    +Explanation:
    +Indices 3 and 5 are the only ones not satisfying arr[i-3] <= arr[i] for 3 <= i <= 5.
    +One of the ways we can make the array K-increasing is by changing arr[3] to 4 and arr[5] to 5.
    +The array will now be [4,1,5,4,6,5].
    +Note that there can be other ways to make the array K-increasing, but none of them require less than 2 operations.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 105
    • +
    • 1 <= arr[i], k <= arr.length
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Can we divide the array into non-overlapping subsequences and simplify the problem? +
    + +
    +Hint 2 +In the final array, arr[i-k] ≤ arr[i] should hold. We can use this to divide the array into at most k non-overlapping sequences, where arr[i] will belong to the (i%k)th sequence. +
    + +
    +Hint 3 +Now our problem boils down to performing the minimum operations on each sequence such that it becomes non-decreasing. Our answer will be the sum of operations on each sequence. +
    + +
    +Hint 4 +Which indices of a sequence should we not change in order to count the minimum operations? Can finding the longest non-decreasing subsequence of the sequence help? +
    diff --git a/problems/minimum-operations-to-remove-adjacent-ones-in-matrix/README.md b/problems/minimum-operations-to-remove-adjacent-ones-in-matrix/README.md new file mode 100644 index 000000000..1d0824208 --- /dev/null +++ b/problems/minimum-operations-to-remove-adjacent-ones-in-matrix/README.md @@ -0,0 +1,40 @@ + + + + + + + +[< Previous](../recover-the-original-array "Recover the Original Array") +                 +[Next >](../check-if-all-as-appears-before-all-bs "Check if All A's Appears Before All B's") + +## [2123. Minimum Operations to Remove Adjacent Ones in Matrix (Hard)](https://leetcode.com/problems/minimum-operations-to-remove-adjacent-ones-in-matrix "") + + + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Consider each cell containing a 1 as a vertex whose neighbors are the cells 4-directionally connected to it. The grid then becomes a bipartite graph. +
    + +
    +Hint 2 +You want to find the smallest set of vertices such that every edge in the graph has an endpoint in this set. If you remove every vertex in this set from the graph, then all the 1’s will be disconnected. Are there any well-known algorithms for finding this set? +
    + +
    +Hint 3 +This set of vertices is called a minimum vertex cover. You can find the size of a minimum vertex cover by finding the size of a maximum matching (Konig’s theorem). +
    + +
    +Hint 4 +There are well-known algorithms such as Kuhn’s algorithm and Hopcroft-Karp-Karzanov algorithm which can find a maximum matching in a bipartite graph quickly. +
    diff --git a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md index 6c894f63b..2bf5130bc 100644 --- a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md +++ b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-submatrices-with-all-ones "Count Submatrices With All Ones") @@ -11,11 +11,9 @@ ## [1505. Minimum Possible Integer After at Most K Adjacent Swaps On Digits (Hard)](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") -

    Given a string num representing the digits of a very large integer and an integer k.

    +

    You are given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times.

    -

    You are allowed to swap any two adjacent digits of the integer at most k times.

    - -

    Return the minimum integer you can obtain also as a string.

    +

    Return the minimum integer you can obtain also as a string.

     

    Example 1:

    @@ -42,34 +40,20 @@ Explanation: We can keep the number without any swaps. -

    Example 4:

    - -
    -Input: num = "22", k = 22
    -Output: "22"
    -
    - -

    Example 5:

    - -
    -Input: num = "9438957234785635408", k = 23
    -Output: "0345989723478563548"
    -
    -

     

    Constraints:

      -
    • 1 <= num.length <= 30000
    • -
    • num contains digits only and doesn't have leading zeros.
    • -
    • 1 <= k <= 10^9
    • +
    • 1 <= num.length <= 3 * 104
    • +
    • num consists of only digits and does not contain leading zeros.
    • +
    • 1 <= k <= 104
    ### Related Topics - [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/minimum-remove-to-make-valid-parentheses/README.md b/problems/minimum-remove-to-make-valid-parentheses/README.md index 370877ada..3dc52b55e 100644 --- a/problems/minimum-remove-to-make-valid-parentheses/README.md +++ b/problems/minimum-remove-to-make-valid-parentheses/README.md @@ -47,13 +47,6 @@ Explanation: An empty string is also valid. -

    Example 4:

    - -
    -Input: s = "(a(b(c)d)"
    -Output: "a(b(c)d)"
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md index 0e88486e6..788e77637 100644 --- a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md +++ b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md @@ -72,6 +72,9 @@ You can skip the first and third rest to arrive in ((7/2 + 0) + (3/2 + 0) [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Minimum Speed to Arrive on Time](../minimum-speed-to-arrive-on-time) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-space-wasted-from-packaging/README.md b/problems/minimum-space-wasted-from-packaging/README.md index a012e8bca..5dc48480a 100644 --- a/problems/minimum-space-wasted-from-packaging/README.md +++ b/problems/minimum-space-wasted-from-packaging/README.md @@ -68,8 +68,8 @@ The total waste is (5-3) + (5-5) + (10-8) + (10-10) + (14-11) + (14-12) = 9. ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/minimum-subsequence-in-non-increasing-order/README.md b/problems/minimum-subsequence-in-non-increasing-order/README.md index af2af0779..d9e699479 100644 --- a/problems/minimum-subsequence-in-non-increasing-order/README.md +++ b/problems/minimum-subsequence-in-non-increasing-order/README.md @@ -50,8 +50,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-suffix-flips/README.md b/problems/minimum-suffix-flips/README.md new file mode 100644 index 000000000..2208589ce --- /dev/null +++ b/problems/minimum-suffix-flips/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../shuffle-string "Shuffle String") +                 +[Next >](../number-of-good-leaf-nodes-pairs "Number of Good Leaf Nodes Pairs") + +## [1529. Minimum Suffix Flips (Medium)](https://leetcode.com/problems/minimum-suffix-flips "最少的后缀翻转次数") + +

    You are given a 0-indexed binary string target of length n. You have another binary string s of length n that is initially set to all zeros. You want to make s equal to target.

    + +

    In one operation, you can pick an index i where 0 <= i < n and flip all bits in the inclusive range [i, n - 1]. Flip means changing '0' to '1' and '1' to '0'.

    + +

    Return the minimum number of operations needed to make s equal to target.

    + +

     

    +

    Example 1:

    + +
    +Input: target = "10111"
    +Output: 3
    +Explanation: Initially, s = "00000".
    +Choose index i = 2: "00000" -> "00111"
    +Choose index i = 0: "00111" -> "11000"
    +Choose index i = 1: "11000" -> "10111"
    +We need at least 3 flip operations to form target.
    +
    + +

    Example 2:

    + +
    +Input: target = "101"
    +Output: 3
    +Explanation: Initially, s = "000".
    +Choose index i = 0: "000" -> "111"
    +Choose index i = 1: "111" -> "100"
    +Choose index i = 2: "100" -> "101"
    +We need at least 3 flip operations to form target.
    +
    + +

    Example 3:

    + +
    +Input: target = "00000"
    +Output: 0
    +Explanation: We do not need any operations since the initial s already equals target.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == target.length
    • +
    • 1 <= n <= 105
    • +
    • target[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Consider a strategy where the choice of bulb with number i is increasing. In such a strategy, you no longer need to worry about bulbs that have been set to the left. +
    diff --git a/problems/minimum-sum-of-four-digit-number-after-splitting-digits/README.md b/problems/minimum-sum-of-four-digit-number-after-splitting-digits/README.md new file mode 100644 index 000000000..a961edf68 --- /dev/null +++ b/problems/minimum-sum-of-four-digit-number-after-splitting-digits/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../order-two-columns-independently "Order Two Columns Independently") +                 +[Next >](../partition-array-according-to-given-pivot "Partition Array According to Given Pivot") + +## [2160. Minimum Sum of Four Digit Number After Splitting Digits (Easy)](https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits "拆分数位后四位数字的最小和") + +

    You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leading zeros are allowed in new1 and new2, and all the digits found in num must be used.

    + +
      +
    • For example, given num = 2932, you have the following digits: two 2's, one 9 and one 3. Some of the possible pairs [new1, new2] are [22, 93], [23, 92], [223, 9] and [2, 329].
    • +
    + +

    Return the minimum possible sum of new1 and new2.

    + +

     

    +

    Example 1:

    + +
    +Input: num = 2932
    +Output: 52
    +Explanation: Some possible pairs [new1, new2] are [29, 23], [223, 9], etc.
    +The minimum sum can be obtained by the pair [29, 23]: 29 + 23 = 52.
    +
    + +

    Example 2:

    + +
    +Input: num = 4009
    +Output: 13
    +Explanation: Some possible pairs [new1, new2] are [0, 49], [490, 0], etc. 
    +The minimum sum can be obtained by the pair [4, 9]: 4 + 9 = 13.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1000 <= num <= 9999
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Notice that the most optimal way to obtain the minimum possible sum using 4 digits is by summing up two 2-digit numbers. +
    + +
    +Hint 2 +We can use the two smallest digits out of the four as the digits found in the tens place respectively. +
    + +
    +Hint 3 +Similarly, we use the final 2 larger digits as the digits found in the ones place. +
    diff --git a/problems/minimum-swaps-to-group-all-1s-together-ii/README.md b/problems/minimum-swaps-to-group-all-1s-together-ii/README.md new file mode 100644 index 000000000..f254b9dd9 --- /dev/null +++ b/problems/minimum-swaps-to-group-all-1s-together-ii/README.md @@ -0,0 +1,91 @@ + + + + + + + +[< Previous](../check-if-every-row-and-column-contains-all-numbers "Check if Every Row and Column Contains All Numbers") +                 +[Next >](../count-words-obtained-after-adding-a-letter "Count Words Obtained After Adding a Letter") + +## [2134. Minimum Swaps to Group All 1's Together II (Medium)](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii "最少交换次数来组合所有的 1 II") + +

    A swap is defined as taking two distinct positions in an array and swapping the values in them.

    + +

    A circular array is defined as an array where we consider the first element and the last element to be adjacent.

    + +

    Given a binary circular array nums, return the minimum number of swaps required to group all 1's present in the array together at any location.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [0,1,0,1,1,0,0]
    +Output: 1
    +Explanation: Here are a few of the ways to group all the 1's together:
    +[0,0,1,1,1,0,0] using 1 swap.
    +[0,1,1,1,0,0,0] using 1 swap.
    +[1,1,0,0,0,0,1] using 2 swaps (using the circular property of the array).
    +There is no way to group all 1's together with 0 swaps.
    +Thus, the minimum number of swaps required is 1.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,1,1,1,0,0,1,1,0]
    +Output: 2
    +Explanation: Here are a few of the ways to group all the 1's together:
    +[1,1,1,0,0,0,0,1,1] using 2 swaps (using the circular property of the array).
    +[1,1,1,1,1,0,0,0,0] using 2 swaps.
    +There is no way to group all 1's together with 0 or 1 swaps.
    +Thus, the minimum number of swaps required is 2.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,1,0,0,1]
    +Output: 0
    +Explanation: All the 1's are already grouped together due to the circular property of the array.
    +Thus, the minimum number of swaps required is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • nums[i] is either 0 or 1.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +Notice that the number of 1’s to be grouped together is fixed. It is the number of 1's the whole array has. +
    + +
    +Hint 2 +Call this number total. We should then check for every subarray of size total (possibly wrapped around), how many swaps are required to have the subarray be all 1’s. +
    + +
    +Hint 3 +The number of swaps required is the number of 0’s in the subarray. +
    + +
    +Hint 4 +To eliminate the circular property of the array, we can append the original array to itself. Then, we check each subarray of length total. +
    + +
    +Hint 5 +How do we avoid recounting the number of 0’s in the subarray each time? The Sliding Window technique can help. +
    diff --git a/problems/minimum-swaps-to-make-sequences-increasing/README.md b/problems/minimum-swaps-to-make-sequences-increasing/README.md index 40e16413e..81ce68ef8 100644 --- a/problems/minimum-swaps-to-make-sequences-increasing/README.md +++ b/problems/minimum-swaps-to-make-sequences-increasing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../similar-rgb-color "Similar RGB Color") @@ -52,3 +52,6 @@ which are both strictly increasing. ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Minimum Operations to Make the Array K-Increasing](../minimum-operations-to-make-the-array-k-increasing) (Hard) diff --git a/problems/minimum-swaps-to-make-strings-equal/README.md b/problems/minimum-swaps-to-make-strings-equal/README.md index c80adf70c..efa4ee8ed 100644 --- a/problems/minimum-swaps-to-make-strings-equal/README.md +++ b/problems/minimum-swaps-to-make-strings-equal/README.md @@ -21,18 +21,18 @@
     Input: s1 = "xx", s2 = "yy"
     Output: 1
    -Explanation: 
    -Swap s1[0] and s2[1], s1 = "yx", s2 = "yx".
    +Explanation: Swap s1[0] and s2[1], s1 = "yx", s2 = "yx". +

    Example 2:

     Input: s1 = "xy", s2 = "yx"
     Output: 2
    -Explanation: 
    -Swap s1[0] and s2[0], s1 = "yy", s2 = "xx".
    +Explanation: Swap s1[0] and s2[0], s1 = "yy", s2 = "xx".
     Swap s1[0] and s2[1], s1 = "xy", s2 = "xy".
    -Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", cause we can only swap chars in different strings.
    +Note that you cannot swap s1[0] and s1[1] to make s1 equal to "yx", cause we can only swap chars in different strings. +

    Example 3:

    @@ -41,13 +41,6 @@ Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", Output: -1 -

    Example 4:

    - -
    -Input: s1 = "xxyyxyxyxx", s2 = "xyyxyxxxyx"
    -Output: 4
    -
    -

     

    Constraints:

    @@ -57,9 +50,12 @@ Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Determine if Two Strings Are Close](../determine-if-two-strings-are-close) (Medium) ### Hints
    diff --git a/problems/minimum-time-for-k-virus-variants-to-spread/README.md b/problems/minimum-time-for-k-virus-variants-to-spread/README.md index 3b5cdd475..c288759ed 100644 --- a/problems/minimum-time-for-k-virus-variants-to-spread/README.md +++ b/problems/minimum-time-for-k-virus-variants-to-spread/README.md @@ -14,10 +14,10 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Enumeration](../../tag/enumeration/README.md)] ### Hints diff --git a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md index 72ac218db..7572aba8c 100644 --- a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md +++ b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md @@ -52,10 +52,10 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/minimum-time-to-make-rope-colorful/README.md b/problems/minimum-time-to-make-rope-colorful/README.md new file mode 100644 index 000000000..0bbeb08a5 --- /dev/null +++ b/problems/minimum-time-to-make-rope-colorful/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "Number of Ways Where Square of Number Is Equal to Product of Two Numbers") +                 +[Next >](../remove-max-number-of-edges-to-keep-graph-fully-traversable "Remove Max Number of Edges to Keep Graph Fully Traversable") + +## [1578. Minimum Time to Make Rope Colorful (Medium)](https://leetcode.com/problems/minimum-time-to-make-rope-colorful "使绳子变成彩色的最短时间") + +

    Alice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the ith balloon.

    + +

    Alice wants the rope to be colorful. She does not want two consecutive balloons to be of the same color, so she asks Bob for help. Bob can remove some balloons from the rope to make it colorful. You are given a 0-indexed integer array neededTime where neededTime[i] is the time (in seconds) that Bob needs to remove the ith balloon from the rope.

    + +

    Return the minimum time Bob needs to make the rope colorful.

    + +

     

    +

    Example 1:

    + +
    +Input: colors = "abaac", neededTime = [1,2,3,4,5]
    +Output: 3
    +Explanation: In the above image, 'a' is blue, 'b' is red, and 'c' is green.
    +Bob can remove the blue balloon at index 2. This takes 3 seconds.
    +There are no longer two consecutive balloons of the same color. Total time = 3.
    + +

    Example 2:

    + +
    +Input: colors = "abc", neededTime = [1,2,3]
    +Output: 0
    +Explanation: The rope is already colorful. Bob does not need to remove any balloons from the rope.
    +
    + +

    Example 3:

    + +
    +Input: colors = "aabaa", neededTime = [1,2,3,4,1]
    +Output: 2
    +Explanation: Bob will remove the ballons at indices 0 and 4. Each ballon takes 1 second to remove.
    +There are no longer two consecutive balloons of the same color. Total time = 1 + 1 = 2.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == colors.length == neededTime.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= neededTime[i] <= 104
    • +
    • colors contains only lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Maintain the running sum and max value for repeated letters. +
    diff --git a/problems/minimum-time-to-remove-all-cars-containing-illegal-goods/README.md b/problems/minimum-time-to-remove-all-cars-containing-illegal-goods/README.md new file mode 100644 index 000000000..2d0a1ba6c --- /dev/null +++ b/problems/minimum-time-to-remove-all-cars-containing-illegal-goods/README.md @@ -0,0 +1,97 @@ + + + + + + + +[< Previous](../design-bitset "Design Bitset") +                 +[Next >](../unique-substrings-with-equal-digit-frequency "Unique Substrings With Equal Digit Frequency") + +## [2167. Minimum Time to Remove All Cars Containing Illegal Goods (Hard)](https://leetcode.com/problems/minimum-time-to-remove-all-cars-containing-illegal-goods "移除所有载有违禁货物车厢所需的最少时间") + +

    You are given a 0-indexed binary string s which represents a sequence of train cars. s[i] = '0' denotes that the ith car does not contain illegal goods and s[i] = '1' denotes that the ith car does contain illegal goods.

    + +

    As the train conductor, you would like to get rid of all the cars containing illegal goods. You can do any of the following three operations any number of times:

    + +
      +
    1. Remove a train car from the left end (i.e., remove s[0]) which takes 1 unit of time.
    2. +
    3. Remove a train car from the right end (i.e., remove s[s.length - 1]) which takes 1 unit of time.
    4. +
    5. Remove a train car from anywhere in the sequence which takes 2 units of time.
    6. +
    + +

    Return the minimum time to remove all the cars containing illegal goods.

    + +

    Note that an empty sequence of cars is considered to have no cars containing illegal goods.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "1100101"
    +Output: 5
    +Explanation: 
    +One way to remove all the cars containing illegal goods from the sequence is to
    +- remove a car from the left end 2 times. Time taken is 2 * 1 = 2.
    +- remove a car from the right end. Time taken is 1.
    +- remove the car containing illegal goods found in the middle. Time taken is 2.
    +This obtains a total time of 2 + 1 + 2 = 5. 
    +
    +An alternative way is to
    +- remove a car from the left end 2 times. Time taken is 2 * 1 = 2.
    +- remove a car from the right end 3 times. Time taken is 3 * 1 = 3.
    +This also obtains a total time of 2 + 3 = 5.
    +
    +5 is the minimum time taken to remove all the cars containing illegal goods. 
    +There are no other ways to remove them with less time.
    +
    + +

    Example 2:

    + +
    +Input: s = "0010"
    +Output: 2
    +Explanation:
    +One way to remove all the cars containing illegal goods from the sequence is to
    +- remove a car from the left end 3 times. Time taken is 3 * 1 = 3.
    +This obtains a total time of 3.
    +
    +Another way to remove all the cars containing illegal goods from the sequence is to
    +- remove the car containing illegal goods found in the middle. Time taken is 2.
    +This obtains a total time of 2.
    +
    +Another way to remove all the cars containing illegal goods from the sequence is to 
    +- remove a car from the right end 2 times. Time taken is 2 * 1 = 2. 
    +This obtains a total time of 2.
    +
    +2 is the minimum time taken to remove all the cars containing illegal goods. 
    +There are no other ways to remove them with less time.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 2 * 105
    • +
    • s[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Build an array withoutFirst where withoutFirst[i] stores the minimum time to remove all the cars containing illegal goods from the ‘suffix’ of the sequence starting from the ith car without using any type 1 operations. +
    + +
    +Hint 2 +Next, build an array onlyFirst where onlyFirst[i] stores the minimum time to remove all the cars containing illegal goods from the ‘prefix’ of the sequence ending on the ith car using only type 1 operations. +
    + +
    +Hint 3 +Finally, we can compare the best way to split the operations amongst these two types by finding the minimum time across all onlyFirst[i] + withoutFirst[i + 1]. +
    diff --git a/problems/minimum-time-visiting-all-points/README.md b/problems/minimum-time-visiting-all-points/README.md index a30f21c83..8182cda1a 100644 --- a/problems/minimum-time-visiting-all-points/README.md +++ b/problems/minimum-time-visiting-all-points/README.md @@ -56,9 +56,9 @@ Total time = 7 seconds ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Hints
    diff --git a/problems/missing-number/README.md b/problems/missing-number/README.md index 6537570f6..6c6174e60 100644 --- a/problems/missing-number/README.md +++ b/problems/missing-number/README.md @@ -19,7 +19,7 @@
     Input: nums = [3,0,1]
     Output: 2
    -Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.
    +Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.
     

    Example 2:

    @@ -27,7 +27,7 @@
     Input: nums = [0,1]
     Output: 2
    -Explanation: n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums.
    +Explanation: n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums.
     

    Example 3:

    @@ -35,15 +35,7 @@
     Input: nums = [9,6,4,2,3,5,7,0,1]
     Output: 8
    -Explanation: n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums.
    -
    - -

    Example 4:

    - -
    -Input: nums = [0]
    -Output: 1
    -Explanation: n = 1 since there is 1 number, so all numbers are in the range [0,1]. 1 is the missing number in the range since it does not appear in nums.
    +Explanation: n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums.
     

     

    @@ -60,10 +52,10 @@

    Follow up: Could you implement a solution using only O(1) extra space complexity and O(n) runtime complexity?

    ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions @@ -71,3 +63,4 @@ 1. [Single Number](../single-number) (Easy) 1. [Find the Duplicate Number](../find-the-duplicate-number) (Medium) 1. [Couples Holding Hands](../couples-holding-hands) (Hard) + 1. [Find Unique Binary String](../find-unique-binary-string) (Medium) diff --git a/problems/monotone-increasing-digits/README.md b/problems/monotone-increasing-digits/README.md index acec2dd07..dca596465 100644 --- a/problems/monotone-increasing-digits/README.md +++ b/problems/monotone-increasing-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sentence-similarity-ii "Sentence Similarity II") diff --git a/problems/monthly-transactions-ii/README.md b/problems/monthly-transactions-ii/README.md index 46803195d..8662b3c72 100644 --- a/problems/monthly-transactions-ii/README.md +++ b/problems/monthly-transactions-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../last-person-to-fit-in-the-bus "Last Person to Fit in the Bus") @@ -82,3 +82,6 @@ Result table: ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Monthly Transactions I](../monthly-transactions-i) (Medium) diff --git a/problems/monthly-transactions-ii/mysql_schemas.sql b/problems/monthly-transactions-ii/mysql_schemas.sql index 7b54c5361..d73b157c0 100644 --- a/problems/monthly-transactions-ii/mysql_schemas.sql +++ b/problems/monthly-transactions-ii/mysql_schemas.sql @@ -1,6 +1,6 @@ -create table if not exists Transactions (id int, country varchar(4), state enum('approved', 'declined'), amount int, trans_date date) +Create table If Not Exists Transactions (id int, country varchar(4), state enum('approved', 'declined'), amount int, trans_date date) ; -create table if not exists Chargebacks (trans_id int, trans_date date) +Create table If Not Exists Chargebacks (trans_id int, trans_date date) ; Truncate table Transactions; insert into Transactions (id, country, state, amount, trans_date) values ('101', 'US', 'approved', '1000', '2019-05-18'); diff --git a/problems/my-calendar-i/README.md b/problems/my-calendar-i/README.md index 11c307265..d8e8ab306 100644 --- a/problems/my-calendar-i/README.md +++ b/problems/my-calendar-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../self-dividing-numbers "Self Dividing Numbers") diff --git a/problems/my-calendar-ii/README.md b/problems/my-calendar-ii/README.md index b7e248b90..07f53d2b3 100644 --- a/problems/my-calendar-ii/README.md +++ b/problems/my-calendar-ii/README.md @@ -39,7 +39,7 @@ MyCalendarTwo myCalendarTwo = new MyCalendarTwo(); myCalendarTwo.book(10, 20); // return True, The event can be booked. myCalendarTwo.book(50, 60); // return True, The event can be booked. myCalendarTwo.book(10, 40); // return True, The event can be double booked. -myCalendarTwo.book(5, 15); // return False, The event ca not be booked, because it would result in a triple booking. +myCalendarTwo.book(5, 15); // return False, The event cannot be booked, because it would result in a triple booking. myCalendarTwo.book(5, 10); // return True, The event can be booked, as it does not use time 10 which is already double booked. myCalendarTwo.book(25, 55); // return True, The event can be booked, as the time in [25, 40) will be double booked with the third event, the time [40, 50) will be single booked, and the time [50, 55) will be double booked with the second event. diff --git a/problems/nearest-exit-from-entrance-in-maze/README.md b/problems/nearest-exit-from-entrance-in-maze/README.md index 6ecf2c2bf..3f05dc6b0 100644 --- a/problems/nearest-exit-from-entrance-in-maze/README.md +++ b/problems/nearest-exit-from-entrance-in-maze/README.md @@ -66,8 +66,8 @@ Thus, the nearest exit is [1,2], which is 2 steps away. ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/new-users-daily-count/README.md b/problems/new-users-daily-count/README.md index 776d40322..76f4e50e6 100644 --- a/problems/new-users-daily-count/README.md +++ b/problems/new-users-daily-count/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../parsing-a-boolean-expression "Parsing A Boolean Expression") diff --git a/problems/non-decreasing-array/README.md b/problems/non-decreasing-array/README.md index de826c401..1bf899059 100644 --- a/problems/non-decreasing-array/README.md +++ b/problems/non-decreasing-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strange-printer "Strange Printer") @@ -43,3 +43,6 @@ ### Related Topics [[Array](../../tag/array/README.md)] + +### Similar Questions + 1. [Find Good Days to Rob the Bank](../find-good-days-to-rob-the-bank) (Medium) diff --git a/problems/nth-highest-salary/README.md b/problems/nth-highest-salary/README.md index c8364cb74..b810c5eca 100644 --- a/problems/nth-highest-salary/README.md +++ b/problems/nth-highest-salary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../second-highest-salary "Second Highest Salary") diff --git a/problems/number-of-1-bits/README.md b/problems/number-of-1-bits/README.md index dc25d62d8..0fff41367 100644 --- a/problems/number-of-1-bits/README.md +++ b/problems/number-of-1-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-bits "Reverse Bits") diff --git a/problems/number-of-corner-rectangles/README.md b/problems/number-of-corner-rectangles/README.md index d6a1bc642..d504a9398 100644 --- a/problems/number-of-corner-rectangles/README.md +++ b/problems/number-of-corner-rectangles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../contain-virus "Contain Virus") diff --git a/problems/number-of-dice-rolls-with-target-sum/README.md b/problems/number-of-dice-rolls-with-target-sum/README.md index 8ef9457d8..2a075c709 100644 --- a/problems/number-of-dice-rolls-with-target-sum/README.md +++ b/problems/number-of-dice-rolls-with-target-sum/README.md @@ -11,68 +11,52 @@ ## [1155. Number of Dice Rolls With Target Sum (Medium)](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum "掷骰子的N种方法") -

    You have d dice and each die has f faces numbered 1, 2, ..., f. You are given three integers d, f, and target.

    +

    You have n dice and each die has k faces numbered from 1 to k.

    -

    Return the number of possible ways (out of fd total ways) modulo 109 + 7 to roll the dice so the sum of the face-up numbers equals target.

    +

    Given three integers n, k, and target, return the number of possible ways (out of the kn total ways) to roll the dice so the sum of the face-up numbers equals target. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    -Input: d = 1, f = 6, target = 3
    +Input: n = 1, k = 6, target = 3
     Output: 1
    -Explanation: 
    -You throw one die with 6 faces.  There is only one way to get a sum of 3.
    +Explanation: You throw one die with 6 faces.
    +There is only one way to get a sum of 3.
     

    Example 2:

    -Input: d = 2, f = 6, target = 7
    +Input: n = 2, k = 6, target = 7
     Output: 6
    -Explanation: 
    -You throw two dice, each with 6 faces.  There are 6 ways to get a sum of 7:
    -1+6, 2+5, 3+4, 4+3, 5+2, 6+1.
    +Explanation: You throw two dice, each with 6 faces.
    +There are 6 ways to get a sum of 7: 1+6, 2+5, 3+4, 4+3, 5+2, 6+1.
     

    Example 3:

    -Input: d = 2, f = 5, target = 10
    -Output: 1
    -Explanation: 
    -You throw two dice, each with 5 faces.  There is only one way to get a sum of 10: 5+5.
    -
    - -

    Example 4:

    - -
    -Input: d = 1, f = 2, target = 3
    -Output: 0
    -Explanation: 
    -You throw one die with 2 faces.  There is no way to get a sum of 3.
    -
    - -

    Example 5:

    - -
    -Input: d = 30, f = 30, target = 500
    +Input: n = 30, k = 30, target = 500
     Output: 222616187
    -Explanation: 
    -The answer must be returned modulo 10^9 + 7.
    +Explanation: The answer must be returned modulo 109 + 7.
     

     

    Constraints:

      -
    • 1 <= d, f <= 30
    • +
    • 1 <= n, k <= 30
    • 1 <= target <= 1000
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Equal Sum Arrays With Minimum Number of Operations](../equal-sum-arrays-with-minimum-number-of-operations) (Medium) + 1. [Find Missing Observations](../find-missing-observations) (Medium) + ### Hints
    Hint 1 diff --git a/problems/number-of-digit-one/README.md b/problems/number-of-digit-one/README.md index 79ca7fbd5..efc194352 100644 --- a/problems/number-of-digit-one/README.md +++ b/problems/number-of-digit-one/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../implement-queue-using-stacks "Implement Queue using Stacks") @@ -36,12 +36,12 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions - 1. [Factorial Trailing Zeroes](../factorial-trailing-zeroes) (Easy) + 1. [Factorial Trailing Zeroes](../factorial-trailing-zeroes) (Medium) 1. [Digit Count in Range](../digit-count-in-range) (Hard) ### Hints diff --git a/problems/number-of-distinct-substrings-in-a-string/README.md b/problems/number-of-distinct-substrings-in-a-string/README.md index cbf499178..97806c83a 100644 --- a/problems/number-of-distinct-substrings-in-a-string/README.md +++ b/problems/number-of-distinct-substrings-in-a-string/README.md @@ -14,11 +14,11 @@ ### Related Topics - [[Trie](../../tag/trie/README.md)] [[String](../../tag/string/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] [[Suffix Array](../../tag/suffix-array/README.md)] [[Hash Function](../../tag/hash-function/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/number-of-good-leaf-nodes-pairs/README.md b/problems/number-of-good-leaf-nodes-pairs/README.md index b7b4d21c1..d01430c7f 100644 --- a/problems/number-of-good-leaf-nodes-pairs/README.md +++ b/problems/number-of-good-leaf-nodes-pairs/README.md @@ -5,19 +5,19 @@ -[< Previous](../bulb-switcher-iv "Bulb Switcher IV") +[< Previous](../minimum-suffix-flips "Minimum Suffix Flips")                  [Next >](../string-compression-ii "String Compression II") ## [1530. Number of Good Leaf Nodes Pairs (Medium)](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") -

    Given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.

    +

    You are given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.

    Return the number of good leaf node pairs in the tree.

     

    Example 1:

    - +
     Input: root = [1,2,3,null,4], distance = 3
     Output: 1
    @@ -25,7 +25,7 @@
     

    Example 2:

    - +
     Input: root = [1,2,3,4,5,6,7], distance = 3
     Output: 2
    @@ -40,26 +40,12 @@
     Explanation: The only good pair is [2,5].
     
    -

    Example 4:

    - -
    -Input: root = [100], distance = 1
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: root = [1,1,1], distance = 2
    -Output: 1
    -
    -

     

    Constraints:

      -
    • The number of nodes in the tree is in the range [1, 2^10].
    • -
    • Each node's value is between [1, 100].
    • +
    • The number of nodes in the tree is in the range [1, 210].
    • +
    • 1 <= Node.val <= 100
    • 1 <= distance <= 10
    diff --git a/problems/number-of-good-ways-to-split-a-string/README.md b/problems/number-of-good-ways-to-split-a-string/README.md index 93f58f1d9..39d75a7e4 100644 --- a/problems/number-of-good-ways-to-split-a-string/README.md +++ b/problems/number-of-good-ways-to-split-a-string/README.md @@ -11,9 +11,11 @@ ## [1525. Number of Good Ways to Split a String (Medium)](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") -

    You are given a string s, a split is called good if you can split s into 2 non-empty strings p and q where its concatenation is equal to s and the number of distinct letters in p and q are the same.

    +

    You are given a string s.

    -

    Return the number of good splits you can make in s.

    +

    A split is called good if you can split s into two non-empty strings sleft and sright where their concatenation is equal to s (i.e., sleft + sright = s) and the number of distinct letters in sleft and sright is the same.

    + +

    Return the number of good splits you can make in s.

     

    Example 1:

    @@ -34,29 +36,15 @@
     Input: s = "abcd"
     Output: 1
    -Explanation: Split the string as follows ("ab", "cd").
    -
    - -

    Example 3:

    - -
    -Input: s = "aaaaa"
    -Output: 4
    -Explanation: All possible splits are good.
    - -

    Example 4:

    - -
    -Input: s = "acbadbaada"
    -Output: 2
    +Explanation: Split the string as follows ("ab", "cd").
     

     

    Constraints:

      -
    • s contains only lowercase English letters.
    • -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • +
    • s consists of only lowercase English letters.
    ### Related Topics diff --git a/problems/number-of-laser-beams-in-a-bank/README.md b/problems/number-of-laser-beams-in-a-bank/README.md new file mode 100644 index 000000000..831713168 --- /dev/null +++ b/problems/number-of-laser-beams-in-a-bank/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../check-if-all-as-appears-before-all-bs "Check if All A's Appears Before All B's") +                 +[Next >](../destroying-asteroids "Destroying Asteroids") + +## [2125. Number of Laser Beams in a Bank (Medium)](https://leetcode.com/problems/number-of-laser-beams-in-a-bank "银行中的激光束数量") + +

    Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is an m x n 2D matrix. bank[i] represents the ith row, consisting of '0's and '1's. '0' means the cell is empty, while'1' means the cell has a security device.

    + +

    There is one laser beam between any two security devices if both conditions are met:

    + +
      +
    • The two devices are located on two different rows: r1 and r2, where r1 < r2.
    • +
    • For each row i where r1 < i < r2, there are no security devices in the ith row.
    • +
    + +

    Laser beams are independent, i.e., one beam does not interfere nor join with another.

    + +

    Return the total number of laser beams in the bank.

    + +

     

    +

    Example 1:

    + +
    +Input: bank = ["011001","000000","010100","001000"]
    +Output: 8
    +Explanation: Between each of the following device pairs, there is one beam. In total, there are 8 beams:
    + * bank[0][1] -- bank[2][1]
    + * bank[0][1] -- bank[2][3]
    + * bank[0][2] -- bank[2][1]
    + * bank[0][2] -- bank[2][3]
    + * bank[0][5] -- bank[2][1]
    + * bank[0][5] -- bank[2][3]
    + * bank[2][1] -- bank[3][2]
    + * bank[2][3] -- bank[3][2]
    +Note that there is no beam between any device on the 0th row with any on the 3rd row.
    +This is because the 2nd row contains security devices, which breaks the second condition.
    +
    + +

    Example 2:

    + +
    +Input: bank = ["000","111","000"]
    +Output: 0
    +Explanation: There does not exist two devices located on two different rows.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == bank.length
    • +
    • n == bank[i].length
    • +
    • 1 <= m, n <= 500
    • +
    • bank[i][j] is either '0' or '1'.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +What is the commonality between security devices on the same row? +
    + +
    +Hint 2 +Each device on the same row has the same number of beams pointing towards the devices on the next row with devices. +
    + +
    +Hint 3 +If you were given an integer array where each element is the number of security devices on each row, can you solve it? +
    + +
    +Hint 4 +Convert the input to such an array, skip any row with no security device, then find the sum of the product between adjacent elements. +
    diff --git a/problems/number-of-lines-to-write-string/README.md b/problems/number-of-lines-to-write-string/README.md index bff49cf49..c21fe3637 100644 --- a/problems/number-of-lines-to-write-string/README.md +++ b/problems/number-of-lines-to-write-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-array-with-same-average "Split Array With Same Average") diff --git a/problems/number-of-longest-increasing-subsequence/README.md b/problems/number-of-longest-increasing-subsequence/README.md index 9baaae016..b3431dc6c 100644 --- a/problems/number-of-longest-increasing-subsequence/README.md +++ b/problems/number-of-longest-increasing-subsequence/README.md @@ -42,10 +42,10 @@ ### Related Topics - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] ### Similar Questions 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) diff --git a/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md b/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md index 633560907..fbfb6a7ef 100644 --- a/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md +++ b/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md @@ -11,17 +11,17 @@ ## [1519. Number of Nodes in the Sub-Tree With the Same Label (Medium)](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") -

    Given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).

    +

    You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).

    The edges array is given on the form edges[i] = [ai, bi], which means there is an edge between nodes ai and bi in the tree.

    -

    Return an array of size n where ans[i] is the number of nodes in the subtree of the ith node which have the same label as node i.

    +

    Return an array of size n where ans[i] is the number of nodes in the subtree of the ith node which have the same label as node i.

    -

    A subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.

    +

    A subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.

     

    Example 1:

    - +
     Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], labels = "abaedcd"
     Output: [2,1,1,1,1,1,1]
    @@ -30,7 +30,7 @@ Node 1 has a label 'b'. The sub-tree of node 1 contains nodes 1,4 and 5,
     

    Example 2:

    - +
     Input: n = 4, edges = [[0,1],[1,2],[0,3]], labels = "bbbb"
     Output: [4,2,1,1]
    @@ -41,37 +41,23 @@ The sub-tree of node 0 contains nodes 0, 1, 2 and 3, all with label 'b',
     

    Example 3:

    - +
     Input: n = 5, edges = [[0,1],[0,2],[1,3],[0,4]], labels = "aabab"
     Output: [3,2,1,1,1]
     
    -

    Example 4:

    - -
    -Input: n = 6, edges = [[0,1],[0,2],[1,3],[3,4],[4,5]], labels = "cbabaa"
    -Output: [1,2,1,1,2,1]
    -
    - -

    Example 5:

    - -
    -Input: n = 7, edges = [[0,1],[1,2],[2,3],[3,4],[4,5],[5,6]], labels = "aaabaaa"
    -Output: [6,5,4,1,3,2,1]
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^5
    • +
    • 1 <= n <= 105
    • edges.length == n - 1
    • edges[i].length == 2
    • -
    • 0 <= ai, bi < n
    • -
    • ai != bi
    • +
    • 0 <= ai, bi < n
    • +
    • ai != bi
    • labels.length == n
    • -
    • labels is consisting of only of lower-case English letters.
    • +
    • labels is consisting of only of lowercase English letters.
    ### Related Topics diff --git a/problems/number-of-operations-to-make-network-connected/README.md b/problems/number-of-operations-to-make-network-connected/README.md index 68f9686b0..77fb4cf07 100644 --- a/problems/number-of-operations-to-make-network-connected/README.md +++ b/problems/number-of-operations-to-make-network-connected/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-flips-to-make-a-or-b-equal-to-c "Minimum Flips to Make a OR b Equal to c") @@ -11,15 +11,15 @@ ## [1319. Number of Operations to Make Network Connected (Medium)](https://leetcode.com/problems/number-of-operations-to-make-network-connected "连通网络的操作次数") -

    There are n computers numbered from 0 to n-1 connected by ethernet cables connections forming a network where connections[i] = [a, b] represents a connection between computers a and b. Any computer can reach any other computer directly or indirectly through the network.

    +

    There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection between computers ai and bi. Any computer can reach any other computer directly or indirectly through the network.

    -

    Given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected. Return the minimum number of times you need to do this in order to make all the computers connected. If it's not possible, return -1. 

    +

    You are given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected.

    + +

    Return the minimum number of times you need to do this in order to make all the computers connected. If it is not possible, return -1.

     

    Example 1:

    - -

    - +
     Input: n = 4, connections = [[0,1],[0,2],[1,2]]
     Output: 1
    @@ -27,9 +27,7 @@
     

    Example 2:

    - -

    - +
     Input: n = 6, connections = [[0,1],[0,2],[0,3],[1,2],[1,3]]
     Output: 2
    @@ -43,22 +41,15 @@
     Explanation: There are not enough cables.
     
    -

    Example 4:

    - -
    -Input: n = 5, connections = [[0,1],[0,2],[3,4],[2,3]]
    -Output: 0
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^5
    • -
    • 1 <= connections.length <= min(n*(n-1)/2, 10^5)
    • +
    • 1 <= n <= 105
    • +
    • 1 <= connections.length <= min(n * (n - 1) / 2, 105)
    • connections[i].length == 2
    • -
    • 0 <= connections[i][0], connections[i][1] < n
    • -
    • connections[i][0] != connections[i][1]
    • +
    • 0 <= ai, bi < n
    • +
    • ai != bi
    • There are no repeated connections.
    • No two computers are connected by more than one cable.
    diff --git a/problems/number-of-segments-in-a-string/README.md b/problems/number-of-segments-in-a-string/README.md index 75512a97e..ccd1d349a 100644 --- a/problems/number-of-segments-in-a-string/README.md +++ b/problems/number-of-segments-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-genetic-mutation "Minimum Genetic Mutation") @@ -11,7 +11,7 @@ ## [434. Number of Segments in a String (Easy)](https://leetcode.com/problems/number-of-segments-in-a-string "字符串中的单词数") -

    You are given a string s, return the number of segments in the string

    +

    Given a string s, return the number of segments in the string.

    A segment is defined to be a contiguous sequence of non-space characters.

    @@ -31,26 +31,12 @@ Output: 1 -

    Example 3:

    - -
    -Input: s = "love live! mu'sic forever"
    -Output: 4
    -
    - -

    Example 4:

    - -
    -Input: s = ""
    -Output: 0
    -
    -

     

    Constraints:

    • 0 <= s.length <= 300
    • -
    • s consists of lower-case and upper-case English letters, digits or one of the following characters "!@#$%^&*()_+-=',.:".
    • +
    • s consists of lowercase and uppercase English letters, digits, or one of the following characters "!@#$%^&*()_+-=',.:".
    • The only space character in s is ' '.
    diff --git a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md index 693b07e4d..72246a390 100644 --- a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md +++ b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md @@ -13,7 +13,7 @@

    Given n points on a 1-D plane, where the ith point (from 0 to n-1) is at x = i, find the number of ways we can draw exactly k non-overlapping line segments such that each segment covers two or more points. The endpoints of each segment must have integral coordinates. The k line segments do not have to cover all n points, and they are allowed to share endpoints.

    -

    Return the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 109 + 7.

    +

    Return the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 109 + 7.

     

    Example 1:

    @@ -21,16 +21,16 @@
     Input: n = 4, k = 2
     Output: 5
    -Explanation: 
    -The two line segments are shown in red and blue.
    -The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),(2,3)}, {(1,2),(2,3)}, {(0,1),(1,2)}.
    +Explanation: The two line segments are shown in red and blue. +The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),(2,3)}, {(1,2),(2,3)}, {(0,1),(1,2)}. +

    Example 2:

     Input: n = 3, k = 1
     Output: 3
    -Explanation: The 3 ways are {(0,1)}, {(0,2)}, {(1,2)}.
    +Explanation: The 3 ways are {(0,1)}, {(0,2)}, {(1,2)}.
     

    Example 3:

    @@ -38,22 +38,9 @@ The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),
     Input: n = 30, k = 7
     Output: 796297179
    -Explanation: The total number of possible ways to draw 7 line segments is 3796297200. Taking this number modulo 109 + 7 gives us 796297179.
    -
    - -

    Example 4:

    - -
    -Input: n = 5, k = 3
    -Output: 7
    +Explanation: The total number of possible ways to draw 7 line segments is 3796297200. Taking this number modulo 109 + 7 gives us 796297179.
     
    -

    Example 5:

    - -
    -Input: n = 3, k = 2
    -Output: 1
    -

     

    Constraints:

    diff --git a/problems/number-of-smooth-descent-periods-of-a-stock/README.md b/problems/number-of-smooth-descent-periods-of-a-stock/README.md new file mode 100644 index 000000000..8a05be526 --- /dev/null +++ b/problems/number-of-smooth-descent-periods-of-a-stock/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../adding-spaces-to-a-string "Adding Spaces to a String") +                 +[Next >](../minimum-operations-to-make-the-array-k-increasing "Minimum Operations to Make the Array K-Increasing") + +## [2110. Number of Smooth Descent Periods of a Stock (Medium)](https://leetcode.com/problems/number-of-smooth-descent-periods-of-a-stock "股票平滑下跌阶段的数目") + +

    You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the ith day.

    + +

    A smooth descent period of a stock consists of one or more contiguous days such that the price on each day is lower than the price on the preceding day by exactly 1. The first day of the period is exempted from this rule.

    + +

    Return the number of smooth descent periods.

    + +

     

    +

    Example 1:

    + +
    +Input: prices = [3,2,1,4]
    +Output: 7
    +Explanation: There are 7 smooth descent periods:
    +[3], [2], [1], [4], [3,2], [2,1], and [3,2,1]
    +Note that a period with one day is a smooth descent period by the definition.
    +
    + +

    Example 2:

    + +
    +Input: prices = [8,6,7,7]
    +Output: 4
    +Explanation: There are 4 smooth descent periods: [8], [6], [7], and [7]
    +Note that [8,6] is not a smooth descent period as 8 - 6 ≠ 1.
    +
    + +

    Example 3:

    + +
    +Input: prices = [1]
    +Output: 1
    +Explanation: There is 1 smooth descent period: [1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= prices.length <= 105
    • +
    • 1 <= prices[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Any array is a series of adjacent longest possible smooth descent periods. For example, [5,3,2,1,7,6] is [5] + [3,2,1] + [7,6]. +
    + +
    +Hint 2 +Think of a 2-pointer approach to traverse the array and find each longest possible period. +
    + +
    +Hint 3 +Suppose you found the longest possible period with a length of k. How many periods are within that period? How can you count them quickly? Think of the formula to calculate the sum of 1, 2, 3, ..., k. +
    diff --git a/problems/number-of-spaces-cleaning-robot-cleaned/README.md b/problems/number-of-spaces-cleaning-robot-cleaned/README.md index f9fed2877..c40efb276 100644 --- a/problems/number-of-spaces-cleaning-robot-cleaned/README.md +++ b/problems/number-of-spaces-cleaning-robot-cleaned/README.md @@ -9,7 +9,7 @@                  [Next >](../count-vowel-substrings-of-a-string "Count Vowel Substrings of a String") -## [2061. Number of Spaces Cleaning Robot Cleaned (Medium)](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned "") +## [2061. Number of Spaces Cleaning Robot Cleaned (Medium)](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned "扫地机器人清扫过的空间个数") diff --git a/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md b/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md index 089c252a9..a94b24aca 100644 --- a/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md +++ b/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md @@ -65,8 +65,11 @@ Step 1) 2 is even, divide by 2 and obtain 1.  ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Similar Questions + 1. [Minimum Moves to Reach Target Score](../minimum-moves-to-reach-target-score) (Medium) ### Hints
    diff --git a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md index ac1dab90c..6a5b12197 100644 --- a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md +++ b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md @@ -57,8 +57,12 @@ Step 4) 1 is odd; subtract 1 and obtain 0. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Similar Questions + 1. [Minimum Moves to Reach Target Score](../minimum-moves-to-reach-target-score) (Medium) + 1. [Count Operations to Obtain Zero](../count-operations-to-obtain-zero) (Easy) ### Hints
    diff --git a/problems/number-of-students-doing-homework-at-a-given-time/README.md b/problems/number-of-students-doing-homework-at-a-given-time/README.md index 549a039e0..0378b7668 100644 --- a/problems/number-of-students-doing-homework-at-a-given-time/README.md +++ b/problems/number-of-students-doing-homework-at-a-given-time/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../form-largest-integer-with-digits-that-add-up-to-target "Form Largest Integer With Digits That Add up to Target") @@ -15,7 +15,7 @@

    The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].

    -

    Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.

    +

    Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.

     

    Example 1:

    @@ -37,27 +37,6 @@ The third student started doing homework at time 3 and finished at time 7 and wa Explanation: The only student was doing their homework at the queryTime. -

    Example 3:

    - -
    -Input: startTime = [4], endTime = [4], queryTime = 5
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: startTime = [1,1,1,1], endTime = [1,3,2,4], queryTime = 7
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: startTime = [9,8,7,6,5,4,3,2,1], endTime = [10,10,10,10,10,10,10,10,10], queryTime = 5
    -Output: 5
    -
    -

     

    Constraints:

    @@ -65,7 +44,7 @@ The third student started doing homework at time 3 and finished at time 7 and wa
  • startTime.length == endTime.length
  • 1 <= startTime.length <= 100
  • 1 <= startTime[i] <= endTime[i] <= 1000
  • -
  • 1 <= queryTime <= 1000
  • +
  • 1 <= queryTime <= 1000
  • ### Related Topics diff --git a/problems/number-of-students-unable-to-eat-lunch/README.md b/problems/number-of-students-unable-to-eat-lunch/README.md index 0251d8e4b..010fc4510 100644 --- a/problems/number-of-students-unable-to-eat-lunch/README.md +++ b/problems/number-of-students-unable-to-eat-lunch/README.md @@ -60,11 +60,14 @@ Hence all students are able to eat. ### Related Topics + [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] [[Queue](../../tag/queue/README.md)] - [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] +### Similar Questions + 1. [Time Needed to Buy Tickets](../time-needed-to-buy-tickets) (Easy) + ### Hints
    Hint 1 diff --git a/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md b/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md index 4eead3055..ea0d4c7dd 100644 --- a/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md +++ b/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md @@ -11,9 +11,7 @@ ## [1343. Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold (Medium)](https://leetcode.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "大小为 K 且平均值大于等于阈值的子数组数目") -

    Given an array of integers arr and two integers k and threshold.

    - -

    Return the number of sub-arrays of size k and average greater than or equal to threshold.

    +

    Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.

     

    Example 1:

    @@ -26,41 +24,20 @@

    Example 2:

    -
    -Input: arr = [1,1,1,1,1], k = 1, threshold = 0
    -Output: 5
    -
    - -

    Example 3:

    -
     Input: arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5
     Output: 6
     Explanation: The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.
     
    -

    Example 4:

    - -
    -Input: arr = [7,7,7,7,7,7,7], k = 7, threshold = 7
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: arr = [4,4,4,4], k = 4, threshold = 1
    -Output: 1
    -
    -

     

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • -
    • 1 <= arr[i] <= 10^4
    • +
    • 1 <= arr.length <= 105
    • +
    • 1 <= arr[i] <= 104
    • 1 <= k <= arr.length
    • -
    • 0 <= threshold <= 10^4
    • +
    • 0 <= threshold <= 104
    ### Related Topics diff --git a/problems/number-of-sub-arrays-with-odd-sum/README.md b/problems/number-of-sub-arrays-with-odd-sum/README.md index cbb19a8a7..98a5c903c 100644 --- a/problems/number-of-sub-arrays-with-odd-sum/README.md +++ b/problems/number-of-sub-arrays-with-odd-sum/README.md @@ -57,6 +57,9 @@ All sub-arrays have even sum and the answer is 0. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Subsequence of Size K With the Largest Even Sum](../subsequence-of-size-k-with-the-largest-even-sum) (Medium) + ### Hints
    Hint 1 diff --git a/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md b/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md index d049a56a9..e05fcbde2 100644 --- a/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md +++ b/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-array-pairs-are-divisible-by-k "Check If Array Pairs Are Divisible by k") @@ -11,9 +11,9 @@ ## [1498. Number of Subsequences That Satisfy the Given Sum Condition (Medium)](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition "满足条件的子序列数目") -

    Given an array of integers nums and an integer target.

    +

    You are given an array of integers nums and an integer target.

    -

    Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.

    +

    Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -21,7 +21,7 @@
     Input: nums = [3,5,6,7], target = 9
     Output: 4
    -Explanation: There are 4 subsequences that satisfy the condition.
    +Explanation: There are 4 subsequences that satisfy the condition.
     [3] -> Min value + max value <= target (3 + 3 <= 9)
     [3,5] -> (3 + 5 <= 9)
     [3,5,6] -> (3 + 6 <= 9)
    @@ -33,25 +33,19 @@
     
     Input: nums = [3,3,6,8], target = 10
     Output: 6
    -Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).
    -[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]
    +Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers). +[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6] +

    Example 3:

     Input: nums = [2,3,3,4,6,7], target = 12
     Output: 61
    -Explanation: There are 63 non-empty subsequences, two of them don't satisfy the condition ([6,7], [7]).
    +Explanation: There are 63 non-empty subsequences, two of them do not satisfy the condition ([6,7], [7]).
     Number of valid subsequences (63 - 2 = 61).
     
    -

    Example 4:

    - -
    -Input: nums = [5,2,4,1,7,6,8], target = 16
    -Output: 127
    -Explanation: All non-empty subset satisfy the condition (2^7 - 1) = 127
    -

     

    Constraints:

    diff --git a/problems/number-of-substrings-with-only-1s/README.md b/problems/number-of-substrings-with-only-1s/README.md index ac9643cdb..3e0062cdb 100644 --- a/problems/number-of-substrings-with-only-1s/README.md +++ b/problems/number-of-substrings-with-only-1s/README.md @@ -40,13 +40,6 @@ Explanation: Each substring contains only 1's characters. -

    Example 4:

    - -
    -Input: s = "000"
    -Output: 0
    -
    -

     

    Constraints:

    @@ -59,6 +52,10 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) + 1. [Count Vowel Substrings of a String](../count-vowel-substrings-of-a-string) (Easy) + ### Hints
    Hint 1 diff --git a/problems/number-of-transactions-per-visit/README.md b/problems/number-of-transactions-per-visit/README.md index 423f88ca9..e08f68f39 100644 --- a/problems/number-of-transactions-per-visit/README.md +++ b/problems/number-of-transactions-per-visit/README.md @@ -95,6 +95,3 @@ Note that we stopped at transactions_count = 3 as this is the maximum number of ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Find the Missing IDs](../find-the-missing-ids) (Medium) diff --git a/problems/number-of-unique-flavors-after-sharing-k-candies/README.md b/problems/number-of-unique-flavors-after-sharing-k-candies/README.md new file mode 100644 index 000000000..e77956fbe --- /dev/null +++ b/problems/number-of-unique-flavors-after-sharing-k-candies/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../maximum-fruits-harvested-after-at-most-k-steps "Maximum Fruits Harvested After at Most K Steps") +                 +[Next >](../find-first-palindromic-string-in-the-array "Find First Palindromic String in the Array") + +## [2107. Number of Unique Flavors After Sharing K Candies (Medium)](https://leetcode.com/problems/number-of-unique-flavors-after-sharing-k-candies "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +For every group of k consecutive candies, count the number of unique flavors not inside that group. Return the largest number of unique flavors. +
    + +
    +Hint 2 +When calculating an adjacent group of k consecutive candies, can you use some of your previous calculations? +
    + +
    +Hint 3 +Use a sliding window where the window is the group of k consecutive candies you are sharing. Use a hash map to store the number of candies of each type you can keep. +
    diff --git a/problems/number-of-valid-move-combinations-on-chessboard/README.md b/problems/number-of-valid-move-combinations-on-chessboard/README.md index dfb94f7e2..89549528a 100644 --- a/problems/number-of-valid-move-combinations-on-chessboard/README.md +++ b/problems/number-of-valid-move-combinations-on-chessboard/README.md @@ -58,33 +58,6 @@ Explanation: The image above shows the possible squares the piece can move to. -

    Example 4:

    - -
    -Input: pieces = ["rook","rook"], positions = [[1,1],[8,8]]
    -Output: 223
    -Explanation: There are 15 moves for each rook which results in 15 * 15 = 225 move combinations.
    -However, there are two invalid move combinations:
    -- Move both rooks to (8, 1), where they collide.
    -- Move both rooks to (1, 8), where they collide.
    -Thus there are 225 - 2 = 223 valid move combinations.
    -Note that there are two valid move combinations that would result in one rook at (1, 8) and the other at (8, 1).
    -Even though the board state is the same, these two move combinations are considered different since the moves themselves are different.
    -
    - -

    Example 5:

    - -
    -Input: pieces = ["queen","bishop"], positions = [[5,7],[3,4]]
    -Output: 281
    -Explanation: There are 12 * 24 = 288 move combinations.
    -However, there are several invalid move combinations:
    -- If the queen stops at (6, 7), it blocks the bishop from moving to (6, 7) or (7, 8).
    -- If the queen stops at (5, 6), it blocks the bishop from moving to (5, 6), (6, 7), or (7, 8).
    -- If the bishop stops at (5, 2), it blocks the queen from moving to (5, 2) or (5, 1).
    -Of the 288 move combinations, 281 are valid.
    -
    -

     

    Constraints:

    @@ -92,10 +65,10 @@ Of the 288 move combinations, 281 are valid.
  • n == pieces.length
  • n == positions.length
  • 1 <= n <= 4
  • -
  • pieces only contains the strings "rook""queen", and "bishop".
  • +
  • pieces only contains the strings "rook", "queen", and "bishop".
  • There will be at most one queen on the chessboard.
  • 1 <= xi, yi <= 8
  • -
  • Each positions[i] is distinct.
  • +
  • Each positions[i] is distinct.
  • ### Related Topics diff --git a/problems/number-of-valid-words-in-a-sentence/README.md b/problems/number-of-valid-words-in-a-sentence/README.md index 624517eb4..6687e6bd5 100644 --- a/problems/number-of-valid-words-in-a-sentence/README.md +++ b/problems/number-of-valid-words-in-a-sentence/README.md @@ -53,14 +53,6 @@ "stone-game10" is invalid because it contains digits. -

    Example 4:

    - -
    -Input: sentence = "he bought 2 pencils, 3 erasers, and 1  pencil-sharpener."
    -Output: 6
    -Explanation: The valid words in the sentence are "he", "bought", "pencils,", "erasers,", "and", and "pencil-sharpener.".
    -
    -

     

    Constraints:

    diff --git a/problems/number-of-ways-to-divide-a-long-corridor/README.md b/problems/number-of-ways-to-divide-a-long-corridor/README.md new file mode 100644 index 000000000..020172312 --- /dev/null +++ b/problems/number-of-ways-to-divide-a-long-corridor/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../k-highest-ranked-items-within-a-price-range "K Highest Ranked Items Within a Price Range") +                 +[Next >](../count-elements-with-strictly-smaller-and-greater-elements "Count Elements With Strictly Smaller and Greater Elements ") + +## [2147. Number of Ways to Divide a Long Corridor (Hard)](https://leetcode.com/problems/number-of-ways-to-divide-a-long-corridor "分隔长廊的方案数") + +

    Along a long library corridor, there is a line of seats and decorative plants. You are given a 0-indexed string corridor of length n consisting of letters 'S' and 'P' where each 'S' represents a seat and each 'P' represents a plant.

    + +

    One room divider has already been installed to the left of index 0, and another to the right of index n - 1. Additional room dividers can be installed. For each position between indices i - 1 and i (1 <= i <= n - 1), at most one divider can be installed.

    + +

    Divide the corridor into non-overlapping sections, where each section has exactly two seats with any number of plants. There may be multiple ways to perform the division. Two ways are different if there is a position with a room divider installed in the first way but not in the second way.

    + +

    Return the number of ways to divide the corridor. Since the answer may be very large, return it modulo 109 + 7. If there is no way, return 0.

    + +

     

    +

    Example 1:

    + +
    +Input: corridor = "SSPPSPS"
    +Output: 3
    +Explanation: There are 3 different ways to divide the corridor.
    +The black bars in the above image indicate the two room dividers already installed.
    +Note that in each of the ways, each section has exactly two seats.
    +
    + +

    Example 2:

    + +
    +Input: corridor = "PPSPSP"
    +Output: 1
    +Explanation: There is only 1 way to divide the corridor, by not installing any additional dividers.
    +Installing any would create some section that does not have exactly two seats.
    +
    + +

    Example 3:

    + +
    +Input: corridor = "S"
    +Output: 0
    +Explanation: There is no way to divide the corridor because there will always be a section that does not have exactly two seats.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == corridor.length
    • +
    • 1 <= n <= 105
    • +
    • corridor[i] is either 'S' or 'P'.
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Divide the corridor into segments. Each segment has two seats, starts precisely with one seat, and ends precisely with the other seat. +
    + +
    +Hint 2 +How many dividers can you install between two adjacent segments? You must install precisely one. Otherwise, you would have created a section with not exactly two seats. +
    + +
    +Hint 3 +If there are k plants between two adjacent segments, there are k + 1 positions (ways) you could install the divider you must install. +
    + +
    +Hint 4 +The problem now becomes: Find the product of all possible positions between every two adjacent segments. +
    diff --git a/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md b/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md index 209ae1f48..8ef01bd16 100644 --- a/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md +++ b/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md @@ -22,7 +22,7 @@
  • Repeat the process until you form the string target.
  • -

    Notice that you can use multiple characters from the same string in words provided the conditions above are met.

    +

    Notice that you can use multiple characters from the same string in words provided the conditions above are met.

    Return the number of ways to form target from words. Since the answer may be too large, return it modulo 109 + 7.

    @@ -53,20 +53,6 @@ "bab" -> index 1 ("abba"), index 2 ("baab"), index 3 ("baab") -

    Example 3:

    - -
    -Input: words = ["abcd"], target = "abcd"
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: words = ["abab","baba","abba","baab"], target = "abba"
    -Output: 16
    -
    -

     

    Constraints:

    diff --git a/problems/number-of-ways-to-paint-n-3-grid/README.md b/problems/number-of-ways-to-paint-n-3-grid/README.md index 5b1198fdb..aea32d531 100644 --- a/problems/number-of-ways-to-paint-n-3-grid/README.md +++ b/problems/number-of-ways-to-paint-n-3-grid/README.md @@ -26,27 +26,6 @@

    Example 2:

    -
    -Input: n = 2
    -Output: 54
    -
    - -

    Example 3:

    - -
    -Input: n = 3
    -Output: 246
    -
    - -

    Example 4:

    - -
    -Input: n = 7
    -Output: 106494
    -
    - -

    Example 5:

    -
     Input: n = 5000
     Output: 30228214
    @@ -57,13 +36,15 @@
     
     
    • n == grid.length
    • -
    • grid[i].length == 3
    • 1 <= n <= 5000
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Painting a Grid With Three Different Colors](../painting-a-grid-with-three-different-colors) (Hard) + ### Hints
    Hint 1 diff --git a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md index b6a36b36a..698d1d0ed 100644 --- a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md +++ b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md @@ -11,33 +11,31 @@ ## [1569. Number of Ways to Reorder Array to Get Same BST (Hard)](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") -

    Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the original array nums.

    +

    Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the original array nums.

    -

    For example, given nums = [2,1,3], we will have 2 as the root, 1 as a left child, and 3 as a right child. The array [2,3,1] also yields the same BST but [3,2,1] yields a different BST.

    +
      +
    • For example, given nums = [2,1,3], we will have 2 as the root, 1 as a left child, and 3 as a right child. The array [2,3,1] also yields the same BST but [3,2,1] yields a different BST.
    • +
    -

    Return the number of ways to reorder nums such that the BST formed is identical to the original BST formed from nums.

    +

    Return the number of ways to reorder nums such that the BST formed is identical to the original BST formed from nums.

    -

    Since the answer may be very large, return it modulo 10^9 + 7.

    +

    Since the answer may be very large, return it modulo 109 + 7.

     

    Example 1:

    - -

    - +
     Input: nums = [2,1,3]
     Output: 1
    -Explanation: We can reorder nums to be [2,3,1] which will yield the same BST. There are no other ways to reorder nums which will yield the same BST.
    +Explanation: We can reorder nums to be [2,3,1] which will yield the same BST. There are no other ways to reorder nums which will yield the same BST.
     

    Example 2:

    - -

    - +
     Input: nums = [3,4,5,1,2]
     Output: 5
    -Explanation: The following 5 arrays will yield the same BST: 
    +Explanation: The following 5 arrays will yield the same BST: 
     [3,1,2,4,5]
     [3,1,4,2,5]
     [3,1,4,5,2]
    @@ -46,30 +44,11 @@
     

    Example 3:

    - -

    - +
     Input: nums = [1,2,3]
     Output: 0
    -Explanation: There are no other orderings of nums that will yield the same BST.
    -
    - -

    Example 4:

    - -

    - -
    -Input: nums = [3,1,2,5,4,6]
    -Output: 19
    -
    - -

    Example 5:

    - -
    -Input: nums = [9,4,2,1,3,6,5,7,8,14,11,10,12,13,16,15,17,18]
    -Output: 216212978
    -Explanation: The number of ways to reorder nums to get the same BST is 3216212999. Taking this number modulo 10^9 + 7 gives 216212978.
    +Explanation: There are no other orderings of nums that will yield the same BST.
     

     

    @@ -78,20 +57,20 @@
    • 1 <= nums.length <= 1000
    • 1 <= nums[i] <= nums.length
    • -
    • All integers in nums are distinct.
    • +
    • All integers in nums are distinct.
    ### Related Topics - [[Tree](../../tag/tree/README.md)] - [[Union Find](../../tag/union-find/README.md)] - [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Binary Tree](../../tag/binary-tree/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Memoization](../../tag/memoization/README.md)] [[Combinatorics](../../tag/combinatorics/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/number-of-ways-to-separate-numbers/README.md b/problems/number-of-ways-to-separate-numbers/README.md index f305dec5b..1d359dd07 100644 --- a/problems/number-of-ways-to-separate-numbers/README.md +++ b/problems/number-of-ways-to-separate-numbers/README.md @@ -21,7 +21,7 @@
     Input: num = "327"
     Output: 2
    -Explanation: You could have written down the numbers:
    +Explanation: You could have written down the numbers:
     3, 27
     327
     
    @@ -31,7 +31,7 @@
     Input: num = "094"
     Output: 0
    -Explanation: No numbers can have leading zeros and all numbers must be positive.
    +Explanation: No numbers can have leading zeros and all numbers must be positive.
     

    Example 3:

    @@ -39,14 +39,7 @@
     Input: num = "0"
     Output: 0
    -Explanation: No numbers can have leading zeros and all numbers must be positive.
    -
    - -

    Example 4:

    - -
    -Input: num = "9999999999999"
    -Output: 101
    +Explanation: No numbers can have leading zeros and all numbers must be positive.
     

     

    diff --git a/problems/number-of-ways-to-split-a-string/README.md b/problems/number-of-ways-to-split-a-string/README.md index cfdbf11da..9874c1112 100644 --- a/problems/number-of-ways-to-split-a-string/README.md +++ b/problems/number-of-ways-to-split-a-string/README.md @@ -11,11 +11,9 @@ ## [1573. Number of Ways to Split a String (Medium)](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") -

    Given a binary string s (a string consisting only of '0's and '1's), we can split s into 3 non-empty strings s1, s2, s3 (s1+ s2+ s3 = s).

    +

    Given a binary string s, you can split s into 3 non-empty strings s1, s2, and s3 where s1 + s2 + s3 = s.

    -

    Return the number of ways s can be split such that the number of characters '1' is the same in s1, s2, and s3.

    - -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Return the number of ways s can be split such that the number of ones is the same in s1, s2, and s3. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -48,25 +46,21 @@ "00|0|0"
    -

    Example 4:

    - -
    -Input: s = "100100010100110"
    -Output: 12
    -
    -

     

    Constraints:

      -
    • 3 <= s.length <= 10^5
    • -
    • s[i] is '0' or '1'.
    • +
    • 3 <= s.length <= 105
    • +
    • s[i] is either '0' or '1'.
    ### Related Topics [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Split Array with Equal Sum](../split-array-with-equal-sum) (Hard) + ### Hints
    Hint 1 diff --git a/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md index f49a48d8b..a5b016402 100644 --- a/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md +++ b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-a-string-can-break-another-string "Check If a String Can Break Another String") @@ -11,13 +11,13 @@ ## [1434. Number of Ways to Wear Different Hats to Each Other (Hard)](https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other "每个人戴不同帽子的方案数") -

    There are n people and 40 types of hats labeled from 1 to 40.

    +

    There are n people and 40 types of hats labeled from 1 to 40.

    -

    Given a list of list of integers hats, where hats[i] is a list of all hats preferred by the i-th person.

    +

    Given a 2D integer array hats, where hats[i] is a list of all hats preferred by the ith person.

    -

    Return the number of ways that the n people wear different hats to each other.

    +

    Return the number of ways that the n people wear different hats to each other.

    -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -25,15 +25,16 @@
     Input: hats = [[3,4],[4,5],[5]]
     Output: 1
    -Explanation: There is only one way to choose hats given the conditions. 
    -First person choose hat 3, Second person choose hat 4 and last one hat 5.
    +Explanation: There is only one way to choose hats given the conditions. +First person choose hat 3, Second person choose hat 4 and last one hat 5. +

    Example 2:

     Input: hats = [[3,5,1],[3,5]]
     Output: 4
    -Explanation: There are 4 ways to choose hats
    +Explanation: There are 4 ways to choose hats:
     (3,5), (5,3), (1,3) and (1,5)
     
    @@ -42,17 +43,10 @@ First person choose hat 3, Second person choose hat 4 and last one hat 5.
     Input: hats = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]
     Output: 24
    -Explanation: Each person can choose hats labeled from 1 to 4.
    +Explanation: Each person can choose hats labeled from 1 to 4.
     Number of Permutations of (1,2,3,4) = 24.
     
    -

    Example 4:

    - -
    -Input: hats = [[1,2,3],[2,3,5,6],[1,3,7,9],[1,8,9],[2,5,7]]
    -Output: 111
    -
    -

     

    Constraints:

    diff --git a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md index 4a9a83b5e..9a7b126db 100644 --- a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md +++ b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md @@ -7,15 +7,15 @@ [< Previous](../replace-all-s-to-avoid-consecutive-repeating-characters "Replace All ?'s to Avoid Consecutive Repeating Characters")                  -[Next >](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters") +[Next >](../minimum-time-to-make-rope-colorful "Minimum Time to Make Rope Colorful") ## [1577. Number of Ways Where Square of Number Is Equal to Product of Two Numbers (Medium)](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") -

    Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:

    +

    Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:

      -
    • Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
    • -
    • Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.
    • +
    • Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
    • +
    • Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.

     

    @@ -24,7 +24,7 @@
     Input: nums1 = [7,4], nums2 = [5,2,8,9]
     Output: 1
    -Explanation: Type 1: (1,1,2), nums1[1]^2 = nums2[1] * nums2[2]. (4^2 = 2 * 8). 
    +Explanation: Type 1: (1, 1, 2), nums1[1]2 = nums2[1] * nums2[2]. (42 = 2 * 8). 
     

    Example 2:

    @@ -32,9 +32,9 @@
     Input: nums1 = [1,1], nums2 = [1,1,1]
     Output: 9
    -Explanation: All Triplets are valid, because 1^2 = 1 * 1.
    -Type 1: (0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2).  nums1[i]^2 = nums2[j] * nums2[k].
    -Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]^2 = nums1[j] * nums1[k].
    +Explanation: All Triplets are valid, because 12 = 1 * 1.
    +Type 1: (0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2).  nums1[i]2 = nums2[j] * nums2[k].
    +Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]2 = nums1[j] * nums1[k].
     

    Example 3:

    @@ -43,16 +43,8 @@ Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]^2 = nums1[j] * nums1[k]. Input: nums1 = [7,7,8,3], nums2 = [1,2,9,7] Output: 2 Explanation: There are 2 valid triplets. -Type 1: (3,0,2). nums1[3]^2 = nums2[0] * nums2[2]. -Type 2: (3,0,1). nums2[3]^2 = nums1[0] * nums1[1]. - - -

    Example 4:

    - -
    -Input: nums1 = [4,7,9,11,23], nums2 = [3,5,1024,12,18]
    -Output: 0
    -Explanation: There are no valid triplets.
    +Type 1: (3,0,2).  nums1[3]2 = nums2[0] * nums2[2].
    +Type 2: (3,0,1).  nums2[3]2 = nums1[0] * nums1[1].
     

     

    @@ -60,7 +52,7 @@ Type 2: (3,0,1). nums2[3]^2 = nums1[0] * nums1[1].
    • 1 <= nums1.length, nums2.length <= 1000
    • -
    • 1 <= nums1[i], nums2[i] <= 10^5
    • +
    • 1 <= nums1[i], nums2[i] <= 105
    ### Related Topics diff --git a/problems/numbers-with-repeated-digits/README.md b/problems/numbers-with-repeated-digits/README.md index 83006a889..4d2f0738f 100644 --- a/problems/numbers-with-repeated-digits/README.md +++ b/problems/numbers-with-repeated-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../capacity-to-ship-packages-within-d-days "Capacity To Ship Packages Within D Days") diff --git a/problems/odd-even-jump/README.md b/problems/odd-even-jump/README.md index faf449c89..43a345e2d 100644 --- a/problems/odd-even-jump/README.md +++ b/problems/odd-even-jump/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subarray-sums-divisible-by-k "Subarray Sums Divisible by K") diff --git a/problems/online-majority-element-in-subarray/README.md b/problems/online-majority-element-in-subarray/README.md index 5dd0844bb..a21a6a7ed 100644 --- a/problems/online-majority-element-in-subarray/README.md +++ b/problems/online-majority-element-in-subarray/README.md @@ -52,11 +52,11 @@ majorityChecker.query(2, 3, 2); // return 2 ### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Design](../../tag/design/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] ### Hints
    diff --git a/problems/order-two-columns-independently/README.md b/problems/order-two-columns-independently/README.md new file mode 100644 index 000000000..24bed0989 --- /dev/null +++ b/problems/order-two-columns-independently/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../amount-of-new-area-painted-each-day "Amount of New Area Painted Each Day") +                 +[Next >](../minimum-sum-of-four-digit-number-after-splitting-digits "Minimum Sum of Four Digit Number After Splitting Digits") + +## [2159. Order Two Columns Independently (Medium)](https://leetcode.com/problems/order-two-columns-independently "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/order-two-columns-independently/mysql_schemas.sql b/problems/order-two-columns-independently/mysql_schemas.sql new file mode 100644 index 000000000..444d9231f --- /dev/null +++ b/problems/order-two-columns-independently/mysql_schemas.sql @@ -0,0 +1,6 @@ +Create table If Not Exists Data (first_col int, second_col int); +Truncate table Data; +insert into Data (first_col, second_col) values ('4', '2'); +insert into Data (first_col, second_col) values ('2', '3'); +insert into Data (first_col, second_col) values ('3', '1'); +insert into Data (first_col, second_col) values ('1', '4'); diff --git a/problems/orders-with-maximum-quantity-above-average/README.md b/problems/orders-with-maximum-quantity-above-average/README.md index 063bde62f..4743751d8 100644 --- a/problems/orders-with-maximum-quantity-above-average/README.md +++ b/problems/orders-with-maximum-quantity-above-average/README.md @@ -9,7 +9,7 @@                  [Next >](../product-of-two-run-length-encoded-arrays "Product of Two Run-Length Encoded Arrays") -## [1867. Orders With Maximum Quantity Above Average (Medium)](https://leetcode.com/problems/orders-with-maximum-quantity-above-average "") +## [1867. Orders With Maximum Quantity Above Average (Medium)](https://leetcode.com/problems/orders-with-maximum-quantity-above-average "最大数量高于平均水平的订单") diff --git a/problems/paint-fence/README.md b/problems/paint-fence/README.md index 3317001f8..508201a5d 100644 --- a/problems/paint-fence/README.md +++ b/problems/paint-fence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../h-index-ii "H-Index II") diff --git a/problems/paint-house-iii/README.md b/problems/paint-house-iii/README.md index 71f75b642..2edda59c6 100644 --- a/problems/paint-house-iii/README.md +++ b/problems/paint-house-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-browser-history "Design Browser History") @@ -19,7 +19,7 @@
  • For example: houses = [1,2,2,3,3,2,1,1] contains 5 neighborhoods [{1}, {2,2}, {3,3}, {2}, {1,1}].
  • -

    Given an array houses, an m x n matrix cost and an integer target where:

    +

    Given an array houses, an m x n matrix cost and an integer target where:

    • houses[i]: is the color of the house i, and 0 if the house is not painted yet.
    • @@ -51,13 +51,6 @@ Cost of paint the first and last house (10 + 1) = 11.

      Example 3:

      -
      -Input: houses = [0,0,0,0,0], cost = [[1,10],[10,1],[1,10],[10,1],[1,10]], m = 5, n = 2, target = 5
      -Output: 5
      -
      - -

      Example 4:

      -
       Input: houses = [3,1,2,3], cost = [[1,1,1],[1,1,1],[1,1,1],[1,1,1]], m = 4, n = 3, target = 3
       Output: -1
      @@ -74,7 +67,7 @@ Cost of paint the first and last house (10 + 1) = 11.
       	
    • 1 <= n <= 20
    • 1 <= target <= m
    • 0 <= houses[i] <= n
    • -
    • 1 <= cost[i][j] <= 10^4
    • +
    • 1 <= cost[i][j] <= 104
    ### Related Topics diff --git a/problems/palindrome-linked-list/README.md b/problems/palindrome-linked-list/README.md index 3baebf8c4..95753900b 100644 --- a/problems/palindrome-linked-list/README.md +++ b/problems/palindrome-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-digit-one "Number of Digit One") diff --git a/problems/palindrome-pairs/README.md b/problems/palindrome-pairs/README.md index 7c370230a..05b89368f 100644 --- a/problems/palindrome-pairs/README.md +++ b/problems/palindrome-pairs/README.md @@ -55,3 +55,4 @@ ### Similar Questions 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) 1. [Shortest Palindrome](../shortest-palindrome) (Hard) + 1. [Longest Palindrome by Concatenating Two Letter Words](../longest-palindrome-by-concatenating-two-letter-words) (Medium) diff --git a/problems/palindrome-partitioning-iii/README.md b/problems/palindrome-partitioning-iii/README.md index b54eb04ff..8116ce7c1 100644 --- a/problems/palindrome-partitioning-iii/README.md +++ b/problems/palindrome-partitioning-iii/README.md @@ -55,6 +55,9 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Palindrome Partitioning IV](../palindrome-partitioning-iv) (Hard) + ### Hints
    Hint 1 diff --git a/problems/palindrome-removal/README.md b/problems/palindrome-removal/README.md index 63f3f227e..f7b82a429 100644 --- a/problems/palindrome-removal/README.md +++ b/problems/palindrome-removal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tree-diameter "Tree Diameter") diff --git a/problems/parallel-courses-ii/README.md b/problems/parallel-courses-ii/README.md index 01d706e9c..f3ace5883 100644 --- a/problems/parallel-courses-ii/README.md +++ b/problems/parallel-courses-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-subarray-of-1s-after-deleting-one-element "Longest Subarray of 1's After Deleting One Element") @@ -67,14 +67,11 @@ In the fourth semester, you can take course 5. ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bitmask](../../tag/bitmask/README.md)] -### Similar Questions - 1. [Parallel Courses](../parallel-courses) (Medium) - ### Hints
    Hint 1 diff --git a/problems/partition-array-according-to-given-pivot/README.md b/problems/partition-array-according-to-given-pivot/README.md new file mode 100644 index 000000000..c058a818e --- /dev/null +++ b/problems/partition-array-according-to-given-pivot/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../minimum-sum-of-four-digit-number-after-splitting-digits "Minimum Sum of Four Digit Number After Splitting Digits") +                 +[Next >](../minimum-cost-to-set-cooking-time "Minimum Cost to Set Cooking Time") + +## [2161. Partition Array According to Given Pivot (Medium)](https://leetcode.com/problems/partition-array-according-to-given-pivot "根据给定数字划分数组") + +

    You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:

    + +
      +
    • Every element less than pivot appears before every element greater than pivot.
    • +
    • Every element equal to pivot appears in between the elements less than and greater than pivot.
    • +
    • The relative order of the elements less than pivot and the elements greater than pivot is maintained. +
        +
      • More formally, consider every pi, pj where pi is the new position of the ith element and pj is the new position of the jth element. For elements less than pivot, if i < j and nums[i] < pivot and nums[j] < pivot, then pi < pj. Similarly for elements greater than pivot, if i < j and nums[i] > pivot and nums[j] > pivot, then pi < pj.
      • +
      +
    • +
    + +

    Return nums after the rearrangement.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [9,12,5,10,14,3,10], pivot = 10
    +Output: [9,5,3,10,10,12,14]
    +Explanation: 
    +The elements 9, 5, and 3 are less than the pivot so they are on the left side of the array.
    +The elements 12 and 14 are greater than the pivot so they are on the right side of the array.
    +The relative ordering of the elements less than and greater than pivot is also maintained. [9, 5, 3] and [12, 14] are the respective orderings.
    +
    + +

    Example 2:

    + +
    +Input: nums = [-3,4,3,2], pivot = 2
    +Output: [-3,2,4,3]
    +Explanation: 
    +The element -3 is less than the pivot so it is on the left side of the array.
    +The elements 4 and 3 are greater than the pivot so they are on the right side of the array.
    +The relative ordering of the elements less than and greater than pivot is also maintained. [-3] and [4, 3] are the respective orderings.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • -106 <= nums[i] <= 106
    • +
    • pivot equals to an element of nums.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Could you put the elements smaller than the pivot and greater than the pivot in a separate list as in the sequence that they occur? +
    + +
    +Hint 2 +With the separate lists generated, could you then generate the result? +
    diff --git a/problems/partition-list/README.md b/problems/partition-list/README.md index fc0ea514d..e212ee33c 100644 --- a/problems/partition-list/README.md +++ b/problems/partition-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximal-rectangle "Maximal Rectangle") diff --git a/problems/path-sum-ii/README.md b/problems/path-sum-ii/README.md index acd143c07..50e88d874 100644 --- a/problems/path-sum-ii/README.md +++ b/problems/path-sum-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-sum "Path Sum") @@ -50,9 +50,9 @@ ### Related Topics - [[Backtracking](../../tag/backtracking/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/path-sum/README.md b/problems/path-sum/README.md index db538a498..71194c380 100644 --- a/problems/path-sum/README.md +++ b/problems/path-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-depth-of-binary-tree "Minimum Depth of Binary Tree") @@ -21,6 +21,7 @@
     Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22
     Output: true
    +Explanation: The root-to-leaf path with the target sum is shown.
     

    Example 2:

    @@ -28,13 +29,18 @@
     Input: root = [1,2,3], targetSum = 5
     Output: false
    +Explanation: There two root-to-leaf paths in the tree:
    +(1 --> 2): The sum is 3.
    +(1 --> 3): The sum is 4.
    +There is no root-to-leaf path with sum = 5.
     

    Example 3:

    -Input: root = [1,2], targetSum = 0
    +Input: root = [], targetSum = 0
     Output: false
    +Explanation: Since the tree is empty, there are no root-to-leaf paths.
     

     

    @@ -49,6 +55,7 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/path-with-minimum-effort/README.md b/problems/path-with-minimum-effort/README.md index b964c1049..9cee131df 100644 --- a/problems/path-with-minimum-effort/README.md +++ b/problems/path-with-minimum-effort/README.md @@ -58,17 +58,13 @@ This is better than the route of [1,2,2,2,5], where the maximum absolute differe ### Related Topics - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Matrix](../../tag/matrix/README.md)] - -### Similar Questions - 1. [Swim in Rising Water](../swim-in-rising-water) (Hard) - 1. [Path With Maximum Minimum Value](../path-with-maximum-minimum-value) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/perfect-rectangle/README.md b/problems/perfect-rectangle/README.md index 8949f5f14..971198a6f 100644 --- a/problems/perfect-rectangle/README.md +++ b/problems/perfect-rectangle/README.md @@ -33,14 +33,6 @@

    Example 3:

    - -
    -Input: rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[3,2,4,4]]
    -Output: false
    -Explanation: Because there is a gap in the top center.
    -
    - -

    Example 4:

     Input: rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]]
    diff --git a/problems/pizza-with-3n-slices/README.md b/problems/pizza-with-3n-slices/README.md
    index fb5a05914..eb813cd89 100644
    --- a/problems/pizza-with-3n-slices/README.md
    +++ b/problems/pizza-with-3n-slices/README.md
    @@ -1,8 +1,8 @@
     
     
    -
    -
    -
    +
    +
    +
     
     
     [< Previous](../sort-integers-by-the-power-value "Sort Integers by The Power Value")
    @@ -11,24 +11,20 @@
     
     ## [1388. Pizza With 3n Slices (Hard)](https://leetcode.com/problems/pizza-with-3n-slices "3n 块披萨")
     
    -

    There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:

    +

    There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:

    • You will pick any pizza slice.
    • -
    • Your friend Alice will pick next slice in anti clockwise direction of your pick. 
    • -
    • Your friend Bob will pick next slice in clockwise direction of your pick.
    • -
    • Repeat until there are no more slices of pizzas.
    • +
    • Your friend Alice will pick the next slice in the anti-clockwise direction of your pick.
    • +
    • Your friend Bob will pick the next slice in the clockwise direction of your pick.
    • +
    • Repeat until there are no more slices of pizzas.
    -

    Sizes of Pizza slices is represented by circular array slices in clockwise direction.

    - -

    Return the maximum possible sum of slice sizes which you can have.

    +

    Given an integer array slices that represent the sizes of the pizza slices in a clockwise direction, return the maximum possible sum of slice sizes that you can pick.

     

    Example 1:

    - -

    - +
     Input: slices = [1,2,3,4,5,6]
     Output: 10
    @@ -36,35 +32,19 @@
     

    Example 2:

    - -

    - +
     Input: slices = [8,9,8,6,1,1]
     Output: 16
    -Output: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.
    -
    - -

    Example 3:

    - -
    -Input: slices = [4,1,2,5,8,3,1,9,7]
    -Output: 21
    -
    - -

    Example 4:

    - -
    -Input: slices = [3,1,2]
    -Output: 3
    +Explanation: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.
     

     

    Constraints:

      +
    • 3 * n == slices.length
    • 1 <= slices.length <= 500
    • -
    • slices.length % 3 == 0
    • 1 <= slices[i] <= 1000
    diff --git a/problems/plus-one-linked-list/README.md b/problems/plus-one-linked-list/README.md index b8d162510..ae6a641b4 100644 --- a/problems/plus-one-linked-list/README.md +++ b/problems/plus-one-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-divisible-subset "Largest Divisible Subset") diff --git a/problems/poor-pigs/README.md b/problems/poor-pigs/README.md index a63d6d81b..ed7c5ff79 100644 --- a/problems/poor-pigs/README.md +++ b/problems/poor-pigs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../circular-array-loop "Circular Array Loop") diff --git a/problems/populating-next-right-pointers-in-each-node-ii/README.md b/problems/populating-next-right-pointers-in-each-node-ii/README.md index ea527badd..7621d80dc 100644 --- a/problems/populating-next-right-pointers-in-each-node-ii/README.md +++ b/problems/populating-next-right-pointers-in-each-node-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../populating-next-right-pointers-in-each-node "Populating Next Right Pointers in Each Node") @@ -62,6 +62,7 @@ struct Node { [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Linked List](../../tag/linked-list/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/possible-bipartition/README.md b/problems/possible-bipartition/README.md index 1bd27615c..d37d11381 100644 --- a/problems/possible-bipartition/README.md +++ b/problems/possible-bipartition/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../spiral-matrix-iii "Spiral Matrix III") diff --git a/problems/pour-water-between-buckets-to-make-water-levels-equal/README.md b/problems/pour-water-between-buckets-to-make-water-levels-equal/README.md new file mode 100644 index 000000000..3c977e969 --- /dev/null +++ b/problems/pour-water-between-buckets-to-make-water-levels-equal/README.md @@ -0,0 +1,39 @@ + + + + + + + +[< Previous](../earliest-possible-day-of-full-bloom "Earliest Possible Day of Full Bloom") +                 +[Next >](../divide-a-string-into-groups-of-size-k "Divide a String Into Groups of Size k") + +## [2137. Pour Water Between Buckets to Make Water Levels Equal (Medium)](https://leetcode.com/problems/pour-water-between-buckets-to-make-water-levels-equal "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +What is the range that the answer must fall into? +
    + +
    +Hint 2 +The answer has to be in the range [0, max(buckets)] (inclusive). +
    + +
    +Hint 3 +For a number x, is there an efficient way to check if it is possible to make the amount of water in each bucket x. +
    + +
    +Hint 4 +Let in be the total amount of water that needs to be poured into buckets and out be the total amount of water that needs to be poured out of buckets to make the amount of water in each bucket x. If out - (out * loss) >= in, then it is possible. +
    diff --git a/problems/power-of-three/README.md b/problems/power-of-three/README.md index e9bd83b14..1f77942fa 100644 --- a/problems/power-of-three/README.md +++ b/problems/power-of-three/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../maximum-size-subarray-sum-equals-k "Maximum Size Subarray Sum Equals k")                  [Next >](../count-of-range-sum "Count of Range Sum") -## [326. Power of Three (Easy)](https://leetcode.com/problems/power-of-three "3的幂") +## [326. Power of Three (Easy)](https://leetcode.com/problems/power-of-three "3 的幂")

    Given an integer n, return true if it is a power of three. Otherwise, return false.

    @@ -17,18 +17,26 @@

     

    Example 1:

    -
    Input: n = 27
    +
    +
    +Input: n = 27
     Output: true
    -

    Example 2:

    -
    Input: n = 0
    +
    + +

    Example 2:

    + +
    +Input: n = 0
     Output: false
    -

    Example 3:

    -
    Input: n = 9
    +
    + +

    Example 3:

    + +
    +Input: n = 9
     Output: true
    -

    Example 4:

    -
    Input: n = 45
    -Output: false
     
    +

     

    Constraints:

    diff --git a/problems/prime-arrangements/README.md b/problems/prime-arrangements/README.md index b85fa61f2..bb7caddf2 100644 --- a/problems/prime-arrangements/README.md +++ b/problems/prime-arrangements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../immediate-food-delivery-ii "Immediate Food Delivery II") diff --git a/problems/print-in-order/README.md b/problems/print-in-order/README.md index b97cb6ac8..2f0675943 100644 --- a/problems/print-in-order/README.md +++ b/problems/print-in-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reported-posts "Reported Posts") diff --git a/problems/prison-cells-after-n-days/README.md b/problems/prison-cells-after-n-days/README.md index fe203b401..1459ec6aa 100644 --- a/problems/prison-cells-after-n-days/README.md +++ b/problems/prison-cells-after-n-days/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tallest-billboard "Tallest Billboard") @@ -60,7 +60,7 @@ Day 7: [0, 0, 1, 1, 0, 0, 0, 0] ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md index 40e16a1df..4e558e1e6 100644 --- a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md +++ b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md @@ -53,22 +53,6 @@ Probability is 8/12 = 0.66667 Probability = 108 / 180 = 0.6
    -

    Example 4:

    - -
    -Input: balls = [3,2,1]
    -Output: 0.30000
    -Explanation: The set of balls is [1, 1, 1, 2, 2, 3]. It is hard to display all the 60 possible random shuffles of this set but it is easy to check that 18 of them will have the same number of distinct colors in each box.
    -Probability = 18 / 60 = 0.3
    -
    - -

    Example 5:

    - -
    -Input: balls = [6,6,6,6,6,6]
    -Output: 0.90327
    -
    -

     

    Constraints:

    diff --git a/problems/product-of-array-except-self/README.md b/problems/product-of-array-except-self/README.md index 665cd7199..0b3fe0d47 100644 --- a/problems/product-of-array-except-self/README.md +++ b/problems/product-of-array-except-self/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-node-in-a-linked-list "Delete Node in a Linked List") diff --git a/problems/products-price-for-each-store/README.md b/problems/products-price-for-each-store/README.md index 5d46b038f..ad3e0f768 100644 --- a/problems/products-price-for-each-store/README.md +++ b/problems/products-price-for-each-store/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Rearrange Products Table](../rearrange-products-table) (Easy) diff --git a/problems/projection-area-of-3d-shapes/README.md b/problems/projection-area-of-3d-shapes/README.md index 5d23f8dbe..645e1c1af 100644 --- a/problems/projection-area-of-3d-shapes/README.md +++ b/problems/projection-area-of-3d-shapes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reachable-nodes-in-subdivided-graph "Reachable Nodes In Subdivided Graph") @@ -44,27 +44,12 @@ Output: 8
    -

    Example 4:

    - -
    -Input: grid = [[1,1,1],[1,0,1],[1,1,1]]
    -Output: 14
    -
    - -

    Example 5:

    - -
    -Input: grid = [[2,2,2],[2,1,2],[2,2,2]]
    -Output: 21
    -
    -

     

    Constraints:

      -
    • n == grid.length
    • -
    • n == grid[i].length
    • -
    • 1 <= n <= 50
    • +
    • n == grid.length == grid[i].length
    • +
    • 1 <= n <= 50
    • 0 <= grid[i][j] <= 50
    diff --git a/problems/put-boxes-into-the-warehouse-ii/README.md b/problems/put-boxes-into-the-warehouse-ii/README.md index e6089dd71..467663579 100644 --- a/problems/put-boxes-into-the-warehouse-ii/README.md +++ b/problems/put-boxes-into-the-warehouse-ii/README.md @@ -14,10 +14,13 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Put Boxes Into the Warehouse I](../put-boxes-into-the-warehouse-i) (Medium) + ### Hints
    Hint 1 diff --git a/problems/queries-on-a-permutation-with-key/README.md b/problems/queries-on-a-permutation-with-key/README.md index 60eb9a5fb..d1f4999c2 100644 --- a/problems/queries-on-a-permutation-with-key/README.md +++ b/problems/queries-on-a-permutation-with-key/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../string-matching-in-an-array "String Matching in an Array") diff --git a/problems/queries-quality-and-percentage/README.md b/problems/queries-quality-and-percentage/README.md index 36250d98d..a856dd542 100644 --- a/problems/queries-quality-and-percentage/README.md +++ b/problems/queries-quality-and-percentage/README.md @@ -78,3 +78,6 @@ Cat queries poor_ query_percentage is (1 / 3) * 100 = 33.33 ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Percentage of Users Attended a Contest](../percentage-of-users-attended-a-contest) (Easy) diff --git a/problems/queue-reconstruction-by-height/README.md b/problems/queue-reconstruction-by-height/README.md index 2378a7f52..7045e7aa1 100644 --- a/problems/queue-reconstruction-by-height/README.md +++ b/problems/queue-reconstruction-by-height/README.md @@ -49,8 +49,8 @@ Hence [[5,0],[7,0],[5,2],[6,1],[4,4],[7,1]] is the reconstructed queue. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/race-car/README.md b/problems/race-car/README.md index bbb7c6451..f0097cbbb 100644 --- a/problems/race-car/README.md +++ b/problems/race-car/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../linked-list-components "Linked List Components") diff --git a/problems/random-pick-index/README.md b/problems/random-pick-index/README.md index 01f9412be..8a120eb57 100644 --- a/problems/random-pick-index/README.md +++ b/problems/random-pick-index/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../integer-replacement "Integer Replacement") @@ -48,9 +48,9 @@ solution.pick(3); // It should return either index 2, 3, or 4 randomly. Each ind ### Related Topics - [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] [[Randomized](../../tag/randomized/README.md)] ### Similar Questions diff --git a/problems/random-pick-with-weight/README.md b/problems/random-pick-with-weight/README.md index a9dd6b22b..003bbd478 100644 --- a/problems/random-pick-with-weight/README.md +++ b/problems/random-pick-with-weight/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-abbreviation "Word Abbreviation") @@ -11,11 +11,13 @@ ## [528. Random Pick with Weight (Medium)](https://leetcode.com/problems/random-pick-with-weight "按权重随机选择") -

    You are given an array of positive integers w where w[i] describes the weight of ith index (0-indexed).

    +

    You are given a 0-indexed array of positive integers w where w[i] describes the weight of the ith index.

    -

    We need to call the function pickIndex() which randomly returns an integer in the range [0, w.length - 1]pickIndex() should return the integer proportional to its weight in the w array. For example, for w = [1, 3], the probability of picking the index 0 is 1 / (1 + 3) = 0.25 (i.e 25%) while the probability of picking the index 1 is 3 / (1 + 3) = 0.75 (i.e 75%).

    +

    You need to implement the function pickIndex(), which randomly picks an index in the range [0, w.length - 1] (inclusive) and returns it. The probability of picking an index i is w[i] / sum(w).

    -

    More formally, the probability of picking index i is w[i] / sum(w).

    +
      +
    • For example, if w = [1, 3], the probability of picking index 0 is 1 / (1 + 3) = 0.25 (i.e., 25%), and the probability of picking index 1 is 3 / (1 + 3) = 0.75 (i.e., 75%).
    • +

     

    Example 1:

    @@ -29,7 +31,7 @@ Explanation Solution solution = new Solution([1]); -solution.pickIndex(); // return 0. Since there is only one single element on the array the only option is to return the first element. +solution.pickIndex(); // return 0. The only option is to return 0 since there is only one element in w.

    Example 2:

    @@ -43,13 +45,14 @@ solution.pickIndex(); // return 0. Since there is only one single element on the Explanation Solution solution = new Solution([1, 3]); -solution.pickIndex(); // return 1. It's returning the second element (index = 1) that has probability of 3/4. +solution.pickIndex(); // return 1. It is returning the second element (index = 1) that has a probability of 3/4. solution.pickIndex(); // return 1 solution.pickIndex(); // return 1 solution.pickIndex(); // return 1 -solution.pickIndex(); // return 0. It's returning the first element (index = 0) that has probability of 1/4. +solution.pickIndex(); // return 0. It is returning the first element (index = 0) that has a probability of 1/4. -Since this is a randomization problem, multiple answers are allowed so the following outputs can be considered correct : +Since this is a randomization problem, multiple answers are allowed. +All of the following outputs can be considered correct: [null,1,1,1,1,0] [null,1,1,1,1,1] [null,1,1,1,0,0] @@ -63,9 +66,9 @@ and so on.

    Constraints:

      -
    • 1 <= w.length <= 10000
    • -
    • 1 <= w[i] <= 10^5
    • -
    • pickIndex will be called at most 10000 times.
    • +
    • 1 <= w.length <= 104
    • +
    • 1 <= w[i] <= 105
    • +
    • pickIndex will be called at most 104 times.
    ### Related Topics diff --git a/problems/range-sum-query-mutable/README.md b/problems/range-sum-query-mutable/README.md index 8dd88dfdd..9e9b4991a 100644 --- a/problems/range-sum-query-mutable/README.md +++ b/problems/range-sum-query-mutable/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../additive-number "Additive Number") @@ -56,10 +56,10 @@ numArray.sumRange(0, 2); // return 1 + 2 + 5 = 8 ### Related Topics + [[Array](../../tag/array/README.md)] [[Design](../../tag/design/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] - [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Range Sum Query - Immutable](../range-sum-query-immutable) (Easy) diff --git a/problems/rank-scores/README.md b/problems/rank-scores/README.md index 6160acfc4..22dc4120c 100644 --- a/problems/rank-scores/README.md +++ b/problems/rank-scores/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nth-highest-salary "Nth Highest Salary") diff --git a/problems/rank-transform-of-a-matrix/README.md b/problems/rank-transform-of-a-matrix/README.md index 836561c15..50ab56c4c 100644 --- a/problems/rank-transform-of-a-matrix/README.md +++ b/problems/rank-transform-of-a-matrix/README.md @@ -27,7 +27,7 @@
  • The rank should be as small as possible.
  • -

    It is guaranteed that answer is unique under the given rules.

    +

    The test cases are generated so that answer is unique under the given rules.

     

    Example 1:

    @@ -56,13 +56,6 @@ The rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][ Output: [[4,2,3],[1,3,4],[5,1,6],[1,3,4]] -

    Example 4:

    - -
    -Input: matrix = [[7,3,6],[1,4,5],[9,8,2]]
    -Output: [[5,1,4],[1,2,3],[6,3,1]]
    -
    -

     

    Constraints:

    diff --git a/problems/reach-a-number/README.md b/problems/reach-a-number/README.md index c9cfef930..3d3d442ee 100644 --- a/problems/reach-a-number/README.md +++ b/problems/reach-a-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cracking-the-safe "Cracking the Safe") diff --git a/problems/rearrange-array-elements-by-sign/README.md b/problems/rearrange-array-elements-by-sign/README.md new file mode 100644 index 000000000..42e6a72bd --- /dev/null +++ b/problems/rearrange-array-elements-by-sign/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../count-elements-with-strictly-smaller-and-greater-elements "Count Elements With Strictly Smaller and Greater Elements ") +                 +[Next >](../find-all-lonely-numbers-in-the-array "Find All Lonely Numbers in the Array") + +## [2149. Rearrange Array Elements by Sign (Medium)](https://leetcode.com/problems/rearrange-array-elements-by-sign "按符号重排数组") + +

    You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.

    + +

    You should rearrange the elements of nums such that the modified array follows the given conditions:

    + +
      +
    1. Every consecutive pair of integers have opposite signs.
    2. +
    3. For all integers with the same sign, the order in which they were present in nums is preserved.
    4. +
    5. The rearranged array begins with a positive integer.
    6. +
    + +

    Return the modified array after rearranging the elements to satisfy the aforementioned conditions.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,1,-2,-5,2,-4]
    +Output: [3,-2,1,-5,2,-4]
    +Explanation:
    +The positive integers in nums are [3,1,2]. The negative integers are [-2,-5,-4].
    +The only possible way to rearrange them such that they satisfy all conditions is [3,-2,1,-5,2,-4].
    +Other ways such as [1,-2,2,-5,3,-4], [3,1,2,-2,-5,-4], [-2,3,-5,1,-4,2] are incorrect because they do not satisfy one or more conditions.  
    +
    + +

    Example 2:

    + +
    +Input: nums = [-1,1]
    +Output: [1,-1]
    +Explanation:
    +1 is the only positive integer and -1 the only negative integer in nums.
    +So nums is rearranged to [1,-1].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 2 * 105
    • +
    • nums.length is even
    • +
    • 1 <= |nums[i]| <= 105
    • +
    • nums consists of equal number of positive and negative integers.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Divide the array into two parts- one comprising of only positive integers and the other of negative integers. +
    + +
    +Hint 2 +Merge the two parts to get the resultant array. +
    diff --git a/problems/rearrange-spaces-between-words/README.md b/problems/rearrange-spaces-between-words/README.md index bd77b2d6f..96a5b97d5 100644 --- a/problems/rearrange-spaces-between-words/README.md +++ b/problems/rearrange-spaces-between-words/README.md @@ -23,7 +23,7 @@
     Input: text = "  this   is  a sentence "
     Output: "this   is   a   sentence"
    -Explanation: There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces.
    +Explanation: There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces.
     

    Example 2:

    @@ -31,28 +31,7 @@
     Input: text = " practice   makes   perfect"
     Output: "practice   makes   perfect "
    -Explanation: There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string.
    -
    - -

    Example 3:

    - -
    -Input: text = "hello   world"
    -Output: "hello   world"
    -
    - -

    Example 4:

    - -
    -Input: text = "  walks  udp package   into  bar a"
    -Output: "walks  udp  package  into  bar  a "
    -
    - -

    Example 5:

    - -
    -Input: text = "a"
    -Output: "a"
    +Explanation: There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string.
     

     

    @@ -60,13 +39,16 @@
    • 1 <= text.length <= 100
    • -
    • text consists of lowercase English letters and ' '.
    • -
    • text contains at least one word.
    • +
    • text consists of lowercase English letters and ' '.
    • +
    • text contains at least one word.
    ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Text Justification](../text-justification) (Hard) + ### Hints
    Hint 1 diff --git a/problems/rearrange-string-k-distance-apart/README.md b/problems/rearrange-string-k-distance-apart/README.md index 491309082..831175238 100644 --- a/problems/rearrange-string-k-distance-apart/README.md +++ b/problems/rearrange-string-k-distance-apart/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-numbers-with-unique-digits "Count Numbers with Unique Digits") diff --git a/problems/rearrange-words-in-a-sentence/README.md b/problems/rearrange-words-in-a-sentence/README.md index 5a62d6e06..b920aad7d 100644 --- a/problems/rearrange-words-in-a-sentence/README.md +++ b/problems/rearrange-words-in-a-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-students-doing-homework-at-a-given-time "Number of Students Doing Homework at a Given Time") diff --git a/problems/recover-the-original-array/README.md b/problems/recover-the-original-array/README.md new file mode 100644 index 000000000..31c4a2224 --- /dev/null +++ b/problems/recover-the-original-array/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../intervals-between-identical-elements "Intervals Between Identical Elements") +                 +[Next >](../minimum-operations-to-remove-adjacent-ones-in-matrix "Minimum Operations to Remove Adjacent Ones in Matrix") + +## [2122. Recover the Original Array (Hard)](https://leetcode.com/problems/recover-the-original-array "还原原数组") + +

    Alice had a 0-indexed array arr consisting of n positive integers. She chose an arbitrary positive integer k and created two new 0-indexed integer arrays lower and higher in the following manner:

    + +
      +
    1. lower[i] = arr[i] - k, for every index i where 0 <= i < n
    2. +
    3. higher[i] = arr[i] + k, for every index i where 0 <= i < n
    4. +
    + +

    Unfortunately, Alice lost all three arrays. However, she remembers the integers that were present in the arrays lower and higher, but not the array each integer belonged to. Help Alice and recover the original array.

    + +

    Given an array nums consisting of 2n integers, where exactly n of the integers were present in lower and the remaining in higher, return the original array arr. In case the answer is not unique, return any valid array.

    + +

    Note: The test cases are generated such that there exists at least one valid array arr.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,10,6,4,8,12]
    +Output: [3,7,11]
    +Explanation:
    +If arr = [3,7,11] and k = 1, we get lower = [2,6,10] and higher = [4,8,12].
    +Combining lower and higher gives us [2,6,10,4,8,12], which is a permutation of nums.
    +Another valid possibility is that arr = [5,7,9] and k = 3. In that case, lower = [2,4,6] and higher = [8,10,12]. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,1,3,3]
    +Output: [2,2]
    +Explanation:
    +If arr = [2,2] and k = 1, we get lower = [1,1] and higher = [3,3].
    +Combining lower and higher gives us [1,1,3,3], which is equal to nums.
    +Note that arr cannot be [1,3] because in that case, the only possible way to obtain [1,1,3,3] is with k = 0.
    +This is invalid since k must be positive.
    +
    + +

    Example 3:

    + +
    +Input: nums = [5,435]
    +Output: [220]
    +Explanation:
    +The only possible combination is arr = [220] and k = 215. Using them, we get lower = [5] and higher = [435].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 * n == nums.length
    • +
    • 1 <= n <= 1000
    • +
    • 1 <= nums[i] <= 109
    • +
    • The test cases are generated such that there exists at least one valid array arr.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +If we fix the value of k, how can we check if an original array exists for the fixed k? +
    + +
    +Hint 2 +The smallest value of nums is obtained by subtracting k from the smallest value of the original array. How can we use this to reduce the search space for finding a valid k? +
    + +
    +Hint 3 +You can compute every possible k by using the smallest value of nums (as lower[i]) against every other value in nums (as the corresponding higher[i]). +
    + +
    +Hint 4 +For every computed k, greedily pair up the values in nums. This can be done sorting nums, then using a map to store previous values and searching that map for a corresponding lower[i] for the current nums[j] (as higher[i]). +
    diff --git a/problems/rectangle-overlap/README.md b/problems/rectangle-overlap/README.md index 00ff72825..e5649b1d5 100644 --- a/problems/rectangle-overlap/README.md +++ b/problems/rectangle-overlap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../image-overlap "Image Overlap") @@ -39,8 +39,8 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Similar Questions 1. [Rectangle Area](../rectangle-area) (Medium) diff --git a/problems/rectangles-area/README.md b/problems/rectangles-area/README.md index f63085a0a..f64effc69 100644 --- a/problems/rectangles-area/README.md +++ b/problems/rectangles-area/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-dot-product-of-two-subsequences "Max Dot Product of Two Subsequences") diff --git a/problems/reduce-array-size-to-the-half/README.md b/problems/reduce-array-size-to-the-half/README.md index 3667f864d..7dcae1f59 100644 --- a/problems/reduce-array-size-to-the-half/README.md +++ b/problems/reduce-array-size-to-the-half/README.md @@ -23,7 +23,7 @@ Output: 2 Explanation: Choosing {3,7} will make the new array [5,5,5,2,2] which has size 5 (i.e equal to half of the size of the old array). Possible sets of size 2 are {3,5},{3,2},{5,2}. -Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] which has size greater than half of the size of the old array. +Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] which has a size greater than half of the size of the old array.

    Example 2:

    @@ -34,40 +34,19 @@ Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] Explanation: The only possible set you can choose is {7}. This will make the new array empty. -

    Example 3:

    - -
    -Input: arr = [1,9]
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: arr = [1000,1000,3,7]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: arr = [1,2,3,4,5,6,7,8,9,10]
    -Output: 5
    -
    -

     

    Constraints:

      -
    • 1 <= arr.length <= 105
    • +
    • 2 <= arr.length <= 105
    • arr.length is even.
    • 1 <= arr[i] <= 105
    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/reducing-dishes/README.md b/problems/reducing-dishes/README.md index 6e87b7e6c..c17b51662 100644 --- a/problems/reducing-dishes/README.md +++ b/problems/reducing-dishes/README.md @@ -41,14 +41,7 @@ Each dish is prepared in one unit of time.
     Input: satisfaction = [-1,-4,-5]
     Output: 0
    -Explanation: People don't like the dishes. No dish is prepared.
    -
    - -

    Example 4:

    - -
    -Input: satisfaction = [-2,5,-1,0,3,-3]
    -Output: 35
    +Explanation: People do not like the dishes. No dish is prepared.
     

     

    @@ -61,9 +54,9 @@ Each dish is prepared in one unit of time. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/reformat-phone-number/README.md b/problems/reformat-phone-number/README.md index 0ee2dbf14..d4dc85908 100644 --- a/problems/reformat-phone-number/README.md +++ b/problems/reformat-phone-number/README.md @@ -60,26 +60,12 @@ Step 3: There are 2 digits left, so put them in a single block of length 2. The Joining the blocks gives "123-456-78". -

    Example 4:

    - -
    -Input: number = "12"
    -Output: "12"
    -
    - -

    Example 5:

    - -
    -Input: number = "--17-5 229 35-39475 "
    -Output: "175-229-353-94-75"
    -
    -

     

    Constraints:

    • 2 <= number.length <= 100
    • -
    • number consists of digits and the characters '-' and ' '.
    • +
    • number consists of digits and the characters '-' and ' '.
    • There are at least two digits in number.
    diff --git a/problems/remove-all-ones-with-row-and-column-flips/README.md b/problems/remove-all-ones-with-row-and-column-flips/README.md new file mode 100644 index 000000000..f1857a910 --- /dev/null +++ b/problems/remove-all-ones-with-row-and-column-flips/README.md @@ -0,0 +1,46 @@ + + + + + + + +[< Previous](../maximum-employees-to-be-invited-to-a-meeting "Maximum Employees to Be Invited to a Meeting") +                 +[Next >](../capitalize-the-title "Capitalize the Title") + +## [2128. Remove All Ones With Row and Column Flips (Medium)](https://leetcode.com/problems/remove-all-ones-with-row-and-column-flips "") + + + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Does the order, in which you do the operations, matter? +
    + +
    +Hint 2 +No, it does not. An element will keep its original value if the number of operations done on it is even and vice versa. This also means that doing more than 1 operation on the same row or column is unproductive. +
    + +
    +Hint 3 +Try working backward, start with a matrix of all zeros and try to construct grid using operations. +
    + +
    +Hint 4 +Start with operations on columns, after doing them what do you notice about each row? +
    + +
    +Hint 5 +Each row is the exact same. If we then flip some rows, that leaves only two possible arrangements for each row: the same as the original or the opposite. +
    diff --git a/problems/remove-covered-intervals/README.md b/problems/remove-covered-intervals/README.md index b319a77a3..22a2a0ad3 100644 --- a/problems/remove-covered-intervals/README.md +++ b/problems/remove-covered-intervals/README.md @@ -23,7 +23,7 @@
     Input: intervals = [[1,4],[3,6],[2,8]]
     Output: 2
    -Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.
    +Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.
     

    Example 2:

    @@ -33,27 +33,6 @@ Output: 1 -

    Example 3:

    - -
    -Input: intervals = [[0,10],[5,12]]
    -Output: 2
    -
    - -

    Example 4:

    - -
    -Input: intervals = [[3,10],[4,10],[5,11]]
    -Output: 2
    -
    - -

    Example 5:

    - -
    -Input: intervals = [[1,2],[1,4],[3,4]]
    -Output: 1
    -
    -

     

    Constraints:

    diff --git a/problems/remove-interval/README.md b/problems/remove-interval/README.md index 89f6001a6..bce96a0c0 100644 --- a/problems/remove-interval/README.md +++ b/problems/remove-interval/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../hexspeak "Hexspeak") diff --git a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md index 2073e3fc8..11e59e27d 100644 --- a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md +++ b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md @@ -5,7 +5,7 @@ -[< Previous](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters") +[< Previous](../minimum-time-to-make-rope-colorful "Minimum Time to Make Rope Colorful")                  [Next >](../put-boxes-into-the-warehouse-ii "Put Boxes Into the Warehouse II") diff --git a/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md b/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md index c8499e554..2a1183730 100644 --- a/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md +++ b/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md @@ -46,14 +46,6 @@ No resulting array is strictly increasing, so return false. [1,1] is not strictly increasing, so return false. -

    Example 4:

    - -
    -Input: nums = [1,2,3]
    -Output: true
    -Explanation: [1,2,3] is already strictly increasing, so return true.
    -
    -

     

    Constraints:

    diff --git a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md index 239cd5e5b..674f758f7 100644 --- a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md +++ b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md @@ -52,6 +52,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] +### Similar Questions + 1. [Delete N Nodes After M Nodes of a Linked List](../delete-n-nodes-after-m-nodes-of-a-linked-list) (Easy) + ### Hints
    Hint 1 diff --git a/problems/removing-minimum-and-maximum-from-array/README.md b/problems/removing-minimum-and-maximum-from-array/README.md new file mode 100644 index 000000000..6a9d08876 --- /dev/null +++ b/problems/removing-minimum-and-maximum-from-array/README.md @@ -0,0 +1,94 @@ + + + + + + + +[< Previous](../k-radius-subarray-averages "K Radius Subarray Averages") +                 +[Next >](../find-all-people-with-secret "Find All People With Secret") + +## [2091. Removing Minimum and Maximum From Array (Medium)](https://leetcode.com/problems/removing-minimum-and-maximum-from-array "从数组中移除最大值和最小值") + +

    You are given a 0-indexed array of distinct integers nums.

    + +

    There is an element in nums that has the lowest value and an element that has the highest value. We call them the minimum and maximum respectively. Your goal is to remove both these elements from the array.

    + +

    A deletion is defined as either removing an element from the front of the array or removing an element from the back of the array.

    + +

    Return the minimum number of deletions it would take to remove both the minimum and maximum element from the array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,10,7,5,4,1,8,6]
    +Output: 5
    +Explanation: 
    +The minimum element in the array is nums[5], which is 1.
    +The maximum element in the array is nums[1], which is 10.
    +We can remove both the minimum and maximum by removing 2 elements from the front and 3 elements from the back.
    +This results in 2 + 3 = 5 deletions, which is the minimum number possible.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,-4,19,1,8,-2,-3,5]
    +Output: 3
    +Explanation: 
    +The minimum element in the array is nums[1], which is -4.
    +The maximum element in the array is nums[2], which is 19.
    +We can remove both the minimum and maximum by removing 3 elements from the front.
    +This results in only 3 deletions, which is the minimum number possible.
    +
    + +

    Example 3:

    + +
    +Input: nums = [101]
    +Output: 1
    +Explanation:  
    +There is only one element in the array, which makes it both the minimum and maximum element.
    +We can remove it with 1 deletion.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • -105 <= nums[i] <= 105
    • +
    • The integers in nums are distinct.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +There can only be three scenarios for deletions such that both minimum and maximum elements are removed: +
    + +
    +Hint 2 +Scenario 1: Both elements are removed by only deleting from the front. +
    + +
    +Hint 3 +Scenario 2: Both elements are removed by only deleting from the back. +
    + +
    +Hint 4 +Scenario 3: Delete from the front to remove one of the elements, and delete from the back to remove the other element. +
    + +
    +Hint 5 +Compare which of the three scenarios results in the minimum number of moves. +
    diff --git a/problems/removing-minimum-number-of-magic-beans/README.md b/problems/removing-minimum-number-of-magic-beans/README.md new file mode 100644 index 000000000..0e495bb15 --- /dev/null +++ b/problems/removing-minimum-number-of-magic-beans/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../minimum-operations-to-make-the-array-alternating "Minimum Operations to Make the Array Alternating") +                 +[Next >](../maximum-and-sum-of-array "Maximum AND Sum of Array") + +## [2171. Removing Minimum Number of Magic Beans (Medium)](https://leetcode.com/problems/removing-minimum-number-of-magic-beans "拿出最少数目的魔法豆") + +

    You are given an array of positive integers beans, where each integer represents the number of magic beans found in a particular magic bag.

    + +

    Remove any number of beans (possibly none) from each bag such that the number of beans in each remaining non-empty bag (still containing at least one bean) is equal. Once a bean has been removed from a bag, you are not allowed to return it to any of the bags.

    + +

    Return the minimum number of magic beans that you have to remove.

    + +

     

    +

    Example 1:

    + +
    +Input: beans = [4,1,6,5]
    +Output: 4
    +Explanation: 
    +- We remove 1 bean from the bag with only 1 bean.
    +  This results in the remaining bags: [4,0,6,5]
    +- Then we remove 2 beans from the bag with 6 beans.
    +  This results in the remaining bags: [4,0,4,5]
    +- Then we remove 1 bean from the bag with 5 beans.
    +  This results in the remaining bags: [4,0,4,4]
    +We removed a total of 1 + 2 + 1 = 4 beans to make the remaining non-empty bags have an equal number of beans.
    +There are no other solutions that remove 4 beans or fewer.
    +
    + +

    Example 2:

    + +
    +Input: beans = [2,10,3,2]
    +Output: 7
    +Explanation:
    +- We remove 2 beans from one of the bags with 2 beans.
    +  This results in the remaining bags: [0,10,3,2]
    +- Then we remove 2 beans from the other bag with 2 beans.
    +  This results in the remaining bags: [0,10,3,0]
    +- Then we remove 3 beans from the bag with 3 beans. 
    +  This results in the remaining bags: [0,10,0,0]
    +We removed a total of 2 + 2 + 3 = 7 beans to make the remaining non-empty bags have an equal number of beans.
    +There are no other solutions that removes 7 beans or fewer.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= beans.length <= 105
    • +
    • 1 <= beans[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Notice that if we choose to make x bags of beans empty, we should choose the x bags with the least amount of beans. +
    + +
    +Hint 2 +Notice that if the minimum number of beans in a non-empty bag is m, then the best way to make all bags have an equal amount of beans is to reduce all the bags to have m beans. +
    + +
    +Hint 3 +Can we iterate over how many bags we should remove and choose the one that minimizes the total amount of beans to remove? +
    + +
    +Hint 4 +Sort the bags of beans first. +
    diff --git a/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md b/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md index 192f235ee..6743b154d 100644 --- a/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md +++ b/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts") diff --git a/problems/repeated-string-match/README.md b/problems/repeated-string-match/README.md index 508494d61..49ac83fce 100644 --- a/problems/repeated-string-match/README.md +++ b/problems/repeated-string-match/README.md @@ -11,9 +11,9 @@ ## [686. Repeated String Match (Medium)](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") -

    Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b​​​​​​ to be a substring of a after repeating it, return -1.

    +

    Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b​​​​​​ to be a substring of a after repeating it, return -1.

    -

    Notice: string "abc" repeated 0 times is "",  repeated 1 time is "abc" and repeated 2 times is "abcabc".

    +

    Notice: string "abc" repeated 0 times is "", repeated 1 time is "abc" and repeated 2 times is "abcabc".

     

    Example 1:

    @@ -31,27 +31,12 @@ Output: 2 -

    Example 3:

    - -
    -Input: a = "a", b = "a"
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: a = "abc", b = "wxyz"
    -Output: -1
    -
    -

     

    Constraints:

      -
    • 1 <= a.length <= 104
    • -
    • 1 <= b.length <= 104
    • -
    • a and b consist of lower-case English letters.
    • +
    • 1 <= a.length, b.length <= 104
    • +
    • a and b consist of lowercase English letters.
    ### Related Topics diff --git a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md index 42bc3386d..e9aadef5e 100644 --- a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md +++ b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md @@ -23,28 +23,15 @@
     Input: s = "?zs"
     Output: "azs"
    -Explanation: There are 25 solutions for this problem. From "azs" to "yzs", all are valid. Only "z" is an invalid modification as the string will consist of consecutive repeating characters in "zzs".
    +Explanation: There are 25 solutions for this problem. From "azs" to "yzs", all are valid. Only "z" is an invalid modification as the string will consist of consecutive repeating characters in "zzs". +

    Example 2:

     Input: s = "ubv?w"
     Output: "ubvaw"
    -Explanation: There are 24 solutions for this problem. Only "v" and "w" are invalid modifications as the strings will consist of consecutive repeating characters in "ubvvw" and "ubvww".
    -
    - -

    Example 3:

    - -
    -Input: s = "j?qg??b"
    -Output: "jaqgacb"
    -
    - -

    Example 4:

    - -
    -Input: s = "??yw?ipkj?"
    -Output: "acywaipkja"
    +Explanation: There are 24 solutions for this problem. Only "v" and "w" are invalid modifications as the strings will consist of consecutive repeating characters in "ubvvw" and "ubvww".
     

     

    diff --git a/problems/reported-posts-ii/README.md b/problems/reported-posts-ii/README.md index b14a7515b..bd1a28b4e 100644 --- a/problems/reported-posts-ii/README.md +++ b/problems/reported-posts-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-of-absolute-value-expression "Maximum of Absolute Value Expression") diff --git a/problems/restore-the-array/README.md b/problems/restore-the-array/README.md index 570dbce5a..caa50f9a9 100644 --- a/problems/restore-the-array/README.md +++ b/problems/restore-the-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "The k-th Lexicographical String of All Happy Strings of Length n") @@ -40,21 +40,6 @@ Explanation: Possible arrays are [1317],[131,7],[13,17],[1,317],[13,1,7],[1,31,7],[1,3,17],[1,3,1,7] -

    Example 4:

    - -
    -Input: s = "2020", k = 30
    -Output: 1
    -Explanation: The only possible array is [20,20]. [2020] is invalid because 2020 > 30. [2,020] is ivalid because 020 contains leading zeros.
    -
    - -

    Example 5:

    - -
    -Input: s = "1234567890", k = 90
    -Output: 34
    -
    -

     

    Constraints:

    @@ -68,6 +53,9 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Number of Ways to Separate Numbers](../number-of-ways-to-separate-numbers) (Hard) + ### Hints
    Hint 1 diff --git a/problems/reverse-bits/README.md b/problems/reverse-bits/README.md index a613f07a4..37efcfc69 100644 --- a/problems/reverse-bits/README.md +++ b/problems/reverse-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rotate-array "Rotate Array") @@ -48,8 +48,8 @@

    Follow up: If this function is called many times, how would you optimize it?

    ### Related Topics - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions 1. [Reverse Integer](../reverse-integer) (Medium) diff --git a/problems/reverse-linked-list/README.md b/problems/reverse-linked-list/README.md index 393cdb8d1..be9956cae 100644 --- a/problems/reverse-linked-list/README.md +++ b/problems/reverse-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../isomorphic-strings "Isomorphic Strings") @@ -47,10 +47,12 @@

    Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both?

    ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Reverse Linked List II](../reverse-linked-list-ii) (Medium) 1. [Binary Tree Upside Down](../binary-tree-upside-down) (Medium) 1. [Palindrome Linked List](../palindrome-linked-list) (Easy) + 1. [Reverse Nodes in Even Length Groups](../reverse-nodes-in-even-length-groups) (Medium) + 1. [Maximum Twin Sum of a Linked List](../maximum-twin-sum-of-a-linked-list) (Medium) diff --git a/problems/reverse-nodes-in-even-length-groups/README.md b/problems/reverse-nodes-in-even-length-groups/README.md index 1acbfaf3b..ff39ee8c6 100644 --- a/problems/reverse-nodes-in-even-length-groups/README.md +++ b/problems/reverse-nodes-in-even-length-groups/README.md @@ -32,9 +32,9 @@ Input: head = [5,2,6,3,9,1,7,3,8,4] Output: [5,6,2,3,9,1,4,8,3,7] Explanation: -- The length of the first group is 1, which is odd, hence no reversal occurrs. +- The length of the first group is 1, which is odd, hence no reversal occurs. - The length of the second group is 2, which is even, hence the nodes are reversed. -- The length of the third group is 3, which is odd, hence no reversal occurrs. +- The length of the third group is 3, which is odd, hence no reversal occurs. - The length of the last group is 4, which is even, hence the nodes are reversed. @@ -44,9 +44,9 @@ Input: head = [1,1,0,6] Output: [1,0,1,6] Explanation: -- The length of the first group is 1. No reversal occurrs. +- The length of the first group is 1. No reversal occurs. - The length of the second group is 2. The nodes are reversed. -- The length of the last group is 1. No reversal occurrs. +- The length of the last group is 1. No reversal occurs.

    Example 3:

    @@ -55,29 +55,11 @@ Input: head = [1,1,0,6,5] Output: [1,0,1,5,6] Explanation: -- The length of the first group is 1. No reversal occurrs. +- The length of the first group is 1. No reversal occurs. - The length of the second group is 2. The nodes are reversed. - The length of the last group is 2. The nodes are reversed. -

    Example 4:

    - -
    -Input: head = [2,1]
    -Output: [2,1]
    -Explanation:
    -- The length of the first group is 1. No reversal occurrs.
    -- The length of the last group is 1. No reversal occurrs.
    -
    - -

    Example 5:

    - -
    -Input: head = [8]
    -Output: [8]
    -Explanation: There is only one group whose length is 1. No reversal occurrs.
    -
    -

     

    Constraints:

    diff --git a/problems/reverse-words-in-a-string/README.md b/problems/reverse-words-in-a-string/README.md index a42fabf98..0a2002fd0 100644 --- a/problems/reverse-words-in-a-string/README.md +++ b/problems/reverse-words-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../evaluate-reverse-polish-notation "Evaluate Reverse Polish Notation") @@ -43,20 +43,6 @@ Explanation: You need to reduce multiple spaces between two words to a single space in the reversed string. -

    Example 4:

    - -
    -Input: s = "  Bob    Loves  Alice   "
    -Output: "Alice Loves Bob"
    -
    - -

    Example 5:

    - -
    -Input: s = "Alice does not even like bob"
    -Output: "bob like even not does Alice"
    -
    -

     

    Constraints:

    diff --git a/problems/rings-and-rods/README.md b/problems/rings-and-rods/README.md new file mode 100644 index 000000000..3944e5b9c --- /dev/null +++ b/problems/rings-and-rods/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../sequentially-ordinal-rank-tracker "Sequentially Ordinal Rank Tracker") +                 +[Next >](../sum-of-subarray-ranges "Sum of Subarray Ranges") + +## [2103. Rings and Rods (Easy)](https://leetcode.com/problems/rings-and-rods "环和杆") + +

    There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9.

    + +

    You are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring where:

    + +
      +
    • The first character of the ith pair denotes the ith ring's color ('R', 'G', 'B').
    • +
    • The second character of the ith pair denotes the rod that the ith ring is placed on ('0' to '9').
    • +
    + +

    For example, "R3G2B1" describes n == 3 rings: a red ring placed onto the rod labeled 3, a green ring placed onto the rod labeled 2, and a blue ring placed onto the rod labeled 1.

    + +

    Return the number of rods that have all three colors of rings on them.

    + +

     

    +

    Example 1:

    + +
    +Input: rings = "B0B6G0R6R0R6G9"
    +Output: 1
    +Explanation: 
    +- The rod labeled 0 holds 3 rings with all colors: red, green, and blue.
    +- The rod labeled 6 holds 3 rings, but it only has red and blue.
    +- The rod labeled 9 holds only a green ring.
    +Thus, the number of rods with all three colors is 1.
    +
    + +

    Example 2:

    + +
    +Input: rings = "B0R0G0R9R0B0G0"
    +Output: 1
    +Explanation: 
    +- The rod labeled 0 holds 6 rings with all colors: red, green, and blue.
    +- The rod labeled 9 holds only a red ring.
    +Thus, the number of rods with all three colors is 1.
    +
    + +

    Example 3:

    + +
    +Input: rings = "G4"
    +Output: 0
    +Explanation: 
    +Only one ring is given. Thus, no rods have all three colors.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • rings.length == 2 * n
    • +
    • 1 <= n <= 100
    • +
    • rings[i] where i is even is either 'R', 'G', or 'B' (0-indexed).
    • +
    • rings[i] where i is odd is a digit from '0' to '9' (0-indexed).
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +For every rod, look through ‘rings’ to see if the rod contains all colors. +
    + +
    +Hint 2 +Create 3 booleans, 1 for each color, to store if that color is present for the current rod. If all 3 are true after looking through the string, then the rod contains all the colors. +
    diff --git a/problems/rotate-array/README.md b/problems/rotate-array/README.md index cf4d0ec51..9b80793b2 100644 --- a/problems/rotate-array/README.md +++ b/problems/rotate-array/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../best-time-to-buy-and-sell-stock-iv "Best Time to Buy and Sell Stock IV")                  [Next >](../reverse-bits "Reverse Bits") -## [189. Rotate Array (Medium)](https://leetcode.com/problems/rotate-array "旋转数组") +## [189. Rotate Array (Medium)](https://leetcode.com/problems/rotate-array "轮转数组")

    Given an array, rotate the array to the right by k steps, where k is non-negative.

    diff --git a/problems/rotate-function/README.md b/problems/rotate-function/README.md index 56f6101fd..1dd719a63 100644 --- a/problems/rotate-function/README.md +++ b/problems/rotate-function/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-substring-with-at-least-k-repeating-characters "Longest Substring with At Least K Repeating Characters") diff --git a/problems/running-total-for-different-genders/README.md b/problems/running-total-for-different-genders/README.md index db8e732bc..107500405 100644 --- a/problems/running-total-for-different-genders/README.md +++ b/problems/running-total-for-different-genders/README.md @@ -76,6 +76,3 @@ Fifth day is 2020-01-07, Bajrang scored 7 points and the total score for the tea ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Last Person to Fit in the Bus](../last-person-to-fit-in-the-bus) (Medium) diff --git a/problems/russian-doll-envelopes/README.md b/problems/russian-doll-envelopes/README.md index de6f285d3..96062bae2 100644 --- a/problems/russian-doll-envelopes/README.md +++ b/problems/russian-doll-envelopes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-snake-game "Design Snake Game") @@ -39,9 +39,9 @@

    Constraints:

      -
    • 1 <= envelopes.length <= 5000
    • +
    • 1 <= envelopes.length <= 105
    • envelopes[i].length == 2
    • -
    • 1 <= wi, hi <= 104
    • +
    • 1 <= wi, hi <= 105
    ### Related Topics diff --git a/problems/sales-analysis-ii/README.md b/problems/sales-analysis-ii/README.md index 30e305088..c0995e4d1 100644 --- a/problems/sales-analysis-ii/README.md +++ b/problems/sales-analysis-ii/README.md @@ -77,3 +77,7 @@ The buyer with id 1 bought an S8 but didn't buy an iPhone. The buyer with id ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Sales Analysis I](../sales-analysis-i) (Easy) + 1. [Sales Analysis III](../sales-analysis-iii) (Easy) diff --git a/problems/sales-by-day-of-the-week/README.md b/problems/sales-by-day-of-the-week/README.md index dcc18624a..753d7a48d 100644 --- a/problems/sales-by-day-of-the-week/README.md +++ b/problems/sales-by-day-of-the-week/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../allocate-mailboxes "Allocate Mailboxes") diff --git a/problems/search-insert-position/README.md b/problems/search-insert-position/README.md index b94c0636a..09a83df93 100644 --- a/problems/search-insert-position/README.md +++ b/problems/search-insert-position/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-first-and-last-position-of-element-in-sorted-array "Find First and Last Position of Element in Sorted Array") @@ -17,21 +17,26 @@

     

    Example 1:

    -
    Input: nums = [1,3,5,6], target = 5
    +
    +
    +Input: nums = [1,3,5,6], target = 5
     Output: 2
    -

    Example 2:

    -
    Input: nums = [1,3,5,6], target = 2
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,3,5,6], target = 2
     Output: 1
    -

    Example 3:

    -
    Input: nums = [1,3,5,6], target = 7
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,3,5,6], target = 7
     Output: 4
    -

    Example 4:

    -
    Input: nums = [1,3,5,6], target = 0
    -Output: 0
    -

    Example 5:

    -
    Input: nums = [1], target = 0
    -Output: 0
     
    +

     

    Constraints:

    diff --git a/problems/search-suggestions-system/README.md b/problems/search-suggestions-system/README.md index e572da055..be6fd4f4d 100644 --- a/problems/search-suggestions-system/README.md +++ b/problems/search-suggestions-system/README.md @@ -11,9 +11,11 @@ ## [1268. Search Suggestions System (Medium)](https://leetcode.com/problems/search-suggestions-system "搜索推荐系统") -

    Given an array of strings products and a string searchWord. We want to design a system that suggests at most three product names from products after each character of searchWord is typed. Suggested products should have common prefix with the searchWord. If there are more than three products with a common prefix return the three lexicographically minimums products.

    +

    You are given an array of strings products and a string searchWord.

    -

    Return list of lists of the suggested products after each character of searchWord is typed. 

    +

    Design a system that suggests at most three product names from products after each character of searchWord is typed. Suggested products should have common prefix with searchWord. If there are more than three products with a common prefix return the three lexicographically minimums products.

    + +

    Return a list of lists of the suggested products after each character of searchWord is typed.

     

    Example 1:

    @@ -46,23 +48,17 @@ After typing mou, mous and mouse the system suggests ["mouse","mo Output: [["baggage","bags","banner"],["baggage","bags","banner"],["baggage","bags"],["bags"]]
    -

    Example 4:

    - -
    -Input: products = ["havana"], searchWord = "tatiana"
    -Output: [[],[],[],[],[],[],[]]
    -
    -

     

    Constraints:

    • 1 <= products.length <= 1000
    • -
    • There are no repeated elements in products.
    • -
    • 1 <= Σ products[i].length <= 2 * 10^4
    • -
    • All characters of products[i] are lower-case English letters.
    • +
    • 1 <= products[i].length <= 3000
    • +
    • 1 <= sum(products[i].length) <= 2 * 104
    • +
    • All the strings of products are unique.
    • +
    • products[i] consists of lowercase English letters.
    • 1 <= searchWord.length <= 1000
    • -
    • All characters of searchWord are lower-case English letters.
    • +
    • searchWord consists of lowercase English letters.
    ### Related Topics diff --git a/problems/second-highest-salary/README.md b/problems/second-highest-salary/README.md index 6f9a61f07..6cb8a3e24 100644 --- a/problems/second-highest-salary/README.md +++ b/problems/second-highest-salary/README.md @@ -1,35 +1,71 @@ - - - + + + [< Previous](../combine-two-tables "Combine Two Tables")                  [Next >](../nth-highest-salary "Nth Highest Salary") -## [176. Second Highest Salary (Easy)](https://leetcode.com/problems/second-highest-salary "第二高的薪水") +## [176. Second Highest Salary (Medium)](https://leetcode.com/problems/second-highest-salary "第二高的薪水") -

    Write a SQL query to get the second highest salary from the Employee table.

    +

    Table: Employee

    ++-------------+------+
    +| Column Name | Type |
    ++-------------+------+
    +| id          | int  |
    +| salary      | int  |
    ++-------------+------+
    +id is the primary key column for this table.
    +Each row of this table contains information about the salary of an employee.
    +
    + +

     

    + +

    Write an SQL query to report the second highest salary from the Employee table. If there is no second highest salary, the query should report null.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    + +
    +Input: 
    +Employee table:
     +----+--------+
    -| Id | Salary |
    +| id | salary |
     +----+--------+
     | 1  | 100    |
     | 2  | 200    |
     | 3  | 300    |
     +----+--------+
    +Output: 
    ++---------------------+
    +| SecondHighestSalary |
    ++---------------------+
    +| 200                 |
    ++---------------------+
     
    -

    For example, given the above Employee table, the query should return 200 as the second highest salary. If there is no second highest salary, then the query should return null.

    +

    Example 2:

    +Input: 
    +Employee table:
    ++----+--------+
    +| id | salary |
    ++----+--------+
    +| 1  | 100    |
    ++----+--------+
    +Output: 
     +---------------------+
     | SecondHighestSalary |
     +---------------------+
    -| 200                 |
    +| null                |
     +---------------------+
     
    diff --git a/problems/second-highest-salary/mysql_schemas.sql b/problems/second-highest-salary/mysql_schemas.sql index c08cc8bd5..f98a8511a 100644 --- a/problems/second-highest-salary/mysql_schemas.sql +++ b/problems/second-highest-salary/mysql_schemas.sql @@ -1,5 +1,5 @@ -Create table If Not Exists Employee (Id int, Salary int); +Create table If Not Exists Employee (id int, salary int); Truncate table Employee; -insert into Employee (Id, Salary) values ('1', '100'); -insert into Employee (Id, Salary) values ('2', '200'); -insert into Employee (Id, Salary) values ('3', '300'); +insert into Employee (id, salary) values ('1', '100'); +insert into Employee (id, salary) values ('2', '200'); +insert into Employee (id, salary) values ('3', '300'); diff --git a/problems/second-minimum-time-to-reach-destination/README.md b/problems/second-minimum-time-to-reach-destination/README.md index b6cd23da1..6511ed733 100644 --- a/problems/second-minimum-time-to-reach-destination/README.md +++ b/problems/second-minimum-time-to-reach-destination/README.md @@ -80,7 +80,6 @@ The second minimum time path is 1 -> 2 -> 1 -> 2 with time = 11 minutes ### Related Topics [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Array](../../tag/array/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] ### Hints diff --git a/problems/self-crossing/README.md b/problems/self-crossing/README.md index fdf7c5d0b..39f96b944 100644 --- a/problems/self-crossing/README.md +++ b/problems/self-crossing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../increasing-triplet-subsequence "Increasing Triplet Subsequence") diff --git a/problems/sell-diminishing-valued-colored-balls/README.md b/problems/sell-diminishing-valued-colored-balls/README.md index 4f26b0d86..e010dd174 100644 --- a/problems/sell-diminishing-valued-colored-balls/README.md +++ b/problems/sell-diminishing-valued-colored-balls/README.md @@ -38,21 +38,6 @@ The maximum total value is 2 + 5 + 4 + 3 = 14. The maximum total value is 3 + 2 + 5 + 4 + 3 + 2 = 19. -

    Example 3:

    - -
    -Input: inventory = [2,8,4,10,6], orders = 20
    -Output: 110
    -
    - -

    Example 4:

    - -
    -Input: inventory = [1000000000], orders = 1000000000
    -Output: 21
    -Explanation: Sell the 1st color 1000000000 times for a total value of 500000000500000000. 500000000500000000 modulo 109 + 7 = 21.
    -
    -

     

    Constraints:

    diff --git a/problems/sentence-similarity-iii/README.md b/problems/sentence-similarity-iii/README.md index 02839ffad..45db111c7 100644 --- a/problems/sentence-similarity-iii/README.md +++ b/problems/sentence-similarity-iii/README.md @@ -42,13 +42,6 @@ Explanation: sentence2 can be turned to sentence1 by inserting "right now" at the end of the sentence. -

    Example 4:

    - -
    -Input: sentence1 = "Luky", sentence2 = "Lucccky"
    -Output: false
    -
    -

     

    Constraints:

    diff --git a/problems/sequentially-ordinal-rank-tracker/README.md b/problems/sequentially-ordinal-rank-tracker/README.md new file mode 100644 index 000000000..4b1402419 --- /dev/null +++ b/problems/sequentially-ordinal-rank-tracker/README.md @@ -0,0 +1,113 @@ + + + + + + + +[< Previous](../detonate-the-maximum-bombs "Detonate the Maximum Bombs") +                 +[Next >](../rings-and-rods "Rings and Rods") + +## [2102. Sequentially Ordinal Rank Tracker (Hard)](https://leetcode.com/problems/sequentially-ordinal-rank-tracker "序列顺序查询") + +

    A scenic location is represented by its name and attractiveness score, where name is a unique string among all locations and score is an integer. Locations can be ranked from the best to the worst. The higher the score, the better the location. If the scores of two locations are equal, then the location with the lexicographically smaller name is better.

    + +

    You are building a system that tracks the ranking of locations with the system initially starting with no locations. It supports:

    + +
      +
    • Adding scenic locations, one at a time.
    • +
    • Querying the ith best location of all locations already added, where i is the number of times the system has been queried (including the current query). +
        +
      • For example, when the system is queried for the 4th time, it returns the 4th best location of all locations already added.
      • +
      +
    • +
    + +

    Note that the test data are generated so that at any time, the number of queries does not exceed the number of locations added to the system.

    + +

    Implement the SORTracker class:

    + +
      +
    • SORTracker() Initializes the tracker system.
    • +
    • void add(string name, int score) Adds a scenic location with name and score to the system.
    • +
    • string get() Queries and returns the ith best location, where i is the number of times this method has been invoked (including this invocation).
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["SORTracker", "add", "add", "get", "add", "get", "add", "get", "add", "get", "add", "get", "get"]
    +[[], ["bradford", 2], ["branford", 3], [], ["alps", 2], [], ["orland", 2], [], ["orlando", 3], [], ["alpine", 2], [], []]
    +Output
    +[null, null, null, "branford", null, "alps", null, "bradford", null, "bradford", null, "bradford", "orland"]
    +
    +Explanation
    +SORTracker tracker = new SORTracker(); // Initialize the tracker system.
    +tracker.add("bradford", 2); // Add location with name="bradford" and score=2 to the system.
    +tracker.add("branford", 3); // Add location with name="branford" and score=3 to the system.
    +tracker.get();              // The sorted locations, from best to worst, are: branford, bradford.
    +                            // Note that branford precedes bradford due to its higher score (3 > 2).
    +                            // This is the 1st time get() is called, so return the best location: "branford".
    +tracker.add("alps", 2);     // Add location with name="alps" and score=2 to the system.
    +tracker.get();              // Sorted locations: branford, alps, bradford.
    +                            // Note that alps precedes bradford even though they have the same score (2).
    +                            // This is because "alps" is lexicographically smaller than "bradford".
    +                            // Return the 2nd best location "alps", as it is the 2nd time get() is called.
    +tracker.add("orland", 2);   // Add location with name="orland" and score=2 to the system.
    +tracker.get();              // Sorted locations: branford, alps, bradford, orland.
    +                            // Return "bradford", as it is the 3rd time get() is called.
    +tracker.add("orlando", 3);  // Add location with name="orlando" and score=3 to the system.
    +tracker.get();              // Sorted locations: branford, orlando, alps, bradford, orland.
    +                            // Return "bradford".
    +tracker.add("alpine", 2);   // Add location with name="alpine" and score=2 to the system.
    +tracker.get();              // Sorted locations: branford, orlando, alpine, alps, bradford, orland.
    +                            // Return "bradford".
    +tracker.get();              // Sorted locations: branford, orlando, alpine, alps, bradford, orland.
    +                            // Return "orland".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • name consists of lowercase English letters, and is unique among all locations.
    • +
    • 1 <= name.length <= 10
    • +
    • 1 <= score <= 105
    • +
    • At any time, the number of calls to get does not exceed the number of calls to add.
    • +
    • At most 4 * 104 calls in total will be made to add and get.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +If the problem were to find the median of a stream of scenery locations while they are being added, can you solve it? +
    + +
    +Hint 2 +We can use a similar approach as an optimization to avoid repeated sorting. +
    + +
    +Hint 3 +Employ two heaps: left heap and right heap. The left heap is a max-heap, and the right heap is a min-heap. The size of the left heap is k + 1 (best locations), where k is the number of times the get method was invoked. The other locations are maintained in the right heap. +
    + +
    +Hint 4 +Every time when add is being called, we add it to the left heap. If the size of the left heap exceeds k + 1, we move the head element to the right heap. +
    + +
    +Hint 5 +When the get method is invoked again (the k + 1 time it is invoked), we can return the head element of the left heap. But before returning it, if the right heap is not empty, we maintain the left heap to have the best k + 2 items by moving the best location from the right heap to the left heap. +
    diff --git a/problems/set-matrix-zeroes/README.md b/problems/set-matrix-zeroes/README.md index f2ba94241..f3c767924 100644 --- a/problems/set-matrix-zeroes/README.md +++ b/problems/set-matrix-zeroes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../edit-distance "Edit Distance") @@ -11,7 +11,7 @@ ## [73. Set Matrix Zeroes (Medium)](https://leetcode.com/problems/set-matrix-zeroes "矩阵置零") -

    Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's, and return the matrix.

    +

    Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.

    You must do it in place.

    @@ -56,6 +56,8 @@ ### Similar Questions 1. [Game of Life](../game-of-life) (Medium) + 1. [Number of Laser Beams in a Bank](../number-of-laser-beams-in-a-bank) (Medium) + 1. [Minimum Operations to Remove Adjacent Ones in Matrix](../minimum-operations-to-remove-adjacent-ones-in-matrix) (Hard) ### Hints
    diff --git a/problems/set-mismatch/README.md b/problems/set-mismatch/README.md index 4fd90d16f..afde337fb 100644 --- a/problems/set-mismatch/README.md +++ b/problems/set-mismatch/README.md @@ -34,9 +34,9 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/shift-2d-grid/README.md b/problems/shift-2d-grid/README.md index 2e724740e..3474f127a 100644 --- a/problems/shift-2d-grid/README.md +++ b/problems/shift-2d-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../handshakes-that-dont-cross "Handshakes That Don't Cross") diff --git a/problems/shortest-bridge/README.md b/problems/shortest-bridge/README.md index c99a6492f..c28bec2ab 100644 --- a/problems/shortest-bridge/README.md +++ b/problems/shortest-bridge/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-recent-calls "Number of Recent Calls") @@ -11,11 +11,13 @@ ## [934. Shortest Bridge (Medium)](https://leetcode.com/problems/shortest-bridge "最短的桥") -

    In a given 2D binary array grid, there are two islands.  (An island is a 4-directionally connected group of 1s not connected to any other 1s.)

    +

    You are given an n x n binary matrix grid where 1 represents land and 0 represents water.

    -

    Now, we may change 0s to 1s so as to connect the two islands together to form 1 island.

    +

    An island is a 4-directionally connected group of 1's not connected to any other 1's. There are exactly two islands in grid.

    -

    Return the smallest number of 0s that must be flipped.  (It is guaranteed that the answer is at least 1.)

    +

    You may change 0's to 1's to connect the two islands to form one island.

    + +

    Return the smallest number of 0's you must flip to connect the two islands.

     

    Example 1:

    @@ -43,8 +45,10 @@

    Constraints:

      -
    • 2 <= grid.length == grid[0].length <= 100
    • -
    • grid[i][j] == 0 or grid[i][j] == 1
    • +
    • n == grid.length == grid[i].length
    • +
    • 2 <= n <= 100
    • +
    • grid[i][j] is either 0 or 1.
    • +
    • There are exactly two islands in grid.
    ### Related Topics diff --git a/problems/shortest-completing-word/README.md b/problems/shortest-completing-word/README.md index 5501b8b5b..10eb3e10f 100644 --- a/problems/shortest-completing-word/README.md +++ b/problems/shortest-completing-word/README.md @@ -41,27 +41,6 @@ Since "steps" is the only word containing all the letters, that is the Explanation: licensePlate only contains the letter 's'. All the words contain 's', but among these "pest", "stew", and "show" are shortest. The answer is "pest" because it is the word that appears earliest of the 3. -

    Example 3:

    - -
    -Input: licensePlate = "Ah71752", words = ["suggest","letter","of","husband","easy","education","drug","prevent","writer","old"]
    -Output: "husband"
    -
    - -

    Example 4:

    - -
    -Input: licensePlate = "OgEu755", words = ["enough","these","play","wide","wonder","box","arrive","money","tax","thus"]
    -Output: "enough"
    -
    - -

    Example 5:

    - -
    -Input: licensePlate = "iMSlpe4", words = ["claim","consumer","student","camera","public","never","wonder","simple","thought","use"]
    -Output: "simple"
    -
    -

     

    Constraints:

    @@ -74,6 +53,7 @@ Since "steps" is the only word containing all the letters, that is the ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/shortest-distance-from-all-buildings/README.md b/problems/shortest-distance-from-all-buildings/README.md index ee20e154f..d8508700c 100644 --- a/problems/shortest-distance-from-all-buildings/README.md +++ b/problems/shortest-distance-from-all-buildings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicate-letters "Remove Duplicate Letters") diff --git a/problems/shortest-path-in-a-hidden-grid/README.md b/problems/shortest-path-in-a-hidden-grid/README.md index 9a8aae6c9..c519f5a97 100644 --- a/problems/shortest-path-in-a-hidden-grid/README.md +++ b/problems/shortest-path-in-a-hidden-grid/README.md @@ -19,6 +19,10 @@ [[Graph](../../tag/graph/README.md)] [[Interactive](../../tag/interactive/README.md)] +### Similar Questions + 1. [Robot Room Cleaner](../robot-room-cleaner) (Hard) + 1. [Minimum Path Cost in a Hidden Grid](../minimum-path-cost-in-a-hidden-grid) (Medium) + ### Hints
    Hint 1 diff --git a/problems/shortest-path-to-get-food/README.md b/problems/shortest-path-to-get-food/README.md index 1332ad811..d6251d5c9 100644 --- a/problems/shortest-path-to-get-food/README.md +++ b/problems/shortest-path-to-get-food/README.md @@ -14,10 +14,14 @@ ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [01 Matrix](../01-matrix) (Medium) + 1. [Shortest Path in a Grid with Obstacles Elimination](../shortest-path-in-a-grid-with-obstacles-elimination) (Hard) + ### Hints
    Hint 1 diff --git a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md index 0c1a1106f..6af342eff 100644 --- a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md +++ b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md @@ -23,15 +23,16 @@
     Input: arr = [1,2,3,10,4,2,3,5]
     Output: 3
    -Explanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted.
    -Another correct solution is to remove the subarray [3,10,4].
    +Explanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted. +Another correct solution is to remove the subarray [3,10,4]. +

    Example 2:

     Input: arr = [5,4,3,2,1]
     Output: 4
    -Explanation: Since the array is strictly decreasing, we can only keep a single element. Therefore we need to remove a subarray of length 4, either [5,4,3,2] or [4,3,2,1].
    +Explanation: Since the array is strictly decreasing, we can only keep a single element. Therefore we need to remove a subarray of length 4, either [5,4,3,2] or [4,3,2,1].
     

    Example 3:

    @@ -39,14 +40,7 @@ Another correct solution is to remove the subarray [3,10,4].
     Input: arr = [1,2,3]
     Output: 0
    -Explanation: The array is already non-decreasing. We do not need to remove any elements.
    -
    - -

    Example 4:

    - -
    -Input: arr = [1]
    -Output: 0
    +Explanation: The array is already non-decreasing. We do not need to remove any elements.
     

     

    @@ -58,10 +52,10 @@ Another correct solution is to remove the subarray [3,10,4]. ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Stack](../../tag/stack/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints diff --git a/problems/shortest-way-to-form-string/README.md b/problems/shortest-way-to-form-string/README.md index 6a522ebee..2a8fb3a4b 100644 --- a/problems/shortest-way-to-form-string/README.md +++ b/problems/shortest-way-to-form-string/README.md @@ -51,13 +51,12 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Is Subsequence](../is-subsequence) (Easy) - 1. [Number of Matching Subsequences](../number-of-matching-subsequences) (Medium) ### Hints
    diff --git a/problems/shuffle-string/README.md b/problems/shuffle-string/README.md index 83e038f81..ab3bf2124 100644 --- a/problems/shuffle-string/README.md +++ b/problems/shuffle-string/README.md @@ -7,13 +7,11 @@ [< Previous](../patients-with-a-condition "Patients With a Condition")                  -[Next >](../bulb-switcher-iv "Bulb Switcher IV") +[Next >](../minimum-suffix-flips "Minimum Suffix Flips") ## [1528. Shuffle String (Easy)](https://leetcode.com/problems/shuffle-string "重新排列字符串") -

    Given a string s and an integer array indices of the same length.

    - -

    The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.

    +

    You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.

    Return the shuffled string.

    @@ -34,36 +32,15 @@ Explanation: After shuffling, each character remains in its position. -

    Example 3:

    - -
    -Input: s = "aiohn", indices = [3,1,4,2,0]
    -Output: "nihao"
    -
    - -

    Example 4:

    - -
    -Input: s = "aaiougrt", indices = [4,0,2,6,7,3,1,5]
    -Output: "arigatou"
    -
    - -

    Example 5:

    - -
    -Input: s = "art", indices = [1,0,2]
    -Output: "rat"
    -
    -

     

    Constraints:

    • s.length == indices.length == n
    • 1 <= n <= 100
    • -
    • s contains only lower-case English letters.
    • -
    • 0 <= indices[i] < n
    • -
    • All values of indices are unique (i.e. indices is a permutation of the integers from 0 to n - 1).
    • +
    • s consists of only lowercase English letters.
    • +
    • 0 <= indices[i] < n
    • +
    • All values of indices are unique.
    ### Related Topics diff --git a/problems/shuffle-the-array/README.md b/problems/shuffle-the-array/README.md index 43679a3af..9180ca6d1 100644 --- a/problems/shuffle-the-array/README.md +++ b/problems/shuffle-the-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-all-the-lonely-nodes "Find All The Lonely Nodes") diff --git a/problems/simplify-path/README.md b/problems/simplify-path/README.md index 842c7792e..3e55de4ff 100644 --- a/problems/simplify-path/README.md +++ b/problems/simplify-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../climbing-stairs "Climbing Stairs") @@ -48,14 +48,7 @@
     Input: path = "/home//foo/"
     Output: "/home/foo"
    -Explanation: In the canonical path, multiple consecutive slashes are replaced by a single one.
    -
    - -

    Example 4:

    - -
    -Input: path = "/a/./b/../../c/"
    -Output: "/c"
    +Explanation: In the canonical path, multiple consecutive slashes are replaced by a single one.
     

     

    diff --git a/problems/single-row-keyboard/README.md b/problems/single-row-keyboard/README.md index dabe10b72..37330813a 100644 --- a/problems/single-row-keyboard/README.md +++ b/problems/single-row-keyboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../product-price-at-a-given-date "Product Price at a Given Date") diff --git a/problems/smallest-greater-multiple-made-of-two-digits/README.md b/problems/smallest-greater-multiple-made-of-two-digits/README.md index 2b62f9d3f..cd7e4bd7f 100644 --- a/problems/smallest-greater-multiple-made-of-two-digits/README.md +++ b/problems/smallest-greater-multiple-made-of-two-digits/README.md @@ -9,7 +9,7 @@                  [Next >](../reverse-prefix-of-word "Reverse Prefix of Word") -## [1999. Smallest Greater Multiple Made of Two Digits (Medium)](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits "") +## [1999. Smallest Greater Multiple Made of Two Digits (Medium)](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits "最小的仅由两个数组成的倍数") diff --git a/problems/smallest-index-with-equal-value/README.md b/problems/smallest-index-with-equal-value/README.md index 580d8f059..48843d83d 100644 --- a/problems/smallest-index-with-equal-value/README.md +++ b/problems/smallest-index-with-equal-value/README.md @@ -49,14 +49,6 @@ i=3: 3 mod 10 = 3 != nums[3]. Explanation: No index satisfies i mod 10 == nums[i]. -

    Example 4:

    - -
    -Input: nums = [2,1,3,5,2]
    -Output: 1
    -Explanation: 1 is the only index with i mod 10 == nums[i].
    -
    -

     

    Constraints:

    diff --git a/problems/smallest-range-covering-elements-from-k-lists/README.md b/problems/smallest-range-covering-elements-from-k-lists/README.md index c6b732dd2..7738b24d9 100644 --- a/problems/smallest-range-covering-elements-from-k-lists/README.md +++ b/problems/smallest-range-covering-elements-from-k-lists/README.md @@ -34,27 +34,6 @@ List 3: [5, 18, 22, 30], 22 is in range [20,24]. Output: [1,1] -

    Example 3:

    - -
    -Input: nums = [[10,10],[11,11]]
    -Output: [10,11]
    -
    - -

    Example 4:

    - -
    -Input: nums = [[10],[11]]
    -Output: [10,11]
    -
    - -

    Example 5:

    - -
    -Input: nums = [[1],[2],[3],[4],[5],[6],[7]]
    -Output: [1,7]
    -
    -

     

    Constraints:

    @@ -67,9 +46,12 @@ List 3: [5, 18, 22, 30], 22 is in range [20,24]. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Sorting](../../tag/sorting/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Similar Questions + 1. [Minimum Window Substring](../minimum-window-substring) (Hard) diff --git a/problems/smallest-string-starting-from-leaf/README.md b/problems/smallest-string-starting-from-leaf/README.md index 2cacbb7f1..9b0831735 100644 --- a/problems/smallest-string-starting-from-leaf/README.md +++ b/problems/smallest-string-starting-from-leaf/README.md @@ -54,9 +54,9 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md index 8c29362be..f7479d7cc 100644 --- a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md +++ b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-to-get-all-keys "Shortest Path to Get All Keys") @@ -15,11 +15,9 @@

    Return the smallest subtree such that it contains all the deepest nodes in the original tree.

    -

    A node is called the deepest if it has the largest depth possible among any node in the entire tree.

    +

    A node is called the deepest if it has the largest depth possible among any node in the entire tree.

    -

    The subtree of a node is tree consisting of that node, plus the set of all descendants of that node.

    - -

    Note: This question is the same as 1123: https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/

    +

    The subtree of a node is a tree consisting of that node, plus the set of all descendants of that node.

     

    Example 1:

    @@ -54,12 +52,15 @@ Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is
    • The number of nodes in the tree will be in the range [1, 500].
    • 0 <= Node.val <= 500
    • -
    • The values of the nodes in the tree are unique.
    • +
    • The values of the nodes in the tree are unique.
    +

     

    +

    Note: This question is the same as 1123: https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/

    + ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/smallest-value-of-the-rearranged-number/README.md b/problems/smallest-value-of-the-rearranged-number/README.md new file mode 100644 index 000000000..3d029d147 --- /dev/null +++ b/problems/smallest-value-of-the-rearranged-number/README.md @@ -0,0 +1,59 @@ + + + + + + + +[< Previous](../sort-even-and-odd-indices-independently "Sort Even and Odd Indices Independently") +                 +[Next >](../design-bitset "Design Bitset") + +## [2165. Smallest Value of the Rearranged Number (Medium)](https://leetcode.com/problems/smallest-value-of-the-rearranged-number "重排数字的最小值") + +

    You are given an integer num. Rearrange the digits of num such that its value is minimized and it does not contain any leading zeros.

    + +

    Return the rearranged number with minimal value.

    + +

    Note that the sign of the number does not change after rearranging the digits.

    + +

     

    +

    Example 1:

    + +
    +Input: num = 310
    +Output: 103
    +Explanation: The possible arrangements for the digits of 310 are 013, 031, 103, 130, 301, 310. 
    +The arrangement with the smallest value that does not contain any leading zeros is 103.
    +
    + +

    Example 2:

    + +
    +Input: num = -7605
    +Output: -7650
    +Explanation: Some possible arrangements for the digits of -7605 are -7650, -6705, -5076, -0567.
    +The arrangement with the smallest value that does not contain any leading zeros is -7650.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • -1015 <= num <= 1015
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +For positive numbers, the leading digit should be the smallest nonzero digit. Then the remaining digits follow in ascending order. +
    + +
    +Hint 2 +For negative numbers, the digits should be arranged in descending order. +
    diff --git a/problems/solving-questions-with-brainpower/README.md b/problems/solving-questions-with-brainpower/README.md new file mode 100644 index 000000000..91656b129 --- /dev/null +++ b/problems/solving-questions-with-brainpower/README.md @@ -0,0 +1,92 @@ + + + + + + + +[< Previous](../minimum-moves-to-reach-target-score "Minimum Moves to Reach Target Score") +                 +[Next >](../maximum-running-time-of-n-computers "Maximum Running Time of N Computers") + +## [2140. Solving Questions With Brainpower (Medium)](https://leetcode.com/problems/solving-questions-with-brainpower "解决智力问题") + +

    You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri].

    + +

    The array describes the questions of an exam, where you have to process the questions in order (i.e., starting from question 0) and make a decision whether to solve or skip each question. Solving question i will earn you pointsi points but you will be unable to solve each of the next brainpoweri questions. If you skip question i, you get to make the decision on the next question.

    + +
      +
    • For example, given questions = [[3, 2], [4, 3], [4, 4], [2, 5]]: +
        +
      • If question 0 is solved, you will earn 3 points but you will be unable to solve questions 1 and 2.
      • +
      • If instead, question 0 is skipped and question 1 is solved, you will earn 4 points but you will be unable to solve questions 2 and 3.
      • +
      +
    • +
    + +

    Return the maximum points you can earn for the exam.

    + +

     

    +

    Example 1:

    + +
    +Input: questions = [[3,2],[4,3],[4,4],[2,5]]
    +Output: 5
    +Explanation: The maximum points can be earned by solving questions 0 and 3.
    +- Solve question 0: Earn 3 points, will be unable to solve the next 2 questions
    +- Unable to solve questions 1 and 2
    +- Solve question 3: Earn 2 points
    +Total points earned: 3 + 2 = 5. There is no other way to earn 5 or more points.
    +
    + +

    Example 2:

    + +
    +Input: questions = [[1,1],[2,2],[3,3],[4,4],[5,5]]
    +Output: 7
    +Explanation: The maximum points can be earned by solving questions 1 and 4.
    +- Skip question 0
    +- Solve question 1: Earn 2 points, will be unable to solve the next 2 questions
    +- Unable to solve questions 2 and 3
    +- Solve question 4: Earn 5 points
    +Total points earned: 2 + 5 = 7. There is no other way to earn 7 or more points.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= questions.length <= 105
    • +
    • questions[i].length == 2
    • +
    • 1 <= pointsi, brainpoweri <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +For each question, we can either solve it or skip it. How can we use Dynamic Programming to decide the most optimal option for each problem? +
    + +
    +Hint 2 +We store for each question the maximum points we can earn if we started the exam on that question. +
    + +
    +Hint 3 +If we skip a question, then the answer for it will be the same as the answer for the next question. +
    + +
    +Hint 4 +If we solve a question, then the answer for it will be the points of the current question plus the answer for the next solvable question. +
    + +
    +Hint 5 +The maximum of these two values will be the answer to the current question. +
    diff --git a/problems/sort-an-array/README.md b/problems/sort-an-array/README.md index defec3b25..eade2aa53 100644 --- a/problems/sort-an-array/README.md +++ b/problems/sort-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../online-election "Online Election") @@ -32,9 +32,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Bucket Sort](../../tag/bucket-sort/README.md)] - [[Counting Sort](../../tag/counting-sort/README.md)] - [[Radix Sort](../../tag/radix-sort/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Merge Sort](../../tag/merge-sort/README.md)] + [[Bucket Sort](../../tag/bucket-sort/README.md)] + [[Radix Sort](../../tag/radix-sort/README.md)] + [[Counting Sort](../../tag/counting-sort/README.md)] diff --git a/problems/sort-array-by-increasing-frequency/README.md b/problems/sort-array-by-increasing-frequency/README.md index 9ed63490c..e5cbf4b46 100644 --- a/problems/sort-array-by-increasing-frequency/README.md +++ b/problems/sort-array-by-increasing-frequency/README.md @@ -51,9 +51,6 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Sort Characters By Frequency](../sort-characters-by-frequency) (Medium) - ### Hints
    Hint 1 diff --git a/problems/sort-even-and-odd-indices-independently/README.md b/problems/sort-even-and-odd-indices-independently/README.md new file mode 100644 index 000000000..9cf9fc559 --- /dev/null +++ b/problems/sort-even-and-odd-indices-independently/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../minimum-difference-in-sums-after-removal-of-elements "Minimum Difference in Sums After Removal of Elements") +                 +[Next >](../smallest-value-of-the-rearranged-number "Smallest Value of the Rearranged Number") + +## [2164. Sort Even and Odd Indices Independently (Easy)](https://leetcode.com/problems/sort-even-and-odd-indices-independently "对奇偶下标分别排序") + +

    You are given a 0-indexed integer array nums. Rearrange the values of nums according to the following rules:

    + +
      +
    1. Sort the values at odd indices of nums in non-increasing order. +
        +
      • For example, if nums = [4,1,2,3] before this step, it becomes [4,3,2,1] after. The values at odd indices 1 and 3 are sorted in non-increasing order.
      • +
      +
    2. +
    3. Sort the values at even indices of nums in non-decreasing order. +
        +
      • For example, if nums = [4,1,2,3] before this step, it becomes [2,1,4,3] after. The values at even indices 0 and 2 are sorted in non-decreasing order.
      • +
      +
    4. +
    + +

    Return the array formed after rearranging the values of nums.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [4,1,2,3]
    +Output: [2,3,4,1]
    +Explanation: 
    +First, we sort the values present at odd indices (1 and 3) in non-increasing order.
    +So, nums changes from [4,1,2,3] to [4,3,2,1].
    +Next, we sort the values present at even indices (0 and 2) in non-decreasing order.
    +So, nums changes from [4,1,2,3] to [2,3,4,1].
    +Thus, the array formed after rearranging the values is [2,3,4,1].
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,1]
    +Output: [2,1]
    +Explanation: 
    +Since there is exactly one odd index and one even index, no rearrangement of values takes place.
    +The resultant array formed is [2,1], which is the same as the initial array. 
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 1 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Try to separate the elements at odd indices from the elements at even indices. +
    + +
    +Hint 2 +Sort the two groups of elements individually. +
    + +
    +Hint 3 +Combine them to form the resultant array. +
    diff --git a/problems/sort-integers-by-the-number-of-1-bits/README.md b/problems/sort-integers-by-the-number-of-1-bits/README.md index 21a136eaf..9ffba5ff0 100644 --- a/problems/sort-integers-by-the-number-of-1-bits/README.md +++ b/problems/sort-integers-by-the-number-of-1-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../activity-participants "Activity Participants") @@ -11,9 +11,9 @@ ## [1356. Sort Integers by The Number of 1 Bits (Easy)](https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits "根据数字二进制下 1 的数目排序") -

    Given an integer array arr. You have to sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.

    +

    You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.

    -

    Return the sorted array.

    +

    Return the array after sorting it.

     

    Example 1:

    @@ -36,33 +36,12 @@ The sorted array by bits is [0,1,2,4,8,3,5,6,7] Explantion: All integers have 1 bit in the binary representation, you should just sort them in ascending order. -

    Example 3:

    - -
    -Input: arr = [10000,10000]
    -Output: [10000,10000]
    -
    - -

    Example 4:

    - -
    -Input: arr = [2,3,5,7,11,13,17,19]
    -Output: [2,3,5,17,7,11,13,19]
    -
    - -

    Example 5:

    - -
    -Input: arr = [10,100,1000,10000]
    -Output: [10,100,10000,1000]
    -
    -

     

    Constraints:

    • 1 <= arr.length <= 500
    • -
    • 0 <= arr[i] <= 10^4
    • +
    • 0 <= arr[i] <= 104
    ### Related Topics @@ -71,6 +50,9 @@ The sorted array by bits is [0,1,2,4,8,3,5,6,7] [[Sorting](../../tag/sorting/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Find Subsequence of Length K With the Largest Sum](../find-subsequence-of-length-k-with-the-largest-sum) (Easy) + ### Hints
    Hint 1 diff --git a/problems/sort-integers-by-the-power-value/README.md b/problems/sort-integers-by-the-power-value/README.md index 80eefa8c1..7a507f22c 100644 --- a/problems/sort-integers-by-the-power-value/README.md +++ b/problems/sort-integers-by-the-power-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cinema-seat-allocation "Cinema Seat Allocation") @@ -11,20 +11,20 @@ ## [1387. Sort Integers by The Power Value (Medium)](https://leetcode.com/problems/sort-integers-by-the-power-value "将整数按权重排序") -

    The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:

    +

    The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:

    • if x is even then x = x / 2
    • if x is odd then x = 3 * x + 1
    -

    For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).

    +

    For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).

    Given three integers lo, hi and k. The task is to sort all integers in the interval [lo, hi] by the power value in ascending order, if two or more integers have the same power value sort them by ascending order.

    -

    Return the k-th integer in the range [lo, hi] sorted by the power value.

    +

    Return the kth integer in the range [lo, hi] sorted by the power value.

    -

    Notice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in 32 bit signed integer.

    +

    Notice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in a 32-bit signed integer.

     

    Example 1:

    @@ -42,13 +42,6 @@ Notice that 12 and 13 have the same power value and we sorted them in ascending

    Example 2:

    -
    -Input: lo = 1, hi = 1, k = 1
    -Output: 1
    -
    - -

    Example 3:

    -
     Input: lo = 7, hi = 11, k = 4
     Output: 7
    @@ -57,20 +50,6 @@ The interval sorted by power is [8, 10, 11, 7, 9].
     The fourth number in the sorted array is 7.
     
    -

    Example 4:

    - -
    -Input: lo = 10, hi = 20, k = 5
    -Output: 13
    -
    - -

    Example 5:

    - -
    -Input: lo = 1, hi = 1000, k = 777
    -Output: 570
    -
    -

     

    Constraints:

    @@ -80,8 +59,8 @@ The fourth number in the sorted array is 7. ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Memoization](../../tag/memoization/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/sort-linked-list-already-sorted-using-absolute-values/README.md b/problems/sort-linked-list-already-sorted-using-absolute-values/README.md index 787f6c9e5..452636892 100644 --- a/problems/sort-linked-list-already-sorted-using-absolute-values/README.md +++ b/problems/sort-linked-list-already-sorted-using-absolute-values/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-valid-words-in-a-sentence "Number of Valid Words in a Sentence") -## [2046. Sort Linked List Already Sorted Using Absolute Values (Medium)](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values "") +## [2046. Sort Linked List Already Sorted Using Absolute Values (Medium)](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values "给按照绝对值排序的链表排序") diff --git a/problems/sort-transformed-array/README.md b/problems/sort-transformed-array/README.md index 5e0bdca3e..6135d7d68 100644 --- a/problems/sort-transformed-array/README.md +++ b/problems/sort-transformed-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../logger-rate-limiter "Logger Rate Limiter") diff --git a/problems/sorting-the-sentence/README.md b/problems/sorting-the-sentence/README.md index bf34188c7..8f696c17d 100644 --- a/problems/sorting-the-sentence/README.md +++ b/problems/sorting-the-sentence/README.md @@ -53,6 +53,9 @@ [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Check if Numbers Are Ascending in a Sentence](../check-if-numbers-are-ascending-in-a-sentence) (Easy) + ### Hints
    Hint 1 diff --git a/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md b/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md index 421305253..acdb00777 100644 --- a/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md +++ b/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md @@ -46,13 +46,6 @@ x cannot be greater since there are only 2 numbers in nums. Explanation: There are 3 values that are greater than or equal to 3. -

    Example 4:

    - -
    -Input: nums = [3,6,7,7,0]
    -Output: -1
    -
    -

     

    Constraints:

    diff --git a/problems/special-positions-in-a-binary-matrix/README.md b/problems/special-positions-in-a-binary-matrix/README.md index a3e5ee837..3f8fe5cdd 100644 --- a/problems/special-positions-in-a-binary-matrix/README.md +++ b/problems/special-positions-in-a-binary-matrix/README.md @@ -11,60 +11,35 @@ ## [1582. Special Positions in a Binary Matrix (Easy)](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") -

    Given a rows x cols matrix mat, where mat[i][j] is either 0 or 1, return the number of special positions in mat.

    +

    Given an m x n binary matrix mat, return the number of special positions in mat.

    -

    A position (i,j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).

    +

    A position (i, j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).

     

    Example 1:

    - +
    -Input: mat = [[1,0,0],
    -              [0,0,1],
    -              [1,0,0]]
    +Input: mat = [[1,0,0],[0,0,1],[1,0,0]]
     Output: 1
    -Explanation: (1,2) is a special position because mat[1][2] == 1 and all other elements in row 1 and column 2 are 0.
    +Explanation: (1, 2) is a special position because mat[1][2] == 1 and all other elements in row 1 and column 2 are 0.
     

    Example 2:

    - -
    -Input: mat = [[1,0,0],
    -              [0,1,0],
    -              [0,0,1]]
    -Output: 3
    -Explanation: (0,0), (1,1) and (2,2) are special positions. 
    -
    - -

    Example 3:

    - -
    -Input: mat = [[0,0,0,1],
    -              [1,0,0,0],
    -              [0,1,1,0],
    -              [0,0,0,0]]
    -Output: 2
    -
    - -

    Example 4:

    - +
    -Input: mat = [[0,0,0,0,0],
    -              [1,0,0,0,0],
    -              [0,1,0,0,0],
    -              [0,0,1,0,0],
    -              [0,0,0,1,1]]
    +Input: mat = [[1,0,0],[0,1,0],[0,0,1]]
     Output: 3
    +Explanation: (0, 0), (1, 1) and (2, 2) are special positions.
     

     

    Constraints:

      -
    • rows == mat.length
    • -
    • cols == mat[i].length
    • -
    • 1 <= rows, cols <= 100
    • -
    • mat[i][j] is 0 or 1.
    • +
    • m == mat.length
    • +
    • n == mat[i].length
    • +
    • 1 <= m, n <= 100
    • +
    • mat[i][j] is either 0 or 1.
    ### Related Topics diff --git a/problems/split-array-into-fibonacci-sequence/README.md b/problems/split-array-into-fibonacci-sequence/README.md index bf63e8c47..1d3c593ce 100644 --- a/problems/split-array-into-fibonacci-sequence/README.md +++ b/problems/split-array-into-fibonacci-sequence/README.md @@ -29,26 +29,20 @@

    Example 1:

    -Input: num = "123456579"
    -Output: [123,456,579]
    +Input: num = "1101111"
    +Output: [11,0,11,11]
    +Explanation: The output [110, 1, 111] would also be accepted.
     

    Example 2:

    -
    -Input: num = "11235813"
    -Output: [1,1,2,3,5,8,13]
    -
    - -

    Example 3:

    -
     Input: num = "112358130"
     Output: []
     Explanation: The task is impossible.
     
    -

    Example 4:

    +

    Example 3:

     Input: num = "0123"
    @@ -56,14 +50,6 @@
     Explanation: Leading zeroes are not allowed, so "01", "2", "3" is not valid.
     
    -

    Example 5:

    - -
    -Input: num = "1101111"
    -Output: [11,0,11,11]
    -Explanation: The output [11, 0, 11, 11] would also be accepted.
    -
    -

     

    Constraints:

    diff --git a/problems/split-array-with-same-average/README.md b/problems/split-array-with-same-average/README.md index 248dac471..f7cfa9d69 100644 --- a/problems/split-array-with-same-average/README.md +++ b/problems/split-array-with-same-average/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-morse-code-words "Unique Morse Code Words") diff --git a/problems/split-two-strings-to-make-palindrome/README.md b/problems/split-two-strings-to-make-palindrome/README.md index 8684258eb..b8a9ef7b2 100644 --- a/problems/split-two-strings-to-make-palindrome/README.md +++ b/problems/split-two-strings-to-make-palindrome/README.md @@ -34,8 +34,8 @@ Then, aprefix + bsuffix = "" + "y" = &

    Example 2:

    -Input: a = "abdef", b = "fecab"
    -Output: true
    +Input: a = "xbdef", b = "xecab"
    +Output: false
     

    Example 3:

    @@ -49,13 +49,6 @@ bprefix = "jiz", bsuffix = "alu" Then, aprefix + bsuffix = "ula" + "alu" = "ulaalu", which is a palindrome. -

    Example 4:

    - -
    -Input: a = "xbdef", b = "xecab"
    -Output: false
    -
    -

     

    Constraints:

    @@ -66,9 +59,9 @@ Then, aprefix + bsuffix = "ula" + "alu" ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/splitting-a-string-into-descending-consecutive-values/README.md b/problems/splitting-a-string-into-descending-consecutive-values/README.md index 936b7ddf8..97aca561b 100644 --- a/problems/splitting-a-string-into-descending-consecutive-values/README.md +++ b/problems/splitting-a-string-into-descending-consecutive-values/README.md @@ -50,15 +50,6 @@ The values are in descending order with adjacent values differing by 1. Explanation: There is no valid way to split s. -

    Example 4:

    - -
    -Input: s = "10009998"
    -Output: true
    -Explanation: s can be split into ["100", "099", "98"] with numerical values [100,99,98].
    -The values are in descending order with adjacent values differing by 1.
    -
    -

     

    Constraints:

    diff --git a/problems/squares-of-a-sorted-array/README.md b/problems/squares-of-a-sorted-array/README.md index db487bee4..d4c8ef936 100644 --- a/problems/squares-of-a-sorted-array/README.md +++ b/problems/squares-of-a-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-perimeter-triangle "Largest Perimeter Triangle") diff --git a/problems/stamping-the-grid/README.md b/problems/stamping-the-grid/README.md new file mode 100644 index 000000000..e11e22239 --- /dev/null +++ b/problems/stamping-the-grid/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../longest-palindrome-by-concatenating-two-letter-words "Longest Palindrome by Concatenating Two Letter Words") +                 +[Next >](../check-if-every-row-and-column-contains-all-numbers "Check if Every Row and Column Contains All Numbers") + +## [2132. Stamping the Grid (Hard)](https://leetcode.com/problems/stamping-the-grid "用邮票贴满网格图") + +

    You are given an m x n binary matrix grid where each cell is either 0 (empty) or 1 (occupied).

    + +

    You are then given stamps of size stampHeight x stampWidth. We want to fit the stamps such that they follow the given restrictions and requirements:

    + +
      +
    1. Cover all the empty cells.
    2. +
    3. Do not cover any of the occupied cells.
    4. +
    5. We can put as many stamps as we want.
    6. +
    7. Stamps can overlap with each other.
    8. +
    9. Stamps are not allowed to be rotated.
    10. +
    11. Stamps must stay completely inside the grid.
    12. +
    + +

    Return true if it is possible to fit the stamps while following the given restrictions and requirements. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]], stampHeight = 4, stampWidth = 3
    +Output: true
    +Explanation: We have two overlapping stamps (labeled 1 and 2 in the image) that are able to cover all the empty cells.
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]], stampHeight = 2, stampWidth = 2 
    +Output: false 
    +Explanation: There is no way to fit the stamps onto all the empty cells without the stamps going outside the grid.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[r].length
    • +
    • 1 <= m, n <= 105
    • +
    • 1 <= m * n <= 2 * 105
    • +
    • grid[r][c] is either 0 or 1.
    • +
    • 1 <= stampHeight, stampWidth <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +We can check if every empty cell is a part of a consecutive row of empty cells that has a width of at least stampWidth as well as a consecutive column of empty cells that has a height of at least stampHeight. +
    + +
    +Hint 2 +We can prove that this condition is sufficient and necessary to fit the stamps while following the given restrictions and requirements. +
    + +
    +Hint 3 +For each row, find every consecutive row of empty cells, and mark all the cells where the consecutive row is at least stampWidth wide. Do the same for the columns with stampHeight. Then, you can check if every cell is marked twice. +
    diff --git a/problems/stamping-the-sequence/README.md b/problems/stamping-the-sequence/README.md index b260b7a9b..9b995d25d 100644 --- a/problems/stamping-the-sequence/README.md +++ b/problems/stamping-the-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../knight-dialer "Knight Dialer") @@ -61,7 +61,7 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Queue](../../tag/queue/README.md)] - [[String](../../tag/string/README.md)] diff --git a/problems/step-by-step-directions-from-a-binary-tree-node-to-another/README.md b/problems/step-by-step-directions-from-a-binary-tree-node-to-another/README.md new file mode 100644 index 000000000..ad7f54d10 --- /dev/null +++ b/problems/step-by-step-directions-from-a-binary-tree-node-to-another/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../delete-the-middle-node-of-a-linked-list "Delete the Middle Node of a Linked List") +                 +[Next >](../valid-arrangement-of-pairs "Valid Arrangement of Pairs") + +## [2096. Step-By-Step Directions From a Binary Tree Node to Another (Medium)](https://leetcode.com/problems/step-by-step-directions-from-a-binary-tree-node-to-another "从二叉树一个节点到另一个节点每一步的方向") + +

    You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing the value of the start node s, and a different integer destValue representing the value of the destination node t.

    + +

    Find the shortest path starting from node s and ending at node t. Generate step-by-step directions of such path as a string consisting of only the uppercase letters 'L', 'R', and 'U'. Each letter indicates a specific direction:

    + +
      +
    • 'L' means to go from a node to its left child node.
    • +
    • 'R' means to go from a node to its right child node.
    • +
    • 'U' means to go from a node to its parent node.
    • +
    + +

    Return the step-by-step directions of the shortest path from node s to node t.

    + +

     

    +

    Example 1:

    + +
    +Input: root = [5,1,2,3,null,6,4], startValue = 3, destValue = 6
    +Output: "UURL"
    +Explanation: The shortest path is: 3 → 1 → 5 → 2 → 6.
    +
    + +

    Example 2:

    + +
    +Input: root = [2,1], startValue = 2, destValue = 1
    +Output: "L"
    +Explanation: The shortest path is: 2 → 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is n.
    • +
    • 2 <= n <= 105
    • +
    • 1 <= Node.val <= n
    • +
    • All the values in the tree are unique.
    • +
    • 1 <= startValue, destValue <= n
    • +
    • startValue != destValue
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[String](../../tag/string/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + +### Hints +
    +Hint 1 +The shortest path between any two nodes in a tree must pass through their Lowest Common Ancestor (LCA). The path will travel upwards from node s to the LCA and then downwards from the LCA to node t. +
    + +
    +Hint 2 +Find the path strings from root → s, and root → t. Can you use these two strings to prepare the final answer? +
    + +
    +Hint 3 +Remove the longest common prefix of the two path strings to get the path LCA → s, and LCA → t. Each step in the path of LCA → s should be reversed as 'U'. +
    diff --git a/problems/stepping-numbers/README.md b/problems/stepping-numbers/README.md index 1ee2c7220..015aa8167 100644 --- a/problems/stepping-numbers/README.md +++ b/problems/stepping-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum-bsts "Two Sum BSTs") diff --git a/problems/stock-price-fluctuation/README.md b/problems/stock-price-fluctuation/README.md index 85f72ad28..993eb2005 100644 --- a/problems/stock-price-fluctuation/README.md +++ b/problems/stock-price-fluctuation/README.md @@ -69,6 +69,7 @@ stockPrice.minimum(); // return 2, the minimum price is 2 at timestamp 4. ### Related Topics [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/stone-game-ii/README.md b/problems/stone-game-ii/README.md index 61c60a903..7a40acc4c 100644 --- a/problems/stone-game-ii/README.md +++ b/problems/stone-game-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-1-bordered-square "Largest 1-Bordered Square") diff --git a/problems/stone-game-iii/README.md b/problems/stone-game-iii/README.md index e0f6523b3..cb4cc8145 100644 --- a/problems/stone-game-iii/README.md +++ b/problems/stone-game-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-happy-string "Longest Happy String") @@ -11,17 +11,17 @@ ## [1406. Stone Game III (Hard)](https://leetcode.com/problems/stone-game-iii "石子游戏 III") -

    Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.

    +

    Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.

    -

    Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2 or 3 stones from the first remaining stones in the row.

    +

    Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2, or 3 stones from the first remaining stones in the row.

    -

    The score of each player is the sum of values of the stones taken. The score of each player is 0 initially.

    +

    The score of each player is the sum of the values of the stones taken. The score of each player is 0 initially.

    The objective of the game is to end with the highest score, and the winner is the player with the highest score and there could be a tie. The game continues until all the stones have been taken.

    -

    Assume Alice and Bob play optimally.

    +

    Assume Alice and Bob play optimally.

    -

    Return "Alice" if Alice will win, "Bob" if Bob will win or "Tie" if they end the game with the same score.

    +

    Return "Alice" if Alice will win, "Bob" if Bob will win, or "Tie" if they will end the game with the same score.

     

    Example 1:

    @@ -38,8 +38,8 @@ Input: values = [1,2,3,-9] Output: "Alice" Explanation: Alice must choose all the three piles at the first move to win and leave Bob with negative score. -If Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. The next move Alice will take the pile with value = -9 and lose. -If Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. The next move Alice will take the pile with value = -9 and also lose. +If Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. In the next move, Alice will take the pile with value = -9 and lose. +If Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. In the next move, Alice will take the pile with value = -9 and also lose. Remember that both play optimally so here Alice will choose the scenario that makes her win. @@ -51,26 +51,12 @@ Remember that both play optimally so here Alice will choose the scenario that ma Explanation: Alice cannot win this game. She can end the game in a draw if she decided to choose all the first three piles, otherwise she will lose. -

    Example 4:

    - -
    -Input: values = [1,2,3,-1,-2,-3,7]
    -Output: "Alice"
    -
    - -

    Example 5:

    - -
    -Input: values = [-1,-2,-3]
    -Output: "Tie"
    -
    -

     

    Constraints:

      -
    • 1 <= values.length <= 50000
    • -
    • -1000 <= values[i] <= 1000
    • +
    • 1 <= stoneValue.length <= 5 * 104
    • +
    • -1000 <= stoneValue[i] <= 1000
    ### Related Topics diff --git a/problems/stone-game-iv/README.md b/problems/stone-game-iv/README.md index e54c3fc94..e353d2524 100644 --- a/problems/stone-game-iv/README.md +++ b/problems/stone-game-iv/README.md @@ -13,11 +13,11 @@

    Alice and Bob take turns playing a game, with Alice starting first.

    -

    Initially, there are n stones in a pile.  On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.

    +

    Initially, there are n stones in a pile. On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.

    Also, if a player cannot make a move, he/she loses the game.

    -

    Given a positive integer n. Return True if and only if Alice wins the game otherwise return False, assuming both players play optimally.

    +

    Given a positive integer n, return true if and only if Alice wins the game otherwise return false, assuming both players play optimally.

     

    Example 1:

    @@ -32,7 +32,8 @@
     Input: n = 2
     Output: false
    -Explanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0).
    +Explanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0). +

    Example 3:

    @@ -42,28 +43,11 @@ Explanation: n is already a perfect square, Alice can win with one move, removing 4 stones (4 -> 0). -

    Example 4:

    - -
    -Input: n = 7
    -Output: false
    -Explanation: Alice can't win the game if Bob plays optimally.
    -If Alice starts removing 4 stones, Bob will remove 1 stone then Alice should remove only 1 stone and finally Bob removes the last one (7 -> 3 -> 2 -> 1 -> 0). 
    -If Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can remove 1 stone and finally Bob removes the last one (7 -> 6 -> 2 -> 1 -> 0).
    - -

    Example 5:

    - -
    -Input: n = 17
    -Output: false
    -Explanation: Alice can't win the game if Bob plays optimally.
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^5
    • +
    • 1 <= n <= 105
    ### Related Topics @@ -71,6 +55,13 @@ If Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can r [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] +### Similar Questions + 1. [Stone Game V](../stone-game-v) (Hard) + 1. [Stone Game VI](../stone-game-vi) (Medium) + 1. [Stone Game VII](../stone-game-vii) (Medium) + 1. [Stone Game VIII](../stone-game-viii) (Hard) + 1. [Stone Game IX](../stone-game-ix) (Medium) + ### Hints
    Hint 1 diff --git a/problems/stone-game-vii/README.md b/problems/stone-game-vii/README.md index c84453367..5d1b5878e 100644 --- a/problems/stone-game-vii/README.md +++ b/problems/stone-game-vii/README.md @@ -55,17 +55,6 @@ The score difference is 18 - 12 = 6. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] -### Similar Questions - 1. [Stone Game](../stone-game) (Medium) - 1. [Stone Game II](../stone-game-ii) (Medium) - 1. [Stone Game III](../stone-game-iii) (Hard) - 1. [Stone Game IV](../stone-game-iv) (Hard) - 1. [Stone Game V](../stone-game-v) (Hard) - 1. [Stone Game VI](../stone-game-vi) (Medium) - 1. [Maximum Score from Performing Multiplication Operations](../maximum-score-from-performing-multiplication-operations) (Medium) - 1. [Stone Game VIII](../stone-game-viii) (Hard) - 1. [Stone Game IX](../stone-game-ix) (Medium) - ### Hints
    Hint 1 diff --git a/problems/strange-printer-ii/README.md b/problems/strange-printer-ii/README.md index efef2f8b8..4f5b30e03 100644 --- a/problems/strange-printer-ii/README.md +++ b/problems/strange-printer-ii/README.md @@ -24,18 +24,14 @@

     

    Example 1:

    - -

    - +
     Input: targetGrid = [[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]]
     Output: true
     

    Example 2:

    - -

    - +
     Input: targetGrid = [[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]]
     Output: true
    @@ -46,13 +42,7 @@
     
     Input: targetGrid = [[1,2,1],[2,1,2],[1,2,1]]
     Output: false
    -Explanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.
    - -

    Example 4:

    - -
    -Input: targetGrid = [[1,1,1],[3,1,3]]
    -Output: false
    +Explanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.
     

     

    diff --git a/problems/stream-of-characters/README.md b/problems/stream-of-characters/README.md index 1ed4f85dc..3f297045a 100644 --- a/problems/stream-of-characters/README.md +++ b/problems/stream-of-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-sum-of-two-non-overlapping-subarrays "Maximum Sum of Two Non-Overlapping Subarrays") @@ -60,10 +60,10 @@ streamChecker.query("l"); // return True, because 'kl' is in t ### Related Topics - [[Design](../../tag/design/README.md)] - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] [[Data Stream](../../tag/data-stream/README.md)] ### Hints diff --git a/problems/string-matching-in-an-array/README.md b/problems/string-matching-in-an-array/README.md index 39e81221c..0465ce113 100644 --- a/problems/string-matching-in-an-array/README.md +++ b/problems/string-matching-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../top-travellers "Top Travellers") diff --git a/problems/string-to-integer-atoi/README.md b/problems/string-to-integer-atoi/README.md index f3583d52e..fc45cb209 100644 --- a/problems/string-to-integer-atoi/README.md +++ b/problems/string-to-integer-atoi/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-integer "Reverse Integer") @@ -80,38 +80,6 @@ The parsed integer is 4193. Since 4193 is in the range [-231, 231 - 1], the final result is 4193.
    -

    Example 4:

    - -
    -Input: s = "words and 987"
    -Output: 0
    -Explanation:
    -Step 1: "words and 987" (no characters read because there is no leading whitespace)
    -         ^
    -Step 2: "words and 987" (no characters read because there is neither a '-' nor '+')
    -         ^
    -Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w')
    -         ^
    -The parsed integer is 0 because no digits were read.
    -Since 0 is in the range [-231, 231 - 1], the final result is 0.
    -
    - -

    Example 5:

    - -
    -Input: s = "-91283472332"
    -Output: -2147483648
    -Explanation:
    -Step 1: "-91283472332" (no characters read because there is no leading whitespace)
    -         ^
    -Step 2: "-91283472332" ('-' is read, so the result should be negative)
    -          ^
    -Step 3: "-91283472332" ("91283472332" is read in)
    -                     ^
    -The parsed integer is -91283472332.
    -Since -91283472332 is less than the lower bound of the range [-231, 231 - 1], the final result is clamped to -231 = -2147483648. 
    -
    -

     

    Constraints:

    @@ -124,5 +92,6 @@ Since -91283472332 is less than the lower bound of the range [-231, 2 [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Reverse Integer](../reverse-integer) (Easy) + 1. [Reverse Integer](../reverse-integer) (Medium) 1. [Valid Number](../valid-number) (Hard) + 1. [Check if Numbers Are Ascending in a Sentence](../check-if-numbers-are-ascending-in-a-sentence) (Easy) diff --git a/problems/strings-differ-by-one-character/README.md b/problems/strings-differ-by-one-character/README.md index 16a62cb47..497638a14 100644 --- a/problems/strings-differ-by-one-character/README.md +++ b/problems/strings-differ-by-one-character/README.md @@ -16,8 +16,8 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/strobogrammatic-number-iii/README.md b/problems/strobogrammatic-number-iii/README.md index 4648f1223..6ba33e54b 100644 --- a/problems/strobogrammatic-number-iii/README.md +++ b/problems/strobogrammatic-number-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strobogrammatic-number-ii "Strobogrammatic Number II") diff --git a/problems/strobogrammatic-number/README.md b/problems/strobogrammatic-number/README.md index 805989ec0..781c90165 100644 --- a/problems/strobogrammatic-number/README.md +++ b/problems/strobogrammatic-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-word-distance-iii "Shortest Word Distance III") diff --git a/problems/strong-friendship/README.md b/problems/strong-friendship/README.md index d02716190..793c73063 100644 --- a/problems/strong-friendship/README.md +++ b/problems/strong-friendship/README.md @@ -9,7 +9,7 @@                  [Next >](../maximum-of-minimum-values-in-all-subarrays "Maximum of Minimum Values in All Subarrays") -## [1949. Strong Friendship (Medium)](https://leetcode.com/problems/strong-friendship "") +## [1949. Strong Friendship (Medium)](https://leetcode.com/problems/strong-friendship "坚定的友谊") diff --git a/problems/student-attendance-record-ii/README.md b/problems/student-attendance-record-ii/README.md index 2db7f1dce..6931ce270 100644 --- a/problems/student-attendance-record-ii/README.md +++ b/problems/student-attendance-record-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../student-attendance-record-i "Student Attendance Record I") diff --git a/problems/subrectangle-queries/README.md b/problems/subrectangle-queries/README.md index fd1f45944..2f116e489 100644 --- a/problems/subrectangle-queries/README.md +++ b/problems/subrectangle-queries/README.md @@ -94,8 +94,8 @@ subrectangleQueries.getValue(2, 2); // return 20 ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Design](../../tag/design/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/subsequence-of-size-k-with-the-largest-even-sum/README.md b/problems/subsequence-of-size-k-with-the-largest-even-sum/README.md new file mode 100644 index 000000000..b37446fc3 --- /dev/null +++ b/problems/subsequence-of-size-k-with-the-largest-even-sum/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../valid-arrangement-of-pairs "Valid Arrangement of Pairs") +                 +[Next >](../find-subsequence-of-length-k-with-the-largest-sum "Find Subsequence of Length K With the Largest Sum") + +## [2098. Subsequence of Size K With the Largest Even Sum (Medium)](https://leetcode.com/problems/subsequence-of-size-k-with-the-largest-even-sum "") + + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Is the sum of two even numbers even or odd? How about two odd numbers? One odd number and one even number? +
    + +
    +Hint 2 +If there is an even number of odd numbers, the sum will be even and vice versa. +
    + +
    +Hint 3 +Create an integer array to store all the even numbers in nums and another array to store all the odd numbers in nums. Sort both arrays. +
    diff --git a/problems/substrings-of-size-three-with-distinct-characters/README.md b/problems/substrings-of-size-three-with-distinct-characters/README.md index ee678eb6c..eedd2515f 100644 --- a/problems/substrings-of-size-three-with-distinct-characters/README.md +++ b/problems/substrings-of-size-three-with-distinct-characters/README.md @@ -49,8 +49,8 @@ The good substrings are "abc", "bca", "cab", and & ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] [[Counting](../../tag/counting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/substrings-that-begin-and-end-with-the-same-letter/README.md b/problems/substrings-that-begin-and-end-with-the-same-letter/README.md index d3d18e50a..0bd2bd07a 100644 --- a/problems/substrings-that-begin-and-end-with-the-same-letter/README.md +++ b/problems/substrings-that-begin-and-end-with-the-same-letter/README.md @@ -9,10 +9,17 @@                  [Next >](../drop-type-1-orders-for-customers-with-type-0-orders "Drop Type 1 Orders for Customers With Type 0 Orders") -## [2083. Substrings That Begin and End With the Same Letter (Medium)](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter "") +## [2083. Substrings That Begin and End With the Same Letter (Medium)](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter "求以相同字母开头和结尾的子串总数") +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + ### Hints
    Hint 1 diff --git a/problems/subtree-removal-game-with-fibonacci-tree/README.md b/problems/subtree-removal-game-with-fibonacci-tree/README.md index 07cd9d6f4..094bb4c14 100644 --- a/problems/subtree-removal-game-with-fibonacci-tree/README.md +++ b/problems/subtree-removal-game-with-fibonacci-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../count-number-of-pairs-with-absolute-difference-k "Count Number of Pairs With Absolute Difference K") -## [2005. Subtree Removal Game with Fibonacci Tree (Hard)](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree "") +## [2005. Subtree Removal Game with Fibonacci Tree (Hard)](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree "斐波那契树的移除子树游戏") diff --git a/problems/sudoku-solver/README.md b/problems/sudoku-solver/README.md index beb8613ad..df556e33c 100644 --- a/problems/sudoku-solver/README.md +++ b/problems/sudoku-solver/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-sudoku "Valid Sudoku") diff --git a/problems/sum-of-square-numbers/README.md b/problems/sum-of-square-numbers/README.md index 1a6589b9a..bdd0de9dd 100644 --- a/problems/sum-of-square-numbers/README.md +++ b/problems/sum-of-square-numbers/README.md @@ -29,27 +29,6 @@ Output: false -

    Example 3:

    - -
    -Input: c = 4
    -Output: true
    -
    - -

    Example 4:

    - -
    -Input: c = 2
    -Output: true
    -
    - -

    Example 5:

    - -
    -Input: c = 1
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/sum-of-subarray-minimums/README.md b/problems/sum-of-subarray-minimums/README.md index bb47a9d74..ee1e208f7 100644 --- a/problems/sum-of-subarray-minimums/README.md +++ b/problems/sum-of-subarray-minimums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../super-palindromes "Super Palindromes") diff --git a/problems/sum-of-subarray-ranges/README.md b/problems/sum-of-subarray-ranges/README.md new file mode 100644 index 000000000..78e5d4cbd --- /dev/null +++ b/problems/sum-of-subarray-ranges/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../rings-and-rods "Rings and Rods") +                 +[Next >](../watering-plants-ii "Watering Plants II") + +## [2104. Sum of Subarray Ranges (Medium)](https://leetcode.com/problems/sum-of-subarray-ranges "子数组范围和") + +

    You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.

    + +

    Return the sum of all subarray ranges of nums.

    + +

    A subarray is a contiguous non-empty sequence of elements within an array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3]
    +Output: 4
    +Explanation: The 6 subarrays of nums are the following:
    +[1], range = largest - smallest = 1 - 1 = 0 
    +[2], range = 2 - 2 = 0
    +[3], range = 3 - 3 = 0
    +[1,2], range = 2 - 1 = 1
    +[2,3], range = 3 - 2 = 1
    +[1,2,3], range = 3 - 1 = 2
    +So the sum of all ranges is 0 + 0 + 0 + 1 + 1 + 2 = 4.
    + +

    Example 2:

    + +
    +Input: nums = [1,3,3]
    +Output: 4
    +Explanation: The 6 subarrays of nums are the following:
    +[1], range = largest - smallest = 1 - 1 = 0
    +[3], range = 3 - 3 = 0
    +[3], range = 3 - 3 = 0
    +[1,3], range = 3 - 1 = 2
    +[3,3], range = 3 - 3 = 0
    +[1,3,3], range = 3 - 1 = 2
    +So the sum of all ranges is 0 + 0 + 0 + 2 + 0 + 2 = 4.
    +
    + +

    Example 3:

    + +
    +Input: nums = [4,-2,-3,4,1]
    +Output: 59
    +Explanation: The sum of all subarray ranges of nums is 59.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • -109 <= nums[i] <= 109
    • +
    + +

     

    +

    Follow-up: Could you find a solution with O(n) time complexity?

    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + +### Hints +
    +Hint 1 +Can you get the max/min of a certain subarray by using the max/min of a smaller subarray within it? +
    + +
    +Hint 2 +Notice that the max of the subarray from index i to j is equal to max of (max of the subarray from index i to j-1) and nums[j]. +
    diff --git a/problems/sum-of-subsequence-widths/README.md b/problems/sum-of-subsequence-widths/README.md index ed7f78ad6..237896b1c 100644 --- a/problems/sum-of-subsequence-widths/README.md +++ b/problems/sum-of-subsequence-widths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-and-replace-pattern "Find and Replace Pattern") diff --git a/problems/surface-area-of-3d-shapes/README.md b/problems/surface-area-of-3d-shapes/README.md index cc90f7bea..26186f55f 100644 --- a/problems/surface-area-of-3d-shapes/README.md +++ b/problems/surface-area-of-3d-shapes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-subsequence-widths "Sum of Subsequence Widths") @@ -21,34 +21,20 @@

     

    Example 1:

    - -
    -Input: grid = [[2]]
    -Output: 10
    -
    - -

    Example 2:

     Input: grid = [[1,2],[3,4]]
     Output: 34
     
    -

    Example 3:

    - -
    -Input: grid = [[1,0],[0,2]]
    -Output: 16
    -
    - -

    Example 4:

    +

    Example 2:

     Input: grid = [[1,1,1],[1,0,1],[1,1,1]]
     Output: 32
     
    -

    Example 5:

    +

    Example 3:

     Input: grid = [[2,2,2],[2,1,2],[2,2,2]]
    @@ -59,8 +45,7 @@
     

    Constraints:

      -
    • n == grid.length
    • -
    • n == grid[i].length
    • +
    • n == grid.length == grid[i].length
    • 1 <= n <= 50
    • 0 <= grid[i][j] <= 50
    diff --git a/problems/surrounded-regions/README.md b/problems/surrounded-regions/README.md index b0fdb237d..ed9eb8e89 100644 --- a/problems/surrounded-regions/README.md +++ b/problems/surrounded-regions/README.md @@ -42,10 +42,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions diff --git a/problems/suspicious-bank-accounts/README.md b/problems/suspicious-bank-accounts/README.md index 5d8cdf1ff..10a9cba44 100644 --- a/problems/suspicious-bank-accounts/README.md +++ b/problems/suspicious-bank-accounts/README.md @@ -9,7 +9,7 @@                  [Next >](../replace-all-digits-with-characters "Replace All Digits with Characters") -## [1843. Suspicious Bank Accounts (Medium)](https://leetcode.com/problems/suspicious-bank-accounts "") +## [1843. Suspicious Bank Accounts (Medium)](https://leetcode.com/problems/suspicious-bank-accounts "可疑银行账户") diff --git a/problems/swap-adjacent-in-lr-string/README.md b/problems/swap-adjacent-in-lr-string/README.md index ae714477d..ccc6e21f8 100644 --- a/problems/swap-adjacent-in-lr-string/README.md +++ b/problems/swap-adjacent-in-lr-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-bst "Split BST") @@ -34,27 +34,6 @@ XRLXXRRLX Output: false
    -

    Example 3:

    - -
    -Input: start = "LLR", end = "RRL"
    -Output: false
    -
    - -

    Example 4:

    - -
    -Input: start = "XL", end = "LX"
    -Output: true
    -
    - -

    Example 5:

    - -
    -Input: start = "XLLR", end = "LXLX"
    -Output: false
    -
    -

     

    Constraints:

    diff --git a/problems/swap-for-longest-repeated-character-substring/README.md b/problems/swap-for-longest-repeated-character-substring/README.md index 117c95cdd..d4f009b32 100644 --- a/problems/swap-for-longest-repeated-character-substring/README.md +++ b/problems/swap-for-longest-repeated-character-substring/README.md @@ -21,7 +21,7 @@
     Input: text = "ababa"
     Output: 3
    -Explanation: We can swap the first 'b' with the last 'a', or the last 'b' with the first 'a'. Then, the longest repeated character substring is "aaa", which its length is 3.
    +Explanation: We can swap the first 'b' with the last 'a', or the last 'b' with the first 'a'. Then, the longest repeated character substring is "aaa" with length 3.
     

    Example 2:

    @@ -29,29 +29,15 @@
     Input: text = "aaabaaa"
     Output: 6
    -Explanation: Swap 'b' with the last 'a' (or the first 'a'), and we get longest repeated character substring "aaaaaa", which its length is 6.
    +Explanation: Swap 'b' with the last 'a' (or the first 'a'), and we get longest repeated character substring "aaaaaa" with length 6.
     

    Example 3:

    -
    -Input: text = "aaabbaaa"
    -Output: 4
    -
    - -

    Example 4:

    -
     Input: text = "aaaaa"
     Output: 5
    -Explanation: No need to swap, longest repeated character substring is "aaaaa", length is 5.
    -
    - -

    Example 5:

    - -
    -Input: text = "abcdef"
    -Output: 1
    +Explanation: No need to swap, longest repeated character substring is "aaaaa" with length is 5.
     

     

    diff --git a/problems/swapping-nodes-in-a-linked-list/README.md b/problems/swapping-nodes-in-a-linked-list/README.md index 6ec21a3ad..230f24024 100644 --- a/problems/swapping-nodes-in-a-linked-list/README.md +++ b/problems/swapping-nodes-in-a-linked-list/README.md @@ -17,7 +17,7 @@

     

    Example 1:

    - +
     Input: head = [1,2,3,4,5], k = 2
     Output: [1,4,3,2,5]
    @@ -30,27 +30,6 @@
     Output: [7,9,6,6,8,7,3,0,9,5]
     
    -

    Example 3:

    - -
    -Input: head = [1], k = 1
    -Output: [1]
    -
    - -

    Example 4:

    - -
    -Input: head = [1,2], k = 1
    -Output: [2,1]
    -
    - -

    Example 5:

    - -
    -Input: head = [1,2,3], k = 2
    -Output: [1,2,3]
    -
    -

     

    Constraints:

    @@ -64,6 +43,11 @@ [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] +### Similar Questions + 1. [Remove Nth Node From End of List](../remove-nth-node-from-end-of-list) (Medium) + 1. [Swap Nodes in Pairs](../swap-nodes-in-pairs) (Medium) + 1. [Reverse Nodes in k-Group](../reverse-nodes-in-k-group) (Hard) + ### Hints
    Hint 1 diff --git a/problems/symmetric-tree/README.md b/problems/symmetric-tree/README.md index b10b5a489..d5627165a 100644 --- a/problems/symmetric-tree/README.md +++ b/problems/symmetric-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../same-tree "Same Tree") diff --git a/problems/synonymous-sentences/README.md b/problems/synonymous-sentences/README.md index 3bac93e3b..011fc9ffe 100644 --- a/problems/synonymous-sentences/README.md +++ b/problems/synonymous-sentences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-common-region "Smallest Common Region") @@ -40,11 +40,11 @@ text = "I am happy today but was sad yesterday" ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Hints
    diff --git a/problems/the-airport-with-the-most-traffic/README.md b/problems/the-airport-with-the-most-traffic/README.md new file mode 100644 index 000000000..00c570b75 --- /dev/null +++ b/problems/the-airport-with-the-most-traffic/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../minimum-operations-to-make-the-array-k-increasing "Minimum Operations to Make the Array K-Increasing") +                 +[Next >](../elements-in-array-after-removing-and-replacing-elements "Elements in Array After Removing and Replacing Elements") + +## [2112. The Airport With the Most Traffic (Medium)](https://leetcode.com/problems/the-airport-with-the-most-traffic "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-airport-with-the-most-traffic/mysql_schemas.sql b/problems/the-airport-with-the-most-traffic/mysql_schemas.sql new file mode 100644 index 000000000..2c4c276f3 --- /dev/null +++ b/problems/the-airport-with-the-most-traffic/mysql_schemas.sql @@ -0,0 +1,5 @@ +Create table If Not Exists Flights (departure_airport int, arrival_airport int, flights_count int); +Truncate table Flights; +insert into Flights (departure_airport, arrival_airport, flights_count) values ('1', '2', '4'); +insert into Flights (departure_airport, arrival_airport, flights_count) values ('2', '1', '5'); +insert into Flights (departure_airport, arrival_airport, flights_count) values ('2', '4', '5'); diff --git a/problems/the-earliest-moment-when-everyone-become-friends/README.md b/problems/the-earliest-moment-when-everyone-become-friends/README.md index 5dd41821e..97e5581bb 100644 --- a/problems/the-earliest-moment-when-everyone-become-friends/README.md +++ b/problems/the-earliest-moment-when-everyone-become-friends/README.md @@ -52,8 +52,8 @@ The sixth event occurs at timestamp = 20190301 and after 0 and 3 become friends ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Similar Questions 1. [Number of Provinces](../number-of-provinces) (Medium) diff --git a/problems/the-k-strongest-values-in-an-array/README.md b/problems/the-k-strongest-values-in-an-array/README.md index 2249537cb..d063932a0 100644 --- a/problems/the-k-strongest-values-in-an-array/README.md +++ b/problems/the-k-strongest-values-in-an-array/README.md @@ -11,18 +11,18 @@ ## [1471. The k Strongest Values in an Array (Medium)](https://leetcode.com/problems/the-k-strongest-values-in-an-array "数组中的 k 个最强值") -

    Given an array of integers arr and an integer k.

    +

    Given an array of integers arr and an integer k.

    -

    A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array.
    +

    A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array.
    If |arr[i] - m| == |arr[j] - m|, then arr[i] is said to be stronger than arr[j] if arr[i] > arr[j].

    Return a list of the strongest k values in the array. return the answer in any arbitrary order.

    -

    Median is the middle value in an ordered integer list. More formally, if the length of the list is n, the median is the element in position ((n - 1) / 2) in the sorted list (0-indexed).

    +

    Median is the middle value in an ordered integer list. More formally, if the length of the list is n, the median is the element in position ((n - 1) / 2) in the sorted list (0-indexed).

      -
    • For arr = [6, -3, 7, 2, 11]n = 5 and the median is obtained by sorting the array arr = [-3, 2, 6, 7, 11] and the median is arr[m] where m = ((5 - 1) / 2) = 2. The median is 6.
    • -
    • For arr = [-7, 22, 17, 3]n = 4 and the median is obtained by sorting the array arr = [-7, 3, 17, 22] and the median is arr[m] where m = ((4 - 1) / 2) = 1. The median is 3.
    • +
    • For arr = [6, -3, 7, 2, 11], n = 5 and the median is obtained by sorting the array arr = [-3, 2, 6, 7, 11] and the median is arr[m] where m = ((5 - 1) / 2) = 2. The median is 6.
    • +
    • For arr = [-7, 22, 17, 3], n = 4 and the median is obtained by sorting the array arr = [-7, 3, 17, 22] and the median is arr[m] where m = ((4 - 1) / 2) = 1. The median is 3.

     

    @@ -52,26 +52,12 @@ Please note that although |5 - 3| == |1 - 3| but 5 is stronger than 1 because 5 Any permutation of [11,8,6,6,7] is accepted. -

    Example 4:

    - -
    -Input: arr = [6,-3,7,2,11], k = 3
    -Output: [-3,11,2]
    -
    - -

    Example 5:

    - -
    -Input: arr = [-7,22,17,3], k = 2
    -Output: [22,17]
    -
    -

     

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • -
    • -10^5 <= arr[i] <= 10^5
    • +
    • 1 <= arr.length <= 105
    • +
    • -105 <= arr[i] <= 105
    • 1 <= k <= arr.length
    diff --git a/problems/the-kth-factor-of-n/README.md b/problems/the-kth-factor-of-n/README.md index 50dfaa95a..ce9c4a33b 100644 --- a/problems/the-kth-factor-of-n/README.md +++ b/problems/the-kth-factor-of-n/README.md @@ -11,11 +11,9 @@ ## [1492. The kth Factor of n (Medium)](https://leetcode.com/problems/the-kth-factor-of-n "n 的第 k 个因子") -

    Given two positive integers n and k.

    +

    You are given two positive integers n and k. A factor of an integer n is defined as an integer i where n % i == 0.

    -

    A factor of an integer n is defined as an integer i where n % i == 0.

    - -

    Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.

    +

    Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.

     

    Example 1:

    @@ -23,7 +21,7 @@
     Input: n = 12, k = 3
     Output: 3
    -Explanation: Factors list is [1, 2, 3, 4, 6, 12], the 3rd factor is 3.
    +Explanation: Factors list is [1, 2, 3, 4, 6, 12], the 3rd factor is 3.
     

    Example 2:

    @@ -31,7 +29,7 @@
     Input: n = 7, k = 2
     Output: 7
    -Explanation: Factors list is [1, 7], the 2nd factor is 7.
    +Explanation: Factors list is [1, 7], the 2nd factor is 7.
     

    Example 3:

    @@ -42,22 +40,6 @@ Explanation: Factors list is [1, 2, 4], there is only 3 factors. We should return -1. -

    Example 4:

    - -
    -Input: n = 1, k = 1
    -Output: 1
    -Explanation: Factors list is [1], the 1st factor is 1.
    -
    - -

    Example 5:

    - -
    -Input: n = 1000, k = 3
    -Output: 4
    -Explanation: Factors list is [1, 2, 4, 5, 8, 10, 20, 25, 40, 50, 100, 125, 200, 250, 500, 1000].
    -
    -

     

    Constraints:

    diff --git a/problems/the-most-frequently-ordered-products-for-each-customer/README.md b/problems/the-most-frequently-ordered-products-for-each-customer/README.md index 876cd2c83..e820d61c9 100644 --- a/problems/the-most-frequently-ordered-products-for-each-customer/README.md +++ b/problems/the-most-frequently-ordered-products-for-each-customer/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [The Most Recent Orders for Each Product](../the-most-recent-orders-for-each-product) (Medium) diff --git a/problems/the-number-of-full-rounds-you-have-played/README.md b/problems/the-number-of-full-rounds-you-have-played/README.md index 72715c1e9..79d5b74f0 100644 --- a/problems/the-number-of-full-rounds-you-have-played/README.md +++ b/problems/the-number-of-full-rounds-you-have-played/README.md @@ -11,54 +11,53 @@ ## [1904. The Number of Full Rounds You Have Played (Medium)](https://leetcode.com/problems/the-number-of-full-rounds-you-have-played "你完成的完整对局数") -

    A new online video game has been released, and in this video game, there are 15-minute rounds scheduled every quarter-hour period. This means that at HH:00, HH:15, HH:30 and HH:45, a new round starts, where HH represents an integer number from 00 to 23. A 24-hour clock is used, so the earliest time in the day is 00:00 and the latest is 23:59.

    +

    You are participating in an online chess tournament. There is a chess round that starts every 15 minutes. The first round of the day starts at 00:00, and after every 15 minutes, a new round starts.

    -

    Given two strings startTime and finishTime in the format "HH:MM" representing the exact time you started and finished playing the game, respectively, calculate the number of full rounds that you played during your game session.

    +
      +
    • For example, the second round starts at 00:15, the fourth round starts at 00:45, and the seventh round starts at 01:30.
    • +
    + +

    You are given two strings loginTime and logoutTime where:

      -
    • For example, if startTime = "05:20" and finishTime = "05:59" this means you played only one full round from 05:30 to 05:45. You did not play the full round from 05:15 to 05:30 because you started after the round began, and you did not play the full round from 05:45 to 06:00 because you stopped before the round ended.
    • +
    • loginTime is the time you will login to the game, and
    • +
    • logoutTime is the time you will logout from the game.
    -

    If finishTime is earlier than startTime, this means you have played overnight (from startTime to the midnight and from midnight to finishTime).

    +

    If logoutTime is earlier than loginTime, this means you have played from loginTime to midnight and from midnight to logoutTime.

    + +

    Return the number of full chess rounds you have played in the tournament.

    -

    Return the number of full rounds that you have played if you had started playing at startTime and finished at finishTime.

    +

    Note: All the given times follow the 24-hour clock. That means the first round of the day starts at 00:00 and the last round of the day starts at 23:45.

     

    Example 1:

    -Input: startTime = "12:01", finishTime = "12:44"
    +Input: loginTime = "09:31", logoutTime = "10:14"
     Output: 1
    -Explanation: You played one full round from 12:15 to 12:30.
    -You did not play the full round from 12:00 to 12:15 because you started playing at 12:01 after it began.
    -You did not play the full round from 12:30 to 12:45 because you stopped playing at 12:44 before it ended.
    +Explanation: You played one full round from 09:45 to 10:00.
    +You did not play the full round from 09:30 to 09:45 because you logged in at 09:31 after it began.
    +You did not play the full round from 10:00 to 10:15 because you logged out at 10:14 before it ended.
     

    Example 2:

    -Input: startTime = "20:00", finishTime = "06:00"
    -Output: 40
    -Explanation: You played 16 full rounds from 20:00 to 00:00 and 24 full rounds from 00:00 to 06:00.
    -16 + 24 = 40.
    -
    - -

    Example 3:

    - -
    -Input: startTime = "00:00", finishTime = "23:59"
    -Output: 95
    -Explanation: You played 4 full rounds each hour except for the last hour where you played 3 full rounds.
    +Input: loginTime = "21:30", logoutTime = "03:00"
    +Output: 22
    +Explanation: You played 10 full rounds from 21:30 to 00:00 and 12 full rounds from 00:00 to 03:00.
    +10 + 12 = 22.
     

     

    Constraints:

      -
    • startTime and finishTime are in the format HH:MM.
    • -
    • 00 <= HH <= 23
    • -
    • 00 <= MM <= 59
    • -
    • startTime and finishTime are not equal.
    • +
    • loginTime and logoutTime are in the format hh:mm.
    • +
    • 00 <= hh <= 23
    • +
    • 00 <= mm <= 59
    • +
    • loginTime and logoutTime are not equal.
    ### Related Topics diff --git a/problems/the-number-of-passengers-in-each-bus-i/README.md b/problems/the-number-of-passengers-in-each-bus-i/README.md new file mode 100644 index 000000000..42c598909 --- /dev/null +++ b/problems/the-number-of-passengers-in-each-bus-i/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../maximum-running-time-of-n-computers "Maximum Running Time of N Computers") +                 +[Next >](../choose-numbers-from-two-arrays-in-range "Choose Numbers From Two Arrays in Range") + +## [2142. The Number of Passengers in Each Bus I (Medium)](https://leetcode.com/problems/the-number-of-passengers-in-each-bus-i "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-number-of-passengers-in-each-bus-i/mysql_schemas.sql b/problems/the-number-of-passengers-in-each-bus-i/mysql_schemas.sql new file mode 100644 index 000000000..0fc11eefe --- /dev/null +++ b/problems/the-number-of-passengers-in-each-bus-i/mysql_schemas.sql @@ -0,0 +1,11 @@ +Create table If Not Exists Buses (bus_id int, arrival_time int); +Create table If Not Exists Passengers (passenger_id int, arrival_time int); +Truncate table Buses; +insert into Buses (bus_id, arrival_time) values ('1', '2'); +insert into Buses (bus_id, arrival_time) values ('2', '4'); +insert into Buses (bus_id, arrival_time) values ('3', '7'); +Truncate table Passengers; +insert into Passengers (passenger_id, arrival_time) values ('11', '1'); +insert into Passengers (passenger_id, arrival_time) values ('12', '5'); +insert into Passengers (passenger_id, arrival_time) values ('13', '6'); +insert into Passengers (passenger_id, arrival_time) values ('14', '7'); diff --git a/problems/the-number-of-passengers-in-each-bus-ii/README.md b/problems/the-number-of-passengers-in-each-bus-ii/README.md new file mode 100644 index 000000000..55bbc3466 --- /dev/null +++ b/problems/the-number-of-passengers-in-each-bus-ii/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../minimum-number-of-lines-to-cover-points "Minimum Number of Lines to Cover Points") +                 +[Next >](../keep-multiplying-found-values-by-two "Keep Multiplying Found Values by Two") + +## [2153. The Number of Passengers in Each Bus II (Hard)](https://leetcode.com/problems/the-number-of-passengers-in-each-bus-ii "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-number-of-passengers-in-each-bus-ii/mysql_schemas.sql b/problems/the-number-of-passengers-in-each-bus-ii/mysql_schemas.sql new file mode 100644 index 000000000..58e4a205c --- /dev/null +++ b/problems/the-number-of-passengers-in-each-bus-ii/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists Buses (bus_id int, arrival_time int, capacity int); +Create table If Not Exists Passengers (passenger_id int, arrival_time int); +Truncate table Buses; +insert into Buses (bus_id, arrival_time, capacity) values ('1', '2', '1'); +insert into Buses (bus_id, arrival_time, capacity) values ('2', '4', '10'); +insert into Buses (bus_id, arrival_time, capacity) values ('3', '7', '2'); +Truncate table Passengers; +insert into Passengers (passenger_id, arrival_time) values ('11', '1'); +insert into Passengers (passenger_id, arrival_time) values ('12', '1'); +insert into Passengers (passenger_id, arrival_time) values ('13', '5'); +insert into Passengers (passenger_id, arrival_time) values ('14', '6'); +insert into Passengers (passenger_id, arrival_time) values ('15', '7'); diff --git a/problems/the-number-of-rich-customers/README.md b/problems/the-number-of-rich-customers/README.md index c9d106c47..9cde4d167 100644 --- a/problems/the-number-of-rich-customers/README.md +++ b/problems/the-number-of-rich-customers/README.md @@ -9,7 +9,7 @@                  [Next >](../substrings-that-begin-and-end-with-the-same-letter "Substrings That Begin and End With the Same Letter") -## [2082. The Number of Rich Customers (Easy)](https://leetcode.com/problems/the-number-of-rich-customers "") +## [2082. The Number of Rich Customers (Easy)](https://leetcode.com/problems/the-number-of-rich-customers "富有客户的数量") diff --git a/problems/the-score-of-students-solving-math-expression/README.md b/problems/the-score-of-students-solving-math-expression/README.md index d4f8632b1..d6b8d68bc 100644 --- a/problems/the-score-of-students-solving-math-expression/README.md +++ b/problems/the-score-of-students-solving-math-expression/README.md @@ -60,19 +60,6 @@ By the rules of grading, the students will still be rewarded 5 points (as they g The points for the students are: [0,0,5,0,0,5]. The sum of the points is 10. -

    Example 4:

    - -
    -Input: s = "1+2*3+4", answers = [13,21,11,15]
    -Output: 11
    -Explanation: The correct answer of the expression is 11.
    -Every other student was rewarded 2 points because they could have applied the operators as follows:
    -- ((1+2)*3)+4 = 13
    -- (1+2)*(3+4) = 21
    -- 1+(2*(3+4)) = 15
    -The points for the students are: [2,2,5,2]. The sum of the points is 11.
    -
    -

     

    Constraints:

    diff --git a/problems/the-winner-university/README.md b/problems/the-winner-university/README.md index aa1d5cf91..569867b73 100644 --- a/problems/the-winner-university/README.md +++ b/problems/the-winner-university/README.md @@ -9,7 +9,7 @@                  [Next >](../time-needed-to-buy-tickets "Time Needed to Buy Tickets") -## [2072. The Winner University (Easy)](https://leetcode.com/problems/the-winner-university "") +## [2072. The Winner University (Easy)](https://leetcode.com/problems/the-winner-university "赢得比赛的大学") diff --git a/problems/thousand-separator/README.md b/problems/thousand-separator/README.md index 66c20c984..87bf7dfd4 100644 --- a/problems/thousand-separator/README.md +++ b/problems/thousand-separator/README.md @@ -28,25 +28,11 @@ Output: "1.234" -

    Example 3:

    - -
    -Input: n = 123456789
    -Output: "123.456.789"
    -
    - -

    Example 4:

    - -
    -Input: n = 0
    -Output: "0"
    -
    -

     

    Constraints:

      -
    • 0 <= n < 231
    • +
    • 0 <= n <= 231 - 1
    ### Related Topics diff --git a/problems/three-divisors/README.md b/problems/three-divisors/README.md index 259c755b3..cc81d110e 100644 --- a/problems/three-divisors/README.md +++ b/problems/three-divisors/README.md @@ -42,6 +42,9 @@ ### Related Topics [[Math](../../tag/math/README.md)] +### Similar Questions + 1. [Find Greatest Common Divisor of Array](../find-greatest-common-divisor-of-array) (Easy) + ### Hints
    Hint 1 diff --git a/problems/throne-inheritance/README.md b/problems/throne-inheritance/README.md index 1c639babc..e33c7ee62 100644 --- a/problems/throne-inheritance/README.md +++ b/problems/throne-inheritance/README.md @@ -81,10 +81,13 @@ t.getInheritanceOrder(); // return ["king", "andy", "ma ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Design](../../tag/design/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + +### Similar Questions + 1. [Operations on Tree](../operations-on-tree) (Medium) ### Hints
    diff --git a/problems/time-based-key-value-store/README.md b/problems/time-based-key-value-store/README.md index 3905deed8..559c1350b 100644 --- a/problems/time-based-key-value-store/README.md +++ b/problems/time-based-key-value-store/README.md @@ -53,10 +53,7 @@ timeMap.get("foo", 5); // return "bar2" ### Related Topics + [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Design](../../tag/design/README.md)] - -### Similar Questions - 1. [Stock Price Fluctuation ](../stock-price-fluctuation) (Medium) diff --git a/problems/time-needed-to-inform-all-employees/README.md b/problems/time-needed-to-inform-all-employees/README.md index 562cedbe1..af158e624 100644 --- a/problems/time-needed-to-inform-all-employees/README.md +++ b/problems/time-needed-to-inform-all-employees/README.md @@ -1,11 +1,11 @@ - - - + + + -[< Previous](../bulb-switcher-iii "Bulb Switcher III") +[< Previous](../number-of-times-binary-string-is-prefix-aligned "Number of Times Binary String Is Prefix-Aligned")                  [Next >](../frog-position-after-t-seconds "Frog Position After T Seconds") @@ -39,37 +39,6 @@ The tree structure of the employees in the company is shown. -

    Example 3:

    - -
    -Input: n = 7, headID = 6, manager = [1,2,3,4,5,6,-1], informTime = [0,6,5,4,3,2,1]
    -Output: 21
    -Explanation: The head has id = 6. He will inform employee with id = 5 in 1 minute.
    -The employee with id = 5 will inform the employee with id = 4 in 2 minutes.
    -The employee with id = 4 will inform the employee with id = 3 in 3 minutes.
    -The employee with id = 3 will inform the employee with id = 2 in 4 minutes.
    -The employee with id = 2 will inform the employee with id = 1 in 5 minutes.
    -The employee with id = 1 will inform the employee with id = 0 in 6 minutes.
    -Needed time = 1 + 2 + 3 + 4 + 5 + 6 = 21.
    -
    - -

    Example 4:

    - -
    -Input: n = 15, headID = 0, manager = [-1,0,0,1,1,2,2,3,3,4,4,5,5,6,6], informTime = [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0]
    -Output: 3
    -Explanation: The first minute the head will inform employees 1 and 2.
    -The second minute they will inform employees 3, 4, 5 and 6.
    -The third minute they will inform the rest of employees.
    -
    - -

    Example 5:

    - -
    -Input: n = 4, headID = 2, manager = [3,3,-1,2], informTime = [0,0,162,914]
    -Output: 1076
    -
    -

     

    Constraints:

    diff --git a/problems/total-sales-amount-by-year/README.md b/problems/total-sales-amount-by-year/README.md index 7a27cc853..f2a0dc254 100644 --- a/problems/total-sales-amount-by-year/README.md +++ b/problems/total-sales-amount-by-year/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-performance-of-a-team "Maximum Performance of a Team") diff --git a/problems/trapping-rain-water/README.md b/problems/trapping-rain-water/README.md index ea93f83c4..63809ff6f 100644 --- a/problems/trapping-rain-water/README.md +++ b/problems/trapping-rain-water/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../first-missing-positive "First Missing Positive") diff --git a/problems/tuple-with-same-product/README.md b/problems/tuple-with-same-product/README.md index 89f9e7bd6..bca35af2d 100644 --- a/problems/tuple-with-same-product/README.md +++ b/problems/tuple-with-same-product/README.md @@ -29,27 +29,13 @@
     Input: nums = [1,2,4,5,10]
     Output: 16
    -Explanation: There are 16 valids tuples:
    +Explanation: There are 16 valid tuples:
     (1,10,2,5) , (1,10,5,2) , (10,1,2,5) , (10,1,5,2)
     (2,5,1,10) , (2,5,10,1) , (5,2,1,10) , (5,2,10,1)
     (2,10,4,5) , (2,10,5,4) , (10,2,4,5) , (10,2,5,4)
     (4,5,2,10) , (4,5,10,2) , (5,4,2,10) , (5,4,10,2)
     
    -

    Example 3:

    - -
    -Input: nums = [2,3,4,6,8,12]
    -Output: 40
    -
    - -

    Example 4:

    - -
    -Input: nums = [2,3,5,7]
    -Output: 0
    -
    -

     

    Constraints:

    diff --git a/problems/two-sum/README.md b/problems/two-sum/README.md index 447a249c4..aa409a146 100644 --- a/problems/two-sum/README.md +++ b/problems/two-sum/README.md @@ -1,8 +1,8 @@ - - - + + + < Previous @@ -23,7 +23,7 @@
     Input: nums = [2,7,11,15], target = 9
     Output: [0,1]
    -Output: Because nums[0] + nums[1] == 9, we return [0, 1].
    +Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
     

    Example 2:

    @@ -60,7 +60,7 @@ ### Similar Questions 1. [3Sum](../3sum) (Medium) 1. [4Sum](../4sum) (Medium) - 1. [Two Sum II - Input array is sorted](../two-sum-ii-input-array-is-sorted) (Easy) + 1. [Two Sum II - Input Array Is Sorted](../two-sum-ii-input-array-is-sorted) (Medium) 1. [Two Sum III - Data structure design](../two-sum-iii-data-structure-design) (Easy) 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) 1. [Two Sum IV - Input is a BST](../two-sum-iv-input-is-a-bst) (Easy) diff --git a/problems/unique-substrings-with-equal-digit-frequency/README.md b/problems/unique-substrings-with-equal-digit-frequency/README.md new file mode 100644 index 000000000..18b80c84a --- /dev/null +++ b/problems/unique-substrings-with-equal-digit-frequency/README.md @@ -0,0 +1,47 @@ + + + + + + + +[< Previous](../minimum-time-to-remove-all-cars-containing-illegal-goods "Minimum Time to Remove All Cars Containing Illegal Goods") +                 +[Next >](../count-operations-to-obtain-zero "Count Operations to Obtain Zero") + +## [2168. Unique Substrings With Equal Digit Frequency (Medium)](https://leetcode.com/problems/unique-substrings-with-equal-digit-frequency "") + + + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] + +### Hints +
    +Hint 1 +With the constraints, could we try every substring? +
    + +
    +Hint 2 +Yes, checking every substring has runtime O(n^2), which will pass. +
    + +
    +Hint 3 +How can we make sure we only count unique substrings? +
    + +
    +Hint 4 +Use a set to store previously counted substrings. Hashing a string s of length m takes O(m) time. Is there a fast way to compute the hash of s if we know the hash of s[0..m - 2]? +
    + +
    +Hint 5 +Use a rolling hash. +
    diff --git a/problems/user-activity-for-the-past-30-days-i/README.md b/problems/user-activity-for-the-past-30-days-i/README.md index 8450ec32e..123c6b996 100644 --- a/problems/user-activity-for-the-past-30-days-i/README.md +++ b/problems/user-activity-for-the-past-30-days-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-ii "Stone Game II") diff --git a/problems/users-that-actively-request-confirmation-messages/README.md b/problems/users-that-actively-request-confirmation-messages/README.md index 1b94ef273..d8642a55d 100644 --- a/problems/users-that-actively-request-confirmation-messages/README.md +++ b/problems/users-that-actively-request-confirmation-messages/README.md @@ -9,7 +9,7 @@                  [Next >](../longest-common-subsequence-between-sorted-arrays "Longest Common Subsequence Between Sorted Arrays") -## [1939. Users That Actively Request Confirmation Messages (Easy)](https://leetcode.com/problems/users-that-actively-request-confirmation-messages "") +## [1939. Users That Actively Request Confirmation Messages (Easy)](https://leetcode.com/problems/users-that-actively-request-confirmation-messages "主动请求确认消息的用户") diff --git a/problems/utf-8-validation/README.md b/problems/utf-8-validation/README.md index cbbf134ce..fa8e947a3 100644 --- a/problems/utf-8-validation/README.md +++ b/problems/utf-8-validation/README.md @@ -64,8 +64,8 @@ But the second continuation byte does not start with 10, so it is invalid. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/valid-arrangement-of-pairs/README.md b/problems/valid-arrangement-of-pairs/README.md new file mode 100644 index 000000000..68c06e545 --- /dev/null +++ b/problems/valid-arrangement-of-pairs/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../step-by-step-directions-from-a-binary-tree-node-to-another "Step-By-Step Directions From a Binary Tree Node to Another") +                 +[Next >](../subsequence-of-size-k-with-the-largest-even-sum "Subsequence of Size K With the Largest Even Sum") + +## [2097. Valid Arrangement of Pairs (Hard)](https://leetcode.com/problems/valid-arrangement-of-pairs "合法重新排列数对") + +

    You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi]. An arrangement of pairs is valid if for every index i where 1 <= i < pairs.length, we have endi-1 == starti.

    + +

    Return any valid arrangement of pairs.

    + +

    Note: The inputs will be generated such that there exists a valid arrangement of pairs.

    + +

     

    +

    Example 1:

    + +
    +Input: pairs = [[5,1],[4,5],[11,9],[9,4]]
    +Output: [[11,9],[9,4],[4,5],[5,1]]
    +Explanation:
    +This is a valid arrangement since endi-1 always equals starti.
    +end0 = 9 == 9 = start1 
    +end1 = 4 == 4 = start2
    +end2 = 5 == 5 = start3
    +
    + +

    Example 2:

    + +
    +Input: pairs = [[1,3],[3,2],[2,1]]
    +Output: [[1,3],[3,2],[2,1]]
    +Explanation:
    +This is a valid arrangement since endi-1 always equals starti.
    +end0 = 3 == 3 = start1
    +end1 = 2 == 2 = start2
    +The arrangements [[2,1],[1,3],[3,2]] and [[3,2],[2,1],[1,3]] are also valid.
    +
    + +

    Example 3:

    + +
    +Input: pairs = [[1,2],[1,3],[2,1]]
    +Output: [[1,2],[2,1],[1,3]]
    +Explanation:
    +This is a valid arrangement since endi-1 always equals starti.
    +end0 = 2 == 2 = start1
    +end1 = 1 == 1 = start2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= pairs.length <= 105
    • +
    • pairs[i].length == 2
    • +
    • 0 <= starti, endi <= 109
    • +
    • starti != endi
    • +
    • No two pairs are exactly the same.
    • +
    • There exists a valid arrangement of pairs.
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Eulerian Circuit](../../tag/eulerian-circuit/README.md)] + +### Hints +
    +Hint 1 +Could you convert this into a graph problem? +
    + +
    +Hint 2 +Consider the pairs as edges and each number as a node. +
    + +
    +Hint 3 +We have to find an Eulerian path of this graph. Hierholzer’s algorithm can be used. +
    diff --git a/problems/valid-parenthesis-string/README.md b/problems/valid-parenthesis-string/README.md index b4ce17b44..3edabff41 100644 --- a/problems/valid-parenthesis-string/README.md +++ b/problems/valid-parenthesis-string/README.md @@ -49,3 +49,4 @@ ### Similar Questions 1. [Special Binary String](../special-binary-string) (Hard) + 1. [Check if a Parentheses String Can Be Valid](../check-if-a-parentheses-string-can-be-valid) (Medium) diff --git a/problems/valid-word-abbreviation/README.md b/problems/valid-word-abbreviation/README.md index 29cd566e3..63b929eb4 100644 --- a/problems/valid-word-abbreviation/README.md +++ b/problems/valid-word-abbreviation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../trapping-rain-water-ii "Trapping Rain Water II") @@ -49,3 +49,4 @@ Return false. ### Similar Questions 1. [Minimum Unique Word Abbreviation](../minimum-unique-word-abbreviation) (Hard) 1. [Word Abbreviation](../word-abbreviation) (Hard) + 1. [Check if an Original String Exists Given Two Encoded Strings](../check-if-an-original-string-exists-given-two-encoded-strings) (Hard) diff --git a/problems/verbal-arithmetic-puzzle/README.md b/problems/verbal-arithmetic-puzzle/README.md index 9982377e8..6068accde 100644 --- a/problems/verbal-arithmetic-puzzle/README.md +++ b/problems/verbal-arithmetic-puzzle/README.md @@ -11,18 +11,18 @@ ## [1307. Verbal Arithmetic Puzzle (Hard)](https://leetcode.com/problems/verbal-arithmetic-puzzle "口算难题") -

    Given an equation, represented by words on left side and the result on right side.

    +

    Given an equation, represented by words on the left side and the result on the right side.

    -

    You need to check if the equation is solvable under the following rules:

    +

    You need to check if the equation is solvable under the following rules:

    • Each character is decoded as one digit (0 - 9).
    • -
    • Every pair of different characters they must map to different digits.
    • -
    • Each words[i] and result are decoded as one number without leading zeros.
    • -
    • Sum of numbers on left side (words) will equal to the number on right side (result). 
    • +
    • Every pair of different characters must map to different digits.
    • +
    • Each words[i] and result are decoded as one number without leading zeros.
    • +
    • Sum of numbers on the left side (words) will equal to the number on the right side (result).
    -

    Return True if the equation is solvable otherwise return False.

    +

    Return true if the equation is solvable, otherwise return false.

     

    Example 1:

    @@ -43,13 +43,6 @@ Such that: "SIX" + "SEVEN" + "SEVEN" = "TWENT

    Example 3:

    -
    -Input: words = ["THIS","IS","TOO"], result = "FUNNY"
    -Output: true
    -
    - -

    Example 4:

    -
     Input: words = ["LEET","CODE"], result = "POINT"
     Output: false
    diff --git a/problems/video-stitching/README.md b/problems/video-stitching/README.md
    index c97194b4c..bc7031855 100644
    --- a/problems/video-stitching/README.md
    +++ b/problems/video-stitching/README.md
    @@ -1,8 +1,8 @@
     
     
    -
    -
    -
    +
    +
    +
     
     
     [< Previous](../camelcase-matching "Camelcase Matching")
    @@ -29,8 +29,7 @@
     
     Input: clips = [[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]], time = 10
     Output: 3
    -Explanation: 
    -We take the clips [0,2], [8,10], [1,9]; a total of 3 clips.
    +Explanation: We take the clips [0,2], [8,10], [1,9]; a total of 3 clips.
     Then, we can reconstruct the sporting event as follows:
     We cut [1,9] into segments [1,2] + [2,8] + [8,9].
     Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 10].
    @@ -41,7 +40,7 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1
     
     Input: clips = [[0,1],[1,2]], time = 5
     Output: -1
    -Explanation: We can't cover [0,5] with only [0,1] and [1,2].
    +Explanation: We cannot cover [0,5] with only [0,1] and [1,2].
     

    Example 3:

    @@ -52,14 +51,6 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1 Explanation: We can take clips [0,4], [4,7], and [6,9].
    -

    Example 4:

    - -
    -Input: clips = [[0,4],[2,8]], time = 5
    -Output: 2
    -Explanation: Notice you can have extra video after the event ends.
    -
    -

     

    Constraints:

    diff --git a/problems/vowels-of-all-substrings/README.md b/problems/vowels-of-all-substrings/README.md index 3d35932cd..a508e72c8 100644 --- a/problems/vowels-of-all-substrings/README.md +++ b/problems/vowels-of-all-substrings/README.md @@ -40,21 +40,15 @@ Hence, the total sum of vowels = 0 + 1 + 1 + 1 + 1 + 2 = 6. All possible substrings are: "a", "ab", "abc", "b", "bc", and "c". - "a", "ab", and "abc" have 1 vowel each - "b", "bc", and "c" have 0 vowels each -Hence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3.
    +Hence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3. +

    Example 3:

     Input: word = "ltcd"
     Output: 0
    -Explanation: There are no vowels in any substring of "ltcd".
    - -

    Example 4:

    - -
    -Input: word = "noosabasboosa"
    -Output: 237
    -Explanation: There are a total of 237 vowels in all the substrings.
    +Explanation: There are no vowels in any substring of "ltcd".
     

     

    diff --git a/problems/water-bottles/README.md b/problems/water-bottles/README.md index a12dce419..b299bdd88 100644 --- a/problems/water-bottles/README.md +++ b/problems/water-bottles/README.md @@ -11,55 +11,37 @@ ## [1518. Water Bottles (Easy)](https://leetcode.com/problems/water-bottles "换酒问题") -

    Given numBottles full water bottles, you can exchange numExchange empty water bottles for one full water bottle.

    +

    There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle.

    The operation of drinking a full water bottle turns it into an empty bottle.

    -

    Return the maximum number of water bottles you can drink.

    +

    Given the two integers numBottles and numExchange, return the maximum number of water bottles you can drink.

     

    Example 1:

    - -

    - +
     Input: numBottles = 9, numExchange = 3
     Output: 13
     Explanation: You can exchange 3 empty bottles to get 1 full water bottle.
    -Number of water bottles you can drink: 9 + 3 + 1 = 13.
    +Number of water bottles you can drink: 9 + 3 + 1 = 13.
     

    Example 2:

    - -

    - +
     Input: numBottles = 15, numExchange = 4
     Output: 19
     Explanation: You can exchange 4 empty bottles to get 1 full water bottle. 
    -Number of water bottles you can drink: 15 + 3 + 1 = 19.
    -
    - -

    Example 3:

    - -
    -Input: numBottles = 5, numExchange = 5
    -Output: 6
    -
    - -

    Example 4:

    - -
    -Input: numBottles = 2, numExchange = 3
    -Output: 2
    +Number of water bottles you can drink: 15 + 3 + 1 = 19.
     

     

    Constraints:

      -
    • 1 <= numBottles <= 100
    • -
    • 2 <= numExchange <= 100
    • +
    • 1 <= numBottles <= 100
    • +
    • 2 <= numExchange <= 100
    ### Related Topics diff --git a/problems/watering-plants-ii/README.md b/problems/watering-plants-ii/README.md new file mode 100644 index 000000000..1d68c1646 --- /dev/null +++ b/problems/watering-plants-ii/README.md @@ -0,0 +1,94 @@ + + + + + + + +[< Previous](../sum-of-subarray-ranges "Sum of Subarray Ranges") +                 +[Next >](../maximum-fruits-harvested-after-at-most-k-steps "Maximum Fruits Harvested After at Most K Steps") + +## [2105. Watering Plants II (Medium)](https://leetcode.com/problems/watering-plants-ii "给植物浇水 II") + +

    Alice and Bob want to water n plants in their garden. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i.

    + +

    Each plant needs a specific amount of water. Alice and Bob have a watering can each, initially full. They water the plants in the following way:

    + +
      +
    • Alice waters the plants in order from left to right, starting from the 0th plant. Bob waters the plants in order from right to left, starting from the (n - 1)th plant. They begin watering the plants simultaneously.
    • +
    • It takes the same amount of time to water each plant regardless of how much water it needs.
    • +
    • Alice/Bob must water the plant if they have enough in their can to fully water it. Otherwise, they first refill their can (instantaneously) then water the plant.
    • +
    • In case both Alice and Bob reach the same plant, the one with more water currently in his/her watering can should water this plant. If they have the same amount of water, then Alice should water this plant.
    • +
    + +

    Given a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and two integers capacityA and capacityB representing the capacities of Alice's and Bob's watering cans respectively, return the number of times they have to refill to water all the plants.

    + +

     

    +

    Example 1:

    + +
    +Input: plants = [2,2,3,3], capacityA = 5, capacityB = 5
    +Output: 1
    +Explanation:
    +- Initially, Alice and Bob have 5 units of water each in their watering cans.
    +- Alice waters plant 0, Bob waters plant 3.
    +- Alice and Bob now have 3 units and 2 units of water respectively.
    +- Alice has enough water for plant 1, so she waters it. Bob does not have enough water for plant 2, so he refills his can then waters it.
    +So, the total number of times they have to refill to water all the plants is 0 + 0 + 1 + 0 = 1.
    +
    + +

    Example 2:

    + +
    +Input: plants = [2,2,3,3], capacityA = 3, capacityB = 4
    +Output: 2
    +Explanation:
    +- Initially, Alice and Bob have 3 units and 4 units of water in their watering cans respectively.
    +- Alice waters plant 0, Bob waters plant 3.
    +- Alice and Bob now have 1 unit of water each, and need to water plants 1 and 2 respectively.
    +- Since neither of them have enough water for their current plants, they refill their cans and then water the plants.
    +So, the total number of times they have to refill to water all the plants is 0 + 1 + 1 + 0 = 2.
    +
    + +

    Example 3:

    + +
    +Input: plants = [5], capacityA = 10, capacityB = 8
    +Output: 0
    +Explanation:
    +- There is only one plant.
    +- Alice's watering can has 10 units of water, whereas Bob's can has 8 units. Since Alice has more water in her can, she waters this plant.
    +So, the total number of times they have to refill is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == plants.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= plants[i] <= 106
    • +
    • max(plants[i]) <= capacityA, capacityB <= 109
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Try "simulating" the process. +
    + +
    +Hint 2 +Since watering each plant takes the same amount of time, where will Alice and Bob meet if they start watering the plants simultaneously? How can you use this to optimize your solution? +
    + +
    +Hint 3 +What will you do when both Alice and Bob have to water the same plant? +
    diff --git a/problems/ways-to-split-array-into-three-subarrays/README.md b/problems/ways-to-split-array-into-three-subarrays/README.md index 543aad389..f9621b2da 100644 --- a/problems/ways-to-split-array-into-three-subarrays/README.md +++ b/problems/ways-to-split-array-into-three-subarrays/README.md @@ -60,6 +60,9 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Number of Ways to Divide a Long Corridor](../number-of-ways-to-divide-a-long-corridor) (Hard) + ### Hints
    Hint 1 diff --git a/problems/weather-type-in-each-country/README.md b/problems/weather-type-in-each-country/README.md index 981076584..a58e2ea24 100644 --- a/problems/weather-type-in-each-country/README.md +++ b/problems/weather-type-in-each-country/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-in-a-grid-with-obstacles-elimination "Shortest Path in a Grid with Obstacles Elimination") diff --git a/problems/where-will-the-ball-fall/README.md b/problems/where-will-the-ball-fall/README.md index 62d5babec..5d79d418e 100644 --- a/problems/where-will-the-ball-fall/README.md +++ b/problems/where-will-the-ball-fall/README.md @@ -66,9 +66,9 @@ Ball b4 is dropped at column 4 and will get stuck on the box between column 2 an ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/wiggle-subsequence/README.md b/problems/wiggle-subsequence/README.md index 1f0439667..238eb4b28 100644 --- a/problems/wiggle-subsequence/README.md +++ b/problems/wiggle-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../guess-number-higher-or-lower-ii "Guess Number Higher or Lower II") @@ -59,6 +59,9 @@ One is [1, 17, 10, 13, 10, 16, 8] with differences (16, -7, 3, -3, 6, -8).

    Follow up: Could you solve this in O(n) time?

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Rearrange Array Elements by Sign](../rearrange-array-elements-by-sign) (Medium) diff --git a/problems/word-abbreviation/README.md b/problems/word-abbreviation/README.md index 16762d141..7fd9f8a67 100644 --- a/problems/word-abbreviation/README.md +++ b/problems/word-abbreviation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../beautiful-arrangement "Beautiful Arrangement") diff --git a/problems/word-pattern-ii/README.md b/problems/word-pattern-ii/README.md index dbe80c671..b7e543f01 100644 --- a/problems/word-pattern-ii/README.md +++ b/problems/word-pattern-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-pattern "Word Pattern") diff --git a/problems/word-squares/README.md b/problems/word-squares/README.md index 05908d666..49634a077 100644 --- a/problems/word-squares/README.md +++ b/problems/word-squares/README.md @@ -82,10 +82,10 @@ The output consists of two word squares. The order of output does not matter (ju

    ### Related Topics - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Trie](../../tag/trie/README.md)] ### Similar Questions 1. [Valid Word Square](../valid-word-square) (Easy) diff --git a/problems/word-subsets/README.md b/problems/word-subsets/README.md index cca849a2d..67b953a6f 100644 --- a/problems/word-subsets/README.md +++ b/problems/word-subsets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-array-into-disjoint-intervals "Partition Array into Disjoint Intervals") @@ -25,21 +25,19 @@

     

    Example 1:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"]
    -Output: ["facebook","google","leetcode"]
    -

    Example 2:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"]
    -Output: ["apple","google","leetcode"]
    -

    Example 3:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","oo"]
    -Output: ["facebook","google"]
    -

    Example 4:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["lo","eo"]
    -Output: ["google","leetcode"]
    -

    Example 5:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["ec","oc","ceo"]
    -Output: ["facebook","leetcode"]
    +
    +
    +Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"]
    +Output: ["facebook","google","leetcode"]
     
    + +

    Example 2:

    + +
    +Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"]
    +Output: ["apple","google","leetcode"]
    +
    +

     

    Constraints:

    diff --git a/problems/xor-operation-in-an-array/README.md b/problems/xor-operation-in-an-array/README.md index fb190c246..89580d8aa 100644 --- a/problems/xor-operation-in-an-array/README.md +++ b/problems/xor-operation-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clone-binary-tree-with-random-pointer "Clone Binary Tree With Random Pointer") @@ -11,11 +11,11 @@ ## [1486. XOR Operation in an Array (Easy)](https://leetcode.com/problems/xor-operation-in-an-array "数组异或操作") -

    Given an integer n and an integer start.

    +

    You are given an integer n and an integer start.

    -

    Define an array nums where nums[i] = start + 2*i (0-indexed) and n == nums.length.

    +

    Define an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length.

    -

    Return the bitwise XOR of all elements of nums.

    +

    Return the bitwise XOR of all elements of nums.

     

    Example 1:

    @@ -23,7 +23,7 @@
     Input: n = 5, start = 0
     Output: 8
    -Explanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.
    +Explanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.
     Where "^" corresponds to bitwise XOR operator.
     
    @@ -32,20 +32,7 @@ Where "^" corresponds to bitwise XOR operator.
     Input: n = 4, start = 3
     Output: 8
    -Explanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.
    - -

    Example 3:

    - -
    -Input: n = 1, start = 7
    -Output: 7
    -
    - -

    Example 4:

    - -
    -Input: n = 10, start = 5
    -Output: 2
    +Explanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.
     

     

    @@ -58,8 +45,8 @@ Where "^" corresponds to bitwise XOR operator. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/xor-queries-of-a-subarray/README.md b/problems/xor-queries-of-a-subarray/README.md index 90df382e7..86c7462b0 100644 --- a/problems/xor-queries-of-a-subarray/README.md +++ b/problems/xor-queries-of-a-subarray/README.md @@ -54,8 +54,8 @@ The XOR values for queries are: ### Related Topics - [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/readme/1-300.md b/readme/1-300.md index a4db89dcb..4bb184fe2 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -130,7 +138,7 @@ LeetCode Problems' Solutions | 50 | [Pow(x, n)](https://leetcode.com/problems/powx-n "Pow(x, n)") | [Go](../problems/powx-n) | Medium | | 51 | [N-Queens](https://leetcode.com/problems/n-queens "N 皇后") | [Go](../problems/n-queens) | Hard | | 52 | [N-Queens II](https://leetcode.com/problems/n-queens-ii "N皇后 II") | [Go](../problems/n-queens-ii) | Hard | -| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray "最大子序和") | [Go](../problems/maximum-subarray) | Easy | +| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray "最大子数组和") | [Go](../problems/maximum-subarray) | Easy | | 54 | [Spiral Matrix](https://leetcode.com/problems/spiral-matrix "螺旋矩阵") | [Go](../problems/spiral-matrix) | Medium | | 55 | [Jump Game](https://leetcode.com/problems/jump-game "跳跃游戏") | [Go](../problems/jump-game) | Medium | | 56 | [Merge Intervals](https://leetcode.com/problems/merge-intervals "合并区间") | [Go](../problems/merge-intervals) | Medium | @@ -146,7 +154,7 @@ LeetCode Problems' Solutions | 66 | [Plus One](https://leetcode.com/problems/plus-one "加一") | [Go](../problems/plus-one) | Easy | | 67 | [Add Binary](https://leetcode.com/problems/add-binary "二进制求和") | [Go](../problems/add-binary) | Easy | | 68 | [Text Justification](https://leetcode.com/problems/text-justification "文本左右对齐") | [Go](../problems/text-justification) | Hard | -| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx "Sqrt(x)") | [Go](../problems/sqrtx) | Easy | +| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx "x 的平方根 ") | [Go](../problems/sqrtx) | Easy | | 70 | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs "爬楼梯") | [Go](../problems/climbing-stairs) | Easy | | 71 | [Simplify Path](https://leetcode.com/problems/simplify-path "简化路径") | [Go](../problems/simplify-path) | Medium | | 72 | [Edit Distance](https://leetcode.com/problems/edit-distance "编辑距离") | [Go](../problems/edit-distance) | Hard | @@ -223,7 +231,7 @@ LeetCode Problems' Solutions | 143 | [Reorder List](https://leetcode.com/problems/reorder-list "重排链表") | [Go](../problems/reorder-list) | Medium | | 144 | [Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") | [Go](../problems/binary-tree-preorder-traversal) | Easy | | 145 | [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") | [Go](../problems/binary-tree-postorder-traversal) | Easy | -| 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU 缓存机制") | [Go](../problems/lru-cache) | Medium | +| 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU 缓存") | [Go](../problems/lru-cache) | Medium | | 147 | [Insertion Sort List](https://leetcode.com/problems/insertion-sort-list "对链表进行插入排序") | [Go](../problems/insertion-sort-list) | Medium | | 148 | [Sort List](https://leetcode.com/problems/sort-list "排序链表") | [Go](../problems/sort-list) | Medium | | 149 | [Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line "直线上最多的点数") | [Go](../problems/max-points-on-a-line) | Hard | @@ -244,7 +252,7 @@ LeetCode Problems' Solutions | 164 | [Maximum Gap](https://leetcode.com/problems/maximum-gap "最大间距") | [Go](../problems/maximum-gap) | Hard | | 165 | [Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers "比较版本号") | [Go](../problems/compare-version-numbers) | Medium | | 166 | [Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal "分数到小数") | [Go](../problems/fraction-to-recurring-decimal) | Medium | -| 167 | [Two Sum II - Input Array Is Sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](../problems/two-sum-ii-input-array-is-sorted) | Easy | +| 167 | [Two Sum II - Input Array Is Sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](../problems/two-sum-ii-input-array-is-sorted) | Medium | | 168 | [Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title "Excel表列名称") | [Go](../problems/excel-sheet-column-title) | Easy | | 169 | [Majority Element](https://leetcode.com/problems/majority-element "多数元素") | [Go](../problems/majority-element) | Easy | | 170 | [Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") 🔒 | [Go](../problems/two-sum-iii-data-structure-design) | Easy | @@ -361,7 +369,7 @@ LeetCode Problems' Solutions | 281 | [Zigzag Iterator](https://leetcode.com/problems/zigzag-iterator "锯齿迭代器") 🔒 | [Go](../problems/zigzag-iterator) | Medium | | 282 | [Expression Add Operators](https://leetcode.com/problems/expression-add-operators "给表达式添加运算符") | [Go](../problems/expression-add-operators) | Hard | | 283 | [Move Zeroes](https://leetcode.com/problems/move-zeroes "移动零") | [Go](../problems/move-zeroes) | Easy | -| 284 | [Peeking Iterator](https://leetcode.com/problems/peeking-iterator "窥探迭代器") | [Go](../problems/peeking-iterator) | Medium | +| 284 | [Peeking Iterator](https://leetcode.com/problems/peeking-iterator "顶端迭代器") | [Go](../problems/peeking-iterator) | Medium | | 285 | [Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的中序后继") 🔒 | [Go](../problems/inorder-successor-in-bst) | Medium | | 286 | [Walls and Gates](https://leetcode.com/problems/walls-and-gates "墙与门") 🔒 | [Go](../problems/walls-and-gates) | Medium | | 287 | [Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number "寻找重复数") | [Go](../problems/find-the-duplicate-number) | Medium | diff --git a/readme/1201-1500.md b/readme/1201-1500.md index 8b5c5123a..cd9ca1be8 100644 --- a/readme/1201-1500.md +++ b/readme/1201-1500.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -252,7 +260,7 @@ LeetCode Problems' Solutions | 1372 | [Longest ZigZag Path in a Binary Tree](https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree "二叉树中的最长交错路径") | [Go](../problems/longest-zigzag-path-in-a-binary-tree) | Medium | | 1373 | [Maximum Sum BST in Binary Tree](https://leetcode.com/problems/maximum-sum-bst-in-binary-tree "二叉搜索子树的最大键值和") | [Go](../problems/maximum-sum-bst-in-binary-tree) | Hard | | 1374 | [Generate a String With Characters That Have Odd Counts](https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts "生成每种字符都是奇数个的字符串") | [Go](../problems/generate-a-string-with-characters-that-have-odd-counts) | Easy | -| 1375 | [Bulb Switcher III](https://leetcode.com/problems/bulb-switcher-iii "灯泡开关 III") | [Go](../problems/bulb-switcher-iii) | Medium | +| 1375 | [Number of Times Binary String Is Prefix-Aligned](https://leetcode.com/problems/number-of-times-binary-string-is-prefix-aligned "二进制字符串前缀一致的次数") | [Go](../problems/number-of-times-binary-string-is-prefix-aligned) | Medium | | 1376 | [Time Needed to Inform All Employees](https://leetcode.com/problems/time-needed-to-inform-all-employees "通知所有员工所需的时间") | [Go](../problems/time-needed-to-inform-all-employees) | Medium | | 1377 | [Frog Position After T Seconds](https://leetcode.com/problems/frog-position-after-t-seconds "T 秒后青蛙的位置") | [Go](../problems/frog-position-after-t-seconds) | Hard | | 1378 | [Replace Employee ID With The Unique Identifier](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier "使用唯一标识码替换员工ID") 🔒 | [MySQL](../problems/replace-employee-id-with-the-unique-identifier) | Easy | diff --git a/readme/1501-1800.md b/readme/1501-1800.md new file mode 100644 index 000000000..85463f503 --- /dev/null +++ b/readme/1501-1800.md @@ -0,0 +1,388 @@ + + + + + + + +# [LeetCode](https://awesee.github.io/leetcode) +LeetCode Problems' Solutions +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] + +[![Go](https://github.com/awesee/leetcode/workflows/Go/badge.svg)](https://github.com/awesee/leetcode/actions) +[![codecov](https://codecov.io/gh/awesee/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/awesee/leetcode) +[![Go Report Card](https://goreportcard.com/badge/github.com/awesee/leetcode)](https://goreportcard.com/report/github.com/awesee/leetcode) +[![GitHub contributors](https://img.shields.io/github/contributors/awesee/leetcode.svg)](https://github.com/awesee/leetcode/graphs/contributors) +[![license](https://img.shields.io/github/license/awesee/leetcode.svg)](https://github.com/awesee/leetcode/blob/master/LICENSE) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fawesee%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fawesee%2Fleetcode?ref=badge_shield) +[![Join the chat](https://badges.gitter.im/awesee/leetcode.svg)](https://gitter.im/awesee/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    + +| # | Title | Solution | Difficulty | +| :-: | - | - | :-: | +| 1501 | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") 🔒 | [MySQL](../problems/countries-you-can-safely-invest-in) | Medium | +| 1502 | [Can Make Arithmetic Progression From Sequence](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") | [Go](../problems/can-make-arithmetic-progression-from-sequence) | Easy | +| 1503 | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](../problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium | +| 1504 | [Count Submatrices With All Ones](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") | [Go](../problems/count-submatrices-with-all-ones) | Medium | +| 1505 | [Minimum Possible Integer After at Most K Adjacent Swaps On Digits](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") | [Go](../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | Hard | +| 1506 | [Find Root of N-Ary Tree](https://leetcode.com/problems/find-root-of-n-ary-tree "找到 N 叉树的根节点") 🔒 | [Go](../problems/find-root-of-n-ary-tree) | Medium | +| 1507 | [Reformat Date](https://leetcode.com/problems/reformat-date "转变日期格式") | [Go](../problems/reformat-date) | Easy | +| 1508 | [Range Sum of Sorted Subarray Sums](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums "子数组和排序后的区间和") | [Go](../problems/range-sum-of-sorted-subarray-sums) | Medium | +| 1509 | [Minimum Difference Between Largest and Smallest Value in Three Moves](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") | [Go](../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | Medium | +| 1510 | [Stone Game IV](https://leetcode.com/problems/stone-game-iv "石子游戏 IV") | [Go](../problems/stone-game-iv) | Hard | +| 1511 | [Customer Order Frequency](https://leetcode.com/problems/customer-order-frequency "消费者下单频率") 🔒 | [MySQL](../problems/customer-order-frequency) | Easy | +| 1512 | [Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs "好数对的数目") | [Go](../problems/number-of-good-pairs) | Easy | +| 1513 | [Number of Substrings With Only 1s](https://leetcode.com/problems/number-of-substrings-with-only-1s "仅含 1 的子串数") | [Go](../problems/number-of-substrings-with-only-1s) | Medium | +| 1514 | [Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability "概率最大的路径") | [Go](../problems/path-with-maximum-probability) | Medium | +| 1515 | [Best Position for a Service Centre](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") | [Go](../problems/best-position-for-a-service-centre) | Hard | +| 1516 | [Move Sub-Tree of N-Ary Tree](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree "移动 N 叉树的子树") 🔒 | [Go](../problems/move-sub-tree-of-n-ary-tree) | Hard | +| 1517 | [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails "查找拥有有效邮箱的用户") 🔒 | [MySQL](../problems/find-users-with-valid-e-mails) | Easy | +| 1518 | [Water Bottles](https://leetcode.com/problems/water-bottles "换酒问题") | [Go](../problems/water-bottles) | Easy | +| 1519 | [Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") | [Go](../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | Medium | +| 1520 | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](../problems/maximum-number-of-non-overlapping-substrings) | Hard | +| 1521 | [Find a Value of a Mysterious Function Closest to Target](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") | [Go](../problems/find-a-value-of-a-mysterious-function-closest-to-target) | Hard | +| 1522 | [Diameter of N-Ary Tree](https://leetcode.com/problems/diameter-of-n-ary-tree "N 叉树的直径") 🔒 | [Go](../problems/diameter-of-n-ary-tree) | Medium | +| 1523 | [Count Odd Numbers in an Interval Range](https://leetcode.com/problems/count-odd-numbers-in-an-interval-range "在区间范围内统计奇数数目") | [Go](../problems/count-odd-numbers-in-an-interval-range) | Easy | +| 1524 | [Number of Sub-arrays With Odd Sum](https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum "和为奇数的子数组数目") | [Go](../problems/number-of-sub-arrays-with-odd-sum) | Medium | +| 1525 | [Number of Good Ways to Split a String](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") | [Go](../problems/number-of-good-ways-to-split-a-string) | Medium | +| 1526 | [Minimum Number of Increments on Subarrays to Form a Target Array](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") | [Go](../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | Hard | +| 1527 | [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition "患某种疾病的患者") 🔒 | [MySQL](../problems/patients-with-a-condition) | Easy | +| 1528 | [Shuffle String](https://leetcode.com/problems/shuffle-string "重新排列字符串") | [Go](../problems/shuffle-string) | Easy | +| 1529 | [Minimum Suffix Flips](https://leetcode.com/problems/minimum-suffix-flips "最少的后缀翻转次数") | [Go](../problems/minimum-suffix-flips) | Medium | +| 1530 | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](../problems/number-of-good-leaf-nodes-pairs) | Medium | +| 1531 | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](../problems/string-compression-ii) | Hard | +| 1532 | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") 🔒 | [MySQL](../problems/the-most-recent-three-orders) | Medium | +| 1533 | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer "找到最大整数的索引") 🔒 | [Go](../problems/find-the-index-of-the-large-integer) | Medium | +| 1534 | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets "统计好三元组") | [Go](../problems/count-good-triplets) | Easy | +| 1535 | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](../problems/find-the-winner-of-an-array-game) | Medium | +| 1536 | [Minimum Swaps to Arrange a Binary Grid](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") | [Go](../problems/minimum-swaps-to-arrange-a-binary-grid) | Medium | +| 1537 | [Get the Maximum Score](https://leetcode.com/problems/get-the-maximum-score "最大得分") | [Go](../problems/get-the-maximum-score) | Hard | +| 1538 | [Guess the Majority in a Hidden Array](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array "找出隐藏数组中出现次数最多的元素") 🔒 | [Go](../problems/guess-the-majority-in-a-hidden-array) | Medium | +| 1539 | [Kth Missing Positive Number](https://leetcode.com/problems/kth-missing-positive-number "第 k 个缺失的正整数") | [Go](../problems/kth-missing-positive-number) | Easy | +| 1540 | [Can Convert String in K Moves](https://leetcode.com/problems/can-convert-string-in-k-moves "K 次操作转变字符串") | [Go](../problems/can-convert-string-in-k-moves) | Medium | +| 1541 | [Minimum Insertions to Balance a Parentheses String](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string "平衡括号字符串的最少插入次数") | [Go](../problems/minimum-insertions-to-balance-a-parentheses-string) | Medium | +| 1542 | [Find Longest Awesome Substring](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") | [Go](../problems/find-longest-awesome-substring) | Hard | +| 1543 | [Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format "产品名称格式修复") 🔒 | [MySQL](../problems/fix-product-name-format) | Easy | +| 1544 | [Make The String Great](https://leetcode.com/problems/make-the-string-great "整理字符串") | [Go](../problems/make-the-string-great) | Easy | +| 1545 | [Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") | [Go](../problems/find-kth-bit-in-nth-binary-string) | Medium | +| 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值且不重叠的非空子数组的最大数目") | [Go](../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | +| 1547 | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](../problems/minimum-cost-to-cut-a-stick) | Hard | +| 1548 | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph "图中最相似的路径") 🔒 | [Go](../problems/the-most-similar-path-in-a-graph) | Hard | +| 1549 | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product "每件商品的最新订单") 🔒 | [MySQL](../problems/the-most-recent-orders-for-each-product) | Medium | +| 1550 | [Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds "存在连续三个奇数的数组") | [Go](../problems/three-consecutive-odds) | Easy | +| 1551 | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](../problems/minimum-operations-to-make-array-equal) | Medium | +| 1552 | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](../problems/magnetic-force-between-two-balls) | Medium | +| 1553 | [Minimum Number of Days to Eat N Oranges](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") | [Go](../problems/minimum-number-of-days-to-eat-n-oranges) | Hard | +| 1554 | [Strings Differ by One Character](https://leetcode.com/problems/strings-differ-by-one-character "只有一个不同字符的字符串") 🔒 | [Go](../problems/strings-differ-by-one-character) | Medium | +| 1555 | [Bank Account Summary](https://leetcode.com/problems/bank-account-summary "银行账户概要") 🔒 | [MySQL](../problems/bank-account-summary) | Medium | +| 1556 | [Thousand Separator](https://leetcode.com/problems/thousand-separator "千位分隔数") | [Go](../problems/thousand-separator) | Easy | +| 1557 | [Minimum Number of Vertices to Reach All Nodes](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes "可以到达所有点的最少点数目") | [Go](../problems/minimum-number-of-vertices-to-reach-all-nodes) | Medium | +| 1558 | [Minimum Numbers of Function Calls to Make Target Array](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") | [Go](../problems/minimum-numbers-of-function-calls-to-make-target-array) | Medium | +| 1559 | [Detect Cycles in 2D Grid](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") | [Go](../problems/detect-cycles-in-2d-grid) | Medium | +| 1560 | [Most Visited Sector in a Circular Track](https://leetcode.com/problems/most-visited-sector-in-a-circular-track "圆形赛道上经过次数最多的扇区") | [Go](../problems/most-visited-sector-in-a-circular-track) | Easy | +| 1561 | [Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") | [Go](../problems/maximum-number-of-coins-you-can-get) | Medium | +| 1562 | [Find Latest Group of Size M](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") | [Go](../problems/find-latest-group-of-size-m) | Medium | +| 1563 | [Stone Game V](https://leetcode.com/problems/stone-game-v "石子游戏 V") | [Go](../problems/stone-game-v) | Hard | +| 1564 | [Put Boxes Into the Warehouse I](https://leetcode.com/problems/put-boxes-into-the-warehouse-i "把箱子放进仓库里 I") 🔒 | [Go](../problems/put-boxes-into-the-warehouse-i) | Medium | +| 1565 | [Unique Orders and Customers Per Month](https://leetcode.com/problems/unique-orders-and-customers-per-month "按月统计订单数与顾客数") 🔒 | [MySQL](../problems/unique-orders-and-customers-per-month) | Easy | +| 1566 | [Detect Pattern of Length M Repeated K or More Times](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") | [Go](../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | Easy | +| 1567 | [Maximum Length of Subarray With Positive Product](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") | [Go](../problems/maximum-length-of-subarray-with-positive-product) | Medium | +| 1568 | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](../problems/minimum-number-of-days-to-disconnect-island) | Hard | +| 1569 | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](../problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard | +| 1570 | [Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors "两个稀疏向量的点积") 🔒 | [Go](../problems/dot-product-of-two-sparse-vectors) | Medium | +| 1571 | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager "仓库经理") 🔒 | [MySQL](../problems/warehouse-manager) | Easy | +| 1572 | [Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum "矩阵对角线元素的和") | [Go](../problems/matrix-diagonal-sum) | Easy | +| 1573 | [Number of Ways to Split a String](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") | [Go](../problems/number-of-ways-to-split-a-string) | Medium | +| 1574 | [Shortest Subarray to be Removed to Make Array Sorted](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") | [Go](../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | Medium | +| 1575 | [Count All Possible Routes](https://leetcode.com/problems/count-all-possible-routes "统计所有可行路径") | [Go](../problems/count-all-possible-routes) | Hard | +| 1576 | [Replace All ?'s to Avoid Consecutive Repeating Characters](https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters "替换所有的问号") | [Go](../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | Easy | +| 1577 | [Number of Ways Where Square of Number Is Equal to Product of Two Numbers](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") | [Go](../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | Medium | +| 1578 | [Minimum Time to Make Rope Colorful](https://leetcode.com/problems/minimum-time-to-make-rope-colorful "使绳子变成彩色的最短时间") | [Go](../problems/minimum-time-to-make-rope-colorful) | Medium | +| 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | +| 1580 | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii "把箱子放进仓库里 II") 🔒 | [Go](../problems/put-boxes-into-the-warehouse-ii) | Medium | +| 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客") 🔒 | [MySQL](../problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | +| 1582 | [Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") | [Go](../problems/special-positions-in-a-binary-matrix) | Easy | +| 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](../problems/count-unhappy-friends) | Medium | +| 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](../problems/min-cost-to-connect-all-points) | Medium | +| 1585 | [Check If String Is Transformable With Substring Sort Operations](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") | [Go](../problems/check-if-string-is-transformable-with-substring-sort-operations) | Hard | +| 1586 | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii "二叉搜索树迭代器 II") 🔒 | [Go](../problems/binary-search-tree-iterator-ii) | Medium | +| 1587 | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii "银行账户概要 II") 🔒 | [MySQL](../problems/bank-account-summary-ii) | Easy | +| 1588 | [Sum of All Odd Length Subarrays](https://leetcode.com/problems/sum-of-all-odd-length-subarrays "所有奇数长度子数组的和") | [Go](../problems/sum-of-all-odd-length-subarrays) | Easy | +| 1589 | [Maximum Sum Obtained of Any Permutation](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation "所有排列中的最大和") | [Go](../problems/maximum-sum-obtained-of-any-permutation) | Medium | +| 1590 | [Make Sum Divisible by P](https://leetcode.com/problems/make-sum-divisible-by-p "使数组和能被 P 整除") | [Go](../problems/make-sum-divisible-by-p) | Medium | +| 1591 | [Strange Printer II](https://leetcode.com/problems/strange-printer-ii "奇怪的打印机 II") | [Go](../problems/strange-printer-ii) | Hard | +| 1592 | [Rearrange Spaces Between Words](https://leetcode.com/problems/rearrange-spaces-between-words "重新排列单词间的空格") | [Go](../problems/rearrange-spaces-between-words) | Easy | +| 1593 | [Split a String Into the Max Number of Unique Substrings](https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings "拆分字符串使唯一子字符串的数目最大") | [Go](../problems/split-a-string-into-the-max-number-of-unique-substrings) | Medium | +| 1594 | [Maximum Non Negative Product in a Matrix](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") | [Go](../problems/maximum-non-negative-product-in-a-matrix) | Medium | +| 1595 | [Minimum Cost to Connect Two Groups of Points](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") | [Go](../problems/minimum-cost-to-connect-two-groups-of-points) | Hard | +| 1596 | [The Most Frequently Ordered Products for Each Customer](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer "每位顾客最经常订购的商品") 🔒 | [MySQL](../problems/the-most-frequently-ordered-products-for-each-customer) | Medium | +| 1597 | [Build Binary Expression Tree From Infix Expression](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression "根据中缀表达式构造二叉表达式树") 🔒 | [Go](../problems/build-binary-expression-tree-from-infix-expression) | Hard | +| 1598 | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") | [Go](../problems/crawler-log-folder) | Easy | +| 1599 | [Maximum Profit of Operating a Centennial Wheel](https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel "经营摩天轮的最大利润") | [Go](../problems/maximum-profit-of-operating-a-centennial-wheel) | Medium | +| 1600 | [Throne Inheritance](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") | [Go](../problems/throne-inheritance) | Medium | +| 1601 | [Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") | [Go](../problems/maximum-number-of-achievable-transfer-requests) | Hard | +| 1602 | [Find Nearest Right Node in Binary Tree](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree "找到二叉树中最近的右侧节点") 🔒 | [Go](../problems/find-nearest-right-node-in-binary-tree) | Medium | +| 1603 | [Design Parking System](https://leetcode.com/problems/design-parking-system "设计停车系统") | [Go](../problems/design-parking-system) | Easy | +| 1604 | [Alert Using Same Key-Card Three or More Times in a One Hour Period](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "警告一小时内使用相同员工卡大于等于三次的人") | [Go](../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | Medium | +| 1605 | [Find Valid Matrix Given Row and Column Sums](https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums "给定行和列的和求可行矩阵") | [Go](../problems/find-valid-matrix-given-row-and-column-sums) | Medium | +| 1606 | [Find Servers That Handled Most Number of Requests](https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests "找到处理最多请求的服务器") | [Go](../problems/find-servers-that-handled-most-number-of-requests) | Hard | +| 1607 | [Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales "没有卖出的卖家") 🔒 | [MySQL](../problems/sellers-with-no-sales) | Easy | +| 1608 | [Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x "特殊数组的特征值") | [Go](../problems/special-array-with-x-elements-greater-than-or-equal-x) | Easy | +| 1609 | [Even Odd Tree](https://leetcode.com/problems/even-odd-tree "奇偶树") | [Go](../problems/even-odd-tree) | Medium | +| 1610 | [Maximum Number of Visible Points](https://leetcode.com/problems/maximum-number-of-visible-points "可见点的最大数目") | [Go](../problems/maximum-number-of-visible-points) | Hard | +| 1611 | [Minimum One Bit Operations to Make Integers Zero](https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero "使整数变为 0 的最少操作次数") | [Go](../problems/minimum-one-bit-operations-to-make-integers-zero) | Hard | +| 1612 | [Check If Two Expression Trees are Equivalent](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent "检查两棵二叉表达式树是否等价") 🔒 | [Go](../problems/check-if-two-expression-trees-are-equivalent) | Medium | +| 1613 | [Find the Missing IDs](https://leetcode.com/problems/find-the-missing-ids "找到遗失的ID") 🔒 | [MySQL](../problems/find-the-missing-ids) | Medium | +| 1614 | [Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses "括号的最大嵌套深度") | [Go](../problems/maximum-nesting-depth-of-the-parentheses) | Easy | +| 1615 | [Maximal Network Rank](https://leetcode.com/problems/maximal-network-rank "最大网络秩") | [Go](../problems/maximal-network-rank) | Medium | +| 1616 | [Split Two Strings to Make Palindrome](https://leetcode.com/problems/split-two-strings-to-make-palindrome "分割两个字符串得到回文串") | [Go](../problems/split-two-strings-to-make-palindrome) | Medium | +| 1617 | [Count Subtrees With Max Distance Between Cities](https://leetcode.com/problems/count-subtrees-with-max-distance-between-cities "统计子树中城市之间最大距离") | [Go](../problems/count-subtrees-with-max-distance-between-cities) | Hard | +| 1618 | [Maximum Font to Fit a Sentence in a Screen](https://leetcode.com/problems/maximum-font-to-fit-a-sentence-in-a-screen "找出适应屏幕的最大字号") 🔒 | [Go](../problems/maximum-font-to-fit-a-sentence-in-a-screen) | Medium | +| 1619 | [Mean of Array After Removing Some Elements](https://leetcode.com/problems/mean-of-array-after-removing-some-elements "删除某些元素后的数组均值") | [Go](../problems/mean-of-array-after-removing-some-elements) | Easy | +| 1620 | [Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") | [Go](../problems/coordinate-with-maximum-network-quality) | Medium | +| 1621 | [Number of Sets of K Non-Overlapping Line Segments](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments "大小为 K 的不重叠线段的数目") | [Go](../problems/number-of-sets-of-k-non-overlapping-line-segments) | Medium | +| 1622 | [Fancy Sequence](https://leetcode.com/problems/fancy-sequence "奇妙序列") | [Go](../problems/fancy-sequence) | Hard | +| 1623 | [All Valid Triplets That Can Represent a Country](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "三人国家代表队") 🔒 | [MySQL](../problems/all-valid-triplets-that-can-represent-a-country) | Easy | +| 1624 | [Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters "两个相同字符之间的最长子字符串") | [Go](../problems/largest-substring-between-two-equal-characters) | Easy | +| 1625 | [Lexicographically Smallest String After Applying Operations](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations "执行操作后字典序最小的字符串") | [Go](../problems/lexicographically-smallest-string-after-applying-operations) | Medium | +| 1626 | [Best Team With No Conflicts](https://leetcode.com/problems/best-team-with-no-conflicts "无矛盾的最佳球队") | [Go](../problems/best-team-with-no-conflicts) | Medium | +| 1627 | [Graph Connectivity With Threshold](https://leetcode.com/problems/graph-connectivity-with-threshold "带阈值的图连通性") | [Go](../problems/graph-connectivity-with-threshold) | Hard | +| 1628 | [Design an Expression Tree With Evaluate Function](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function "设计带解析函数的表达式树") 🔒 | [Go](../problems/design-an-expression-tree-with-evaluate-function) | Medium | +| 1629 | [Slowest Key](https://leetcode.com/problems/slowest-key "按键持续时间最长的键") | [Go](../problems/slowest-key) | Easy | +| 1630 | [Arithmetic Subarrays](https://leetcode.com/problems/arithmetic-subarrays "等差子数组") | [Go](../problems/arithmetic-subarrays) | Medium | +| 1631 | [Path With Minimum Effort](https://leetcode.com/problems/path-with-minimum-effort "最小体力消耗路径") | [Go](../problems/path-with-minimum-effort) | Medium | +| 1632 | [Rank Transform of a Matrix](https://leetcode.com/problems/rank-transform-of-a-matrix "矩阵转换后的秩") | [Go](../problems/rank-transform-of-a-matrix) | Hard | +| 1633 | [Percentage of Users Attended a Contest](https://leetcode.com/problems/percentage-of-users-attended-a-contest "各赛事的用户注册率") 🔒 | [MySQL](../problems/percentage-of-users-attended-a-contest) | Easy | +| 1634 | [Add Two Polynomials Represented as Linked Lists](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists "求两个多项式链表的和") 🔒 | [Go](../problems/add-two-polynomials-represented-as-linked-lists) | Medium | +| 1635 | [Hopper Company Queries I](https://leetcode.com/problems/hopper-company-queries-i "Hopper 公司查询 I") 🔒 | [MySQL](../problems/hopper-company-queries-i) | Hard | +| 1636 | [Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency "按照频率将数组升序排序") | [Go](../problems/sort-array-by-increasing-frequency) | Easy | +| 1637 | [Widest Vertical Area Between Two Points Containing No Points](https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points "两点之间不包含任何点的最宽垂直面积") | [Go](../problems/widest-vertical-area-between-two-points-containing-no-points) | Medium | +| 1638 | [Count Substrings That Differ by One Character](https://leetcode.com/problems/count-substrings-that-differ-by-one-character "统计只差一个字符的子串数目") | [Go](../problems/count-substrings-that-differ-by-one-character) | Medium | +| 1639 | [Number of Ways to Form a Target String Given a Dictionary](https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary "通过给定词典构造目标字符串的方案数") | [Go](../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | Hard | +| 1640 | [Check Array Formation Through Concatenation](https://leetcode.com/problems/check-array-formation-through-concatenation "能否连接形成数组") | [Go](../problems/check-array-formation-through-concatenation) | Easy | +| 1641 | [Count Sorted Vowel Strings](https://leetcode.com/problems/count-sorted-vowel-strings "统计字典序元音字符串的数目") | [Go](../problems/count-sorted-vowel-strings) | Medium | +| 1642 | [Furthest Building You Can Reach](https://leetcode.com/problems/furthest-building-you-can-reach "可以到达的最远建筑") | [Go](../problems/furthest-building-you-can-reach) | Medium | +| 1643 | [Kth Smallest Instructions](https://leetcode.com/problems/kth-smallest-instructions "第 K 条最小指令") | [Go](../problems/kth-smallest-instructions) | Hard | +| 1644 | [Lowest Common Ancestor of a Binary Tree II](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii "二叉树的最近公共祖先 II") 🔒 | [Go](../problems/lowest-common-ancestor-of-a-binary-tree-ii) | Medium | +| 1645 | [Hopper Company Queries II](https://leetcode.com/problems/hopper-company-queries-ii) 🔒 | [MySQL](../problems/hopper-company-queries-ii) | Hard | +| 1646 | [Get Maximum in Generated Array](https://leetcode.com/problems/get-maximum-in-generated-array "获取生成数组中的最大值") | [Go](../problems/get-maximum-in-generated-array) | Easy | +| 1647 | [Minimum Deletions to Make Character Frequencies Unique](https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique "字符频次唯一的最小删除次数") | [Go](../problems/minimum-deletions-to-make-character-frequencies-unique) | Medium | +| 1648 | [Sell Diminishing-Valued Colored Balls](https://leetcode.com/problems/sell-diminishing-valued-colored-balls "销售价值减少的颜色球") | [Go](../problems/sell-diminishing-valued-colored-balls) | Medium | +| 1649 | [Create Sorted Array through Instructions](https://leetcode.com/problems/create-sorted-array-through-instructions "通过指令创建有序数组") | [Go](../problems/create-sorted-array-through-instructions) | Hard | +| 1650 | [Lowest Common Ancestor of a Binary Tree III](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii "二叉树的最近公共祖先 III") 🔒 | [Go](../problems/lowest-common-ancestor-of-a-binary-tree-iii) | Medium | +| 1651 | [Hopper Company Queries III](https://leetcode.com/problems/hopper-company-queries-iii) 🔒 | [MySQL](../problems/hopper-company-queries-iii) | Hard | +| 1652 | [Defuse the Bomb](https://leetcode.com/problems/defuse-the-bomb "拆炸弹") | [Go](../problems/defuse-the-bomb) | Easy | +| 1653 | [Minimum Deletions to Make String Balanced](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced "使字符串平衡的最少删除次数") | [Go](../problems/minimum-deletions-to-make-string-balanced) | Medium | +| 1654 | [Minimum Jumps to Reach Home](https://leetcode.com/problems/minimum-jumps-to-reach-home "到家的最少跳跃次数") | [Go](../problems/minimum-jumps-to-reach-home) | Medium | +| 1655 | [Distribute Repeating Integers](https://leetcode.com/problems/distribute-repeating-integers "分配重复整数") | [Go](../problems/distribute-repeating-integers) | Hard | +| 1656 | [Design an Ordered Stream](https://leetcode.com/problems/design-an-ordered-stream "设计有序流") | [Go](../problems/design-an-ordered-stream) | Easy | +| 1657 | [Determine if Two Strings Are Close](https://leetcode.com/problems/determine-if-two-strings-are-close "确定两个字符串是否接近") | [Go](../problems/determine-if-two-strings-are-close) | Medium | +| 1658 | [Minimum Operations to Reduce X to Zero](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero "将 x 减到 0 的最小操作数") | [Go](../problems/minimum-operations-to-reduce-x-to-zero) | Medium | +| 1659 | [Maximize Grid Happiness](https://leetcode.com/problems/maximize-grid-happiness "最大化网格幸福感") | [Go](../problems/maximize-grid-happiness) | Hard | +| 1660 | [Correct a Binary Tree](https://leetcode.com/problems/correct-a-binary-tree "纠正二叉树") 🔒 | [Go](../problems/correct-a-binary-tree) | Medium | +| 1661 | [Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine "每台机器的进程平均运行时间") 🔒 | [MySQL](../problems/average-time-of-process-per-machine) | Easy | +| 1662 | [Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent "检查两个字符串数组是否相等") | [Go](../problems/check-if-two-string-arrays-are-equivalent) | Easy | +| 1663 | [Smallest String With A Given Numeric Value](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value "具有给定数值的最小字符串") | [Go](../problems/smallest-string-with-a-given-numeric-value) | Medium | +| 1664 | [Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array "生成平衡数组的方案数") | [Go](../problems/ways-to-make-a-fair-array) | Medium | +| 1665 | [Minimum Initial Energy to Finish Tasks](https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks "完成所有任务的最少初始能量") | [Go](../problems/minimum-initial-energy-to-finish-tasks) | Hard | +| 1666 | [Change the Root of a Binary Tree](https://leetcode.com/problems/change-the-root-of-a-binary-tree "改变二叉树的根节点") 🔒 | [Go](../problems/change-the-root-of-a-binary-tree) | Medium | +| 1667 | [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table "修复表中的名字") 🔒 | [MySQL](../problems/fix-names-in-a-table) | Easy | +| 1668 | [Maximum Repeating Substring](https://leetcode.com/problems/maximum-repeating-substring "最大重复子字符串") | [Go](../problems/maximum-repeating-substring) | Easy | +| 1669 | [Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists "合并两个链表") | [Go](../problems/merge-in-between-linked-lists) | Medium | +| 1670 | [Design Front Middle Back Queue](https://leetcode.com/problems/design-front-middle-back-queue "设计前中后队列") | [Go](../problems/design-front-middle-back-queue) | Medium | +| 1671 | [Minimum Number of Removals to Make Mountain Array](https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array "得到山形数组的最少删除次数") | [Go](../problems/minimum-number-of-removals-to-make-mountain-array) | Hard | +| 1672 | [Richest Customer Wealth](https://leetcode.com/problems/richest-customer-wealth "最富有客户的资产总量") | [Go](../problems/richest-customer-wealth) | Easy | +| 1673 | [Find the Most Competitive Subsequence](https://leetcode.com/problems/find-the-most-competitive-subsequence "找出最具竞争力的子序列") | [Go](../problems/find-the-most-competitive-subsequence) | Medium | +| 1674 | [Minimum Moves to Make Array Complementary](https://leetcode.com/problems/minimum-moves-to-make-array-complementary "使数组互补的最少操作次数") | [Go](../problems/minimum-moves-to-make-array-complementary) | Medium | +| 1675 | [Minimize Deviation in Array](https://leetcode.com/problems/minimize-deviation-in-array "数组的最小偏移量") | [Go](../problems/minimize-deviation-in-array) | Hard | +| 1676 | [Lowest Common Ancestor of a Binary Tree IV](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv "二叉树的最近公共祖先 IV") 🔒 | [Go](../problems/lowest-common-ancestor-of-a-binary-tree-iv) | Medium | +| 1677 | [Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices "发票中的产品金额") 🔒 | [MySQL](../problems/products-worth-over-invoices) | Easy | +| 1678 | [Goal Parser Interpretation](https://leetcode.com/problems/goal-parser-interpretation "设计 Goal 解析器") | [Go](../problems/goal-parser-interpretation) | Easy | +| 1679 | [Max Number of K-Sum Pairs](https://leetcode.com/problems/max-number-of-k-sum-pairs "K 和数对的最大数目") | [Go](../problems/max-number-of-k-sum-pairs) | Medium | +| 1680 | [Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers "连接连续二进制数字") | [Go](../problems/concatenation-of-consecutive-binary-numbers) | Medium | +| 1681 | [Minimum Incompatibility](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") | [Go](../problems/minimum-incompatibility) | Hard | +| 1682 | [Longest Palindromic Subsequence II](https://leetcode.com/problems/longest-palindromic-subsequence-ii "最长回文子序列 II") 🔒 | [Go](../problems/longest-palindromic-subsequence-ii) | Medium | +| 1683 | [Invalid Tweets](https://leetcode.com/problems/invalid-tweets "无效的推文") 🔒 | [MySQL](../problems/invalid-tweets) | Easy | +| 1684 | [Count the Number of Consistent Strings](https://leetcode.com/problems/count-the-number-of-consistent-strings "统计一致字符串的数目") | [Go](../problems/count-the-number-of-consistent-strings) | Easy | +| 1685 | [Sum of Absolute Differences in a Sorted Array](https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array "有序数组中差绝对值之和") | [Go](../problems/sum-of-absolute-differences-in-a-sorted-array) | Medium | +| 1686 | [Stone Game VI](https://leetcode.com/problems/stone-game-vi "石子游戏 VI") | [Go](../problems/stone-game-vi) | Medium | +| 1687 | [Delivering Boxes from Storage to Ports](https://leetcode.com/problems/delivering-boxes-from-storage-to-ports "从仓库到码头运输箱子") | [Go](../problems/delivering-boxes-from-storage-to-ports) | Hard | +| 1688 | [Count of Matches in Tournament](https://leetcode.com/problems/count-of-matches-in-tournament "比赛中的配对次数") | [Go](../problems/count-of-matches-in-tournament) | Easy | +| 1689 | [Partitioning Into Minimum Number Of Deci-Binary Numbers](https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers "十-二进制数的最少数目") | [Go](../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | Medium | +| 1690 | [Stone Game VII](https://leetcode.com/problems/stone-game-vii "石子游戏 VII") | [Go](../problems/stone-game-vii) | Medium | +| 1691 | [Maximum Height by Stacking Cuboids](https://leetcode.com/problems/maximum-height-by-stacking-cuboids "堆叠长方体的最大高度") | [Go](../problems/maximum-height-by-stacking-cuboids) | Hard | +| 1692 | [Count Ways to Distribute Candies](https://leetcode.com/problems/count-ways-to-distribute-candies "计算分配糖果的不同方式") 🔒 | [Go](../problems/count-ways-to-distribute-candies) | Hard | +| 1693 | [Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners "每天的领导和合伙人") 🔒 | [MySQL](../problems/daily-leads-and-partners) | Easy | +| 1694 | [Reformat Phone Number](https://leetcode.com/problems/reformat-phone-number "重新格式化电话号码") | [Go](../problems/reformat-phone-number) | Easy | +| 1695 | [Maximum Erasure Value](https://leetcode.com/problems/maximum-erasure-value "删除子数组的最大得分") | [Go](../problems/maximum-erasure-value) | Medium | +| 1696 | [Jump Game VI](https://leetcode.com/problems/jump-game-vi "跳跃游戏 VI") | [Go](../problems/jump-game-vi) | Medium | +| 1697 | [Checking Existence of Edge Length Limited Paths](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths "检查边长度限制的路径是否存在") | [Go](../problems/checking-existence-of-edge-length-limited-paths) | Hard | +| 1698 | [Number of Distinct Substrings in a String](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string "字符串的不同子字符串个数") 🔒 | [Go](../problems/number-of-distinct-substrings-in-a-string) | Medium | +| 1699 | [Number of Calls Between Two Persons](https://leetcode.com/problems/number-of-calls-between-two-persons "两人之间的通话次数") 🔒 | [MySQL](../problems/number-of-calls-between-two-persons) | Medium | +| 1700 | [Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch "无法吃午餐的学生数量") | [Go](../problems/number-of-students-unable-to-eat-lunch) | Easy | +| 1701 | [Average Waiting Time](https://leetcode.com/problems/average-waiting-time "平均等待时间") | [Go](../problems/average-waiting-time) | Medium | +| 1702 | [Maximum Binary String After Change](https://leetcode.com/problems/maximum-binary-string-after-change "修改后的最大二进制字符串") | [Go](../problems/maximum-binary-string-after-change) | Medium | +| 1703 | [Minimum Adjacent Swaps for K Consecutive Ones](https://leetcode.com/problems/minimum-adjacent-swaps-for-k-consecutive-ones "得到连续 K 个 1 的最少相邻交换次数") | [Go](../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | Hard | +| 1704 | [Determine if String Halves Are Alike](https://leetcode.com/problems/determine-if-string-halves-are-alike "判断字符串的两半是否相似") | [Go](../problems/determine-if-string-halves-are-alike) | Easy | +| 1705 | [Maximum Number of Eaten Apples](https://leetcode.com/problems/maximum-number-of-eaten-apples "吃苹果的最大数目") | [Go](../problems/maximum-number-of-eaten-apples) | Medium | +| 1706 | [Where Will the Ball Fall](https://leetcode.com/problems/where-will-the-ball-fall "球会落何处") | [Go](../problems/where-will-the-ball-fall) | Medium | +| 1707 | [Maximum XOR With an Element From Array](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") | [Go](../problems/maximum-xor-with-an-element-from-array) | Hard | +| 1708 | [Largest Subarray Length K](https://leetcode.com/problems/largest-subarray-length-k "长度为 K 的最大子数组") 🔒 | [Go](../problems/largest-subarray-length-k) | Easy | +| 1709 | [Biggest Window Between Visits](https://leetcode.com/problems/biggest-window-between-visits "访问日期之间最大的空档期") 🔒 | [MySQL](../problems/biggest-window-between-visits) | Medium | +| 1710 | [Maximum Units on a Truck](https://leetcode.com/problems/maximum-units-on-a-truck "卡车上的最大单元数") | [Go](../problems/maximum-units-on-a-truck) | Easy | +| 1711 | [Count Good Meals](https://leetcode.com/problems/count-good-meals "大餐计数") | [Go](../problems/count-good-meals) | Medium | +| 1712 | [Ways to Split Array Into Three Subarrays](https://leetcode.com/problems/ways-to-split-array-into-three-subarrays "将数组分成三个子数组的方案数") | [Go](../problems/ways-to-split-array-into-three-subarrays) | Medium | +| 1713 | [Minimum Operations to Make a Subsequence](https://leetcode.com/problems/minimum-operations-to-make-a-subsequence "得到子序列的最少操作次数") | [Go](../problems/minimum-operations-to-make-a-subsequence) | Hard | +| 1714 | [Sum Of Special Evenly-Spaced Elements In Array](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array "数组中特殊等间距元素的和") 🔒 | [Go](../problems/sum-of-special-evenly-spaced-elements-in-array) | Hard | +| 1715 | [Count Apples and Oranges](https://leetcode.com/problems/count-apples-and-oranges "苹果和橘子的个数") 🔒 | [MySQL](../problems/count-apples-and-oranges) | Medium | +| 1716 | [Calculate Money in Leetcode Bank](https://leetcode.com/problems/calculate-money-in-leetcode-bank "计算力扣银行的钱") | [Go](../problems/calculate-money-in-leetcode-bank) | Easy | +| 1717 | [Maximum Score From Removing Substrings](https://leetcode.com/problems/maximum-score-from-removing-substrings "删除子字符串的最大得分") | [Go](../problems/maximum-score-from-removing-substrings) | Medium | +| 1718 | [Construct the Lexicographically Largest Valid Sequence](https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence "构建字典序最大的可行序列") | [Go](../problems/construct-the-lexicographically-largest-valid-sequence) | Medium | +| 1719 | [Number Of Ways To Reconstruct A Tree](https://leetcode.com/problems/number-of-ways-to-reconstruct-a-tree "重构一棵树的方案数") | [Go](../problems/number-of-ways-to-reconstruct-a-tree) | Hard | +| 1720 | [Decode XORed Array](https://leetcode.com/problems/decode-xored-array "解码异或后的数组") | [Go](../problems/decode-xored-array) | Easy | +| 1721 | [Swapping Nodes in a Linked List](https://leetcode.com/problems/swapping-nodes-in-a-linked-list "交换链表中的节点") | [Go](../problems/swapping-nodes-in-a-linked-list) | Medium | +| 1722 | [Minimize Hamming Distance After Swap Operations](https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations "执行交换操作后的最小汉明距离") | [Go](../problems/minimize-hamming-distance-after-swap-operations) | Medium | +| 1723 | [Find Minimum Time to Finish All Jobs](https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs "完成所有工作的最短时间") | [Go](../problems/find-minimum-time-to-finish-all-jobs) | Hard | +| 1724 | [Checking Existence of Edge Length Limited Paths II](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii "检查边长度限制的路径是否存在 II") 🔒 | [Go](../problems/checking-existence-of-edge-length-limited-paths-ii) | Hard | +| 1725 | [Number Of Rectangles That Can Form The Largest Square](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square "可以形成最大正方形的矩形数目") | [Go](../problems/number-of-rectangles-that-can-form-the-largest-square) | Easy | +| 1726 | [Tuple with Same Product](https://leetcode.com/problems/tuple-with-same-product "同积元组") | [Go](../problems/tuple-with-same-product) | Medium | +| 1727 | [Largest Submatrix With Rearrangements](https://leetcode.com/problems/largest-submatrix-with-rearrangements "重新排列后的最大子矩阵") | [Go](../problems/largest-submatrix-with-rearrangements) | Medium | +| 1728 | [Cat and Mouse II](https://leetcode.com/problems/cat-and-mouse-ii "猫和老鼠 II") | [Go](../problems/cat-and-mouse-ii) | Hard | +| 1729 | [Find Followers Count](https://leetcode.com/problems/find-followers-count "求关注者的数量") 🔒 | [MySQL](../problems/find-followers-count) | Easy | +| 1730 | [Shortest Path to Get Food](https://leetcode.com/problems/shortest-path-to-get-food "获取食物的最短路径") 🔒 | [Go](../problems/shortest-path-to-get-food) | Medium | +| 1731 | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee "每位经理的下属员工数量") 🔒 | [MySQL](../problems/the-number-of-employees-which-report-to-each-employee) | Easy | +| 1732 | [Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude "找到最高海拔") | [Go](../problems/find-the-highest-altitude) | Easy | +| 1733 | [Minimum Number of People to Teach](https://leetcode.com/problems/minimum-number-of-people-to-teach "需要教语言的最少人数") | [Go](../problems/minimum-number-of-people-to-teach) | Medium | +| 1734 | [Decode XORed Permutation](https://leetcode.com/problems/decode-xored-permutation "解码异或后的排列") | [Go](../problems/decode-xored-permutation) | Medium | +| 1735 | [Count Ways to Make Array With Product](https://leetcode.com/problems/count-ways-to-make-array-with-product "生成乘积数组的方案数") | [Go](../problems/count-ways-to-make-array-with-product) | Hard | +| 1736 | [Latest Time by Replacing Hidden Digits](https://leetcode.com/problems/latest-time-by-replacing-hidden-digits "替换隐藏数字得到的最晚时间") | [Go](../problems/latest-time-by-replacing-hidden-digits) | Easy | +| 1737 | [Change Minimum Characters to Satisfy One of Three Conditions](https://leetcode.com/problems/change-minimum-characters-to-satisfy-one-of-three-conditions "满足三条件之一需改变的最少字符数") | [Go](../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | Medium | +| 1738 | [Find Kth Largest XOR Coordinate Value](https://leetcode.com/problems/find-kth-largest-xor-coordinate-value "找出第 K 大的异或坐标值") | [Go](../problems/find-kth-largest-xor-coordinate-value) | Medium | +| 1739 | [Building Boxes](https://leetcode.com/problems/building-boxes "放置盒子") | [Go](../problems/building-boxes) | Hard | +| 1740 | [Find Distance in a Binary Tree](https://leetcode.com/problems/find-distance-in-a-binary-tree "找到二叉树中的距离") 🔒 | [Go](../problems/find-distance-in-a-binary-tree) | Medium | +| 1741 | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee "查找每个员工花费的总时间") 🔒 | [MySQL](../problems/find-total-time-spent-by-each-employee) | Easy | +| 1742 | [Maximum Number of Balls in a Box](https://leetcode.com/problems/maximum-number-of-balls-in-a-box "盒子中小球的最大数量") | [Go](../problems/maximum-number-of-balls-in-a-box) | Easy | +| 1743 | [Restore the Array From Adjacent Pairs](https://leetcode.com/problems/restore-the-array-from-adjacent-pairs "从相邻元素对还原数组") | [Go](../problems/restore-the-array-from-adjacent-pairs) | Medium | +| 1744 | [Can You Eat Your Favorite Candy on Your Favorite Day?](https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day "你能在你最喜欢的那天吃到你最喜欢的糖果吗?") | [Go](../problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | Medium | +| 1745 | [Palindrome Partitioning IV](https://leetcode.com/problems/palindrome-partitioning-iv "回文串分割 IV") | [Go](../problems/palindrome-partitioning-iv) | Hard | +| 1746 | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation "经过一次操作后的最大子数组和") 🔒 | [Go](../problems/maximum-subarray-sum-after-one-operation) | Medium | +| 1747 | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts "应该被禁止的Leetflex账户") 🔒 | [MySQL](../problems/leetflex-banned-accounts) | Medium | +| 1748 | [Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements "唯一元素的和") | [Go](../problems/sum-of-unique-elements) | Easy | +| 1749 | [Maximum Absolute Sum of Any Subarray](https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray "任意子数组和的绝对值的最大值") | [Go](../problems/maximum-absolute-sum-of-any-subarray) | Medium | +| 1750 | [Minimum Length of String After Deleting Similar Ends](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends "删除字符串两端相同字符后的最短长度") | [Go](../problems/minimum-length-of-string-after-deleting-similar-ends) | Medium | +| 1751 | [Maximum Number of Events That Can Be Attended II](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended-ii "最多可以参加的会议数目 II") | [Go](../problems/maximum-number-of-events-that-can-be-attended-ii) | Hard | +| 1752 | [Check if Array Is Sorted and Rotated](https://leetcode.com/problems/check-if-array-is-sorted-and-rotated "检查数组是否经排序和轮转得到") | [Go](../problems/check-if-array-is-sorted-and-rotated) | Easy | +| 1753 | [Maximum Score From Removing Stones](https://leetcode.com/problems/maximum-score-from-removing-stones "移除石子的最大得分") | [Go](../problems/maximum-score-from-removing-stones) | Medium | +| 1754 | [Largest Merge Of Two Strings](https://leetcode.com/problems/largest-merge-of-two-strings "构造字典序最大的合并字符串") | [Go](../problems/largest-merge-of-two-strings) | Medium | +| 1755 | [Closest Subsequence Sum](https://leetcode.com/problems/closest-subsequence-sum "最接近目标值的子序列和") | [Go](../problems/closest-subsequence-sum) | Hard | +| 1756 | [Design Most Recently Used Queue](https://leetcode.com/problems/design-most-recently-used-queue "设计最近使用(MRU)队列") 🔒 | [Go](../problems/design-most-recently-used-queue) | Medium | +| 1757 | [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products "可回收且低脂的产品") 🔒 | [MySQL](../problems/recyclable-and-low-fat-products) | Easy | +| 1758 | [Minimum Changes To Make Alternating Binary String](https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string "生成交替二进制字符串的最少操作数") | [Go](../problems/minimum-changes-to-make-alternating-binary-string) | Easy | +| 1759 | [Count Number of Homogenous Substrings](https://leetcode.com/problems/count-number-of-homogenous-substrings "统计同构子字符串的数目") | [Go](../problems/count-number-of-homogenous-substrings) | Medium | +| 1760 | [Minimum Limit of Balls in a Bag](https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag "袋子里最少数目的球") | [Go](../problems/minimum-limit-of-balls-in-a-bag) | Medium | +| 1761 | [Minimum Degree of a Connected Trio in a Graph](https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph "一个图中连通三元组的最小度数") | [Go](../problems/minimum-degree-of-a-connected-trio-in-a-graph) | Hard | +| 1762 | [Buildings With an Ocean View](https://leetcode.com/problems/buildings-with-an-ocean-view "能看到海景的建筑物") 🔒 | [Go](../problems/buildings-with-an-ocean-view) | Medium | +| 1763 | [Longest Nice Substring](https://leetcode.com/problems/longest-nice-substring "最长的美好子字符串") | [Go](../problems/longest-nice-substring) | Easy | +| 1764 | [Form Array by Concatenating Subarrays of Another Array](https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array "通过连接另一个数组的子数组得到一个数组") | [Go](../problems/form-array-by-concatenating-subarrays-of-another-array) | Medium | +| 1765 | [Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak "地图中的最高点") | [Go](../problems/map-of-highest-peak) | Medium | +| 1766 | [Tree of Coprimes](https://leetcode.com/problems/tree-of-coprimes "互质树") | [Go](../problems/tree-of-coprimes) | Hard | +| 1767 | [Find the Subtasks That Did Not Execute](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute "寻找没有被执行的任务对") 🔒 | [MySQL](../problems/find-the-subtasks-that-did-not-execute) | Hard | +| 1768 | [Merge Strings Alternately](https://leetcode.com/problems/merge-strings-alternately "交替合并字符串") | [Go](../problems/merge-strings-alternately) | Easy | +| 1769 | [Minimum Number of Operations to Move All Balls to Each Box](https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box "移动所有球到每个盒子所需的最小操作数") | [Go](../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | Medium | +| 1770 | [Maximum Score from Performing Multiplication Operations](https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations "执行乘法运算的最大分数") | [Go](../problems/maximum-score-from-performing-multiplication-operations) | Medium | +| 1771 | [Maximize Palindrome Length From Subsequences](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度") | [Go](../problems/maximize-palindrome-length-from-subsequences) | Hard | +| 1772 | [Sort Features by Popularity](https://leetcode.com/problems/sort-features-by-popularity "按受欢迎程度排列功能") 🔒 | [Go](../problems/sort-features-by-popularity) | Medium | +| 1773 | [Count Items Matching a Rule](https://leetcode.com/problems/count-items-matching-a-rule "统计匹配检索规则的物品数量") | [Go](../problems/count-items-matching-a-rule) | Easy | +| 1774 | [Closest Dessert Cost](https://leetcode.com/problems/closest-dessert-cost "最接近目标价格的甜点成本") | [Go](../problems/closest-dessert-cost) | Medium | +| 1775 | [Equal Sum Arrays With Minimum Number of Operations](https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations "通过最少操作次数使数组的和相等") | [Go](../problems/equal-sum-arrays-with-minimum-number-of-operations) | Medium | +| 1776 | [Car Fleet II](https://leetcode.com/problems/car-fleet-ii "车队 II") | [Go](../problems/car-fleet-ii) | Hard | +| 1777 | [Product's Price for Each Store](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") 🔒 | [MySQL](../problems/products-price-for-each-store) | Easy | +| 1778 | [Shortest Path in a Hidden Grid](https://leetcode.com/problems/shortest-path-in-a-hidden-grid "未知网格中的最短路径") 🔒 | [Go](../problems/shortest-path-in-a-hidden-grid) | Medium | +| 1779 | [Find Nearest Point That Has the Same X or Y Coordinate](https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate "找到最近的有相同 X 或 Y 坐标的点") | [Go](../problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | Easy | +| 1780 | [Check if Number is a Sum of Powers of Three](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和") | [Go](../problems/check-if-number-is-a-sum-of-powers-of-three) | Medium | +| 1781 | [Sum of Beauty of All Substrings](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和") | [Go](../problems/sum-of-beauty-of-all-substrings) | Medium | +| 1782 | [Count Pairs Of Nodes](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") | [Go](../problems/count-pairs-of-nodes) | Hard | +| 1783 | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles "大满贯数量") 🔒 | [MySQL](../problems/grand-slam-titles) | Medium | +| 1784 | [Check if Binary String Has at Most One Segment of Ones](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones "检查二进制字符串字段") | [Go](../problems/check-if-binary-string-has-at-most-one-segment-of-ones) | Easy | +| 1785 | [Minimum Elements to Add to Form a Given Sum](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素") | [Go](../problems/minimum-elements-to-add-to-form-a-given-sum) | Medium | +| 1786 | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](../problems/number-of-restricted-paths-from-first-to-last-node) | Medium | +| 1787 | [Make the XOR of All Segments Equal to Zero](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零") | [Go](../problems/make-the-xor-of-all-segments-equal-to-zero) | Hard | +| 1788 | [Maximize the Beauty of the Garden](https://leetcode.com/problems/maximize-the-beauty-of-the-garden "最大化花园的美观度") 🔒 | [Go](../problems/maximize-the-beauty-of-the-garden) | Hard | +| 1789 | [Primary Department for Each Employee](https://leetcode.com/problems/primary-department-for-each-employee "员工的直属部门") 🔒 | [MySQL](../problems/primary-department-for-each-employee) | Easy | +| 1790 | [Check if One String Swap Can Make Strings Equal](https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal "仅执行一次字符串交换能否使两个字符串相等") | [Go](../problems/check-if-one-string-swap-can-make-strings-equal) | Easy | +| 1791 | [Find Center of Star Graph](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") | [Go](../problems/find-center-of-star-graph) | Easy | +| 1792 | [Maximum Average Pass Ratio](https://leetcode.com/problems/maximum-average-pass-ratio "最大平均通过率") | [Go](../problems/maximum-average-pass-ratio) | Medium | +| 1793 | [Maximum Score of a Good Subarray](https://leetcode.com/problems/maximum-score-of-a-good-subarray "好子数组的最大分数") | [Go](../problems/maximum-score-of-a-good-subarray) | Hard | +| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "统计距离最小的子串对个数") 🔒 | [Go](../problems/count-pairs-of-equal-substrings-with-minimum-difference) | Medium | +| 1795 | [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table "每个产品在不同商店的价格") 🔒 | [MySQL](../problems/rearrange-products-table) | Easy | +| 1796 | [Second Largest Digit in a String](https://leetcode.com/problems/second-largest-digit-in-a-string "字符串中第二大的数字") | [Go](../problems/second-largest-digit-in-a-string) | Easy | +| 1797 | [Design Authentication Manager](https://leetcode.com/problems/design-authentication-manager "设计一个验证系统") | [Go](../problems/design-authentication-manager) | Medium | +| 1798 | [Maximum Number of Consecutive Values You Can Make](https://leetcode.com/problems/maximum-number-of-consecutive-values-you-can-make "你能构造出连续值的最大数目") | [Go](../problems/maximum-number-of-consecutive-values-you-can-make) | Medium | +| 1799 | [Maximize Score After N Operations](https://leetcode.com/problems/maximize-score-after-n-operations "N 次操作后的最大分数和") | [Go](../problems/maximize-score-after-n-operations) | Hard | +| 1800 | [Maximum Ascending Subarray Sum](https://leetcode.com/problems/maximum-ascending-subarray-sum "最大升序子数组和") | [Go](../problems/maximum-ascending-subarray-sum) | Easy | diff --git a/readme/301-600.md b/readme/301-600.md index d0b689921..1a0e6f251 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -103,7 +111,7 @@ LeetCode Problems' Solutions | 323 | [Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph "无向图中连通分量的数目") 🔒 | [Go](../problems/number-of-connected-components-in-an-undirected-graph) | Medium | | 324 | [Wiggle Sort II](https://leetcode.com/problems/wiggle-sort-ii "摆动排序 II") | [Go](../problems/wiggle-sort-ii) | Medium | | 325 | [Maximum Size Subarray Sum Equals k](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k "和等于 k 的最长子数组长度") 🔒 | [Go](../problems/maximum-size-subarray-sum-equals-k) | Medium | -| 326 | [Power of Three](https://leetcode.com/problems/power-of-three "3的幂") | [Go](../problems/power-of-three) | Easy | +| 326 | [Power of Three](https://leetcode.com/problems/power-of-three "3 的幂") | [Go](../problems/power-of-three) | Easy | | 327 | [Count of Range Sum](https://leetcode.com/problems/count-of-range-sum "区间和的个数") | [Go](../problems/count-of-range-sum) | Hard | | 328 | [Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list "奇偶链表") | [Go](../problems/odd-even-linked-list) | Medium | | 329 | [Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix "矩阵中的最长递增路径") | [Go](../problems/longest-increasing-path-in-a-matrix) | Hard | @@ -150,7 +158,7 @@ LeetCode Problems' Solutions | 370 | [Range Addition](https://leetcode.com/problems/range-addition "区间加法") 🔒 | [Go](../problems/range-addition) | Medium | | 371 | [Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers "两整数之和") | [Go](../problems/sum-of-two-integers) | Medium | | 372 | [Super Pow](https://leetcode.com/problems/super-pow "超级次方") | [Go](../problems/super-pow) | Medium | -| 373 | [Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的K对数字") | [Go](../problems/find-k-pairs-with-smallest-sums) | Medium | +| 373 | [Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的 K 对数字") | [Go](../problems/find-k-pairs-with-smallest-sums) | Medium | | 374 | [Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower "猜数字大小") | [Go](../problems/guess-number-higher-or-lower) | Easy | | 375 | [Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii "猜数字大小 II") | [Go](../problems/guess-number-higher-or-lower-ii) | Medium | | 376 | [Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence "摆动序列") | [Go](../problems/wiggle-subsequence) | Medium | diff --git a/readme/601-900.md b/readme/601-900.md index 5ceafc962..91d593fbe 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -165,7 +173,7 @@ LeetCode Problems' Solutions | 685 | [Redundant Connection II](https://leetcode.com/problems/redundant-connection-ii "冗余连接 II") | [Go](../problems/redundant-connection-ii) | Hard | | 686 | [Repeated String Match](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") | [Go](../problems/repeated-string-match) | Medium | | 687 | [Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path "最长同值路径") | [Go](../problems/longest-univalue-path) | Medium | -| 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "“马”在棋盘上的概率") | [Go](../problems/knight-probability-in-chessboard) | Medium | +| 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "骑士在棋盘上的概率") | [Go](../problems/knight-probability-in-chessboard) | Medium | | 689 | [Maximum Sum of 3 Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays "三个无重叠子数组的最大和") | [Go](../problems/maximum-sum-of-3-non-overlapping-subarrays) | Hard | | 690 | [Employee Importance](https://leetcode.com/problems/employee-importance "员工的重要性") | [Go](../problems/employee-importance) | Medium | | 691 | [Stickers to Spell Word](https://leetcode.com/problems/stickers-to-spell-word "贴纸拼词") | [Go](../problems/stickers-to-spell-word) | Hard | @@ -365,7 +373,7 @@ LeetCode Problems' Solutions | 885 | [Spiral Matrix III](https://leetcode.com/problems/spiral-matrix-iii "螺旋矩阵 III") | [Go](../problems/spiral-matrix-iii) | Medium | | 886 | [Possible Bipartition](https://leetcode.com/problems/possible-bipartition "可能的二分法") | [Go](../problems/possible-bipartition) | Medium | | 887 | [Super Egg Drop](https://leetcode.com/problems/super-egg-drop "鸡蛋掉落") | [Go](../problems/super-egg-drop) | Hard | -| 888 | [Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap "公平的糖果棒交换") | [Go](../problems/fair-candy-swap) | Easy | +| 888 | [Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap "公平的糖果交换") | [Go](../problems/fair-candy-swap) | Easy | | 889 | [Construct Binary Tree from Preorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal "根据前序和后序遍历构造二叉树") | [Go](../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | Medium | | 890 | [Find and Replace Pattern](https://leetcode.com/problems/find-and-replace-pattern "查找和替换模式") | [Go](../problems/find-and-replace-pattern) | Medium | | 891 | [Sum of Subsequence Widths](https://leetcode.com/problems/sum-of-subsequence-widths "子序列宽度之和") | [Go](../problems/sum-of-subsequence-widths) | Hard | diff --git a/readme/901-1200.md b/readme/901-1200.md index 56787b7be..d782e4e6a 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -211,7 +219,7 @@ LeetCode Problems' Solutions | 1031 | [Maximum Sum of Two Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") | [Go](../problems/maximum-sum-of-two-non-overlapping-subarrays) | Medium | | 1032 | [Stream of Characters](https://leetcode.com/problems/stream-of-characters "字符流") | [Go](../problems/stream-of-characters) | Hard | | 1033 | [Moving Stones Until Consecutive](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") | [Go](../problems/moving-stones-until-consecutive) | Medium | -| 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边框着色") | [Go](../problems/coloring-a-border) | Medium | +| 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边界着色") | [Go](../problems/coloring-a-border) | Medium | | 1035 | [Uncrossed Lines](https://leetcode.com/problems/uncrossed-lines "不相交的线") | [Go](../problems/uncrossed-lines) | Medium | | 1036 | [Escape a Large Maze](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") | [Go](../problems/escape-a-large-maze) | Hard | | 1037 | [Valid Boomerang](https://leetcode.com/problems/valid-boomerang "有效的回旋镖") | [Go](../problems/valid-boomerang) | Easy | @@ -292,7 +300,7 @@ LeetCode Problems' Solutions | 1112 | [Highest Grade For Each Student](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩") 🔒 | [MySQL](../problems/highest-grade-for-each-student) | Medium | | 1113 | [Reported Posts](https://leetcode.com/problems/reported-posts "报告的记录") 🔒 | [MySQL](../problems/reported-posts) | Easy | | 1114 | [Print in Order](https://leetcode.com/problems/print-in-order "按序打印") | [Go](../problems/print-in-order) | Easy | -| 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印FooBar") | [Go](../problems/print-foobar-alternately) | Medium | +| 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印 FooBar") | [Go](../problems/print-foobar-alternately) | Medium | | 1116 | [Print Zero Even Odd](https://leetcode.com/problems/print-zero-even-odd "打印零与奇偶数") | [Go](../problems/print-zero-even-odd) | Medium | | 1117 | [Building H2O](https://leetcode.com/problems/building-h2o "H2O 生成") | [Go](../problems/building-h2o) | Medium | | 1118 | [Number of Days in a Month](https://leetcode.com/problems/number-of-days-in-a-month "一月有多少天") 🔒 | [Go](../problems/number-of-days-in-a-month) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index 90abb510d..ef5f632f3 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,62 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2171 | [拿出最少数目的魔法豆](../../problems/removing-minimum-number-of-magic-beans) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2166 | [设计位集](../../problems/design-bitset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 2164 | [对奇偶下标分别排序](../../problems/sort-even-and-odd-indices-independently) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2163 | [删除元素后和的最小差值](../../problems/minimum-difference-in-sums-after-removal-of-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2161 | [根据给定数字划分数组](../../problems/partition-array-according-to-given-pivot) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2158 | [Amount of New Area Painted Each Day](../../problems/amount-of-new-area-painted-each-day) 🔒 | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 2155 | [分组得分最高的所有下标](../../problems/all-divisions-with-the-highest-score-of-a-binary-array) | [[数组](../array/README.md)] | Medium | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2150 | [找出数组中的所有孤独数字](../../problems/find-all-lonely-numbers-in-the-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2149 | [按符号重排数组](../../problems/rearrange-array-elements-by-sign) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2148 | [元素计数](../../problems/count-elements-with-strictly-smaller-and-greater-elements) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2145 | [统计隐藏数组数目](../../problems/count-the-hidden-sequences) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2144 | [打折购买糖果的最小开销](../../problems/minimum-cost-of-buying-candies-with-discount) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2143 | [Choose Numbers From Two Arrays in Range](../../problems/choose-numbers-from-two-arrays-in-range) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2140 | [解决智力问题](../../problems/solving-questions-with-brainpower) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2137 | [Pour Water Between Buckets to Make Water Levels Equal](../../problems/pour-water-between-buckets-to-make-water-levels-equal) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 2136 | [全部开花的最早一天](../../problems/earliest-possible-day-of-full-bloom) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2134 | [最少交换次数来组合所有的 1 II](../../problems/minimum-swaps-to-group-all-1s-together-ii) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2133 | [检查是否每一行每一列都包含全部整数](../../problems/check-if-every-row-and-column-contains-all-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2126 | [摧毁小行星](../../problems/destroying-asteroids) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](../../problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2121 | [相同元素的间隔之和](../../problems/intervals-between-identical-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2114 | [句子中的最多单词数](../../problems/maximum-number-of-words-found-in-sentences) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 2113 | [Elements in Array After Removing and Replacing Elements](../../problems/elements-in-array-after-removing-and-replacing-elements) 🔒 | [[数组](../array/README.md)] | Medium | +| 2111 | [使数组 K 递增的最少操作次数](../../problems/minimum-operations-to-make-the-array-k-increasing) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 2110 | [股票平滑下跌阶段的数目](../../problems/number-of-smooth-descent-periods-of-a-stock) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2109 | [向字符串添加空格](../../problems/adding-spaces-to-a-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2108 | [找出数组中的第一个回文字符串](../../problems/find-first-palindromic-string-in-the-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 2107 | [Number of Unique Flavors After Sharing K Candies](../../problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2105 | [给植物浇水 II](../../problems/watering-plants-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2104 | [子数组范围和](../../problems/sum-of-subarray-ranges) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2100 | [适合打劫银行的日子](../../problems/find-good-days-to-rob-the-bank) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 2098 | [Subsequence of Size K With the Largest Even Sum](../../problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2091 | [从数组中移除最大值和最小值](../../problems/removing-minimum-and-maximum-from-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 2090 | [半径为 k 的子数组平均值](../../problems/k-radius-subarray-averages) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2089 | [找出数组排序后的目标下标](../../problems/find-target-indices-after-sorting-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2088 | [统计农场中肥沃金字塔的数目](../../problems/count-fertile-pyramids-in-a-land) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2087 | [网格图中机器人回家的最小代价](../../problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2079 | [给植物浇水](../../problems/watering-plants) | [[数组](../array/README.md)] | Medium | | 2078 | [两栋颜色不同且距离最远的房子](../../problems/two-furthest-houses-with-different-colors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | @@ -17,32 +73,31 @@ | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2064 | [分配给商店的最多商品的最小值](../../problems/minimized-maximum-of-products-distributed-to-any-store) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2061 | [扫地机器人清扫过的空间个数](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2059 | [转化数字的最小运算数](../../problems/minimum-operations-to-convert-number) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 2057 | [值相等的最小索引](../../problems/smallest-index-with-equal-value) | [[数组](../array/README.md)] | Easy | | 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2055 | [蜡烛之间的盘子](../../problems/plates-between-candles) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | -| 2052 | [Minimum Cost to Separate Sentence Into Rows](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2052 | [将句子分隔成行的最低成本](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2040 | [两个有序数组的第 K 小乘积](../../problems/kth-smallest-product-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 2037 | [使每位学生都有座位的最少移动次数](../../problems/minimum-number-of-moves-to-seat-everyone) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | -| 2036 | [Maximum Alternating Subarray Sum](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2036 | [最大交替子数组和](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2032 | [至少在两个数组中出现的值](../../problems/two-out-of-three) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 2029 | [石子游戏 IX](../../problems/stone-game-ix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 2028 | [找出缺失的观测数据](../../problems/find-missing-observations) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2023 | [连接后等于目标字符串的字符串对](../../problems/number-of-pairs-of-strings-with-concatenation-equal-to-target) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | -| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2021 | [街上最亮的位置](../../problems/brightest-position-on-street) 🔒 | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 2017 | [网格游戏](../../problems/grid-game) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | @@ -54,7 +109,7 @@ | 2009 | [使数组连续的最少操作数](../../problems/minimum-number-of-operations-to-make-array-continuous) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | | 2007 | [从双倍数组中还原原数组](../../problems/find-original-array-from-doubled-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | -| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] | Easy | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1997 | [访问完所有房间的第一天](../../problems/first-day-where-you-have-been-in-all-the-rooms) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -65,7 +120,7 @@ | 1991 | [找到数组的中间位置](../../problems/find-the-middle-index-in-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1982 | [从子集的和还原数组](../../problems/find-array-given-subset-sums) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | | 1981 | [最小化目标值与所选元素的差](../../problems/minimize-the-difference-between-target-and-chosen-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1980 | [找出不同的二进制字符串](../../problems/find-unique-binary-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | @@ -89,9 +144,10 @@ | 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1936 | [新增的最少台阶数](../../problems/add-minimum-number-of-rungs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1929 | [数组串联](../../problems/concatenation-of-array) | [[数组](../array/README.md)] | Easy | | 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1924 | [安装栅栏 II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1920 | [基于排列构建数组](../../problems/build-array-from-permutation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | @@ -114,7 +170,7 @@ | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | | 1887 | [使数组元素相等的减少操作次数](../../problems/reduction-operations-to-make-the-array-elements-equal) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1886 | [判断矩阵经轮转后是否一致](../../problems/determine-whether-matrix-can-be-obtained-by-rotation) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | -| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [统计数对](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1883 | [准时抵达会议现场的最小跳过休息次数](../../problems/minimum-skips-to-arrive-at-meeting-on-time) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1882 | [使用服务器处理任务](../../problems/process-tasks-using-servers) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | @@ -146,7 +202,7 @@ | 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 1826 | [有缺陷的传感器](../../problems/faulty-sensor) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1820 | [最多邀请的个数](../../problems/maximum-number-of-accepted-invitations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | @@ -262,6 +318,7 @@ | 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | @@ -274,7 +331,7 @@ | 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -370,7 +427,7 @@ | 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1380 | [矩阵中的幸运数](../../problems/lucky-numbers-in-a-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | -| 1375 | [灯泡开关 III](../../problems/bulb-switcher-iii) | [[数组](../array/README.md)] | Medium | +| 1375 | [二进制字符串前缀一致的次数](../../problems/number-of-times-binary-string-is-prefix-aligned) | [[数组](../array/README.md)] | Medium | | 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | | 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -517,7 +574,7 @@ | 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 1035 | [不相交的线](../../problems/uncrossed-lines) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1032 | [字符流](../../problems/stream-of-characters) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | | 1031 | [两个非重叠子数组的最大和](../../problems/maximum-sum-of-two-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -610,7 +667,7 @@ | 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 883 | [三维形体投影面积](../../problems/projection-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -626,7 +683,7 @@ | 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 860 | [柠檬水找零](../../problems/lemonade-change) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 853 | [车队](../../problems/car-fleet) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 852 | [山脉数组的峰顶索引](../../problems/peak-index-in-a-mountain-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] | Medium | | 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] | Hard | @@ -649,7 +706,7 @@ | 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Hard | | 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 807 | [保持城市天际线](../../problems/max-increase-to-keep-city-skyline) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -664,6 +721,7 @@ | 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 774 | [最小化去加油站的最大距离](../../problems/minimize-max-distance-to-gas-station) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | @@ -680,6 +738,7 @@ | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 744 | [寻找比目标字母大的最小字母](../../problems/find-smallest-letter-greater-than-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | @@ -835,7 +894,7 @@ | 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 373 | [查找和最小的 K 对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 370 | [区间加法](../../problems/range-addition) 🔒 | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | | 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | @@ -877,7 +936,7 @@ | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -923,7 +982,7 @@ | 174 | [地下城游戏](../../problems/dungeon-game) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 169 | [多数元素](../../problems/majority-element) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 164 | [最大间距](../../problems/maximum-gap) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] | Hard | | 163 | [缺失的区间](../../problems/missing-ranges) 🔒 | [[数组](../array/README.md)] | Easy | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -931,6 +990,7 @@ | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | | 137 | [只出现一次的数字 II](../../problems/single-number-ii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | | 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | | 135 | [分发糖果](../../problems/candy) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | @@ -966,7 +1026,7 @@ | 56 | [合并区间](../../problems/merge-intervals) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 55 | [跳跃游戏](../../problems/jump-game) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 53 | [最大子数组和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 51 | [N 皇后](../../problems/n-queens) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 47 | [全排列 II](../../problems/permutations-ii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index b864fa7ec..88a033751 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | @@ -26,6 +28,7 @@ | 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | | 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | @@ -72,6 +75,7 @@ | 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 282 | [给表达式添加运算符](../../problems/expression-add-operators) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index 350e34ae8..efb68694d 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1964 | [找出到每个位置为止最长的有效障碍赛跑路线](../../problems/find-the-longest-valid-obstacle-course-at-each-position) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 3a558f6de..a52f03e70 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[贪心](../greedy/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 3205ba91a..9b634cc8e 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2137 | [Pour Water Between Buckets to Make Water Levels Equal](../../problems/pour-water-between-buckets-to-make-water-levels-equal) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 2111 | [使数组 K 递增的最少操作次数](../../problems/minimum-operations-to-make-the-array-k-increasing) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2089 | [找出数组排序后的目标下标](../../problems/find-target-indices-after-sorting-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -17,7 +22,7 @@ | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2040 | [两个有序数组的第 K 小乘积](../../problems/kth-smallest-product-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 2009 | [使数组连续的最少操作数](../../problems/minimum-number-of-operations-to-make-array-continuous) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -33,7 +38,7 @@ | 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1891 | [割绳子](../../problems/cutting-ribbons) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | -| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [统计数对](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1870 | [准时到达的列车最小时速](../../problems/minimum-speed-to-arrive-on-time) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1862 | [向下取整数对和](../../problems/sum-of-floored-pairs) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -104,7 +109,7 @@ | 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 911 | [在线选举](../../problems/online-election) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 875 | [爱吃香蕉的珂珂](../../problems/koko-eating-bananas) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -161,13 +166,13 @@ | 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 69 | [Sqrt(x)](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 69 | [x 的平方根 ](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/binary-tree/README.md b/tag/binary-tree/README.md index 9cea043e7..3fa30ffc7 100644 --- a/tag/binary-tree/README.md +++ b/tag/binary-tree/README.md @@ -9,9 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -44,7 +45,7 @@ | 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -124,7 +125,7 @@ | 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -139,11 +140,11 @@ | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index f008e795e..aef205ab6 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2157 | [字符串分组](../../problems/groups-of-strings) | [[位运算](../bit-manipulation/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | @@ -39,7 +45,7 @@ | 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/bitmask/README.md b/tag/bitmask/README.md index 056368cdd..c13f4838e 100644 --- a/tag/bitmask/README.md +++ b/tag/bitmask/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1994 | [好子集的数目](../../problems/the-number-of-good-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 54cf36cd5..4e9f76243 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,8 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2059 | [转化数字的最小运算数](../../problems/minimum-operations-to-convert-number) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -76,7 +79,7 @@ | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1197 | [进击的骑士](../../problems/minimum-knight-moves) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -85,7 +88,7 @@ | 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | @@ -189,8 +192,9 @@ | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | diff --git a/tag/concurrency/README.md b/tag/concurrency/README.md index 6ad20643a..2155bbd8d 100644 --- a/tag/concurrency/README.md +++ b/tag/concurrency/README.md @@ -16,5 +16,5 @@ | 1188 | [设计有限阻塞队列](../../problems/design-bounded-blocking-queue) 🔒 | [[多线程](../concurrency/README.md)] | Medium | | 1117 | [H2O 生成](../../problems/building-h2o) | [[多线程](../concurrency/README.md)] | Medium | | 1116 | [打印零与奇偶数](../../problems/print-zero-even-odd) | [[多线程](../concurrency/README.md)] | Medium | -| 1115 | [交替打印FooBar](../../problems/print-foobar-alternately) | [[多线程](../concurrency/README.md)] | Medium | +| 1115 | [交替打印 FooBar](../../problems/print-foobar-alternately) | [[多线程](../concurrency/README.md)] | Medium | | 1114 | [按序打印](../../problems/print-in-order) | [[多线程](../concurrency/README.md)] | Easy | diff --git a/tag/counting/README.md b/tag/counting/README.md index 111d9c1de..c1807c731 100644 --- a/tag/counting/README.md +++ b/tag/counting/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2150 | [找出数组中的所有孤独数字](../../problems/find-all-lonely-numbers-in-the-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | @@ -16,6 +22,7 @@ | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2014 | [重复 K 次的最长子序列](../../problems/longest-subsequence-repeated-k-times) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | @@ -58,6 +65,7 @@ | 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | | 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 621 | [任务调度器](../../problems/task-scheduler) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/data-stream/README.md b/tag/data-stream/README.md index 1f6d61328..c7bd52e2a 100644 --- a/tag/data-stream/README.md +++ b/tag/data-stream/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | | 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 6174bf935..025044f79 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2127 | [参加会议的最多员工数](../../problems/maximum-employees-to-be-invited-to-a-meeting) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2097 | [合法重新排列数对](../../problems/valid-arrangement-of-pairs) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -75,6 +80,7 @@ | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[双连通分量](../biconnected-component/README.md)] | Hard | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -85,7 +91,7 @@ | 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | @@ -208,7 +214,7 @@ | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | @@ -227,11 +233,11 @@ | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | diff --git a/tag/design/README.md b/tag/design/README.md index e62692267..2dc5e63d6 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,10 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2166 | [设计位集](../../problems/design-bitset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2069 | [模拟行走机器人 II](../../problems/walking-robot-simulation-ii) | [[设计](../design/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | @@ -99,7 +101,7 @@ | 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[设计](../design/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | @@ -111,4 +113,4 @@ | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 6e1eebbbb..e8c6de06d 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1982 | [从子集的和还原数组](../../problems/find-array-given-subset-sums) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | | 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -43,6 +43,6 @@ | 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 53 | [最大子数组和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/doubly-linked-list/README.md b/tag/doubly-linked-list/README.md index 104be93b5..2e57a2202 100644 --- a/tag/doubly-linked-list/README.md +++ b/tag/doubly-linked-list/README.md @@ -15,4 +15,4 @@ | 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Hard | | 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | | 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index e156b1010..3e539a824 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,12 +9,23 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2167 | [移除所有载有违禁货物车厢所需的最少时间](../../problems/minimum-time-to-remove-all-cars-containing-illegal-goods) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2163 | [删除元素后和的最小差值](../../problems/minimum-difference-in-sums-after-removal-of-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2147 | [分隔长廊的方案数](../../problems/number-of-ways-to-divide-a-long-corridor) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2143 | [Choose Numbers From Two Arrays in Range](../../problems/choose-numbers-from-two-arrays-in-range) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2140 | [解决智力问题](../../problems/solving-questions-with-brainpower) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2110 | [股票平滑下跌阶段的数目](../../problems/number-of-smooth-descent-periods-of-a-stock) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2100 | [适合打劫银行的日子](../../problems/find-good-days-to-rob-the-bank) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2088 | [统计农场中肥沃金字塔的数目](../../problems/count-fertile-pyramids-in-a-land) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2086 | [从房屋收集雨水需要的最少水桶数](../../problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 2060 | [同源字符串检测](../../problems/check-if-an-original-string-exists-given-two-encoded-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2052 | [Minimum Cost to Separate Sentence Into Rows](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2052 | [将句子分隔成行的最低成本](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 2036 | [Maximum Alternating Subarray Sum](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2036 | [最大交替子数组和](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -85,7 +96,7 @@ | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -237,7 +248,7 @@ | 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 688 | [“马”在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 688 | [骑士在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 664 | [奇怪的打印机](../../problems/strange-printer) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -278,7 +289,7 @@ | 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 446 | [等差数列划分 II - 子序列](../../problems/arithmetic-slices-ii-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | -| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Medium | | 416 | [分割等和子集](../../problems/partition-equal-subset-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -343,7 +354,7 @@ | 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 62 | [不同路径](../../problems/unique-paths) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 55 | [跳跃游戏](../../problems/jump-game) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 53 | [最大子数组和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | diff --git a/tag/enumeration/README.md b/tag/enumeration/README.md index cfa2fed90..ff12a4344 100644 --- a/tag/enumeration/README.md +++ b/tag/enumeration/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2162 | [设置时间的最少代价](../../problems/minimum-cost-to-set-cooking-time) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | | 2081 | [k 镜像数字的和](../../problems/sum-of-k-mirror-numbers) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | @@ -20,7 +24,7 @@ | 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | -| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1566 | [重复至少 K 次且长度为 M 的模式](../../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1534 | [统计好三元组](../../problems/count-good-triplets) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1291 | [顺次数](../../problems/sequential-digits) | [[枚举](../enumeration/README.md)] | Medium | diff --git a/tag/eulerian-circuit/README.md b/tag/eulerian-circuit/README.md index f48b4407a..a616dce95 100644 --- a/tag/eulerian-circuit/README.md +++ b/tag/eulerian-circuit/README.md @@ -9,5 +9,6 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2097 | [合法重新排列数对](../../problems/valid-arrangement-of-pairs) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | | 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | | 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 3bb8dcf8f..e2465ee41 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,8 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1956 | [感染 K 种病毒所需的最短时间](../../problems/minimum-time-for-k-virus-variants-to-spread) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[枚举](../enumeration/README.md)] | Hard | -| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1924 | [安装栅栏 II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | | 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | @@ -34,4 +36,4 @@ | 469 | [凸多边形](../../problems/convex-polygon) 🔒 | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | | 335 | [路径交叉](../../problems/self-crossing) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 223 | [矩形面积](../../problems/rectangle-area) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 2c116d55e..7fb9edbc3 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,11 +9,18 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2127 | [参加会议的最多员工数](../../problems/maximum-employees-to-be-invited-to-a-meeting) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](../../problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2097 | [合法重新排列数对](../../problems/valid-arrangement-of-pairs) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | +| 2093 | [Minimum Cost to Reach City With Discounts](../../problems/minimum-cost-to-reach-city-with-discounts) 🔒 | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2077 | [Paths in Maze That Lead to Same Room](../../problems/paths-in-maze-that-lead-to-same-room) 🔒 | [[图](../graph/README.md)] | Medium | | 2076 | [处理含限制条件的好友请求](../../problems/process-restricted-friend-requests) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1971 | [寻找图中是否存在路径](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 0d5ade543..273b006ac 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,20 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2160 | [拆分数位后四位数字的最小和](../../problems/minimum-sum-of-four-digit-number-after-splitting-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2144 | [打折购买糖果的最小开销](../../problems/minimum-cost-of-buying-candies-with-discount) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2139 | [得到目标值的最少行动次数](../../problems/minimum-moves-to-reach-target-score) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 2136 | [全部开花的最早一天](../../problems/earliest-possible-day-of-full-bloom) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2126 | [摧毁小行星](../../problems/destroying-asteroids) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2116 | [判断一个括号字符串是否有效](../../problems/check-if-a-parentheses-string-can-be-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 2098 | [Subsequence of Size K With the Largest Even Sum](../../problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2091 | [从数组中移除最大值和最小值](../../problems/removing-minimum-and-maximum-from-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 2087 | [网格图中机器人回家的最小代价](../../problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2086 | [从房屋收集雨水需要的最少水桶数](../../problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2078 | [两栋颜色不同且距离最远的房子](../../problems/two-furthest-houses-with-different-colors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -26,6 +40,7 @@ | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1953 | [你可以工作的最大周数](../../problems/maximum-number-of-weeks-for-which-you-can-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1946 | [子字符串突变后可能得到的最大整数](../../problems/largest-number-after-mutating-substring) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1936 | [新增的最少台阶数](../../problems/add-minimum-number-of-rungs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1903 | [字符串中的最大奇数](../../problems/largest-odd-number-in-string) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | @@ -78,7 +93,7 @@ | 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -87,7 +102,7 @@ | 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1537 | [最大得分](../../problems/get-the-maximum-score) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1529 | [最少的后缀翻转次数](../../problems/minimum-suffix-flips) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | | 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -161,7 +176,7 @@ | 846 | [一手顺子](../../problems/hand-of-straights) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 807 | [保持城市天际线](../../problems/max-increase-to-keep-city-skyline) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/hash-function/README.md b/tag/hash-function/README.md index 7061229ce..15abea6e7 100644 --- a/tag/hash-function/README.md +++ b/tag/hash-function/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 1960 | [两个回文子字符串长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-substrings) | [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index ac840e676..d0645f16b 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,16 +9,35 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2166 | [设计位集](../../problems/design-bitset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2150 | [找出数组中的所有孤独数字](../../problems/find-all-lonely-numbers-in-the-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2133 | [检查是否每一行每一列都包含全部整数](../../problems/check-if-every-row-and-column-contains-all-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2121 | [相同元素的间隔之和](../../problems/intervals-between-identical-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2107 | [Number of Unique Flavors After Sharing K Candies](../../problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2103 | [环和杆](../../problems/rings-and-rods) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2062 | [统计字符串中的元音子字符串](../../problems/count-vowel-substrings-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2032 | [至少在两个数组中出现的值](../../problems/two-out-of-three) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 2007 | [从双倍数组中还原原数组](../../problems/find-original-array-from-doubled-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | @@ -194,7 +213,7 @@ | 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -206,11 +225,11 @@ | 819 | [最常见的单词](../../problems/most-common-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 817 | [链表组件](../../problems/linked-list-components) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | | 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -218,12 +237,12 @@ | 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 740 | [删除并获得点数](../../problems/delete-and-earn) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | | 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | @@ -327,8 +346,8 @@ | 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | | 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 141 | [环形链表](../../problems/linked-list-cycle) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 140 | [单词拆分 II](../../problems/word-break-ii) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Hard | diff --git a/tag/heap-priority-queue/README.md b/tag/heap-priority-queue/README.md index c5868632c..04cdd71aa 100644 --- a/tag/heap-priority-queue/README.md +++ b/tag/heap-priority-queue/README.md @@ -9,8 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2163 | [删除元素后和的最小差值](../../problems/minimum-difference-in-sums-after-removal-of-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1962 | [移除石子使总数最小](../../problems/remove-stones-to-minimize-the-total) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -94,7 +98,7 @@ | 420 | [强密码检验器](../../problems/strong-password-checker) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 373 | [查找和最小的 K 对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 355 | [设计推特](../../problems/design-twitter) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/iterator/README.md b/tag/iterator/README.md index 641c321ca..0b206b29a 100644 --- a/tag/iterator/README.md +++ b/tag/iterator/README.md @@ -14,7 +14,7 @@ | 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[迭代器](../iterator/README.md)] | Easy | | 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] [[迭代器](../iterator/README.md)] | Medium | -| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index c58530bba..9a8521393 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,9 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2130 | [链表最大孪生和](../../problems/maximum-twin-sum-of-a-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2095 | [删除链表的中间节点](../../problems/delete-the-middle-node-of-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 2074 | [反转偶数长度组的节点](../../problems/reverse-nodes-in-even-length-groups) | [[链表](../linked-list/README.md)] | Medium | | 2058 | [找出临界点之间的最小和最大距离](../../problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points) | [[链表](../linked-list/README.md)] | Medium | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2046 | [给按照绝对值排序的链表排序](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1836 | [从未排序的链表中移除重复元素](../../problems/remove-duplicates-from-an-unsorted-linked-list) 🔒 | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | | 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | @@ -52,11 +54,13 @@ | 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 148 | [排序链表](../../problems/sort-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[分治](../divide-and-conquer/README.md)] [[排序](../sorting/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[链表](../linked-list/README.md)] [[排序](../sorting/README.md)] | Medium | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | | 143 | [重排链表](../../problems/reorder-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 141 | [环形链表](../../problems/linked-list-cycle) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 92 | [反转链表 II](../../problems/reverse-linked-list-ii) | [[链表](../linked-list/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 053a05c92..da2c17d3e 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,20 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2169 | [得到 0 的操作数](../../problems/count-operations-to-obtain-zero) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2165 | [重排数字的最小值](../../problems/smallest-value-of-the-rearranged-number) | [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2162 | [设置时间的最少代价](../../problems/minimum-cost-to-set-cooking-time) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 2160 | [拆分数位后四位数字的最小和](../../problems/minimum-sum-of-four-digit-number-after-splitting-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2147 | [分隔长廊的方案数](../../problems/number-of-ways-to-divide-a-long-corridor) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2139 | [得到目标值的最少行动次数](../../problems/minimum-moves-to-reach-target-score) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2119 | [反转两次的数字](../../problems/a-number-after-a-double-reversal) | [[数学](../math/README.md)] | Easy | +| 2117 | [一个区间内所有数乘积的缩写](../../problems/abbreviating-the-product-of-a-range) | [[数学](../math/README.md)] | Hard | +| 2110 | [股票平滑下跌阶段的数目](../../problems/number-of-smooth-descent-periods-of-a-stock) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2081 | [k 镜像数字的和](../../problems/sum-of-k-mirror-numbers) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | @@ -27,7 +41,7 @@ | 1952 | [三除数](../../problems/three-divisors) | [[数学](../math/README.md)] | Easy | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | -| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1924 | [安装栅栏 II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1908 | [Nim 游戏 II](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -45,7 +59,7 @@ | 1835 | [所有数对按位与结果的异或和](../../problems/find-xor-sum-of-all-pairs-bitwise-and) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Medium | @@ -97,7 +111,7 @@ | 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | | 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] | Medium | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | | 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | @@ -212,7 +226,7 @@ | 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 788 | [旋转数字](../../problems/rotated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 780 | [到达终点](../../problems/reaching-points) | [[数学](../math/README.md)] | Hard | | 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | @@ -293,7 +307,7 @@ | 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 335 | [路径交叉](../../problems/self-crossing) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 326 | [3的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 326 | [3 的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | | 313 | [超级丑数](../../problems/super-ugly-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Hard | @@ -320,11 +334,11 @@ | 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | | 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 89 | [格雷编码](../../problems/gray-code) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 70 | [爬楼梯](../../problems/climbing-stairs) | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 69 | [Sqrt(x)](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 69 | [x 的平方根 ](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 67 | [二进制求和](../../problems/add-binary) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 66 | [加一](../../problems/plus-one) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 62 | [不同路径](../../problems/unique-paths) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | @@ -336,5 +350,5 @@ | 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 9 | [回文数](../../problems/palindrome-number) | [[数学](../math/README.md)] | Easy | -| 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Easy | +| 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Medium | | 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/matrix/README.md b/tag/matrix/README.md index f1af6860d..8b27d5128 100644 --- a/tag/matrix/README.md +++ b/tag/matrix/README.md @@ -9,7 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2133 | [检查是否每一行每一列都包含全部整数](../../problems/check-if-every-row-and-column-contains-all-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](../../problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2088 | [统计农场中肥沃金字塔的数目](../../problems/count-fertile-pyramids-in-a-land) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2087 | [网格图中机器人回家的最小代价](../../problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2061 | [扫地机器人清扫过的空间个数](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -81,7 +89,7 @@ | 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | | 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | diff --git a/tag/merge-sort/README.md b/tag/merge-sort/README.md index 87b8fff12..81df28808 100644 --- a/tag/merge-sort/README.md +++ b/tag/merge-sort/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/monotonic-stack/README.md b/tag/monotonic-stack/README.md index 69ccccc69..b609198b4 100644 --- a/tag/monotonic-stack/README.md +++ b/tag/monotonic-stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2104 | [子数组范围和](../../problems/sum-of-subarray-ranges) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1950 | [所有子数组最小值中的最大值](../../problems/maximum-of-minimum-values-in-all-subarrays) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -32,6 +33,7 @@ | 962 | [最大宽度坡](../../problems/maximum-width-ramp) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | diff --git a/tag/number-theory/README.md b/tag/number-theory/README.md index 47d79b04e..07cf48872 100644 --- a/tag/number-theory/README.md +++ b/tag/number-theory/README.md @@ -12,6 +12,7 @@ | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[数论](../number-theory/README.md)] | Medium | | 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | diff --git a/tag/ordered-set/README.md b/tag/ordered-set/README.md index 7665f8456..45db4a2aa 100644 --- a/tag/ordered-set/README.md +++ b/tag/ordered-set/README.md @@ -9,13 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2158 | [Amount of New Area Painted Each Day](../../problems/amount-of-new-area-painted-each-day) 🔒 | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | -| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2021 | [街上最亮的位置](../../problems/brightest-position-on-street) 🔒 | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | | 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | diff --git a/tag/prefix-sum/README.md b/tag/prefix-sum/README.md index 82e3e9c76..07ca36a90 100644 --- a/tag/prefix-sum/README.md +++ b/tag/prefix-sum/README.md @@ -9,11 +9,18 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2171 | [拿出最少数目的魔法豆](../../problems/removing-minimum-number-of-magic-beans) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2145 | [统计隐藏数组数目](../../problems/count-the-hidden-sequences) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2121 | [相同元素的间隔之和](../../problems/intervals-between-identical-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2100 | [适合打劫银行的日子](../../problems/find-good-days-to-rob-the-bank) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2055 | [蜡烛之间的盘子](../../problems/plates-between-candles) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2021 | [街上最亮的位置](../../problems/brightest-position-on-street) 🔒 | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2017 | [网格游戏](../../problems/grid-game) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1991 | [找到数组的中间位置](../../problems/find-the-middle-index-in-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index d76a040d3..2db4c7d3d 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -12,6 +12,7 @@ | 2073 | [买票需要的时间](../../problems/time-needed-to-buy-tickets) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[栈](../stack/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 9e3769198..c6113caa1 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -11,7 +11,7 @@ | :-: | - | - | :-: | | 1969 | [数组元素的最小非零乘积](../../problems/minimum-non-zero-product-of-the-array-elements) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1808 | [好因子的最大数目](../../problems/maximize-number-of-nice-divisors) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | | 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | | 1265 | [逆序打印不可变链表](../../problems/print-immutable-linked-list-in-reverse) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | @@ -30,7 +30,7 @@ | 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | | 344 | [反转字符串](../../problems/reverse-string) | [[递归](../recursion/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | -| 326 | [3的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 326 | [3 的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | diff --git a/tag/rolling-hash/README.md b/tag/rolling-hash/README.md index 85629bdc3..929c4e240 100644 --- a/tag/rolling-hash/README.md +++ b/tag/rolling-hash/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 1960 | [两个回文子字符串长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-substrings) | [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index 872832452..d15fa7dfa 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,8 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2158 | [Amount of New Area Painted Each Day](../../problems/amount-of-new-area-painted-each-day) 🔒 | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/shortest-path/README.md b/tag/shortest-path/README.md index a1cacef5d..09e0f7c25 100644 --- a/tag/shortest-path/README.md +++ b/tag/shortest-path/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2093 | [Minimum Cost to Reach City With Discounts](../../problems/minimum-cost-to-reach-city-with-discounts) 🔒 | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/simulation/README.md b/tag/simulation/README.md index de5ff39b9..06983fe1f 100644 --- a/tag/simulation/README.md +++ b/tag/simulation/README.md @@ -9,10 +9,18 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2169 | [得到 0 的操作数](../../problems/count-operations-to-obtain-zero) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2161 | [根据给定数字划分数组](../../problems/partition-array-according-to-given-pivot) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2149 | [按符号重排数组](../../problems/rearrange-array-elements-by-sign) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2138 | [将字符串拆分为若干长度为 k 的组](../../problems/divide-a-string-into-groups-of-size-k) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2120 | [执行所有后缀指令](../../problems/execution-of-all-suffix-instructions-staying-in-a-grid) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2109 | [向字符串添加空格](../../problems/adding-spaces-to-a-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2105 | [给植物浇水 II](../../problems/watering-plants-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2075 | [解码斜向换位密码](../../problems/decode-the-slanted-ciphertext) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2073 | [买票需要的时间](../../problems/time-needed-to-buy-tickets) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2069 | [模拟行走机器人 II](../../problems/walking-robot-simulation-ii) | [[设计](../design/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2061 | [扫地机器人清扫过的空间个数](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2028 | [找出缺失的观测数据](../../problems/find-missing-observations) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | @@ -23,7 +31,7 @@ | 1914 | [循环轮转矩阵](../../problems/cyclically-rotating-a-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1860 | [增长的内存泄露](../../problems/incremental-memory-leak) | [[模拟](../simulation/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | @@ -74,6 +82,7 @@ | 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 498 | [对角线遍历](../../problems/diagonal-traverse) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Medium | | 415 | [字符串相加](../../problems/add-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 412 | [Fizz Buzz](../../problems/fizz-buzz) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 289 | [生命游戏](../../problems/game-of-life) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 888c73f17..c77329490 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,7 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2134 | [最少交换次数来组合所有的 1 II](../../problems/minimum-swaps-to-group-all-1s-together-ii) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2107 | [Number of Unique Flavors After Sharing K Candies](../../problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2090 | [半径为 k 的子数组平均值](../../problems/k-radius-subarray-averages) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1918 | [第 K 小的子数组和·](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1852 | [每个子数组的数字种类数](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | diff --git a/tag/sorting/README.md b/tag/sorting/README.md index 1e795d316..0ac1e9083 100644 --- a/tag/sorting/README.md +++ b/tag/sorting/README.md @@ -9,10 +9,28 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2171 | [拿出最少数目的魔法豆](../../problems/removing-minimum-number-of-magic-beans) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2165 | [重排数字的最小值](../../problems/smallest-value-of-the-rearranged-number) | [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2164 | [对奇偶下标分别排序](../../problems/sort-even-and-odd-indices-independently) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2160 | [拆分数位后四位数字的最小和](../../problems/minimum-sum-of-four-digit-number-after-splitting-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2148 | [元素计数](../../problems/count-elements-with-strictly-smaller-and-greater-elements) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2144 | [打折购买糖果的最小开销](../../problems/minimum-cost-of-buying-candies-with-discount) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2136 | [全部开花的最早一天](../../problems/earliest-possible-day-of-full-bloom) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2126 | [摧毁小行星](../../problems/destroying-asteroids) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 2098 | [Subsequence of Size K With the Largest Even Sum](../../problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2089 | [找出数组排序后的目标下标](../../problems/find-target-indices-after-sorting-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2046 | [给按照绝对值排序的链表排序](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 2037 | [使每位学生都有座位的最少移动次数](../../problems/minimum-number-of-moves-to-seat-everyone) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -21,13 +39,13 @@ | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1968 | [构造元素不等于两相邻元素平均值的数组](../../problems/array-with-elements-not-equal-to-average-of-neighbors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1913 | [两个数对之间的最大乘积差](../../problems/maximum-product-difference-between-two-pairs) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | | 1887 | [使数组元素相等的减少操作次数](../../problems/reduction-operations-to-make-the-array-elements-equal) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [统计数对](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1874 | [两个数组的最小乘积和](../../problems/minimize-product-sum-of-two-arrays) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -140,12 +158,12 @@ | 905 | [按奇偶排序数组](../../problems/sort-array-by-parity) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | | 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Medium | | 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 853 | [车队](../../problems/car-fleet) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 846 | [一手顺子](../../problems/hand-of-straights) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -158,6 +176,7 @@ | 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | | 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | | 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | | 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | diff --git a/tag/stack/README.md b/tag/stack/README.md index 7fe784c89..fa5f7a7cd 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2130 | [链表最大孪生和](../../problems/maximum-twin-sum-of-a-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2116 | [判断一个括号字符串是否有效](../../problems/check-if-a-parentheses-string-can-be-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 2104 | [子数组范围和](../../problems/sum-of-subarray-ranges) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -69,6 +72,7 @@ | 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 880 | [索引处的解码字符串](../../problems/decoded-string-at-index) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | @@ -77,7 +81,7 @@ | 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 735 | [行星碰撞](../../problems/asteroid-collision) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 716 | [最大栈](../../problems/max-stack) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] [[有序集合](../ordered-set/README.md)] | Easy | | 682 | [棒球比赛](../../problems/baseball-game) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index f61110315..0a015eeb0 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,28 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2167 | [移除所有载有违禁货物车厢所需的最少时间](../../problems/minimum-time-to-remove-all-cars-containing-illegal-goods) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2157 | [字符串分组](../../problems/groups-of-strings) | [[位运算](../bit-manipulation/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2147 | [分隔长廊的方案数](../../problems/number-of-ways-to-divide-a-long-corridor) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2138 | [将字符串拆分为若干长度为 k 的组](../../problems/divide-a-string-into-groups-of-size-k) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2129 | [将标题首字母大写](../../problems/capitalize-the-title) | [[字符串](../string/README.md)] | Easy | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2124 | [检查是否所有 A 都在 B 之前](../../problems/check-if-all-as-appears-before-all-bs) | [[字符串](../string/README.md)] | Easy | +| 2120 | [执行所有后缀指令](../../problems/execution-of-all-suffix-instructions-staying-in-a-grid) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2116 | [判断一个括号字符串是否有效](../../problems/check-if-a-parentheses-string-can-be-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2114 | [句子中的最多单词数](../../problems/maximum-number-of-words-found-in-sentences) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 2109 | [向字符串添加空格](../../problems/adding-spaces-to-a-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2108 | [找出数组中的第一个回文字符串](../../problems/find-first-palindromic-string-in-the-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 2103 | [环和杆](../../problems/rings-and-rods) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 2086 | [从房屋收集雨水需要的最少水桶数](../../problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2075 | [解码斜向换位密码](../../problems/decode-the-slanted-ciphertext) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | @@ -122,7 +144,7 @@ | 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | | 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | @@ -133,7 +155,7 @@ | 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1529 | [最少的后缀翻转次数](../../problems/minimum-suffix-flips) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1528 | [重新排列字符串](../../problems/shuffle-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | @@ -147,6 +169,7 @@ | 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | | 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1446 | [连续字符](../../problems/consecutive-characters) | [[字符串](../string/README.md)] | Easy | | 1436 | [旅行终点站](../../problems/destination-city) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -291,7 +314,7 @@ | 820 | [单词的压缩编码](../../problems/short-encoding-of-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 819 | [最常见的单词](../../problems/most-common-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 806 | [写字符串需要的行数](../../problems/number-of-lines-to-write-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | @@ -311,14 +334,14 @@ | 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 745 | [前缀和后缀搜索](../../problems/prefix-and-suffix-search) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Hard | | 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 722 | [删除注释](../../problems/remove-comments) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -392,7 +415,7 @@ | 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 420 | [强密码检验器](../../problems/strong-password-checker) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Medium | | 415 | [字符串相加](../../problems/add-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 412 | [Fizz Buzz](../../problems/fizz-buzz) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | @@ -430,7 +453,7 @@ | 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index f3fc7304f..eddfb8658 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2127 | [参加会议的最多员工数](../../problems/maximum-employees-to-be-invited-to-a-meeting) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | diff --git a/tag/tree/README.md b/tag/tree/README.md index a4f396b09..6db216719 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,12 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | @@ -63,7 +64,7 @@ | 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -153,7 +154,7 @@ | 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -168,11 +169,11 @@ | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index b676b857d..bb35f10de 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,7 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2161 | [根据给定数字划分数组](../../problems/partition-array-according-to-given-pivot) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2149 | [按符号重排数组](../../problems/rearrange-array-elements-by-sign) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2130 | [链表最大孪生和](../../problems/maximum-twin-sum-of-a-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2108 | [找出数组中的第一个回文字符串](../../problems/find-first-palindromic-string-in-the-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 2105 | [给植物浇水 II](../../problems/watering-plants-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2095 | [删除链表的中间节点](../../problems/delete-the-middle-node-of-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2046 | [给按照绝对值排序的链表排序](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2000 | [反转单词前缀](../../problems/reverse-prefix-of-word) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | @@ -120,7 +126,7 @@ | 189 | [轮转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 165 | [比较版本号](../../problems/compare-version-numbers) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index b13c5ebf0..7ac700ad6 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2157 | [字符串分组](../../problems/groups-of-strings) | [[位运算](../bit-manipulation/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2076 | [处理含限制条件的好友请求](../../problems/process-restricted-friend-requests) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard |