From cb30580f4e086e837831650051e84df64bf7ace9 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 27 Nov 2021 21:22:53 +0800 Subject: [PATCH 1/5] A: new --- README.md | 118 ++++++++++-------- helper/README.md | 6 +- problems/1-bit-and-2-bit-characters/README.md | 6 +- problems/2-keys-keyboard/README.md | 6 +- problems/24-game/README.md | 6 +- problems/3sum/README.md | 6 +- problems/4-keys-keyboard/README.md | 6 +- .../README.md | 6 +- problems/account-balance/README.md | 6 +- problems/activity-participants/README.md | 6 +- .../README.md | 6 +- problems/ad-free-sessions/README.md | 6 +- problems/add-bold-tag-in-string/README.md | 6 +- .../add-minimum-number-of-rungs/README.md | 6 +- problems/add-one-row-to-tree/README.md | 6 +- .../add-to-array-form-of-integer/README.md | 6 +- .../README.md | 6 +- .../adding-two-negabinary-numbers/README.md | 6 +- problems/advantage-shuffle/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/alien-dictionary/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../all-possible-full-binary-trees/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/alphabet-board-path/README.md | 6 +- .../angle-between-hands-of-a-clock/README.md | 6 +- .../apply-discount-every-n-orders/README.md | 6 +- .../README.md | 6 +- problems/arithmetic-slices/README.md | 7 +- problems/arithmetic-subarrays/README.md | 10 +- problems/arranging-coins/README.md | 6 +- problems/array-nesting/README.md | 6 +- problems/array-transformation/README.md | 6 +- .../README.md | 6 +- problems/article-views-i/README.md | 6 +- problems/article-views-ii/README.md | 6 +- .../as-far-from-land-as-possible/README.md | 6 +- problems/assign-cookies/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../mysql_schemas.sql | 26 ++-- problems/average-selling-price/README.md | 6 +- .../README.md | 6 +- problems/average-waiting-time/README.md | 9 +- problems/avoid-flood-in-the-city/README.md | 6 +- problems/backspace-string-compare/README.md | 6 +- .../balance-a-binary-search-tree/README.md | 6 +- problems/balanced-binary-tree/README.md | 6 +- problems/bank-account-summary-ii/README.md | 6 +- problems/bank-account-summary/README.md | 6 +- problems/beautiful-arrangement/README.md | 8 +- problems/beautiful-array/README.md | 6 +- problems/before-and-after-puzzle/README.md | 6 +- .../README.md | 6 +- problems/best-sightseeing-pair/README.md | 6 +- .../best-team-with-no-conflicts/README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../biggest-window-between-visits/README.md | 6 +- .../binary-prefix-divisible-by-5/README.md | 6 +- .../binary-search-tree-iterator-ii/README.md | 9 +- problems/binary-search/README.md | 6 +- .../README.md | 6 +- problems/binary-tree-coloring-game/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/binary-tree-paths/README.md | 6 +- .../README.md | 6 +- problems/binary-watch/README.md | 6 +- problems/bitwise-ors-of-subarrays/README.md | 8 +- problems/bomb-enemy/README.md | 6 +- problems/brace-expansion-ii/README.md | 16 +-- problems/brace-expansion/README.md | 6 +- problems/break-a-palindrome/README.md | 6 +- problems/brick-wall/README.md | 6 +- problems/bricks-falling-when-hit/README.md | 6 +- .../brightest-position-on-street/README.md | 6 +- .../build-array-from-permutation/README.md | 6 +- .../README.md | 6 +- .../README.md | 12 +- problems/building-boxes/README.md | 8 +- problems/building-h2o/README.md | 6 +- .../buildings-with-an-ocean-view/README.md | 6 +- problems/bulb-switcher-iv/README.md | 6 +- problems/bus-routes/README.md | 6 +- .../README.md | 6 +- problems/calculate-special-bonus/README.md | 6 +- .../can-convert-string-in-k-moves/README.md | 6 +- .../README.md | 6 +- .../README.md | 11 +- problems/can-place-flowers/README.md | 8 +- .../README.md | 6 +- .../README.md | 14 ++- problems/car-fleet-ii/README.md | 13 +- problems/card-flipping-game/README.md | 6 +- problems/cat-and-mouse-ii/README.md | 6 +- .../README.md | 6 +- problems/chalkboard-xor-game/README.md | 10 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../check-if-it-is-a-good-array/README.md | 6 +- problems/check-if-move-is-legal/README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 11 +- problems/cherry-pickup-ii/README.md | 6 +- problems/cinema-seat-allocation/README.md | 10 +- .../README.md | 8 +- problems/circular-array-loop/README.md | 6 +- .../classes-more-than-5-students/README.md | 70 +++++++---- .../mysql_schemas.sql | 22 ++-- problems/climbing-stairs/README.md | 8 +- problems/clone-graph/README.md | 10 +- .../README.md | 6 +- problems/closest-dessert-cost/README.md | 6 +- .../closest-leaf-in-a-binary-tree/README.md | 6 +- problems/closest-room/README.md | 6 +- problems/closest-subsequence-sum/README.md | 12 +- problems/clumsy-factorial/README.md | 6 +- problems/coin-path/README.md | 6 +- problems/coloring-a-border/README.md | 6 +- problems/combination-sum-iii/README.md | 6 +- problems/combinations/README.md | 6 +- problems/combine-two-tables/README.md | 6 +- .../README.md | 6 +- problems/compare-version-numbers/README.md | 6 +- .../complex-number-multiplication/README.md | 6 +- problems/concatenation-of-array/README.md | 6 +- .../README.md | 6 +- problems/confirmation-rate/README.md | 6 +- problems/confusing-number/README.md | 6 +- problems/consecutive-numbers-sum/README.md | 6 +- problems/consecutive-numbers/README.md | 8 +- .../consecutive-numbers/mysql_schemas.sql | 16 +-- .../constrained-subsequence-sum/README.md | 10 +- .../README.md | 8 +- .../construct-k-palindrome-strings/README.md | 8 +- problems/construct-quad-tree/README.md | 6 +- .../README.md | 14 +-- .../README.md | 6 +- .../README.md | 6 +- problems/contain-virus/README.md | 6 +- problems/contains-duplicate-iii/README.md | 10 +- problems/contains-duplicate/README.md | 6 +- .../convert-1d-array-into-2d-array/README.md | 6 +- .../convert-bst-to-greater-tree/README.md | 6 +- problems/convert-date-format/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/convert-to-base-2/README.md | 6 +- problems/convex-polygon/README.md | 6 +- .../README.md | 6 +- problems/correct-a-binary-tree/README.md | 12 +- problems/count-all-possible-routes/README.md | 24 ++-- problems/count-apples-and-oranges/README.md | 6 +- problems/count-good-meals/README.md | 10 +- problems/count-good-numbers/README.md | 6 +- problems/count-good-triplets/README.md | 6 +- .../count-items-matching-a-rule/README.md | 6 +- problems/count-largest-group/README.md | 6 +- .../README.md | 6 +- .../count-nice-pairs-in-an-array/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- .../count-number-of-nice-subarrays/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../count-of-matches-in-tournament/README.md | 6 +- problems/count-pairs-in-two-arrays/README.md | 6 +- .../README.md | 6 +- problems/count-pairs-of-nodes/README.md | 8 +- .../count-pairs-with-xor-in-a-range/README.md | 6 +- problems/count-salary-categories/README.md | 6 +- .../count-servers-that-communicate/README.md | 10 +- problems/count-sorted-vowel-strings/README.md | 6 +- problems/count-special-quadruplets/README.md | 6 +- problems/count-square-sum-triples/README.md | 6 +- problems/count-sub-islands/README.md | 6 +- .../README.md | 6 +- .../count-submatrices-with-all-ones/README.md | 71 ++++------- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../count-the-number-of-experiments/README.md | 6 +- .../README.md | 8 +- problems/count-unhappy-friends/README.md | 6 +- .../README.md | 6 +- problems/count-vowels-permutation/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/counting-elements/README.md | 6 +- .../README.md | 6 +- problems/course-schedule-ii/README.md | 7 +- problems/course-schedule-iii/README.md | 8 +- problems/course-schedule-iv/README.md | 6 +- problems/cracking-the-safe/README.md | 6 +- problems/crawler-log-folder/README.md | 6 +- problems/create-maximum-number/README.md | 6 +- .../README.md | 6 +- problems/customer-order-frequency/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/customers-who-never-order/README.md | 6 +- problems/cutting-ribbons/README.md | 10 +- problems/cyclically-rotating-a-grid/README.md | 6 +- problems/daily-leads-and-partners/README.md | 6 +- problems/daily-temperatures/README.md | 9 +- problems/day-of-the-week/README.md | 6 +- .../decode-the-slanted-ciphertext/README.md | 6 +- problems/decode-ways-ii/README.md | 7 +- problems/decode-xored-array/README.md | 8 +- problems/decode-xored-permutation/README.md | 6 +- problems/decoded-string-at-index/README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- problems/defanging-an-ip-address/README.md | 6 +- problems/defuse-the-bomb/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../delete-node-in-a-linked-list/README.md | 6 +- .../delete-nodes-and-return-forest/README.md | 6 +- problems/delete-tree-nodes/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/describe-the-painting/README.md | 6 +- .../design-a-file-sharing-system/README.md | 13 +- problems/design-a-leaderboard/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/design-an-ordered-stream/README.md | 6 +- .../design-authentication-manager/README.md | 6 +- .../design-bounded-blocking-queue/README.md | 6 +- problems/design-browser-history/README.md | 12 +- problems/design-circular-deque/README.md | 6 +- problems/design-circular-queue/README.md | 6 +- .../README.md | 6 +- .../design-front-middle-back-queue/README.md | 14 +-- problems/design-hit-counter/README.md | 10 +- .../design-in-memory-file-system/README.md | 10 +- problems/design-log-storage-system/README.md | 6 +- .../design-most-recently-used-queue/README.md | 13 +- problems/design-movie-rental-system/README.md | 6 +- problems/design-parking-system/README.md | 8 +- problems/design-phone-directory/README.md | 6 +- .../README.md | 6 +- problems/design-skiplist/README.md | 13 +- problems/design-underground-system/README.md | 6 +- problems/destination-city/README.md | 6 +- problems/detect-capital/README.md | 6 +- problems/detect-cycles-in-2d-grid/README.md | 6 +- .../README.md | 9 +- problems/detect-squares/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- problems/diagonal-traverse-ii/README.md | 6 +- problems/diagonal-traverse/README.md | 9 +- problems/diameter-of-n-ary-tree/README.md | 6 +- problems/dice-roll-simulation/README.md | 9 +- problems/diet-plan-performance/README.md | 6 +- .../README.md | 6 +- problems/dinner-plate-stacks/README.md | 8 +- problems/distance-between-bus-stops/README.md | 6 +- problems/distant-barcodes/README.md | 6 +- problems/distinct-echo-substrings/README.md | 6 +- .../README.md | 6 +- problems/distinct-subsequences/README.md | 11 +- .../distribute-candies-to-people/README.md | 6 +- problems/distribute-candies/README.md | 6 +- .../distribute-coins-in-binary-tree/README.md | 6 +- .../distribute-repeating-integers/README.md | 6 +- .../README.md | 11 +- .../README.md | 8 +- problems/domino-and-tromino-tiling/README.md | 6 +- .../README.md | 8 +- problems/dota2-senate/README.md | 8 +- .../README.md | 14 +++ .../mysql_schemas.sql | 10 ++ problems/dungeon-game/README.md | 6 +- problems/duplicate-zeros/README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/employee-bonus/README.md | 6 +- problems/employee-bonus/mysql_schemas.sql | 16 +-- .../README.md | 6 +- .../README.md | 6 +- problems/encode-and-decode-tinyurl/README.md | 8 +- problems/encode-number/README.md | 8 +- .../README.md | 6 +- problems/erect-the-fence-ii/README.md | 6 +- problems/erect-the-fence/README.md | 6 +- problems/escape-a-large-maze/README.md | 6 +- problems/escape-the-ghosts/README.md | 12 +- .../README.md | 6 +- .../README.md | 6 +- problems/even-odd-tree/README.md | 6 +- problems/exchange-seats/README.md | 6 +- .../exclusive-time-of-functions/README.md | 6 +- problems/expression-add-operators/README.md | 6 +- problems/expressive-words/README.md | 6 +- problems/factor-combinations/README.md | 6 +- problems/factorial-trailing-zeroes/README.md | 19 +-- problems/falling-squares/README.md | 8 +- problems/fancy-sequence/README.md | 8 +- problems/faulty-sensor/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/find-a-peak-element-ii/README.md | 6 +- .../README.md | 10 +- .../find-all-anagrams-in-a-string/README.md | 6 +- problems/find-all-good-strings/README.md | 6 +- .../find-all-groups-of-farmland/README.md | 6 +- .../README.md | 6 +- problems/find-all-the-lonely-nodes/README.md | 10 +- .../find-array-given-subset-sums/README.md | 6 +- .../find-bottom-left-tree-value/README.md | 6 +- problems/find-center-of-star-graph/README.md | 6 +- problems/find-customer-referee/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../find-distance-in-a-binary-tree/README.md | 8 +- problems/find-duplicate-subtrees/README.md | 7 +- .../README.md | 6 +- problems/find-eventual-safe-states/README.md | 6 +- problems/find-followers-count/README.md | 6 +- .../README.md | 6 +- .../find-if-path-exists-in-graph/README.md | 8 +- problems/find-in-mountain-array/README.md | 41 +++--- problems/find-interview-candidates/README.md | 6 +- .../find-k-pairs-with-smallest-sums/README.md | 6 +- .../README.md | 24 ++-- .../README.md | 6 +- .../README.md | 6 +- .../find-latest-group-of-size-m/README.md | 19 +-- .../find-longest-awesome-substring/README.md | 10 +- .../find-lucky-integer-in-an-array/README.md | 6 +- .../README.md | 6 +- .../mysql_schemas.sql | 10 +- .../README.md | 6 +- problems/find-missing-observations/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- .../README.md | 6 +- problems/find-root-of-n-ary-tree/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/find-the-celebrity/README.md | 8 +- .../find-the-closest-palindrome/README.md | 9 +- .../README.md | 6 +- problems/find-the-difference/README.md | 8 +- .../README.md | 6 +- problems/find-the-highest-altitude/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../find-the-middle-index-in-array/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/find-the-missing-ids/README.md | 11 +- .../README.md | 12 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 8 +- .../README.md | 6 +- problems/find-the-team-size/README.md | 6 +- problems/find-the-town-judge/README.md | 6 +- .../README.md | 16 +-- .../README.md | 6 +- .../README.md | 6 +- problems/find-unique-binary-string/README.md | 6 +- .../find-users-with-valid-e-mails/README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/finding-mk-average/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/first-bad-version/README.md | 6 +- .../README.md | 6 +- problems/first-missing-positive/README.md | 6 +- problems/first-unique-number/README.md | 6 +- problems/fix-names-in-a-table/README.md | 6 +- problems/fix-product-name-format/README.md | 6 +- .../README.md | 69 +++++----- .../flatten-nested-list-iterator/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/flip-game/README.md | 6 +- problems/flood-fill/README.md | 8 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../mysql_schemas.sql | 12 +- .../README.md | 6 +- .../friends-of-appropriate-ages/README.md | 6 +- problems/frog-jump/README.md | 9 +- .../frog-position-after-t-seconds/README.md | 6 +- problems/fruit-into-baskets/README.md | 6 +- .../furthest-building-you-can-reach/README.md | 8 +- problems/game-of-nim/README.md | 6 +- problems/game-play-analysis-iv/README.md | 6 +- problems/game-play-analysis-v/README.md | 6 +- problems/gas-station/README.md | 8 +- problems/gcd-sort-of-an-array/README.md | 6 +- problems/generalized-abbreviation/README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../mysql_schemas.sql | 12 +- .../get-maximum-in-generated-array/README.md | 6 +- problems/get-the-maximum-score/README.md | 21 ++-- .../global-and-local-inversions/README.md | 6 +- problems/goal-parser-interpretation/README.md | 6 +- problems/goat-latin/README.md | 6 +- problems/grand-slam-titles/README.md | 6 +- .../README.md | 6 +- problems/graph-valid-tree/README.md | 6 +- .../README.md | 9 +- .../greatest-sum-divisible-by-three/README.md | 8 +- problems/grid-game/README.md | 6 +- problems/group-anagrams/README.md | 6 +- .../README.md | 6 +- problems/group-shifted-strings/README.md | 6 +- .../README.md | 6 +- problems/grumpy-bookstore-owner/README.md | 6 +- .../README.md | 6 +- problems/guess-the-word/README.md | 8 +- problems/h-index-ii/README.md | 6 +- problems/h-index/README.md | 8 +- problems/hand-of-straights/README.md | 8 +- problems/heaters/README.md | 7 +- problems/height-checker/README.md | 6 +- .../highest-grade-for-each-student/README.md | 6 +- problems/hopper-company-queries-i/README.md | 6 +- problems/hopper-company-queries-ii/README.md | 6 +- problems/hopper-company-queries-iii/README.md | 11 +- problems/house-robber-ii/README.md | 6 +- problems/house-robber-iii/README.md | 6 +- .../README.md | 8 +- problems/human-traffic-of-stadium/README.md | 17 +-- .../mysql_schemas.sql | 20 +-- problems/image-smoother/README.md | 6 +- problems/implement-magic-dictionary/README.md | 12 +- .../implement-queue-using-stacks/README.md | 6 +- .../implement-trie-ii-prefix-tree/README.md | 6 +- .../increasing-order-search-tree/README.md | 6 +- .../increasing-triplet-subsequence/README.md | 6 +- problems/incremental-memory-leak/README.md | 6 +- .../inorder-successor-in-bst-ii/README.md | 6 +- problems/inorder-successor-in-bst/README.md | 6 +- problems/insert-interval/README.md | 6 +- problems/insertion-sort-list/README.md | 6 +- problems/integer-break/README.md | 9 +- .../README.md | 6 +- problems/invalid-transactions/README.md | 6 +- problems/invalid-tweets/README.md | 6 +- problems/investments-in-2016/README.md | 6 +- problems/ip-to-cidr/README.md | 8 +- problems/is-subsequence/README.md | 6 +- problems/iterator-for-combination/README.md | 6 +- problems/jump-game-ii/README.md | 10 +- problems/jump-game-vi/README.md | 14 ++- problems/jump-game-vii/README.md | 6 +- .../k-concatenation-maximum-sum/README.md | 6 +- problems/k-inverse-pairs-array/README.md | 6 +- problems/keys-and-rooms/README.md | 9 +- .../README.md | 6 +- problems/knight-dialer/README.md | 6 +- .../README.md | 6 +- problems/koko-eating-bananas/README.md | 6 +- .../kth-ancestor-of-a-tree-node/README.md | 10 +- .../kth-distinct-string-in-an-array/README.md | 6 +- .../kth-missing-positive-number/README.md | 6 +- .../kth-smallest-element-in-a-bst/README.md | 10 +- problems/kth-smallest-instructions/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/kth-smallest-subarray-sum/README.md | 6 +- problems/largest-bst-subtree/README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- problems/largest-divisible-subset/README.md | 6 +- problems/largest-magic-square/README.md | 9 +- .../largest-merge-of-two-strings/README.md | 8 +- .../README.md | 6 +- problems/largest-number/README.md | 8 +- .../largest-odd-number-in-string/README.md | 6 +- problems/largest-palindrome-product/README.md | 6 +- .../largest-rectangle-in-histogram/README.md | 6 +- problems/largest-subarray-length-k/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../largest-time-for-given-digits/README.md | 6 +- problems/largest-unique-number/README.md | 6 +- problems/largest-values-from-labels/README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../last-person-to-fit-in-the-bus/README.md | 6 +- problems/last-stone-weight-ii/README.md | 6 +- problems/last-stone-weight/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/league-statistics/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/leetcodify-similar-friends/README.md | 6 +- problems/leetflex-banned-accounts/README.md | 6 +- problems/letter-case-permutation/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/lfu-cache/README.md | 6 +- problems/linked-list-cycle-ii/README.md | 6 +- problems/linked-list-cycle/README.md | 6 +- problems/linked-list-in-binary-tree/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/longest-absolute-file-path/README.md | 6 +- .../README.md | 10 +- problems/longest-common-subpath/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/longest-happy-prefix/README.md | 6 +- problems/longest-happy-string/README.md | 8 +- .../README.md | 8 +- .../README.md | 6 +- problems/longest-nice-substring/README.md | 8 +- .../README.md | 6 +- .../longest-palindromic-substring/README.md | 6 +- .../README.md | 6 +- .../longest-repeating-substring/README.md | 6 +- problems/longest-string-chain/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- problems/longest-turbulent-subarray/README.md | 6 +- .../longest-uncommon-subsequence-i/README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- problems/longest-word-in-dictionary/README.md | 6 +- .../longest-word-with-all-prefixes/README.md | 6 +- .../README.md | 6 +- problems/low-quality-problems/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 14 +-- .../README.md | 11 +- problems/lucky-numbers-in-a-matrix/README.md | 6 +- problems/magical-string/README.md | 6 +- .../README.md | 16 +-- problems/make-sum-divisible-by-p/README.md | 9 +- problems/make-the-string-great/README.md | 10 +- .../README.md | 8 +- problems/making-file-names-unique/README.md | 6 +- problems/map-of-highest-peak/README.md | 8 +- problems/market-analysis-i/README.md | 6 +- problems/market-analysis-i/mysql_schemas.sql | 4 +- problems/market-analysis-ii/README.md | 6 +- problems/market-analysis-ii/mysql_schemas.sql | 4 +- .../masking-personal-information/README.md | 6 +- problems/matrix-diagonal-sum/README.md | 6 +- problems/max-area-of-island/README.md | 9 +- problems/max-chunks-to-make-sorted/README.md | 6 +- problems/max-number-of-k-sum-pairs/README.md | 10 +- problems/max-stack/README.md | 6 +- .../README.md | 6 +- problems/max-value-of-equation/README.md | 13 +- problems/maximal-network-rank/README.md | 6 +- problems/maximal-rectangle/README.md | 8 +- .../README.md | 6 +- problems/maximize-grid-happiness/README.md | 8 +- .../README.md | 11 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../maximum-ascending-subarray-sum/README.md | 6 +- problems/maximum-average-pass-ratio/README.md | 8 +- problems/maximum-average-subarray-i/README.md | 6 +- .../maximum-average-subarray-ii/README.md | 6 +- problems/maximum-average-subtree/README.md | 6 +- .../README.md | 8 +- problems/maximum-binary-tree/README.md | 6 +- problems/maximum-building-height/README.md | 6 +- .../README.md | 8 +- .../maximum-compatibility-score-sum/README.md | 6 +- .../maximum-depth-of-n-ary-tree/README.md | 7 +- .../README.md | 6 +- .../README.md | 6 +- problems/maximum-distance-in-arrays/README.md | 6 +- problems/maximum-earnings-from-taxi/README.md | 6 +- .../README.md | 6 +- problems/maximum-equal-frequency/README.md | 6 +- problems/maximum-erasure-value/README.md | 6 +- .../README.md | 6 +- problems/maximum-gap/README.md | 6 +- .../README.md | 6 +- .../README.md | 9 +- problems/maximum-ice-cream-bars/README.md | 6 +- .../README.md | 8 +- .../maximum-length-of-pair-chain/README.md | 8 +- .../README.md | 8 +- problems/maximum-matrix-sum/README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/maximum-number-of-balloons/README.md | 6 +- .../README.md | 6 +- .../README.md | 24 ++-- .../README.md | 6 +- .../README.md | 8 +- .../maximum-number-of-eaten-apples/README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/maximum-number-of-ones/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../maximum-path-quality-of-a-graph/README.md | 6 +- .../maximum-performance-of-a-team/README.md | 6 +- .../README.md | 6 +- problems/maximum-population-year/README.md | 6 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../maximum-repeating-substring/README.md | 9 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 8 +- .../README.md | 8 +- .../README.md | 11 +- .../README.md | 8 +- .../README.md | 6 +- .../maximum-students-taking-exam/README.md | 6 +- .../maximum-subarray-min-product/README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../maximum-sum-circular-subarray/README.md | 6 +- .../README.md | 10 +- .../maximum-transaction-each-day/README.md | 6 +- problems/maximum-units-on-a-truck/README.md | 6 +- problems/maximum-vacation-days/README.md | 6 +- .../maximum-value-after-insertion/README.md | 6 +- .../README.md | 6 +- problems/maximum-xor-for-each-query/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/median-employee-salary/README.md | 6 +- .../median-employee-salary/mysql_schemas.sql | 36 +++--- .../merge-bsts-to-create-single-bst/README.md | 6 +- .../merge-in-between-linked-lists/README.md | 6 +- problems/merge-intervals/README.md | 6 +- problems/merge-strings-alternately/README.md | 9 +- .../README.md | 6 +- problems/merge-two-binary-trees/README.md | 6 +- problems/merge-two-sorted-lists/README.md | 20 +-- problems/min-cost-climbing-stairs/README.md | 23 ++-- .../min-cost-to-connect-all-points/README.md | 8 +- problems/min-stack/README.md | 8 +- problems/minesweeper/README.md | 6 +- .../minimize-deviation-in-array/README.md | 10 +- .../README.md | 6 +- problems/minimize-malware-spread/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../minimum-absolute-sum-difference/README.md | 6 +- .../README.md | 14 +-- .../README.md | 6 +- problems/minimum-area-rectangle-ii/README.md | 8 +- problems/minimum-area-rectangle/README.md | 6 +- .../README.md | 6 +- problems/minimum-cost-for-tickets/README.md | 6 +- .../README.md | 6 +- .../minimum-cost-to-connect-sticks/README.md | 8 +- .../README.md | 10 +- .../minimum-cost-to-cut-a-stick/README.md | 14 +-- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../minimum-depth-of-binary-tree/README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- problems/minimum-factorization/README.md | 8 +- .../minimum-falling-path-sum-ii/README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- problems/minimum-height-trees/README.md | 6 +- problems/minimum-incompatibility/README.md | 6 +- .../minimum-index-sum-of-two-lists/README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- .../minimum-jumps-to-reach-home/README.md | 6 +- .../README.md | 6 +- .../minimum-limit-of-balls-in-a-bag/README.md | 9 +- .../minimum-moves-to-convert-string/README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 12 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 15 +-- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 14 +-- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 12 +- .../README.md | 6 +- problems/minimum-sideway-jumps/README.md | 11 +- problems/minimum-size-subarray-sum/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../minimum-speed-to-arrive-on-time/README.md | 6 +- .../README.md | 8 +- .../README.md | 15 ++- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 20 +-- problems/minimum-window-substring/README.md | 7 +- .../minimum-xor-sum-of-two-arrays/README.md | 6 +- problems/mirror-reflection/README.md | 8 +- .../missing-element-in-sorted-array/README.md | 6 +- .../README.md | 6 +- problems/missing-number/README.md | 6 +- problems/monthly-transactions-i/README.md | 6 +- .../monthly-transactions-i/mysql_schemas.sql | 2 +- .../README.md | 6 +- problems/most-profit-assigning-work/README.md | 6 +- .../README.md | 6 +- .../README.md | 10 +- .../move-sub-tree-of-n-ary-tree/README.md | 9 +- problems/movie-rating/README.md | 6 +- .../moving-average-from-data-stream/README.md | 6 +- .../README.md | 6 +- .../moving-stones-until-consecutive/README.md | 8 +- problems/multiply-strings/README.md | 6 +- problems/my-calendar-ii/README.md | 6 +- .../README.md | 6 +- .../n-ary-tree-postorder-traversal/README.md | 6 +- .../n-ary-tree-preorder-traversal/README.md | 6 +- problems/n-th-tribonacci-number/README.md | 6 +- .../README.md | 6 +- problems/nested-list-weight-sum/README.md | 8 +- problems/new-21-game/README.md | 8 +- problems/next-closest-time/README.md | 6 +- problems/next-greater-element-i/README.md | 6 +- problems/next-greater-element-ii/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/nim-game/README.md | 8 +- .../README.md | 6 +- problems/not-boring-movies/README.md | 6 +- problems/nth-digit/README.md | 6 +- problems/nth-magical-number/README.md | 6 +- problems/number-complement/README.md | 6 +- .../README.md | 6 +- problems/number-of-boomerangs/README.md | 6 +- .../README.md | 6 +- problems/number-of-closed-islands/README.md | 8 +- .../number-of-comments-per-post/README.md | 6 +- .../README.md | 6 +- problems/number-of-days-in-a-month/README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../number-of-good-leaf-nodes-pairs/README.md | 6 +- problems/number-of-good-pairs/README.md | 7 +- .../README.md | 6 +- problems/number-of-islands/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../number-of-orders-in-the-backlog/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../number-of-paths-with-max-score/README.md | 6 +- problems/number-of-recent-calls/README.md | 6 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- .../number-of-ships-in-a-rectangle/README.md | 6 +- .../README.md | 6 +- problems/number-of-squareful-arrays/README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../number-of-wonderful-substrings/README.md | 6 +- .../README.md | 6 +- problems/odd-even-linked-list/README.md | 6 +- problems/one-edit-distance/README.md | 6 +- .../README.md | 6 +- problems/online-stock-span/README.md | 6 +- problems/operations-on-tree/README.md | 6 +- problems/optimal-division/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/out-of-boundary-paths/README.md | 6 +- problems/output-contest-matches/README.md | 8 +- .../pacific-atlantic-water-flow/README.md | 8 +- problems/page-recommendations-ii/README.md | 6 +- problems/page-recommendations/README.md | 6 +- problems/paint-house-ii/README.md | 6 +- problems/paint-house/README.md | 6 +- .../README.md | 6 +- problems/palindrome-pairs/README.md | 8 +- .../palindrome-partitioning-iii/README.md | 9 +- problems/palindrome-partitioning-iv/README.md | 6 +- problems/palindrome-permutation/README.md | 8 +- problems/palindromic-substrings/README.md | 6 +- problems/parallel-courses-iii/README.md | 6 +- problems/parallel-courses/README.md | 6 +- .../parsing-a-boolean-expression/README.md | 8 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- problems/pascals-triangle/README.md | 6 +- problems/path-crossing/README.md | 6 +- .../README.md | 8 +- problems/path-sum-iv/README.md | 8 +- problems/path-with-maximum-gold/README.md | 6 +- .../path-with-maximum-minimum-value/README.md | 13 +- .../path-with-maximum-probability/README.md | 11 +- problems/path-with-minimum-effort/README.md | 6 +- .../README.md | 28 +++++ problems/patients-with-a-condition/README.md | 6 +- problems/peeking-iterator/README.md | 16 +-- .../README.md | 6 +- .../README.md | 9 +- problems/perfect-rectangle/README.md | 6 +- problems/perfect-squares/README.md | 6 +- problems/perform-string-shifts/README.md | 6 +- problems/permutation-in-string/README.md | 6 +- problems/permutations-ii/README.md | 6 +- problems/plates-between-candles/README.md | 6 +- problems/power-of-four/README.md | 8 +- problems/power-of-two/README.md | 8 +- problems/powx-n/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/print-binary-tree/README.md | 6 +- .../README.md | 10 +- problems/print-words-vertically/README.md | 6 +- problems/print-zero-even-odd/README.md | 6 +- .../README.md | 19 ++- .../README.md | 12 +- .../process-tasks-using-servers/README.md | 6 +- .../product-of-the-last-k-numbers/README.md | 10 +- .../README.md | 6 +- .../product-price-at-a-given-date/README.md | 6 +- .../products-price-for-each-store/README.md | 6 +- .../products-worth-over-invoices/README.md | 6 +- problems/profitable-schemes/README.md | 6 +- problems/project-employees-i/README.md | 9 +- problems/project-employees-ii/README.md | 6 +- .../README.md | 6 +- problems/push-dominoes/README.md | 6 +- .../put-boxes-into-the-warehouse-i/README.md | 11 +- .../put-boxes-into-the-warehouse-ii/README.md | 11 +- .../queens-that-can-attack-the-king/README.md | 6 +- .../README.md | 6 +- .../queries-quality-and-percentage/README.md | 6 +- .../queue-reconstruction-by-height/README.md | 8 +- problems/random-flip-matrix/README.md | 8 +- .../README.md | 6 +- problems/range-addition-ii/README.md | 6 +- problems/range-addition/README.md | 6 +- problems/range-frequency-queries/README.md | 79 ++++++++++++ problems/range-module/README.md | 6 +- problems/range-sum-of-bst/README.md | 6 +- .../README.md | 6 +- problems/range-sum-query-immutable/README.md | 8 +- problems/rank-teams-by-votes/README.md | 6 +- problems/rank-transform-of-a-matrix/README.md | 12 +- .../README.md | 6 +- problems/rearrange-products-table/README.md | 9 +- .../rearrange-spaces-between-words/README.md | 9 +- .../README.md | 11 +- problems/reconstruct-itinerary/README.md | 11 +- .../README.md | 6 +- problems/rectangle-area/README.md | 8 +- .../recyclable-and-low-fat-products/README.md | 6 +- .../README.md | 6 +- .../reduce-array-size-to-the-half/README.md | 6 +- problems/reducing-dishes/README.md | 6 +- .../README.md | 6 +- problems/reformat-date/README.md | 6 +- problems/reformat-department-table/README.md | 6 +- problems/reformat-phone-number/README.md | 6 +- problems/relative-ranks/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/remove-covered-intervals/README.md | 6 +- problems/remove-duplicate-letters/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 7 +- .../README.md | 6 +- problems/remove-element/README.md | 6 +- problems/remove-invalid-parentheses/README.md | 6 +- problems/remove-k-digits/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../remove-palindromic-subsequences/README.md | 6 +- .../README.md | 6 +- .../README.md | 24 ++-- .../remove-vowels-from-a-string/README.md | 6 +- .../README.md | 9 +- problems/reorganize-string/README.md | 6 +- problems/repeated-string-match/README.md | 6 +- problems/repeated-substring-pattern/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- problems/replace-words/README.md | 6 +- problems/report-contiguous-dates/README.md | 10 +- problems/reported-posts/README.md | 6 +- problems/reshape-the-matrix/README.md | 9 +- problems/restaurant-growth/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/reverse-only-letters/README.md | 6 +- problems/reverse-prefix-of-word/README.md | 6 +- problems/reverse-string-ii/README.md | 6 +- problems/reverse-string/README.md | 11 +- .../README.md | 12 +- .../README.md | 8 +- problems/reverse-vowels-of-a-string/README.md | 6 +- .../reverse-words-in-a-string-iii/README.md | 6 +- problems/richest-customer-wealth/README.md | 6 +- problems/rle-iterator/README.md | 6 +- problems/rotate-image/README.md | 9 +- problems/rotating-the-box/README.md | 6 +- problems/running-sum-of-1d-array/README.md | 6 +- .../README.md | 6 +- problems/sales-analysis-i/README.md | 9 +- problems/sales-analysis-ii/README.md | 6 +- problems/sales-analysis-iii/README.md | 6 +- problems/sales-person/README.md | 6 +- problems/sales-person/mysql_schemas.sql | 38 +++--- .../score-after-flipping-matrix/README.md | 6 +- problems/scramble-string/README.md | 6 +- problems/search-a-2d-matrix-ii/README.md | 6 +- .../README.md | 6 +- problems/search-suggestions-system/README.md | 8 +- problems/seat-reservation-manager/README.md | 6 +- problems/second-degree-follower/README.md | 6 +- .../second-degree-follower/mysql_schemas.sql | 12 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- problems/sellers-with-no-sales/README.md | 6 +- problems/sentence-similarity-iii/README.md | 6 +- problems/sentence-similarity/README.md | 6 +- problems/sequence-reconstruction/README.md | 6 +- problems/sequential-digits/README.md | 6 +- .../README.md | 6 +- problems/set-mismatch/README.md | 6 +- problems/shifting-letters/README.md | 6 +- problems/shopping-offers/README.md | 6 +- problems/short-encoding-of-words/README.md | 6 +- problems/shortest-completing-word/README.md | 6 +- .../shortest-distance-in-a-line/README.md | 6 +- .../mysql_schemas.sql | 10 +- .../shortest-distance-in-a-plane/README.md | 6 +- .../mysql_schemas.sql | 10 +- .../README.md | 11 +- .../shortest-path-in-a-hidden-grid/README.md | 6 +- .../shortest-path-in-binary-matrix/README.md | 8 +- .../shortest-path-to-get-all-keys/README.md | 6 +- problems/shortest-path-to-get-food/README.md | 6 +- .../README.md | 6 +- .../README.md | 18 +-- .../README.md | 6 +- .../shortest-way-to-form-string/README.md | 9 +- problems/shortest-word-distance/README.md | 6 +- problems/shuffle-string/README.md | 6 +- .../sign-of-the-product-of-an-array/README.md | 6 +- problems/similar-rgb-color/README.md | 6 +- problems/simple-bank-system/README.md | 6 +- problems/simplified-fractions/README.md | 6 +- .../README.md | 16 +-- problems/single-number-ii/README.md | 8 +- problems/single-threaded-cpu/README.md | 6 +- problems/sliding-puzzle/README.md | 8 +- problems/sliding-window-median/README.md | 8 +- problems/slowest-key/README.md | 6 +- problems/smallest-common-region/README.md | 12 +- .../README.md | 6 +- .../smallest-index-with-equal-value/README.md | 6 +- .../smallest-integer-divisible-by-k/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/smallest-range-i/README.md | 6 +- problems/smallest-range-ii/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/smallest-string-with-swaps/README.md | 14 ++- .../README.md | 13 +- problems/smallest-sufficient-team/README.md | 12 +- problems/solve-the-equation/README.md | 6 +- .../README.md | 9 +- problems/sort-array-by-parity/README.md | 6 +- .../sort-features-by-popularity/README.md | 10 +- .../README.md | 6 +- .../README.md | 6 +- problems/sort-the-matrix-diagonally/README.md | 8 +- problems/sorting-the-sentence/README.md | 6 +- problems/soup-servings/README.md | 6 +- .../sparse-matrix-multiplication/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/spiral-matrix/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/split-bst/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/squirrel-simulation/README.md | 6 +- problems/stickers-to-spell-word/README.md | 6 +- problems/stock-price-fluctuation/README.md | 6 +- problems/stone-game-iv/README.md | 6 +- problems/stone-game-ix/README.md | 6 +- problems/stone-game-v/README.md | 12 +- problems/stone-game-vi/README.md | 20 +-- problems/stone-game-vii/README.md | 17 ++- problems/stone-game-viii/README.md | 6 +- problems/strange-printer-ii/README.md | 6 +- problems/strange-printer/README.md | 6 +- problems/string-compression-ii/README.md | 6 +- .../README.md | 6 +- .../strings-differ-by-one-character/README.md | 8 +- problems/strobogrammatic-number-ii/README.md | 7 +- problems/strong-friendship/README.md | 6 +- problems/strong-password-checker/README.md | 8 +- .../student-attendance-record-i/README.md | 6 +- problems/students-and-examinations/README.md | 6 +- .../students-report-by-geography/README.md | 6 +- .../mysql_schemas.sql | 12 +- .../README.md | 6 +- problems/subdomain-visit-count/README.md | 6 +- problems/subrectangle-queries/README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 40 ++++++ .../README.md | 6 +- .../README.md | 6 +- problems/sum-game/README.md | 6 +- .../README.md | 6 +- .../sum-of-all-odd-length-subarrays/README.md | 6 +- .../sum-of-all-subset-xor-totals/README.md | 6 +- problems/sum-of-beauty-in-the-array/README.md | 6 +- .../sum-of-beauty-of-all-substrings/README.md | 6 +- problems/sum-of-digits-in-base-k/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/sum-of-floored-pairs/README.md | 6 +- problems/sum-of-k-mirror-numbers/README.md | 93 ++++++++++++++ .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/sum-of-square-numbers/README.md | 6 +- problems/sum-of-unique-elements/README.md | 6 +- problems/sum-root-to-leaf-numbers/README.md | 6 +- problems/super-palindromes/README.md | 6 +- problems/super-ugly-number/README.md | 6 +- problems/super-washing-machines/README.md | 6 +- problems/surrounded-regions/README.md | 6 +- problems/suspicious-bank-accounts/README.md | 6 +- .../README.md | 6 +- problems/swap-nodes-in-pairs/README.md | 9 +- problems/swap-salary/README.md | 18 +-- problems/swap-salary/mysql_schemas.sql | 2 +- .../swapping-nodes-in-a-linked-list/README.md | 6 +- problems/swim-in-rising-water/README.md | 6 +- problems/tag-validator/README.md | 6 +- problems/task-scheduler/README.md | 6 +- .../README.md | 6 +- problems/teemo-attacking/README.md | 6 +- problems/tenth-line/README.md | 6 +- problems/ternary-expression-parser/README.md | 8 +- .../README.md | 6 +- problems/the-dining-philosophers/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../the-k-weakest-rows-in-a-matrix/README.md | 6 +- problems/the-kth-factor-of-n/README.md | 6 +- problems/the-latest-login-in-2020/README.md | 6 +- problems/the-maze-ii/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../the-most-recent-three-orders/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/the-number-of-good-subsets/README.md | 6 +- .../the-number-of-rich-customers/README.md | 17 +++ .../mysql_schemas.sql | 7 ++ .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/the-winner-university/README.md | 6 +- problems/thousand-separator/README.md | 10 +- problems/three-consecutive-odds/README.md | 6 +- problems/three-divisors/README.md | 6 +- problems/three-equal-parts/README.md | 6 +- problems/throne-inheritance/README.md | 11 +- .../README.md | 6 +- problems/time-based-key-value-store/README.md | 6 +- problems/time-needed-to-buy-tickets/README.md | 6 +- problems/to-lower-case/README.md | 6 +- problems/toeplitz-matrix/README.md | 6 +- problems/top-k-frequent-words/README.md | 6 +- problems/top-travellers/README.md | 6 +- problems/toss-strange-coins/README.md | 6 +- problems/total-hamming-distance/README.md | 8 +- problems/tournament-winners/README.md | 6 +- .../README.md | 6 +- problems/transpose-file/README.md | 6 +- problems/transpose-matrix/README.md | 6 +- problems/trapping-rain-water-ii/README.md | 12 +- problems/tree-diameter/README.md | 9 +- problems/tree-node/README.md | 6 +- problems/tree-node/mysql_schemas.sql | 14 +-- problems/tree-of-coprimes/README.md | 6 +- problems/triangle-judgement/README.md | 6 +- problems/triangle-judgement/mysql_schemas.sql | 8 +- .../README.md | 8 +- problems/truncate-sentence/README.md | 6 +- problems/tuple-with-same-product/README.md | 6 +- problems/tweet-counts-per-frequency/README.md | 6 +- .../two-best-non-overlapping-events/README.md | 6 +- .../README.md | 74 +++++++++++ problems/two-out-of-three/README.md | 6 +- problems/two-sum-bsts/README.md | 6 +- problems/two-sum-iv-input-is-a-bst/README.md | 8 +- problems/two-sum-less-than-k/README.md | 8 +- problems/ugly-number-iii/README.md | 6 +- .../README.md | 6 +- problems/unique-email-addresses/README.md | 6 +- .../README.md | 6 +- problems/unique-morse-code-words/README.md | 6 +- .../unique-number-of-occurrences/README.md | 6 +- .../README.md | 6 +- problems/unique-paths-iii/README.md | 8 +- problems/univalued-binary-tree/README.md | 9 +- problems/unpopular-books/README.md | 6 +- .../README.md | 6 +- problems/user-purchase-platform/README.md | 6 +- .../README.md | 6 +- problems/utf-8-validation/README.md | 8 +- problems/valid-anagram/README.md | 6 +- problems/valid-boomerang/README.md | 6 +- problems/valid-parenthesis-string/README.md | 6 +- problems/valid-perfect-square/README.md | 6 +- problems/valid-phone-numbers/README.md | 6 +- problems/valid-square/README.md | 6 +- problems/valid-tic-tac-toe-state/README.md | 6 +- problems/valid-triangle-number/README.md | 6 +- .../validate-binary-search-tree/README.md | 6 +- problems/validate-binary-tree-nodes/README.md | 6 +- problems/verbal-arithmetic-puzzle/README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- problems/vowels-of-all-substrings/README.md | 6 +- .../walking-robot-simulation-ii/README.md | 6 +- problems/warehouse-manager/README.md | 6 +- problems/water-bottles/README.md | 6 +- problems/watering-plants/README.md | 88 +++++++++++++ problems/ways-to-make-a-fair-array/README.md | 6 +- .../README.md | 6 +- problems/web-crawler-multithreaded/README.md | 6 +- problems/web-crawler/README.md | 11 +- problems/where-will-the-ball-fall/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/wildcard-matching/README.md | 10 +- problems/word-break-ii/README.md | 10 +- problems/word-break/README.md | 6 +- problems/word-frequency/README.md | 6 +- problems/word-ladder-ii/README.md | 6 +- problems/word-ladder/README.md | 6 +- problems/word-pattern/README.md | 6 +- problems/word-search-ii/README.md | 8 +- problems/word-squares/README.md | 6 +- problems/xor-queries-of-a-subarray/README.md | 20 +-- problems/zigzag-iterator/README.md | 6 +- readme/1-300.md | 108 ++++++++-------- readme/1201-1500.md | 108 ++++++++-------- readme/301-600.md | 108 ++++++++-------- readme/601-900.md | 110 ++++++++-------- readme/901-1200.md | 108 ++++++++-------- tag/README.md | 84 ++++++------- tag/array/README.md | 9 +- tag/backtracking/README.md | 6 +- tag/biconnected-component/README.md | 6 +- tag/binary-indexed-tree/README.md | 6 +- tag/binary-search-tree/README.md | 6 +- tag/binary-search/README.md | 7 +- tag/binary-tree/README.md | 6 +- tag/bit-manipulation/README.md | 6 +- tag/bitmask/README.md | 6 +- tag/brainteaser/README.md | 6 +- tag/breadth-first-search/README.md | 8 +- tag/bucket-sort/README.md | 6 +- tag/combinatorics/README.md | 6 +- tag/concurrency/README.md | 6 +- tag/counting-sort/README.md | 6 +- tag/counting/README.md | 6 +- tag/data-stream/README.md | 6 +- tag/depth-first-search/README.md | 8 +- tag/dequeue/README.md | 6 +- tag/design/README.md | 7 +- tag/divide-and-conquer/README.md | 6 +- tag/doubly-linked-list/README.md | 6 +- tag/dynamic-programming/README.md | 8 +- tag/enumeration/README.md | 7 +- tag/eulerian-circuit/README.md | 6 +- tag/game-theory/README.md | 6 +- tag/geometry/README.md | 6 +- tag/graph/README.md | 10 +- tag/greedy/README.md | 7 +- tag/hash-function/README.md | 6 +- tag/hash-table/README.md | 7 +- tag/heap-priority-queue/README.md | 6 +- tag/heap/README.md | 6 +- tag/interactive/README.md | 6 +- tag/iterator/README.md | 6 +- tag/line-sweep/README.md | 6 +- tag/linked-list/README.md | 6 +- tag/math/README.md | 9 +- tag/matrix/README.md | 6 +- tag/meet-in-the-middle/README.md | 6 +- tag/memoization/README.md | 6 +- tag/merge-sort/README.md | 6 +- tag/minimax/README.md | 6 +- tag/minimum-spanning-tree/README.md | 6 +- tag/monotonic-queue/README.md | 6 +- tag/monotonic-stack/README.md | 6 +- tag/number-theory/README.md | 6 +- tag/oop/README.md | 6 +- tag/ordered-map/README.md | 6 +- tag/ordered-set/README.md | 6 +- tag/prefix-sum/README.md | 6 +- tag/probability-and-statistics/README.md | 8 +- tag/queue/README.md | 6 +- tag/quickselect/README.md | 6 +- tag/radix-sort/README.md | 6 +- tag/random/README.md | 6 +- tag/randomized/README.md | 6 +- tag/recursion/README.md | 6 +- tag/rejection-sampling/README.md | 6 +- tag/reservoir-sampling/README.md | 6 +- tag/rolling-hash/README.md | 6 +- tag/segment-tree/README.md | 7 +- tag/shortest-path/README.md | 6 +- tag/simulation/README.md | 6 +- tag/sliding-window/README.md | 8 +- tag/sort/README.md | 6 +- tag/sorting/README.md | 6 +- tag/stack/README.md | 6 +- tag/string-matching/README.md | 6 +- tag/string/README.md | 6 +- tag/strongly-connected-component/README.md | 6 +- tag/suffix-array/README.md | 6 +- tag/topological-sort/README.md | 6 +- tag/tree/README.md | 6 +- tag/trie/README.md | 6 +- tag/two-pointers/README.md | 6 +- tag/union-find/README.md | 7 +- 1421 files changed, 5862 insertions(+), 5414 deletions(-) create mode 100644 problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md create mode 100644 problems/drop-type-1-orders-for-customers-with-type-0-orders/mysql_schemas.sql create mode 100644 problems/paths-in-maze-that-lead-to-same-room/README.md create mode 100644 problems/range-frequency-queries/README.md create mode 100644 problems/substrings-that-begin-and-end-with-the-same-letter/README.md create mode 100644 problems/sum-of-k-mirror-numbers/README.md create mode 100644 problems/the-number-of-rich-customers/README.md create mode 100644 problems/the-number-of-rich-customers/mysql_schemas.sql create mode 100644 problems/two-furthest-houses-with-different-colors/README.md create mode 100644 problems/watering-plants/README.md diff --git a/README.md b/README.md index f967b5ab9..d8ed2b05d 100644 --- a/README.md +++ b/README.md @@ -1,83 +1,91 @@ - - - + + + -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![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][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]
| # | 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 | +| 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 | +| 2078 | [Two Furthest Houses With Different Colors](https://leetcode.com/problems/two-furthest-houses-with-different-colors "两栋颜色不同且距离最远的房子") | [Go](problems/two-furthest-houses-with-different-colors) | Easy | +| 2077 | [Paths in Maze That Lead to Same Room](https://leetcode.com/problems/paths-in-maze-that-lead-to-same-room) 🔒 | [Go](problems/paths-in-maze-that-lead-to-same-room) | Medium | | 2076 | [Process Restricted Friend Requests](https://leetcode.com/problems/process-restricted-friend-requests "处理含限制条件的好友请求") | [Go](problems/process-restricted-friend-requests) | Hard | | 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 | @@ -183,7 +191,7 @@ LeetCode Problems' Solutions | 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 | -| 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 | +| 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 | diff --git a/helper/README.md b/helper/README.md index 0b90a3c9f..b5d445180 100644 --- a/helper/README.md +++ b/helper/README.md @@ -1,8 +1,8 @@ - - - + + + # Helper diff --git a/problems/1-bit-and-2-bit-characters/README.md b/problems/1-bit-and-2-bit-characters/README.md index 8a4f4ecb9..12f6933a1 100644 --- a/problems/1-bit-and-2-bit-characters/README.md +++ b/problems/1-bit-and-2-bit-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-stack "Max Stack") diff --git a/problems/2-keys-keyboard/README.md b/problems/2-keys-keyboard/README.md index 10bd85b1e..6bf91790a 100644 --- a/problems/2-keys-keyboard/README.md +++ b/problems/2-keys-keyboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../dota2-senate "Dota2 Senate") diff --git a/problems/24-game/README.md b/problems/24-game/README.md index bd52440e6..64205b65d 100644 --- a/problems/24-game/README.md +++ b/problems/24-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-parenthesis-string "Valid Parenthesis String") diff --git a/problems/3sum/README.md b/problems/3sum/README.md index f707b18e9..74eb35d4c 100644 --- a/problems/3sum/README.md +++ b/problems/3sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-common-prefix "Longest Common Prefix") diff --git a/problems/4-keys-keyboard/README.md b/problems/4-keys-keyboard/README.md index dc7964f95..14b9a794c 100644 --- a/problems/4-keys-keyboard/README.md +++ b/problems/4-keys-keyboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../2-keys-keyboard "2 Keys Keyboard") diff --git a/problems/accepted-candidates-from-the-interviews/README.md b/problems/accepted-candidates-from-the-interviews/README.md index 25555e9f8..19d0072c0 100644 --- a/problems/accepted-candidates-from-the-interviews/README.md +++ b/problems/accepted-candidates-from-the-interviews/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-smallest-product-of-two-sorted-arrays "Kth Smallest Product of Two Sorted Arrays") diff --git a/problems/account-balance/README.md b/problems/account-balance/README.md index a06c26130..ce0895597 100644 --- a/problems/account-balance/README.md +++ b/problems/account-balance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-path-quality-of-a-graph "Maximum Path Quality of a Graph") diff --git a/problems/activity-participants/README.md b/problems/activity-participants/README.md index 6cba915c9..066be853b 100644 --- a/problems/activity-participants/README.md +++ b/problems/activity-participants/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-target-array-with-multiple-sums "Construct Target Array With Multiple Sums") diff --git a/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md b/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md index 7bf3cb0b6..553490bae 100644 --- a/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md +++ b/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../last-stone-weight-ii "Last Stone Weight II") diff --git a/problems/ad-free-sessions/README.md b/problems/ad-free-sessions/README.md index c65a46fb3..4e9bc9677 100644 --- a/problems/ad-free-sessions/README.md +++ b/problems/ad-free-sessions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-number-of-nice-divisors "Maximize Number of Nice Divisors") diff --git a/problems/add-bold-tag-in-string/README.md b/problems/add-bold-tag-in-string/README.md index eee9b70a5..2af02380c 100644 --- a/problems/add-bold-tag-in-string/README.md +++ b/problems/add-bold-tag-in-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-salary-departments-vs-company "Average Salary: Departments VS Company") diff --git a/problems/add-minimum-number-of-rungs/README.md b/problems/add-minimum-number-of-rungs/README.md index 3f14795f0..a1e778ff4 100644 --- a/problems/add-minimum-number-of-rungs/README.md +++ b/problems/add-minimum-number-of-rungs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-words-you-can-type "Maximum Number of Words You Can Type") diff --git a/problems/add-one-row-to-tree/README.md b/problems/add-one-row-to-tree/README.md index 8a98e1d21..46e4b2d6a 100644 --- a/problems/add-one-row-to-tree/README.md +++ b/problems/add-one-row-to-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-circular-queue "Design Circular Queue") diff --git a/problems/add-to-array-form-of-integer/README.md b/problems/add-to-array-form-of-integer/README.md index db5ec4798..83da4ee23 100644 --- a/problems/add-to-array-form-of-integer/README.md +++ b/problems/add-to-array-form-of-integer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-string-starting-from-leaf "Smallest String Starting From Leaf") diff --git a/problems/add-two-polynomials-represented-as-linked-lists/README.md b/problems/add-two-polynomials-represented-as-linked-lists/README.md index 0b7574ebc..3c0db5e11 100644 --- a/problems/add-two-polynomials-represented-as-linked-lists/README.md +++ b/problems/add-two-polynomials-represented-as-linked-lists/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../percentage-of-users-attended-a-contest "Percentage of Users Attended a Contest") diff --git a/problems/adding-two-negabinary-numbers/README.md b/problems/adding-two-negabinary-numbers/README.md index f7f8a4c72..be61ff03b 100644 --- a/problems/adding-two-negabinary-numbers/README.md +++ b/problems/adding-two-negabinary-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flip-columns-for-maximum-number-of-equal-rows "Flip Columns For Maximum Number of Equal Rows") diff --git a/problems/advantage-shuffle/README.md b/problems/advantage-shuffle/README.md index e32341403..129cfef84 100644 --- a/problems/advantage-shuffle/README.md +++ b/problems/advantage-shuffle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reordered-power-of-2 "Reordered Power of 2") diff --git a/problems/airplane-seat-assignment-probability/README.md b/problems/airplane-seat-assignment-probability/README.md index 7c3ce83cd..27e58d0cf 100644 --- a/problems/airplane-seat-assignment-probability/README.md +++ b/problems/airplane-seat-assignment-probability/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-dining-philosophers "The Dining Philosophers") 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 e225d4dce..e57869f6d 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-parking-system "Design Parking System") diff --git a/problems/alien-dictionary/README.md b/problems/alien-dictionary/README.md index a54c21b2e..4c7fde95a 100644 --- a/problems/alien-dictionary/README.md +++ b/problems/alien-dictionary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../missing-number "Missing Number") diff --git a/problems/all-elements-in-two-binary-search-trees/README.md b/problems/all-elements-in-two-binary-search-trees/README.md index bcefb8caf..3489830b3 100644 --- a/problems/all-elements-in-two-binary-search-trees/README.md +++ b/problems/all-elements-in-two-binary-search-trees/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-n-unique-integers-sum-up-to-zero "Find N Unique Integers Sum up to Zero") diff --git a/problems/all-people-report-to-the-given-manager/README.md b/problems/all-people-report-to-the-given-manager/README.md index 55c7ceec6..e5e7d006b 100644 --- a/problems/all-people-report-to-the-given-manager/README.md +++ b/problems/all-people-report-to-the-given-manager/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-stay-in-the-same-place-after-some-steps "Number of Ways to Stay in the Same Place After Some Steps") diff --git a/problems/all-possible-full-binary-trees/README.md b/problems/all-possible-full-binary-trees/README.md index 2ace2a85a..7d2cba86f 100644 --- a/problems/all-possible-full-binary-trees/README.md +++ b/problems/all-possible-full-binary-trees/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../groups-of-special-equivalent-strings "Groups of Special-Equivalent Strings") diff --git a/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md b/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md index e3b2a3f1f..85484c71c 100644 --- a/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md +++ b/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-of-minimum-values-in-all-subarrays "Maximum of Minimum Values in All Subarrays") diff --git a/problems/all-valid-triplets-that-can-represent-a-country/README.md b/problems/all-valid-triplets-that-can-represent-a-country/README.md index ced73e063..30cf0bbaa 100644 --- a/problems/all-valid-triplets-that-can-represent-a-country/README.md +++ b/problems/all-valid-triplets-that-can-represent-a-country/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fancy-sequence "Fancy Sequence") diff --git a/problems/alphabet-board-path/README.md b/problems/alphabet-board-path/README.md index c5062fab4..6a4c93f65 100644 --- a/problems/alphabet-board-path/README.md +++ b/problems/alphabet-board-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../n-th-tribonacci-number "N-th Tribonacci Number") diff --git a/problems/angle-between-hands-of-a-clock/README.md b/problems/angle-between-hands-of-a-clock/README.md index 96ac413ee..a3bacec65 100644 --- a/problems/angle-between-hands-of-a-clock/README.md +++ b/problems/angle-between-hands-of-a-clock/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold") diff --git a/problems/apply-discount-every-n-orders/README.md b/problems/apply-discount-every-n-orders/README.md index 85a655178..d43de40f0 100644 --- a/problems/apply-discount-every-n-orders/README.md +++ b/problems/apply-discount-every-n-orders/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-integers-by-the-number-of-1-bits "Sort Integers by The Number of 1 Bits") diff --git a/problems/arithmetic-slices-ii-subsequence/README.md b/problems/arithmetic-slices-ii-subsequence/README.md index 642661dd7..8481d5223 100644 --- a/problems/arithmetic-slices-ii-subsequence/README.md +++ b/problems/arithmetic-slices-ii-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../add-two-numbers-ii "Add Two Numbers II") diff --git a/problems/arithmetic-slices/README.md b/problems/arithmetic-slices/README.md index eaed04793..90d411755 100644 --- a/problems/arithmetic-slices/README.md +++ b/problems/arithmetic-slices/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fizz-buzz "Fizz Buzz") @@ -51,3 +51,4 @@ ### Similar Questions 1. [Arithmetic Slices II - Subsequence](../arithmetic-slices-ii-subsequence) (Hard) + 1. [Arithmetic Subarrays](../arithmetic-subarrays) (Medium) diff --git a/problems/arithmetic-subarrays/README.md b/problems/arithmetic-subarrays/README.md index f2b1ee7f4..5c34778f3 100644 --- a/problems/arithmetic-subarrays/README.md +++ b/problems/arithmetic-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../slowest-key "Slowest Key") @@ -64,6 +64,10 @@ 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/arranging-coins/README.md b/problems/arranging-coins/README.md index 0c3efdf6d..57ce5aa46 100644 --- a/problems/arranging-coins/README.md +++ b/problems/arranging-coins/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../k-th-smallest-in-lexicographical-order "K-th Smallest in Lexicographical Order") diff --git a/problems/array-nesting/README.md b/problems/array-nesting/README.md index 977d14105..8d0be2a7b 100644 --- a/problems/array-nesting/README.md +++ b/problems/array-nesting/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-closest-palindrome "Find the Closest Palindrome") diff --git a/problems/array-transformation/README.md b/problems/array-transformation/README.md index e691c4aaf..b4fcc4466 100644 --- a/problems/array-transformation/README.md +++ b/problems/array-transformation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../web-crawler-multithreaded "Web Crawler Multithreaded") diff --git a/problems/array-with-elements-not-equal-to-average-of-neighbors/README.md b/problems/array-with-elements-not-equal-to-average-of-neighbors/README.md index c74800b58..25d9d3c60 100644 --- a/problems/array-with-elements-not-equal-to-average-of-neighbors/README.md +++ b/problems/array-with-elements-not-equal-to-average-of-neighbors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-strings-that-appear-as-substrings-in-word "Number of Strings That Appear as Substrings in Word") diff --git a/problems/article-views-i/README.md b/problems/article-views-i/README.md index d7e60e148..8b68e333a 100644 --- a/problems/article-views-i/README.md +++ b/problems/article-views-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-chunked-palindrome-decomposition "Longest Chunked Palindrome Decomposition") diff --git a/problems/article-views-ii/README.md b/problems/article-views-ii/README.md index efc135214..49af2063a 100644 --- a/problems/article-views-ii/README.md +++ b/problems/article-views-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../article-views-i "Article Views I") diff --git a/problems/as-far-from-land-as-possible/README.md b/problems/as-far-from-land-as-possible/README.md index 904d2bf2a..f7b860658 100644 --- a/problems/as-far-from-land-as-possible/README.md +++ b/problems/as-far-from-land-as-possible/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-level-sum-of-a-binary-tree "Maximum Level Sum of a Binary Tree") diff --git a/problems/assign-cookies/README.md b/problems/assign-cookies/README.md index 15111acc7..b2899d806 100644 --- a/problems/assign-cookies/README.md +++ b/problems/assign-cookies/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../4sum-ii "4Sum II") @@ -46,6 +46,6 @@ You need to output 2. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/average-height-of-buildings-in-each-segment/README.md b/problems/average-height-of-buildings-in-each-segment/README.md index 6bfe8ad96..d47e0bd37 100644 --- a/problems/average-height-of-buildings-in-each-segment/README.md +++ b/problems/average-height-of-buildings-in-each-segment/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-subsequence-repeated-k-times "Longest Subsequence Repeated k Times") diff --git a/problems/average-of-levels-in-binary-tree/README.md b/problems/average-of-levels-in-binary-tree/README.md index 50e5c2181..aac5fb089 100644 --- a/problems/average-of-levels-in-binary-tree/README.md +++ b/problems/average-of-levels-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../exclusive-time-of-functions "Exclusive Time of Functions") diff --git a/problems/average-salary-departments-vs-company/README.md b/problems/average-salary-departments-vs-company/README.md index bd0d831f3..7e1bd353e 100644 --- a/problems/average-salary-departments-vs-company/README.md +++ b/problems/average-salary-departments-vs-company/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../second-degree-follower "Second Degree Follower") diff --git a/problems/average-salary-departments-vs-company/mysql_schemas.sql b/problems/average-salary-departments-vs-company/mysql_schemas.sql index ef2258ccd..3ab9ca94f 100644 --- a/problems/average-salary-departments-vs-company/mysql_schemas.sql +++ b/problems/average-salary-departments-vs-company/mysql_schemas.sql @@ -1,13 +1,13 @@ -Create table If Not Exists salary (id int, employee_id int, amount int, pay_date date); -Create table If Not Exists employee (employee_id int, department_id int); -Truncate table salary; -insert into salary (id, employee_id, amount, pay_date) values ('1', '1', '9000', '2017/03/31'); -insert into salary (id, employee_id, amount, pay_date) values ('2', '2', '6000', '2017/03/31'); -insert into salary (id, employee_id, amount, pay_date) values ('3', '3', '10000', '2017/03/31'); -insert into salary (id, employee_id, amount, pay_date) values ('4', '1', '7000', '2017/02/28'); -insert into salary (id, employee_id, amount, pay_date) values ('5', '2', '6000', '2017/02/28'); -insert into salary (id, employee_id, amount, pay_date) values ('6', '3', '8000', '2017/02/28'); -Truncate table employee; -insert into employee (employee_id, department_id) values ('1', '1'); -insert into employee (employee_id, department_id) values ('2', '2'); -insert into employee (employee_id, department_id) values ('3', '2'); +Create table If Not Exists Salary (id int, employee_id int, amount int, pay_date date); +Create table If Not Exists Employee (employee_id int, department_id int); +Truncate table Salary; +insert into Salary (id, employee_id, amount, pay_date) values ('1', '1', '9000', '2017/03/31'); +insert into Salary (id, employee_id, amount, pay_date) values ('2', '2', '6000', '2017/03/31'); +insert into Salary (id, employee_id, amount, pay_date) values ('3', '3', '10000', '2017/03/31'); +insert into Salary (id, employee_id, amount, pay_date) values ('4', '1', '7000', '2017/02/28'); +insert into Salary (id, employee_id, amount, pay_date) values ('5', '2', '6000', '2017/02/28'); +insert into Salary (id, employee_id, amount, pay_date) values ('6', '3', '8000', '2017/02/28'); +Truncate table Employee; +insert into Employee (employee_id, department_id) values ('1', '1'); +insert into Employee (employee_id, department_id) values ('2', '2'); +insert into Employee (employee_id, department_id) values ('3', '2'); diff --git a/problems/average-selling-price/README.md b/problems/average-selling-price/README.md index cb8de6089..2801a6793 100644 --- a/problems/average-selling-price/README.md +++ b/problems/average-selling-price/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-it-is-a-good-array "Check If It Is a Good Array") diff --git a/problems/average-time-of-process-per-machine/README.md b/problems/average-time-of-process-per-machine/README.md index ded7eb2f7..0a4023215 100644 --- a/problems/average-time-of-process-per-machine/README.md +++ b/problems/average-time-of-process-per-machine/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../correct-a-binary-tree "Correct a Binary Tree") diff --git a/problems/average-waiting-time/README.md b/problems/average-waiting-time/README.md index e176a9e09..ef5e69e93 100644 --- a/problems/average-waiting-time/README.md +++ b/problems/average-waiting-time/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-students-unable-to-eat-lunch "Number of Students Unable to Eat Lunch") @@ -61,6 +61,9 @@ 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 22fc685a0..a691b24b6 100644 --- a/problems/avoid-flood-in-the-city/README.md +++ b/problems/avoid-flood-in-the-city/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../making-file-names-unique "Making File Names Unique") diff --git a/problems/backspace-string-compare/README.md b/problems/backspace-string-compare/README.md index af13e23c9..d11ab235a 100644 --- a/problems/backspace-string-compare/README.md +++ b/problems/backspace-string-compare/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../guess-the-word "Guess the Word") diff --git a/problems/balance-a-binary-search-tree/README.md b/problems/balance-a-binary-search-tree/README.md index c224333b7..29cbd7b6c 100644 --- a/problems/balance-a-binary-search-tree/README.md +++ b/problems/balance-a-binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-a-stack-with-increment-operation "Design a Stack With Increment Operation") diff --git a/problems/balanced-binary-tree/README.md b/problems/balanced-binary-tree/README.md index 26e6aced1..22b4d5ef7 100644 --- a/problems/balanced-binary-tree/README.md +++ b/problems/balanced-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-sorted-list-to-binary-search-tree "Convert Sorted List to Binary Search Tree") diff --git a/problems/bank-account-summary-ii/README.md b/problems/bank-account-summary-ii/README.md index 07e5acb2a..485e97320 100644 --- a/problems/bank-account-summary-ii/README.md +++ b/problems/bank-account-summary-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-search-tree-iterator-ii "Binary Search Tree Iterator II") diff --git a/problems/bank-account-summary/README.md b/problems/bank-account-summary/README.md index 3c9ca5b4e..bbd146880 100644 --- a/problems/bank-account-summary/README.md +++ b/problems/bank-account-summary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strings-differ-by-one-character "Strings Differ by One Character") diff --git a/problems/beautiful-arrangement/README.md b/problems/beautiful-arrangement/README.md index f772c87c4..e9a44b8fa 100644 --- a/problems/beautiful-arrangement/README.md +++ b/problems/beautiful-arrangement/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../contiguous-array "Contiguous Array") @@ -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/beautiful-array/README.md b/problems/beautiful-array/README.md index 481b997ca..7d27947ad 100644 --- a/problems/beautiful-array/README.md +++ b/problems/beautiful-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-falling-path-sum "Minimum Falling Path Sum") diff --git a/problems/before-and-after-puzzle/README.md b/problems/before-and-after-puzzle/README.md index 61d1a4d67..24706b19c 100644 --- a/problems/before-and-after-puzzle/README.md +++ b/problems/before-and-after-puzzle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-substrings-with-only-one-distinct-letter "Count Substrings with Only One Distinct Letter") diff --git a/problems/best-position-for-a-service-centre/README.md b/problems/best-position-for-a-service-centre/README.md index 53dd69ad6..776cdd14f 100644 --- a/problems/best-position-for-a-service-centre/README.md +++ b/problems/best-position-for-a-service-centre/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-with-maximum-probability "Path with Maximum Probability") diff --git a/problems/best-sightseeing-pair/README.md b/problems/best-sightseeing-pair/README.md index da2981efc..2889a419e 100644 --- a/problems/best-sightseeing-pair/README.md +++ b/problems/best-sightseeing-pair/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-array-into-three-parts-with-equal-sum "Partition Array Into Three Parts With Equal Sum") diff --git a/problems/best-team-with-no-conflicts/README.md b/problems/best-team-with-no-conflicts/README.md index ec9b2440d..945122c01 100644 --- a/problems/best-team-with-no-conflicts/README.md +++ b/problems/best-team-with-no-conflicts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lexicographically-smallest-string-after-applying-operations "Lexicographically Smallest String After Applying Operations") diff --git a/problems/best-time-to-buy-and-sell-stock-ii/README.md b/problems/best-time-to-buy-and-sell-stock-ii/README.md index f30d6c5b1..2bd861814 100644 --- a/problems/best-time-to-buy-and-sell-stock-ii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-time-to-buy-and-sell-stock "Best Time to Buy and Sell Stock") @@ -54,9 +54,9 @@ Total profit is 4. ### 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](../best-time-to-buy-and-sell-stock) (Easy) 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 9224d5f41..198700c20 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-time-to-buy-and-sell-stock-ii "Best Time to Buy and Sell Stock II") diff --git a/problems/best-time-to-buy-and-sell-stock-iv/README.md b/problems/best-time-to-buy-and-sell-stock-iv/README.md index d9bf26f46..6bba064fd 100644 --- a/problems/best-time-to-buy-and-sell-stock-iv/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../repeated-dna-sequences "Repeated DNA Sequences") diff --git a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md index 328dcc1d1..1c8c2b76d 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../range-sum-query-2d-mutable "Range Sum Query 2D - Mutable") diff --git a/problems/biggest-window-between-visits/README.md b/problems/biggest-window-between-visits/README.md index 1403336f8..b6e868d16 100644 --- a/problems/biggest-window-between-visits/README.md +++ b/problems/biggest-window-between-visits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-subarray-length-k "Largest Subarray Length K") diff --git a/problems/binary-prefix-divisible-by-5/README.md b/problems/binary-prefix-divisible-by-5/README.md index 05535257d..15d409927 100644 --- a/problems/binary-prefix-divisible-by-5/README.md +++ b/problems/binary-prefix-divisible-by-5/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-to-base-2 "Convert to Base -2") diff --git a/problems/binary-search-tree-iterator-ii/README.md b/problems/binary-search-tree-iterator-ii/README.md index db41437d7..b4e7ca01b 100644 --- a/problems/binary-search-tree-iterator-ii/README.md +++ b/problems/binary-search-tree-iterator-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-string-is-transformable-with-substring-sort-operations "Check If String Is Transformable With Substring Sort Operations") @@ -21,9 +21,6 @@ [[Binary Tree](../../tag/binary-tree/README.md)] [[Iterator](../../tag/iterator/README.md)] -### Similar Questions - 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) - ### Hints
Hint 1 diff --git a/problems/binary-search/README.md b/problems/binary-search/README.md index 551d40e5b..782afcd83 100644 --- a/problems/binary-search/README.md +++ b/problems/binary-search/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-largest-element-in-a-stream "Kth Largest Element in a Stream") 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 36df24998..456b220f6 100644 --- a/problems/binary-searchable-numbers-in-an-unsorted-array/README.md +++ b/problems/binary-searchable-numbers-in-an-unsorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../employees-with-missing-information "Employees With Missing Information") diff --git a/problems/binary-tree-coloring-game/README.md b/problems/binary-tree-coloring-game/README.md index dedbfdff1..d1f3a7289 100644 --- a/problems/binary-tree-coloring-game/README.md +++ b/problems/binary-tree-coloring-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decrease-elements-to-make-array-zigzag "Decrease Elements To Make Array Zigzag") diff --git a/problems/binary-tree-level-order-traversal-ii/README.md b/problems/binary-tree-level-order-traversal-ii/README.md index 0bd7a20bc..4cf8b3360 100644 --- a/problems/binary-tree-level-order-traversal-ii/README.md +++ b/problems/binary-tree-level-order-traversal-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-tree-from-inorder-and-postorder-traversal "Construct Binary Tree from Inorder and Postorder Traversal") diff --git a/problems/binary-tree-longest-consecutive-sequence-ii/README.md b/problems/binary-tree-longest-consecutive-sequence-ii/README.md index 9c5dc7996..04a3c7e03 100644 --- a/problems/binary-tree-longest-consecutive-sequence-ii/README.md +++ b/problems/binary-tree-longest-consecutive-sequence-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-array-with-equal-sum "Split Array with Equal Sum") diff --git a/problems/binary-tree-longest-consecutive-sequence/README.md b/problems/binary-tree-longest-consecutive-sequence/README.md index 0e25f7869..555757df4 100644 --- a/problems/binary-tree-longest-consecutive-sequence/README.md +++ b/problems/binary-tree-longest-consecutive-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../serialize-and-deserialize-binary-tree "Serialize and Deserialize Binary Tree") diff --git a/problems/binary-tree-paths/README.md b/problems/binary-tree-paths/README.md index d91fa309d..7d34b50d0 100644 --- a/problems/binary-tree-paths/README.md +++ b/problems/binary-tree-paths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../paint-house "Paint House") diff --git a/problems/binary-tree-vertical-order-traversal/README.md b/problems/binary-tree-vertical-order-traversal/README.md index b8069f38e..860aab5be 100644 --- a/problems/binary-tree-vertical-order-traversal/README.md +++ b/problems/binary-tree-vertical-order-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../super-ugly-number "Super Ugly Number") diff --git a/problems/binary-watch/README.md b/problems/binary-watch/README.md index d0157a61c..032afb9af 100644 --- a/problems/binary-watch/README.md +++ b/problems/binary-watch/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nth-digit "Nth Digit") diff --git a/problems/bitwise-ors-of-subarrays/README.md b/problems/bitwise-ors-of-subarrays/README.md index b86c8a8a0..1bc3dc5b0 100644 --- a/problems/bitwise-ors-of-subarrays/README.md +++ b/problems/bitwise-ors-of-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../increasing-order-search-tree "Increasing Order Search Tree") @@ -53,6 +53,6 @@ There are 3 unique values, so the answer is 3. ### 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)] diff --git a/problems/bomb-enemy/README.md b/problems/bomb-enemy/README.md index 392e525ad..d4e476cea 100644 --- a/problems/bomb-enemy/README.md +++ b/problems/bomb-enemy/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-transformed-array "Sort Transformed Array") diff --git a/problems/brace-expansion-ii/README.md b/problems/brace-expansion-ii/README.md index fa56a935b..b5dea6de0 100644 --- a/problems/brace-expansion-ii/README.md +++ b/problems/brace-expansion-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-in-mountain-array "Find in Mountain Array") @@ -11,9 +11,9 @@ ## [1096. Brace Expansion II (Hard)](https://leetcode.com/problems/brace-expansion-ii "花括号展开 II") -

Under the grammar given below, strings can represent a set of lowercase words. Let's use R(expr) to denote the set of words the expression represents.

+

Under the grammar given below, strings can represent a set of lowercase words. Let R(expr) denote the set of words the expression represents.

-

Grammar can best be understood through simple examples:

+

The grammar can best be understood through simple examples:

  • Single letters represent a singleton set containing that word. @@ -25,7 +25,7 @@
  • When we take a comma-delimited list of two or more expressions, we take the union of possibilities.
    • R("{a,b,c}") = {"a","b","c"}
    • -
    • R("{{a,b},{b,c}}") = {"a","b","c"} (notice the final set only contains each word at most once)
    • +
    • R("{{a,b},{b,c}}") = {"a","b","c"} (notice the final set only contains each word at most once)
  • When we concatenate two expressions, we take the set of possible concatenations between two words where the first word comes from the first expression and the second word comes from the second expression. @@ -72,10 +72,10 @@
### Related Topics - [[Stack](../../tag/stack/README.md)] - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Similar Questions 1. [Brace Expansion](../brace-expansion) (Medium) diff --git a/problems/brace-expansion/README.md b/problems/brace-expansion/README.md index 29a57fa5b..7aec2e852 100644 --- a/problems/brace-expansion/README.md +++ b/problems/brace-expansion/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../high-five "High Five") diff --git a/problems/break-a-palindrome/README.md b/problems/break-a-palindrome/README.md index 822edba2f..a6d34289d 100644 --- a/problems/break-a-palindrome/README.md +++ b/problems/break-a-palindrome/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../list-the-products-ordered-in-a-period "List the Products Ordered in a Period") diff --git a/problems/brick-wall/README.md b/problems/brick-wall/README.md index 350f76c73..252c2432c 100644 --- a/problems/brick-wall/README.md +++ b/problems/brick-wall/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../optimal-division "Optimal Division") diff --git a/problems/bricks-falling-when-hit/README.md b/problems/bricks-falling-when-hit/README.md index cc73a4f95..9720c2f60 100644 --- a/problems/bricks-falling-when-hit/README.md +++ b/problems/bricks-falling-when-hit/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-eventual-safe-states "Find Eventual Safe States") diff --git a/problems/brightest-position-on-street/README.md b/problems/brightest-position-on-street/README.md index 9c4a0ba90..cf9a10f81 100644 --- a/problems/brightest-position-on-street/README.md +++ b/problems/brightest-position-on-street/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-accounts-that-did-not-stream "Number of Accounts That Did Not Stream") diff --git a/problems/build-array-from-permutation/README.md b/problems/build-array-from-permutation/README.md index 9216a4a8d..e72aa6eb5 100644 --- a/problems/build-array-from-permutation/README.md +++ b/problems/build-array-from-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../leetcodify-similar-friends "Leetcodify Similar Friends") diff --git a/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md b/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md index 9b129e918..a375d8613 100644 --- a/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md +++ b/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-frogs-croaking "Minimum Number of Frogs Croaking") 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 c6bd15cd5..fc0ee4558 100644 --- a/problems/build-binary-expression-tree-from-infix-expression/README.md +++ b/problems/build-binary-expression-tree-from-infix-expression/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-most-frequently-ordered-products-for-each-customer "The Most Frequently Ordered Products for Each Customer") @@ -14,15 +14,11 @@ ### 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/building-boxes/README.md b/problems/building-boxes/README.md index f00a11199..55d42ffd8 100644 --- a/problems/building-boxes/README.md +++ b/problems/building-boxes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-kth-largest-xor-coordinate-value "Find Kth Largest XOR Coordinate Value") @@ -61,9 +61,9 @@ These boxes are placed in the corner of the room, where the corner is on the bac ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Hints
diff --git a/problems/building-h2o/README.md b/problems/building-h2o/README.md index b0f6efc6f..a449643cb 100644 --- a/problems/building-h2o/README.md +++ b/problems/building-h2o/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../print-zero-even-odd "Print Zero Even Odd") diff --git a/problems/buildings-with-an-ocean-view/README.md b/problems/buildings-with-an-ocean-view/README.md index 1f3707e3f..37792f25e 100644 --- a/problems/buildings-with-an-ocean-view/README.md +++ b/problems/buildings-with-an-ocean-view/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-degree-of-a-connected-trio-in-a-graph "Minimum Degree of a Connected Trio in a Graph") diff --git a/problems/bulb-switcher-iv/README.md b/problems/bulb-switcher-iv/README.md index e3b0c4601..dfaa2dd4f 100644 --- a/problems/bulb-switcher-iv/README.md +++ b/problems/bulb-switcher-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shuffle-string "Shuffle String") diff --git a/problems/bus-routes/README.md b/problems/bus-routes/README.md index 547aa9852..8be99bf69 100644 --- a/problems/bus-routes/README.md +++ b/problems/bus-routes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-pruning "Binary Tree Pruning") diff --git a/problems/calculate-money-in-leetcode-bank/README.md b/problems/calculate-money-in-leetcode-bank/README.md index 625ae8730..7f70f38b2 100644 --- a/problems/calculate-money-in-leetcode-bank/README.md +++ b/problems/calculate-money-in-leetcode-bank/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-apples-and-oranges "Count Apples and Oranges") diff --git a/problems/calculate-special-bonus/README.md b/problems/calculate-special-bonus/README.md index 40fc4b72f..1fdb4c0d3 100644 --- a/problems/calculate-special-bonus/README.md +++ b/problems/calculate-special-bonus/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-viii "Stone Game VIII") diff --git a/problems/can-convert-string-in-k-moves/README.md b/problems/can-convert-string-in-k-moves/README.md index a30659677..38ce7036e 100644 --- a/problems/can-convert-string-in-k-moves/README.md +++ b/problems/can-convert-string-in-k-moves/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-missing-positive-number "Kth Missing Positive Number") diff --git a/problems/can-make-arithmetic-progression-from-sequence/README.md b/problems/can-make-arithmetic-progression-from-sequence/README.md index 3a893b278..92f0cbc72 100644 --- a/problems/can-make-arithmetic-progression-from-sequence/README.md +++ b/problems/can-make-arithmetic-progression-from-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../countries-you-can-safely-invest-in "Countries You Can Safely Invest In") diff --git a/problems/can-make-palindrome-from-substring/README.md b/problems/can-make-palindrome-from-substring/README.md index 11caade72..e8a95283e 100644 --- a/problems/can-make-palindrome-from-substring/README.md +++ b/problems/can-make-palindrome-from-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../diet-plan-performance "Diet Plan Performance") @@ -51,11 +51,14 @@ 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/can-place-flowers/README.md b/problems/can-place-flowers/README.md index 8833ed008..2cf0c8bdd 100644 --- a/problems/can-place-flowers/README.md +++ b/problems/can-place-flowers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-compressed-string-iterator "Design Compressed String Iterator") @@ -34,8 +34,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Teemo Attacking](../teemo-attacking) (Easy) diff --git a/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md b/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md index 8aeb288b6..ea7291af7 100644 --- a/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md +++ b/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../restore-the-array-from-adjacent-pairs "Restore the Array From Adjacent Pairs") 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 68f6563bb..b2df14c7d 100644 --- a/problems/capacity-to-ship-packages-within-d-days/README.md +++ b/problems/capacity-to-ship-packages-within-d-days/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../pairs-of-songs-with-total-durations-divisible-by-60 "Pairs of Songs With Total Durations Divisible by 60") @@ -65,9 +65,15 @@ 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/car-fleet-ii/README.md b/problems/car-fleet-ii/README.md index cae3f8577..dda2040c2 100644 --- a/problems/car-fleet-ii/README.md +++ b/problems/car-fleet-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../equal-sum-arrays-with-minimum-number-of-operations "Equal Sum Arrays With Minimum Number of Operations") @@ -48,14 +48,11 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/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) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
diff --git a/problems/card-flipping-game/README.md b/problems/card-flipping-game/README.md index 4f080e4ff..90ae2335a 100644 --- a/problems/card-flipping-game/README.md +++ b/problems/card-flipping-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-distance-to-a-character "Shortest Distance to a Character") diff --git a/problems/cat-and-mouse-ii/README.md b/problems/cat-and-mouse-ii/README.md index 7935c07ae..1163fd2b3 100644 --- a/problems/cat-and-mouse-ii/README.md +++ b/problems/cat-and-mouse-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-submatrix-with-rearrangements "Largest Submatrix With Rearrangements") diff --git a/problems/cells-with-odd-values-in-a-matrix/README.md b/problems/cells-with-odd-values-in-a-matrix/README.md index 3b170b034..b8fc0de26 100644 --- a/problems/cells-with-odd-values-in-a-matrix/README.md +++ b/problems/cells-with-odd-values-in-a-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-selling-price "Average Selling Price") diff --git a/problems/chalkboard-xor-game/README.md b/problems/chalkboard-xor-game/README.md index f1199e2d4..b3e8c6744 100644 --- a/problems/chalkboard-xor-game/README.md +++ b/problems/chalkboard-xor-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../expressive-words "Expressive Words") @@ -54,8 +54,8 @@ If Alice erases 2 first, now nums become [1, 1]. The bitwise XOR of all the elem ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Brainteaser](../../tag/brainteaser/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] [[Game Theory](../../tag/game-theory/README.md)] diff --git a/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md b/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md index 1782e05bd..98008661a 100644 --- a/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md +++ b/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../latest-time-by-replacing-hidden-digits "Latest Time by Replacing Hidden Digits") diff --git a/problems/change-the-root-of-a-binary-tree/README.md b/problems/change-the-root-of-a-binary-tree/README.md index abde09cc9..532482af4 100644 --- a/problems/change-the-root-of-a-binary-tree/README.md +++ b/problems/change-the-root-of-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-initial-energy-to-finish-tasks "Minimum Initial Energy to Finish Tasks") diff --git a/problems/check-array-formation-through-concatenation/README.md b/problems/check-array-formation-through-concatenation/README.md index 26c5480c2..d010e77ab 100644 --- a/problems/check-array-formation-through-concatenation/README.md +++ b/problems/check-array-formation-through-concatenation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-form-a-target-string-given-a-dictionary "Number of Ways to Form a Target String Given a Dictionary") diff --git a/problems/check-completeness-of-a-binary-tree/README.md b/problems/check-completeness-of-a-binary-tree/README.md index d4f4f8b39..e6538cb8f 100644 --- a/problems/check-completeness-of-a-binary-tree/README.md +++ b/problems/check-completeness-of-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../prison-cells-after-n-days "Prison Cells After N Days") diff --git a/problems/check-if-a-string-can-break-another-string/README.md b/problems/check-if-a-string-can-break-another-string/README.md index 47a04fa96..967b846b1 100644 --- a/problems/check-if-a-string-can-break-another-string/README.md +++ b/problems/check-if-a-string-can-break-another-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-difference-you-can-get-from-changing-an-integer "Max Difference You Can Get From Changing an Integer") @@ -50,8 +50,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints 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 bf477e1ad..d33963e44 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-common-subsequence-between-sorted-arrays "Longest Common Subsequence Between Sorted Arrays") diff --git a/problems/check-if-all-the-integers-in-a-range-are-covered/README.md b/problems/check-if-all-the-integers-in-a-range-are-covered/README.md index b8d20d0f6..d12d6aad3 100644 --- a/problems/check-if-all-the-integers-in-a-range-are-covered/README.md +++ b/problems/check-if-all-the-integers-in-a-range-are-covered/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../page-recommendations-ii "Page Recommendations II") 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 028c57844..ce29c124c 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-operations-to-convert-number "Minimum Operations to Convert Number") 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 cf7fd74e0..f10753e75 100644 --- a/problems/check-if-array-is-sorted-and-rotated/README.md +++ b/problems/check-if-array-is-sorted-and-rotated/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-events-that-can-be-attended-ii "Maximum Number of Events That Can Be Attended II") 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 a904e7a19..729dfd51c 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-crossing "Path Crossing") 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 d2e2de0b9..1306dc3e1 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../grand-slam-titles "Grand Slam Titles") diff --git a/problems/check-if-it-is-a-good-array/README.md b/problems/check-if-it-is-a-good-array/README.md index c25acbf33..289c87eae 100644 --- a/problems/check-if-it-is-a-good-array/README.md +++ b/problems/check-if-it-is-a-good-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-remove-to-make-valid-parentheses "Minimum Remove to Make Valid Parentheses") diff --git a/problems/check-if-move-is-legal/README.md b/problems/check-if-move-is-legal/README.md index 9d7c0f21c..026618369 100644 --- a/problems/check-if-move-is-legal/README.md +++ b/problems/check-if-move-is-legal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-characters-to-make-fancy-string "Delete Characters to Make Fancy String") diff --git a/problems/check-if-number-is-a-sum-of-powers-of-three/README.md b/problems/check-if-number-is-a-sum-of-powers-of-three/README.md index f8170ffb3..85e10f36c 100644 --- a/problems/check-if-number-is-a-sum-of-powers-of-three/README.md +++ b/problems/check-if-number-is-a-sum-of-powers-of-three/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-nearest-point-that-has-the-same-x-or-y-coordinate "Find Nearest Point That Has the Same X or Y Coordinate") @@ -49,9 +49,6 @@ ### Related Topics [[Math](../../tag/math/README.md)] -### Similar Questions - 1. [Power of Three](../power-of-three) (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 c74e2a063..7c77fe501 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../accepted-candidates-from-the-interviews "Accepted Candidates From the Interviews") 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 a328452f3..d278fdcd0 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../primary-department-for-each-employee "Primary Department for Each Employee") @@ -61,9 +61,6 @@ [[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-a-prefix-of-array/README.md b/problems/check-if-string-is-a-prefix-of-array/README.md index 05ac3e98c..9bf0c41d0 100644 --- a/problems/check-if-string-is-a-prefix-of-array/README.md +++ b/problems/check-if-string-is-a-prefix-of-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-of-the-length-of-two-palindromic-substrings "Maximum Product of the Length of Two Palindromic Substrings") diff --git a/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md b/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md index f15f0c542..e984f649b 100644 --- a/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md +++ b/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-bsts-to-create-single-bst "Merge BSTs to Create Single BST") 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 1b332b52c..439964b1e 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../min-cost-to-connect-all-points "Min Cost to Connect All Points") diff --git a/problems/check-if-the-sentence-is-pangram/README.md b/problems/check-if-the-sentence-is-pangram/README.md index 21b9fe963..c937655c0 100644 --- a/problems/check-if-the-sentence-is-pangram/README.md +++ b/problems/check-if-the-sentence-is-pangram/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-transaction-each-day "Maximum Transaction Each Day") diff --git a/problems/check-if-two-expression-trees-are-equivalent/README.md b/problems/check-if-two-expression-trees-are-equivalent/README.md index cc128802b..c25f72b60 100644 --- a/problems/check-if-two-expression-trees-are-equivalent/README.md +++ b/problems/check-if-two-expression-trees-are-equivalent/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-one-bit-operations-to-make-integers-zero "Minimum One Bit Operations to Make Integers Zero") diff --git a/problems/check-if-two-string-arrays-are-equivalent/README.md b/problems/check-if-two-string-arrays-are-equivalent/README.md index f06c09fce..4a4b7f734 100644 --- a/problems/check-if-two-string-arrays-are-equivalent/README.md +++ b/problems/check-if-two-string-arrays-are-equivalent/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-time-of-process-per-machine "Average Time of Process per Machine") @@ -54,9 +54,6 @@ The strings are the same, so return true. [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Check if an Original String Exists Given Two Encoded Strings](../check-if-an-original-string-exists-given-two-encoded-strings) (Hard) - ### Hints
Hint 1 diff --git a/problems/check-if-word-can-be-placed-in-crossword/README.md b/problems/check-if-word-can-be-placed-in-crossword/README.md index e747c109d..b67375a41 100644 --- a/problems/check-if-word-can-be-placed-in-crossword/README.md +++ b/problems/check-if-word-can-be-placed-in-crossword/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../grid-game "Grid Game") diff --git a/problems/check-if-word-equals-summation-of-two-words/README.md b/problems/check-if-word-equals-summation-of-two-words/README.md index 72644c446..65bbc3074 100644 --- a/problems/check-if-word-equals-summation-of-two-words/README.md +++ b/problems/check-if-word-equals-summation-of-two-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-xor-sum-of-two-arrays "Minimum XOR Sum of Two Arrays") diff --git a/problems/check-whether-two-strings-are-almost-equivalent/README.md b/problems/check-whether-two-strings-are-almost-equivalent/README.md index fc14405ad..00b1bcd6e 100644 --- a/problems/check-whether-two-strings-are-almost-equivalent/README.md +++ b/problems/check-whether-two-strings-are-almost-equivalent/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-equal-count-substrings "Number of Equal Count Substrings") diff --git a/problems/checking-existence-of-edge-length-limited-paths-ii/README.md b/problems/checking-existence-of-edge-length-limited-paths-ii/README.md index 521244d38..c1bdb7548 100644 --- a/problems/checking-existence-of-edge-length-limited-paths-ii/README.md +++ b/problems/checking-existence-of-edge-length-limited-paths-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-minimum-time-to-finish-all-jobs "Find Minimum Time to Finish All Jobs") @@ -18,9 +18,6 @@ [[Graph](../../tag/graph/README.md)] [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] -### Similar Questions - 1. [Checking Existence of Edge Length Limited Paths](../checking-existence-of-edge-length-limited-paths) (Hard) - ### Hints
Hint 1 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 a7972ea78..86f617a92 100644 --- a/problems/checking-existence-of-edge-length-limited-paths/README.md +++ b/problems/checking-existence-of-edge-length-limited-paths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game-vi "Jump Game VI") @@ -52,11 +52,14 @@ 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 647727cdc..0dac251a8 100644 --- a/problems/cherry-pickup-ii/README.md +++ b/problems/cherry-pickup-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../course-schedule-iv "Course Schedule IV") diff --git a/problems/cinema-seat-allocation/README.md b/problems/cinema-seat-allocation/README.md index 7f0fefe93..b08c37802 100644 --- a/problems/cinema-seat-allocation/README.md +++ b/problems/cinema-seat-allocation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-distance-value-between-two-arrays "Find the Distance Value Between Two Arrays") @@ -57,10 +57,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/circle-and-rectangle-overlapping/README.md b/problems/circle-and-rectangle-overlapping/README.md index edda53622..3f115e148 100644 --- a/problems/circle-and-rectangle-overlapping/README.md +++ b/problems/circle-and-rectangle-overlapping/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-k-palindrome-strings "Construct K Palindrome Strings") @@ -64,8 +64,8 @@ ### Related Topics - [[Math](../../tag/math/README.md)] [[Geometry](../../tag/geometry/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/circular-array-loop/README.md b/problems/circular-array-loop/README.md index 3d67613c6..48326bf27 100644 --- a/problems/circular-array-loop/README.md +++ b/problems/circular-array-loop/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../132-pattern "132 Pattern") diff --git a/problems/classes-more-than-5-students/README.md b/problems/classes-more-than-5-students/README.md index f2c545b0c..4f131c182 100644 --- a/problems/classes-more-than-5-students/README.md +++ b/problems/classes-more-than-5-students/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../big-countries "Big Countries") @@ -11,42 +11,58 @@ ## [596. Classes More Than 5 Students (Easy)](https://leetcode.com/problems/classes-more-than-5-students "超过5名学生的课") -

There is a table courses with columns: student and class

- -

Please list out all classes which have more than or equal to 5 students.

- -

For example, the table:

+

Table: Courses

-+---------+------------+
-| student | class      |
-+---------+------------+
-| A       | Math       |
-| B       | English    |
-| C       | Math       |
-| D       | Biology    |
-| E       | Math       |
-| F       | Computer   |
-| G       | Math       |
-| H       | Math       |
-| I       | Math       |
-+---------+------------+
++-------------+---------+
+| Column Name | Type    |
++-------------+---------+
+| student     | varchar |
+| class       | varchar |
++-------------+---------+
+(student, class) is the primary key column for this table.
+Each row of this table indicates the name of a student and the class in which they are enrolled.
 
-

Should output:

+

 

+ +

Write an SQL query to report all the classes that have at least five students.

+ +

Return the result table in any order.

+ +

The query result format is in the following example.

+ +

 

+

Example 1:

+Input: 
+Courses table:
++---------+----------+
+| student | class    |
++---------+----------+
+| A       | Math     |
+| B       | English  |
+| C       | Math     |
+| D       | Biology  |
+| E       | Math     |
+| F       | Computer |
+| G       | Math     |
+| H       | Math     |
+| I       | Math     |
++---------+----------+
+Output: 
 +---------+
 | class   |
 +---------+
 | Math    |
 +---------+
+Explanation: 
+- Math has 6 students, so we include it.
+- English has 1 student, so we do not include it.
+- Biology has 1 student, so we do not include it.
+- Computer has 1 student, so we do not include it.
 
-

 

- -

Note:
-The students should not be counted duplicate in each course.

- ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/classes-more-than-5-students/mysql_schemas.sql b/problems/classes-more-than-5-students/mysql_schemas.sql index f0d0ac7e3..b063c3153 100644 --- a/problems/classes-more-than-5-students/mysql_schemas.sql +++ b/problems/classes-more-than-5-students/mysql_schemas.sql @@ -1,11 +1,11 @@ -Create table If Not Exists courses (student varchar(255), class varchar(255)); -Truncate table courses; -insert into courses (student, class) values ('A', 'Math'); -insert into courses (student, class) values ('B', 'English'); -insert into courses (student, class) values ('C', 'Math'); -insert into courses (student, class) values ('D', 'Biology'); -insert into courses (student, class) values ('E', 'Math'); -insert into courses (student, class) values ('F', 'Computer'); -insert into courses (student, class) values ('G', 'Math'); -insert into courses (student, class) values ('H', 'Math'); -insert into courses (student, class) values ('I', 'Math'); +Create table If Not Exists Courses (student varchar(255), class varchar(255)); +Truncate table Courses; +insert into Courses (student, class) values ('A', 'Math'); +insert into Courses (student, class) values ('B', 'English'); +insert into Courses (student, class) values ('C', 'Math'); +insert into Courses (student, class) values ('D', 'Biology'); +insert into Courses (student, class) values ('E', 'Math'); +insert into Courses (student, class) values ('F', 'Computer'); +insert into Courses (student, class) values ('G', 'Math'); +insert into Courses (student, class) values ('H', 'Math'); +insert into Courses (student, class) values ('I', 'Math'); diff --git a/problems/climbing-stairs/README.md b/problems/climbing-stairs/README.md index 09fbeff5f..5a7ddf992 100644 --- a/problems/climbing-stairs/README.md +++ b/problems/climbing-stairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sqrtx "Sqrt(x)") @@ -45,9 +45,9 @@ ### Related Topics - [[Memoization](../../tag/memoization/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Memoization](../../tag/memoization/README.md)] ### Similar Questions 1. [Min Cost Climbing Stairs](../min-cost-climbing-stairs) (Easy) diff --git a/problems/clone-graph/README.md b/problems/clone-graph/README.md index 9ba5fa989..4c7683c89 100644 --- a/problems/clone-graph/README.md +++ b/problems/clone-graph/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindrome-partitioning-ii "Palindrome Partitioning II") @@ -82,12 +82,10 @@ class Node { ### Related Topics - [[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)] [[Graph](../../tag/graph/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Copy List with Random Pointer](../copy-list-with-random-pointer) (Medium) - 1. [Clone Binary Tree With Random Pointer](../clone-binary-tree-with-random-pointer) (Medium) - 1. [Clone N-ary Tree](../clone-n-ary-tree) (Medium) diff --git a/problems/closest-binary-search-tree-value/README.md b/problems/closest-binary-search-tree-value/README.md index 0153f8003..e1c3da73f 100644 --- a/problems/closest-binary-search-tree-value/README.md +++ b/problems/closest-binary-search-tree-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../alien-dictionary "Alien Dictionary") diff --git a/problems/closest-dessert-cost/README.md b/problems/closest-dessert-cost/README.md index e3526bff9..82b8f7617 100644 --- a/problems/closest-dessert-cost/README.md +++ b/problems/closest-dessert-cost/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-items-matching-a-rule "Count Items Matching a Rule") diff --git a/problems/closest-leaf-in-a-binary-tree/README.md b/problems/closest-leaf-in-a-binary-tree/README.md index eb7a99ca0..417cfb5a6 100644 --- a/problems/closest-leaf-in-a-binary-tree/README.md +++ b/problems/closest-leaf-in-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cherry-pickup "Cherry Pickup") diff --git a/problems/closest-room/README.md b/problems/closest-room/README.md index cfbce9e63..6b25587c4 100644 --- a/problems/closest-room/README.md +++ b/problems/closest-room/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-element-after-decreasing-and-rearranging "Maximum Element After Decreasing and Rearranging") diff --git a/problems/closest-subsequence-sum/README.md b/problems/closest-subsequence-sum/README.md index 08560e3fa..1f41fe465 100644 --- a/problems/closest-subsequence-sum/README.md +++ b/problems/closest-subsequence-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-merge-of-two-strings "Largest Merge Of Two Strings") @@ -55,16 +55,12 @@ The absolute difference is abs(-4 - (-5)) = abs(1) = 1, which is the minimum. ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] -### Similar Questions - 1. [Minimize the Difference Between Target and Chosen Elements](../minimize-the-difference-between-target-and-chosen-elements) (Medium) - 1. [Partition Array Into Two Arrays to Minimize Sum Difference](../partition-array-into-two-arrays-to-minimize-sum-difference) (Hard) - ### Hints
Hint 1 diff --git a/problems/clumsy-factorial/README.md b/problems/clumsy-factorial/README.md index 0d81c8f41..b6ca2e085 100644 --- a/problems/clumsy-factorial/README.md +++ b/problems/clumsy-factorial/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-sum-of-array-after-k-negations "Maximize Sum Of Array After K Negations") diff --git a/problems/coin-path/README.md b/problems/coin-path/README.md index ae439b41f..35ef5334b 100644 --- a/problems/coin-path/README.md +++ b/problems/coin-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../print-binary-tree "Print Binary Tree") diff --git a/problems/coloring-a-border/README.md b/problems/coloring-a-border/README.md index cd71bfc1e..9ab6ec39b 100644 --- a/problems/coloring-a-border/README.md +++ b/problems/coloring-a-border/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../moving-stones-until-consecutive "Moving Stones Until Consecutive") diff --git a/problems/combination-sum-iii/README.md b/problems/combination-sum-iii/README.md index 1a42716e4..4f08564db 100644 --- a/problems/combination-sum-iii/README.md +++ b/problems/combination-sum-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-largest-element-in-an-array "Kth Largest Element in an Array") diff --git a/problems/combinations/README.md b/problems/combinations/README.md index 5fefaef75..c9bdd2fba 100644 --- a/problems/combinations/README.md +++ b/problems/combinations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-window-substring "Minimum Window Substring") diff --git a/problems/combine-two-tables/README.md b/problems/combine-two-tables/README.md index 905d39ec6..f507a1bf4 100644 --- a/problems/combine-two-tables/README.md +++ b/problems/combine-two-tables/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../dungeon-game "Dungeon Game") diff --git a/problems/compare-strings-by-frequency-of-the-smallest-character/README.md b/problems/compare-strings-by-frequency-of-the-smallest-character/README.md index 2be2ea622..faac7ff0d 100644 --- a/problems/compare-strings-by-frequency-of-the-smallest-character/README.md +++ b/problems/compare-strings-by-frequency-of-the-smallest-character/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../invalid-transactions "Invalid Transactions") diff --git a/problems/compare-version-numbers/README.md b/problems/compare-version-numbers/README.md index 3a5f430e5..08840605a 100644 --- a/problems/compare-version-numbers/README.md +++ b/problems/compare-version-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-gap "Maximum Gap") diff --git a/problems/complex-number-multiplication/README.md b/problems/complex-number-multiplication/README.md index 7c224f346..7e9767ca2 100644 --- a/problems/complex-number-multiplication/README.md +++ b/problems/complex-number-multiplication/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-tree-from-string "Construct Binary Tree from String") diff --git a/problems/concatenation-of-array/README.md b/problems/concatenation-of-array/README.md index 0ad0358f5..1c3c142f7 100644 --- a/problems/concatenation-of-array/README.md +++ b/problems/concatenation-of-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-reach-destination-in-time "Minimum Cost to Reach Destination in Time") diff --git a/problems/concatenation-of-consecutive-binary-numbers/README.md b/problems/concatenation-of-consecutive-binary-numbers/README.md index abe11247d..1bd4d3bc7 100644 --- a/problems/concatenation-of-consecutive-binary-numbers/README.md +++ b/problems/concatenation-of-consecutive-binary-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-number-of-k-sum-pairs "Max Number of K-Sum Pairs") diff --git a/problems/confirmation-rate/README.md b/problems/confirmation-rate/README.md index ce3bac860..4f0f62c6c 100644 --- a/problems/confirmation-rate/README.md +++ b/problems/confirmation-rate/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-string-is-decomposable-into-value-equal-substrings "Check if String Is Decomposable Into Value-Equal Substrings") diff --git a/problems/confusing-number/README.md b/problems/confusing-number/README.md index 63070cfc9..2dab50cf9 100644 --- a/problems/confusing-number/README.md +++ b/problems/confusing-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-way-to-form-string "Shortest Way to Form String") diff --git a/problems/consecutive-numbers-sum/README.md b/problems/consecutive-numbers-sum/README.md index fd6213696..7eae4e37c 100644 --- a/problems/consecutive-numbers-sum/README.md +++ b/problems/consecutive-numbers-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-unique-characters-of-all-substrings-of-a-given-string "Count Unique Characters of All Substrings of a Given String") diff --git a/problems/consecutive-numbers/README.md b/problems/consecutive-numbers/README.md index 283045d24..9fc244819 100644 --- a/problems/consecutive-numbers/README.md +++ b/problems/consecutive-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-number "Largest Number") @@ -38,7 +38,7 @@ id is the primary key for this table. Input: Logs table: +----+-----+ -| Id | Num | +| id | num | +----+-----+ | 1 | 1 | | 2 | 1 | diff --git a/problems/consecutive-numbers/mysql_schemas.sql b/problems/consecutive-numbers/mysql_schemas.sql index ea8fd6816..0576b97dd 100644 --- a/problems/consecutive-numbers/mysql_schemas.sql +++ b/problems/consecutive-numbers/mysql_schemas.sql @@ -1,9 +1,9 @@ -Create table If Not Exists Logs (Id int, Num int); +Create table If Not Exists Logs (id int, num int); Truncate table Logs; -insert into Logs (Id, Num) values ('1', '1'); -insert into Logs (Id, Num) values ('2', '1'); -insert into Logs (Id, Num) values ('3', '1'); -insert into Logs (Id, Num) values ('4', '2'); -insert into Logs (Id, Num) values ('5', '1'); -insert into Logs (Id, Num) values ('6', '2'); -insert into Logs (Id, Num) values ('7', '2'); +insert into Logs (id, num) values ('1', '1'); +insert into Logs (id, num) values ('2', '1'); +insert into Logs (id, num) values ('3', '1'); +insert into Logs (id, num) values ('4', '2'); +insert into Logs (id, num) values ('5', '1'); +insert into Logs (id, num) values ('6', '2'); +insert into Logs (id, num) values ('7', '2'); diff --git a/problems/constrained-subsequence-sum/README.md b/problems/constrained-subsequence-sum/README.md index d11ec6674..007e5bc29 100644 --- a/problems/constrained-subsequence-sum/README.md +++ b/problems/constrained-subsequence-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../diagonal-traverse-ii "Diagonal Traverse II") @@ -49,12 +49,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)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] ### Hints
diff --git a/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md index 2ac7d5a8c..a9cb8e9ca 100644 --- a/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md +++ b/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-depth-of-binary-tree "Maximum Depth of Binary Tree") @@ -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-k-palindrome-strings/README.md b/problems/construct-k-palindrome-strings/README.md index 8b249b0a4..95c994cd8 100644 --- a/problems/construct-k-palindrome-strings/README.md +++ b/problems/construct-k-palindrome-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-largest-group "Count Largest Group") @@ -67,9 +67,9 @@ Some possible constructions "anna" + "elble", "anbna&qu ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[Counting](../../tag/counting/README.md)] ### Hints diff --git a/problems/construct-quad-tree/README.md b/problems/construct-quad-tree/README.md index 955215f0e..54e92d898 100644 --- a/problems/construct-quad-tree/README.md +++ b/problems/construct-quad-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-binary-search-tree-to-sorted-doubly-linked-list "Convert Binary Search Tree to Sorted Doubly Linked List") diff --git a/problems/construct-string-from-binary-tree/README.md b/problems/construct-string-from-binary-tree/README.md index da920e8d0..b1805ba12 100644 --- a/problems/construct-string-from-binary-tree/README.md +++ b/problems/construct-string-from-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../can-place-flowers "Can Place Flowers") @@ -11,7 +11,7 @@ ## [606. Construct String from Binary Tree (Easy)](https://leetcode.com/problems/construct-string-from-binary-tree "根据二叉树创建字符串") -

Given the root of a binary tree, construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way, and return it.

+

Given the root of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it.

Omit all the empty parenthesis pairs that do not affect the one-to-one mapping relationship between the string and the original binary tree.

@@ -21,7 +21,7 @@
 Input: root = [1,2,3,4]
 Output: "1(2(4))(3)"
-Explanation: Originallay it needs to be "1(2(4)())(3()())", but you need to omit all the unnecessary empty parenthesis pairs. And it will be "1(2(4))(3)"
+Explanation: Originally, it needs to be "1(2(4)())(3()())", but you need to omit all the unnecessary empty parenthesis pairs. And it will be "1(2(4))(3)"
 

Example 2:

@@ -29,7 +29,7 @@
 Input: root = [1,2,3,null,4]
 Output: "1(2()(4))(3)"
-Explanation: Almost the same as the first example, except we cannot omit the first parenthesis pair to break the one-to-one mapping relationship between the input and the output.
+Explanation: Almost the same as the first example, except we cannot omit the first parenthesis pair to break the one-to-one mapping relationship between the input and the output.
 

 

@@ -41,9 +41,9 @@ Explanation: Almost the same as the first example, except we cannot omit the fir ### 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/construct-target-array-with-multiple-sums/README.md b/problems/construct-target-array-with-multiple-sums/README.md index 3f029a70f..31a390147 100644 --- a/problems/construct-target-array-with-multiple-sums/README.md +++ b/problems/construct-target-array-with-multiple-sums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-events-that-can-be-attended "Maximum Number of Events That Can Be Attended") diff --git a/problems/construct-the-lexicographically-largest-valid-sequence/README.md b/problems/construct-the-lexicographically-largest-valid-sequence/README.md index c922c5bf7..7a7a64fd4 100644 --- a/problems/construct-the-lexicographically-largest-valid-sequence/README.md +++ b/problems/construct-the-lexicographically-largest-valid-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-score-from-removing-substrings "Maximum Score From Removing Substrings") diff --git a/problems/contain-virus/README.md b/problems/contain-virus/README.md index 5dfaf0c02..4771a9807 100644 --- a/problems/contain-virus/README.md +++ b/problems/contain-virus/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-completing-word "Shortest Completing Word") diff --git a/problems/contains-duplicate-iii/README.md b/problems/contains-duplicate-iii/README.md index ea57af0ca..ded15be9d 100644 --- a/problems/contains-duplicate-iii/README.md +++ b/problems/contains-duplicate-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../contains-duplicate-ii "Contains Duplicate II") @@ -36,10 +36,10 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] - [[Sorting](../../tag/sorting/README.md)] [[Bucket Sort](../../tag/bucket-sort/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Contains Duplicate](../contains-duplicate) (Easy) diff --git a/problems/contains-duplicate/README.md b/problems/contains-duplicate/README.md index 82e2e2365..ef9f2a2d2 100644 --- a/problems/contains-duplicate/README.md +++ b/problems/contains-duplicate/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../combination-sum-iii "Combination Sum III") diff --git a/problems/convert-1d-array-into-2d-array/README.md b/problems/convert-1d-array-into-2d-array/README.md index 923aab8fc..43070be5f 100644 --- a/problems/convert-1d-array-into-2d-array/README.md +++ b/problems/convert-1d-array-into-2d-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../brightest-position-on-street "Brightest Position on Street") diff --git a/problems/convert-bst-to-greater-tree/README.md b/problems/convert-bst-to-greater-tree/README.md index 03a2b8541..203b61449 100644 --- a/problems/convert-bst-to-greater-tree/README.md +++ b/problems/convert-bst-to-greater-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../complex-number-multiplication "Complex Number Multiplication") diff --git a/problems/convert-date-format/README.md b/problems/convert-date-format/README.md index 18ad540b6..3723629a4 100644 --- a/problems/convert-date-format/README.md +++ b/problems/convert-date-format/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distinct-numbers-in-each-subarray "Distinct Numbers in Each Subarray") 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 1d4bf848c..7f0be835b 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distinct-echo-substrings "Distinct Echo Substrings") 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 1a7403853..1a722bd23 100644 --- a/problems/convert-sorted-array-to-binary-search-tree/README.md +++ b/problems/convert-sorted-array-to-binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-level-order-traversal-ii "Binary Tree Level Order Traversal II") diff --git a/problems/convert-to-base-2/README.md b/problems/convert-to-base-2/README.md index 485e14739..93f9120b6 100644 --- a/problems/convert-to-base-2/README.md +++ b/problems/convert-to-base-2/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-string-with-substrings-representing-1-to-n "Binary String With Substrings Representing 1 To N") diff --git a/problems/convex-polygon/README.md b/problems/convex-polygon/README.md index b98a4161f..866c02f6d 100644 --- a/problems/convex-polygon/README.md +++ b/problems/convex-polygon/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../validate-ip-address "Validate IP Address") diff --git a/problems/coordinate-with-maximum-network-quality/README.md b/problems/coordinate-with-maximum-network-quality/README.md index 826eb0d7e..91f1ce025 100644 --- a/problems/coordinate-with-maximum-network-quality/README.md +++ b/problems/coordinate-with-maximum-network-quality/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../mean-of-array-after-removing-some-elements "Mean of Array After Removing Some Elements") diff --git a/problems/correct-a-binary-tree/README.md b/problems/correct-a-binary-tree/README.md index 24a792f77..a98761723 100644 --- a/problems/correct-a-binary-tree/README.md +++ b/problems/correct-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-grid-happiness "Maximize Grid Happiness") @@ -14,16 +14,12 @@ ### 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 - 1. [Flatten Binary Tree to Linked List](../flatten-binary-tree-to-linked-list) (Medium) - 1. [Flatten a Multilevel Doubly Linked List](../flatten-a-multilevel-doubly-linked-list) (Medium) - ### Hints
Hint 1 diff --git a/problems/count-all-possible-routes/README.md b/problems/count-all-possible-routes/README.md index 979194249..9dfddc3fe 100644 --- a/problems/count-all-possible-routes/README.md +++ b/problems/count-all-possible-routes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-subarray-to-be-removed-to-make-array-sorted "Shortest Subarray to be Removed to Make Array Sorted") @@ -11,15 +11,13 @@ ## [1575. Count All Possible Routes (Hard)](https://leetcode.com/problems/count-all-possible-routes "统计所有可行路径") -

You are given an array of distinct positive integers locations where locations[i] represents the position of city i. You are also given integers startfinish and fuel representing the starting city, ending city, and the initial amount of fuel you have, respectively.

+

You are given an array of distinct positive integers locations where locations[i] represents the position of city i. You are also given integers start, finish and fuel representing the starting city, ending city, and the initial amount of fuel you have, respectively.

-

At each step, if you are at city i, you can pick any city j such that j != i and 0 <= j < locations.length and move to city j. Moving from city i to city j reduces the amount of fuel you have by |locations[i] - locations[j]|. Please notice that |x| denotes the absolute value of x.

+

At each step, if you are at city i, you can pick any city j such that j != i and 0 <= j < locations.length and move to city j. Moving from city i to city j reduces the amount of fuel you have by |locations[i] - locations[j]|. Please notice that |x| denotes the absolute value of x.

-

Notice that fuel cannot become negative at any point in time, and that you are allowed to visit any city more than once (including start and finish).

+

Notice that fuel cannot become negative at any point in time, and that you are allowed to visit any city more than once (including start and finish).

-

Return the count of all possible routes from start to finish.

- -

Since the answer may be too large, return it modulo 10^9 + 7.

+

Return the count of all possible routes from start to finish. Since the answer may be too large, return it modulo 109 + 7.

 

Example 1:

@@ -74,10 +72,10 @@
  • 2 <= locations.length <= 100
  • -
  • 1 <= locations[i] <= 10^9
  • -
  • All integers in locations are distinct.
  • -
  • 0 <= start, finish < locations.length
  • -
  • 1 <= fuel <= 200
  • +
  • 1 <= locations[i] <= 109
  • +
  • All integers in locations are distinct.
  • +
  • 0 <= start, finish < locations.length
  • +
  • 1 <= fuel <= 200
### Related Topics diff --git a/problems/count-apples-and-oranges/README.md b/problems/count-apples-and-oranges/README.md index b37077c6d..beb6557bc 100644 --- a/problems/count-apples-and-oranges/README.md +++ b/problems/count-apples-and-oranges/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-special-evenly-spaced-elements-in-array "Sum Of Special Evenly-Spaced Elements In Array") diff --git a/problems/count-good-meals/README.md b/problems/count-good-meals/README.md index e23d90e05..a79cf7106 100644 --- a/problems/count-good-meals/README.md +++ b/problems/count-good-meals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-units-on-a-truck "Maximum Units on a Truck") @@ -48,10 +48,6 @@ 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) - ### Hints
Hint 1 diff --git a/problems/count-good-numbers/README.md b/problems/count-good-numbers/README.md index 58b46f11f..ab7e822a8 100644 --- a/problems/count-good-numbers/README.md +++ b/problems/count-good-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../eliminate-maximum-number-of-monsters "Eliminate Maximum Number of Monsters") diff --git a/problems/count-good-triplets/README.md b/problems/count-good-triplets/README.md index dc0e071a9..782b76d51 100644 --- a/problems/count-good-triplets/README.md +++ b/problems/count-good-triplets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-index-of-the-large-integer "Find the Index of the Large Integer") diff --git a/problems/count-items-matching-a-rule/README.md b/problems/count-items-matching-a-rule/README.md index 06bc64a51..0da1a676a 100644 --- a/problems/count-items-matching-a-rule/README.md +++ b/problems/count-items-matching-a-rule/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-features-by-popularity "Sort Features by Popularity") diff --git a/problems/count-largest-group/README.md b/problems/count-largest-group/README.md index 4f3aaf3a2..577545eae 100644 --- a/problems/count-largest-group/README.md +++ b/problems/count-largest-group/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../customers-who-bought-products-a-and-b-but-not-c "Customers Who Bought Products A and B but Not C") 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 11c98a5ff..b9aac1ed8 100644 --- a/problems/count-negative-numbers-in-a-sorted-matrix/README.md +++ b/problems/count-negative-numbers-in-a-sorted-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../students-with-invalid-departments "Students With Invalid Departments") diff --git a/problems/count-nice-pairs-in-an-array/README.md b/problems/count-nice-pairs-in-an-array/README.md index 6aed91e6a..ce79ee89e 100644 --- a/problems/count-nice-pairs-in-an-array/README.md +++ b/problems/count-nice-pairs-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sentence-similarity-iii "Sentence Similarity III") 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 d528cc422..4edd6ed06 100644 --- a/problems/count-nodes-equal-to-sum-of-descendants/README.md +++ b/problems/count-nodes-equal-to-sum-of-descendants/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../first-and-last-call-on-the-same-day "First and Last Call On the Same Day") diff --git a/problems/count-nodes-with-the-highest-score/README.md b/problems/count-nodes-with-the-highest-score/README.md index cca15d348..1bab0218c 100644 --- a/problems/count-nodes-with-the-highest-score/README.md +++ b/problems/count-nodes-with-the-highest-score/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../next-greater-numerically-balanced-number "Next Greater Numerically Balanced Number") diff --git a/problems/count-number-of-homogenous-substrings/README.md b/problems/count-number-of-homogenous-substrings/README.md index 12e2e7e31..efa87ce86 100644 --- a/problems/count-number-of-homogenous-substrings/README.md +++ b/problems/count-number-of-homogenous-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-changes-to-make-alternating-binary-string "Minimum Changes To Make Alternating Binary String") @@ -59,10 +59,6 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Consecutive Characters](../consecutive-characters) (Easy) - 1. [Number of Substrings With Only 1s](../number-of-substrings-with-only-1s) (Medium) - ### Hints
Hint 1 diff --git a/problems/count-number-of-maximum-bitwise-or-subsets/README.md b/problems/count-number-of-maximum-bitwise-or-subsets/README.md index 30e2c4f41..0a0609c00 100644 --- a/problems/count-number-of-maximum-bitwise-or-subsets/README.md +++ b/problems/count-number-of-maximum-bitwise-or-subsets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../simple-bank-system "Simple Bank System") diff --git a/problems/count-number-of-nice-subarrays/README.md b/problems/count-number-of-nice-subarrays/README.md index ad11c6a23..5a88c6c6a 100644 --- a/problems/count-number-of-nice-subarrays/README.md +++ b/problems/count-number-of-nice-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-swaps-to-make-strings-equal "Minimum Swaps to Make Strings Equal") 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 4cbf730a0..29e70cae0 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subtree-removal-game-with-fibonacci-tree "Subtree Removal Game with Fibonacci Tree") diff --git a/problems/count-number-of-special-subsequences/README.md b/problems/count-number-of-special-subsequences/README.md index 66ffca864..3871d7327 100644 --- a/problems/count-number-of-special-subsequences/README.md +++ b/problems/count-number-of-special-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-garden-perimeter-to-collect-enough-apples "Minimum Garden Perimeter to Collect Enough Apples") diff --git a/problems/count-numbers-with-unique-digits/README.md b/problems/count-numbers-with-unique-digits/README.md index 85c0da7f6..340f61812 100644 --- a/problems/count-numbers-with-unique-digits/README.md +++ b/problems/count-numbers-with-unique-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../line-reflection "Line Reflection") diff --git a/problems/count-odd-numbers-in-an-interval-range/README.md b/problems/count-odd-numbers-in-an-interval-range/README.md index 787c6b9c3..ded9c497f 100644 --- a/problems/count-odd-numbers-in-an-interval-range/README.md +++ b/problems/count-odd-numbers-in-an-interval-range/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../diameter-of-n-ary-tree "Diameter of N-Ary Tree") diff --git a/problems/count-of-matches-in-tournament/README.md b/problems/count-of-matches-in-tournament/README.md index 39e36fa7a..71e5c1cba 100644 --- a/problems/count-of-matches-in-tournament/README.md +++ b/problems/count-of-matches-in-tournament/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delivering-boxes-from-storage-to-ports "Delivering Boxes from Storage to Ports") diff --git a/problems/count-pairs-in-two-arrays/README.md b/problems/count-pairs-in-two-arrays/README.md index 315548881..f7cdb43e0 100644 --- a/problems/count-pairs-in-two-arrays/README.md +++ b/problems/count-pairs-in-two-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../egg-drop-with-2-eggs-and-n-floors "Egg Drop With 2 Eggs and N Floors") diff --git a/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md b/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md index 9a8db9c5d..cd3d037fd 100644 --- a/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md +++ b/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-score-of-a-good-subarray "Maximum Score of a Good Subarray") diff --git a/problems/count-pairs-of-nodes/README.md b/problems/count-pairs-of-nodes/README.md index aa061db47..9678daee2 100644 --- a/problems/count-pairs-of-nodes/README.md +++ b/problems/count-pairs-of-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-beauty-of-all-substrings "Sum of Beauty of All Substrings") @@ -58,9 +58,9 @@ The answers for each of the queries are as follows: ### Related Topics + [[Graph](../../tag/graph/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Graph](../../tag/graph/README.md)] ### Hints
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 35ec7bfce..8195188bb 100644 --- a/problems/count-pairs-with-xor-in-a-range/README.md +++ b/problems/count-pairs-with-xor-in-a-range/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-value-at-a-given-index-in-a-bounded-array "Maximum Value at a Given Index in a Bounded Array") diff --git a/problems/count-salary-categories/README.md b/problems/count-salary-categories/README.md index 503298df1..5ca708082 100644 --- a/problems/count-salary-categories/README.md +++ b/problems/count-salary-categories/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-absolute-difference-queries "Minimum Absolute Difference Queries") diff --git a/problems/count-servers-that-communicate/README.md b/problems/count-servers-that-communicate/README.md index 77cb4e4a3..b5454c4ec 100644 --- a/problems/count-servers-that-communicate/README.md +++ b/problems/count-servers-that-communicate/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-visiting-all-points "Minimum Time Visiting All Points") @@ -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)] - [[Matrix](../../tag/matrix/README.md)] + [[Array](../../tag/array/README.md)] [[Counting](../../tag/counting/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
diff --git a/problems/count-sorted-vowel-strings/README.md b/problems/count-sorted-vowel-strings/README.md index d65e1dafe..9f86adbcb 100644 --- a/problems/count-sorted-vowel-strings/README.md +++ b/problems/count-sorted-vowel-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-array-formation-through-concatenation "Check Array Formation Through Concatenation") diff --git a/problems/count-special-quadruplets/README.md b/problems/count-special-quadruplets/README.md index 4e3dd8ce3..d9938c15d 100644 --- a/problems/count-special-quadruplets/README.md +++ b/problems/count-special-quadruplets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-good-subsets "The Number of Good Subsets") diff --git a/problems/count-square-sum-triples/README.md b/problems/count-square-sum-triples/README.md index 9407c42a5..d9d046279 100644 --- a/problems/count-square-sum-triples/README.md +++ b/problems/count-square-sum-triples/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../erect-the-fence-ii "Erect the Fence II") diff --git a/problems/count-sub-islands/README.md b/problems/count-sub-islands/README.md index 11d21ca47..3bc57c1ed 100644 --- a/problems/count-sub-islands/README.md +++ b/problems/count-sub-islands/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-full-rounds-you-have-played "The Number of Full Rounds You Have Played") 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 c7f52a097..6b4eea3b1 100644 --- a/problems/count-subarrays-with-more-ones-than-zeros/README.md +++ b/problems/count-subarrays-with-more-ones-than-zeros/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-k-length-subsequence-with-occurrences-of-a-letter "Smallest K-Length Subsequence With Occurrences of a Letter") diff --git a/problems/count-submatrices-with-all-ones/README.md b/problems/count-submatrices-with-all-ones/README.md index 543f8cfc6..a142458a3 100644 --- a/problems/count-submatrices-with-all-ones/README.md +++ b/problems/count-submatrices-with-all-ones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../last-moment-before-all-ants-fall-out-of-a-plank "Last Moment Before All Ants Fall Out of a Plank") @@ -11,64 +11,45 @@ ## [1504. Count Submatrices With All Ones (Medium)](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") -

Given a rows * columns matrix mat of ones and zeros, return how many submatrices have all ones.

+

Given an m x n binary matrix mat, return the number of submatrices that have all ones.

 

Example 1:

- +
-Input: mat = [[1,0,1],
-              [1,1,0],
-              [1,1,0]]
+Input: mat = [[1,0,1],[1,1,0],[1,1,0]]
 Output: 13
-Explanation:
-There are 6 rectangles of side 1x1.
-There are 2 rectangles of side 1x2.
-There are 3 rectangles of side 2x1.
-There is 1 rectangle of side 2x2. 
-There is 1 rectangle of side 3x1.
-Total number of rectangles = 6 + 2 + 3 + 1 + 1 = 13.
+Explanation: 
+There are 6 rectangles of side 1x1.
+There are 2 rectangles of side 1x2.
+There are 3 rectangles of side 2x1.
+There is 1 rectangle of side 2x2. 
+There is 1 rectangle of side 3x1.
+Total number of rectangles = 6 + 2 + 3 + 1 + 1 = 13.
 

Example 2:

- +
-Input: mat = [[0,1,1,0],
-              [0,1,1,1],
-              [1,1,1,0]]
+Input: mat = [[0,1,1,0],[0,1,1,1],[1,1,1,0]]
 Output: 24
-Explanation:
-There are 8 rectangles of side 1x1.
-There are 5 rectangles of side 1x2.
-There are 2 rectangles of side 1x3. 
-There are 4 rectangles of side 2x1.
-There are 2 rectangles of side 2x2. 
-There are 2 rectangles of side 3x1. 
-There is 1 rectangle of side 3x2. 
-Total number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24.
-
- -

Example 3:

- -
-Input: mat = [[1,1,1,1,1,1]]
-Output: 21
-
- -

Example 4:

- -
-Input: mat = [[1,0,1],[0,1,0],[1,0,1]]
-Output: 5
+Explanation: 
+There are 8 rectangles of side 1x1.
+There are 5 rectangles of side 1x2.
+There are 2 rectangles of side 1x3. 
+There are 4 rectangles of side 2x1.
+There are 2 rectangles of side 2x2. 
+There are 2 rectangles of side 3x1. 
+There is 1 rectangle of side 3x2. 
+Total number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24.
 

 

Constraints:

    -
  • 1 <= rows <= 150
  • -
  • 1 <= columns <= 150
  • -
  • 0 <= mat[i][j] <= 1
  • +
  • 1 <= m, n <= 150
  • +
  • mat[i][j] is either 0 or 1.
### Related Topics 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 b69935728..dc837a236 100644 --- a/problems/count-substrings-that-differ-by-one-character/README.md +++ b/problems/count-substrings-that-differ-by-one-character/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../widest-vertical-area-between-two-points-containing-no-points "Widest Vertical Area Between Two Points Containing No Points") diff --git a/problems/count-substrings-with-only-one-distinct-letter/README.md b/problems/count-substrings-with-only-one-distinct-letter/README.md index 4636959fc..bb512697a 100644 --- a/problems/count-substrings-with-only-one-distinct-letter/README.md +++ b/problems/count-substrings-with-only-one-distinct-letter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reformat-department-table "Reformat Department Table") 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 ce9398bf5..b2fafe331 100644 --- a/problems/count-subtrees-with-max-distance-between-cities/README.md +++ b/problems/count-subtrees-with-max-distance-between-cities/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-two-strings-to-make-palindrome "Split Two Strings to Make Palindrome") diff --git a/problems/count-the-number-of-consistent-strings/README.md b/problems/count-the-number-of-consistent-strings/README.md index c48a70fcf..e96a04d61 100644 --- a/problems/count-the-number-of-consistent-strings/README.md +++ b/problems/count-the-number-of-consistent-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../invalid-tweets "Invalid Tweets") @@ -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 bbf85f974..004d98070 100644 --- a/problems/count-the-number-of-experiments/README.md +++ b/problems/count-the-number-of-experiments/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-people-that-can-be-caught-in-tag "Maximum Number of People That Can Be Caught in Tag") 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 30c9275c0..db696b55f 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../build-an-array-with-stack-operations "Build an Array With Stack Operations") @@ -72,10 +72,10 @@ ### 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)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/problems/count-unhappy-friends/README.md b/problems/count-unhappy-friends/README.md index 15d272ff7..10eb99863 100644 --- a/problems/count-unhappy-friends/README.md +++ b/problems/count-unhappy-friends/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../special-positions-in-a-binary-matrix "Special Positions in a Binary Matrix") diff --git a/problems/count-vowel-substrings-of-a-string/README.md b/problems/count-vowel-substrings-of-a-string/README.md index baf298120..f66f9ed84 100644 --- a/problems/count-vowel-substrings-of-a-string/README.md +++ b/problems/count-vowel-substrings-of-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-spaces-cleaning-robot-cleaned "Number of Spaces Cleaning Robot Cleaned") diff --git a/problems/count-vowels-permutation/README.md b/problems/count-vowels-permutation/README.md index 31af29368..ea4985e9b 100644 --- a/problems/count-vowels-permutation/README.md +++ b/problems/count-vowels-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-with-maximum-gold "Path with Maximum Gold") diff --git a/problems/count-ways-to-build-rooms-in-an-ant-colony/README.md b/problems/count-ways-to-build-rooms-in-an-ant-colony/README.md index 14dfe8447..60c14efc3 100644 --- a/problems/count-ways-to-build-rooms-in-an-ant-colony/README.md +++ b/problems/count-ways-to-build-rooms-in-an-ant-colony/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-wonderful-substrings "Number of Wonderful Substrings") diff --git a/problems/count-ways-to-distribute-candies/README.md b/problems/count-ways-to-distribute-candies/README.md index 6c08f4c9c..e84290d1c 100644 --- a/problems/count-ways-to-distribute-candies/README.md +++ b/problems/count-ways-to-distribute-candies/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-height-by-stacking-cuboids "Maximum Height by Stacking Cuboids ") diff --git a/problems/count-ways-to-make-array-with-product/README.md b/problems/count-ways-to-make-array-with-product/README.md index 52c4da44f..e96f4859a 100644 --- a/problems/count-ways-to-make-array-with-product/README.md +++ b/problems/count-ways-to-make-array-with-product/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decode-xored-permutation "Decode XORed Permutation") diff --git a/problems/counting-elements/README.md b/problems/counting-elements/README.md index 11326dfda..5b85f3d94 100644 --- a/problems/counting-elements/README.md +++ b/problems/counting-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../constrained-subsequence-sum "Constrained Subsequence Sum") diff --git a/problems/countries-you-can-safely-invest-in/README.md b/problems/countries-you-can-safely-invest-in/README.md index eac2822ed..0450b8cee 100644 --- a/problems/countries-you-can-safely-invest-in/README.md +++ b/problems/countries-you-can-safely-invest-in/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-a-file-sharing-system "Design a File Sharing System") diff --git a/problems/course-schedule-ii/README.md b/problems/course-schedule-ii/README.md index 877d068c6..e84e3bcf3 100644 --- a/problems/course-schedule-ii/README.md +++ b/problems/course-schedule-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-size-subarray-sum "Minimum Size Subarray Sum") @@ -68,6 +68,7 @@ So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3]. 1. [Minimum Height Trees](../minimum-height-trees) (Medium) 1. [Sequence Reconstruction](../sequence-reconstruction) (Medium) 1. [Course Schedule III](../course-schedule-iii) (Hard) + 1. [Parallel Courses](../parallel-courses) (Medium) ### Hints
diff --git a/problems/course-schedule-iii/README.md b/problems/course-schedule-iii/README.md index d9d50a174..bdfa941a0 100644 --- a/problems/course-schedule-iii/README.md +++ b/problems/course-schedule-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../k-inverse-pairs-array "K Inverse Pairs Array") @@ -54,8 +54,8 @@ The 4th course cannot be taken now, since you will finish it on the 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 diff --git a/problems/course-schedule-iv/README.md b/problems/course-schedule-iv/README.md index 097eec13c..261ed9931 100644 --- a/problems/course-schedule-iv/README.md +++ b/problems/course-schedule-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-a-string-contains-all-binary-codes-of-size-k "Check If a String Contains All Binary Codes of Size K") diff --git a/problems/cracking-the-safe/README.md b/problems/cracking-the-safe/README.md index 9682f5adb..17db621dd 100644 --- a/problems/cracking-the-safe/README.md +++ b/problems/cracking-the-safe/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../open-the-lock "Open the Lock") diff --git a/problems/crawler-log-folder/README.md b/problems/crawler-log-folder/README.md index 7b39d13fa..dc6240635 100644 --- a/problems/crawler-log-folder/README.md +++ b/problems/crawler-log-folder/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../build-binary-expression-tree-from-infix-expression "Build Binary Expression Tree From Infix Expression") diff --git a/problems/create-maximum-number/README.md b/problems/create-maximum-number/README.md index 6b7047a53..a556c1b4b 100644 --- a/problems/create-maximum-number/README.md +++ b/problems/create-maximum-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../generalized-abbreviation "Generalized Abbreviation") diff --git a/problems/create-sorted-array-through-instructions/README.md b/problems/create-sorted-array-through-instructions/README.md index d91cd5108..7143b44aa 100644 --- a/problems/create-sorted-array-through-instructions/README.md +++ b/problems/create-sorted-array-through-instructions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sell-diminishing-valued-colored-balls "Sell Diminishing-Valued Colored Balls") diff --git a/problems/customer-order-frequency/README.md b/problems/customer-order-frequency/README.md index 866f4d346..c683e39f5 100644 --- a/problems/customer-order-frequency/README.md +++ b/problems/customer-order-frequency/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-iv "Stone Game IV") diff --git a/problems/customer-placing-the-largest-number-of-orders/README.md b/problems/customer-placing-the-largest-number-of-orders/README.md index 6585eb972..e00893cb3 100644 --- a/problems/customer-placing-the-largest-number-of-orders/README.md +++ b/problems/customer-placing-the-largest-number-of-orders/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../investments-in-2016 "Investments in 2016") diff --git a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md index 128f84e0c..c37bf735d 100644 --- a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md +++ b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../put-boxes-into-the-warehouse-ii "Put Boxes Into the Warehouse II") diff --git a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md index 50dfe74b7..443bb7664 100644 --- a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md +++ b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-all-good-strings "Find All Good Strings") diff --git a/problems/customers-who-never-order/README.md b/problems/customers-who-never-order/README.md index 91232a781..470908e17 100644 --- a/problems/customers-who-never-order/README.md +++ b/problems/customers-who-never-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../duplicate-emails "Duplicate Emails") diff --git a/problems/cutting-ribbons/README.md b/problems/cutting-ribbons/README.md index f9032d076..6d7c7f13c 100644 --- a/problems/cutting-ribbons/README.md +++ b/problems/cutting-ribbons/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-latest-login-in-2020 "The Latest Login in 2020") @@ -17,6 +17,10 @@ [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] +### Similar Questions + 1. [Capacity To Ship Packages Within D Days](../capacity-to-ship-packages-within-d-days) (Medium) + 1. [Add Minimum Number of Rungs](../add-minimum-number-of-rungs) (Medium) + ### Hints
Hint 1 diff --git a/problems/cyclically-rotating-a-grid/README.md b/problems/cyclically-rotating-a-grid/README.md index 827d5058b..bd3a7fc9f 100644 --- a/problems/cyclically-rotating-a-grid/README.md +++ b/problems/cyclically-rotating-a-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-difference-between-two-pairs "Maximum Product Difference Between Two Pairs") diff --git a/problems/daily-leads-and-partners/README.md b/problems/daily-leads-and-partners/README.md index 68f708978..299b0bd44 100644 --- a/problems/daily-leads-and-partners/README.md +++ b/problems/daily-leads-and-partners/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-ways-to-distribute-candies "Count Ways to Distribute Candies") diff --git a/problems/daily-temperatures/README.md b/problems/daily-temperatures/README.md index 39b5d4714..ff6a70607 100644 --- a/problems/daily-temperatures/README.md +++ b/problems/daily-temperatures/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../monotone-increasing-digits "Monotone Increasing Digits") @@ -33,13 +33,12 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Next Greater Element I](../next-greater-element-i) (Easy) - 1. [Online Stock Span](../online-stock-span) (Medium) ### Hints
diff --git a/problems/day-of-the-week/README.md b/problems/day-of-the-week/README.md index f582f978c..9ffca921a 100644 --- a/problems/day-of-the-week/README.md +++ b/problems/day-of-the-week/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distance-between-bus-stops "Distance Between Bus Stops") diff --git a/problems/decode-the-slanted-ciphertext/README.md b/problems/decode-the-slanted-ciphertext/README.md index 9e67b65fe..413cba302 100644 --- a/problems/decode-the-slanted-ciphertext/README.md +++ b/problems/decode-the-slanted-ciphertext/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-nodes-in-even-length-groups "Reverse Nodes in Even Length Groups") diff --git a/problems/decode-ways-ii/README.md b/problems/decode-ways-ii/README.md index 0ce394d3a..d8a78212b 100644 --- a/problems/decode-ways-ii/README.md +++ b/problems/decode-ways-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shopping-offers "Shopping Offers") @@ -80,3 +80,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) diff --git a/problems/decode-xored-array/README.md b/problems/decode-xored-array/README.md index 9a3191419..a1431e45a 100644 --- a/problems/decode-xored-array/README.md +++ b/problems/decode-xored-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-reconstruct-a-tree "Number Of Ways To Reconstruct A Tree") @@ -46,8 +46,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/decode-xored-permutation/README.md b/problems/decode-xored-permutation/README.md index acf817fd1..c848d7942 100644 --- a/problems/decode-xored-permutation/README.md +++ b/problems/decode-xored-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-people-to-teach "Minimum Number of People to Teach") diff --git a/problems/decoded-string-at-index/README.md b/problems/decoded-string-at-index/README.md index 23e24d9b4..db82b21f2 100644 --- a/problems/decoded-string-at-index/README.md +++ b/problems/decoded-string-at-index/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../profitable-schemes "Profitable Schemes") diff --git a/problems/decompress-run-length-encoded-list/README.md b/problems/decompress-run-length-encoded-list/README.md index 9d28d4d54..cda578f8a 100644 --- a/problems/decompress-run-length-encoded-list/README.md +++ b/problems/decompress-run-length-encoded-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-insertion-steps-to-make-a-string-palindrome "Minimum Insertion Steps to Make a String Palindrome") @@ -47,6 +47,9 @@ At the end the concatenation [2] + [4,4,4] is [2,4,4,4]. ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [String Compression](../string-compression) (Medium) + ### Hints
Hint 1 diff --git a/problems/decrease-elements-to-make-array-zigzag/README.md b/problems/decrease-elements-to-make-array-zigzag/README.md index 66c9ddb1e..1abcb21e0 100644 --- a/problems/decrease-elements-to-make-array-zigzag/README.md +++ b/problems/decrease-elements-to-make-array-zigzag/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-common-subsequence "Longest Common Subsequence") 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 ebfe6aaa5..e7eb154e6 100644 --- a/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md +++ b/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../running-total-for-different-genders "Running Total for Different Genders") diff --git a/problems/defanging-an-ip-address/README.md b/problems/defanging-an-ip-address/README.md index 916337166..1a89b5589 100644 --- a/problems/defanging-an-ip-address/README.md +++ b/problems/defanging-an-ip-address/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../new-users-daily-count "New Users Daily Count") diff --git a/problems/defuse-the-bomb/README.md b/problems/defuse-the-bomb/README.md index 49481547e..efc8b1b80 100644 --- a/problems/defuse-the-bomb/README.md +++ b/problems/defuse-the-bomb/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../hopper-company-queries-iii "Hopper Company Queries III") diff --git a/problems/delete-characters-to-make-fancy-string/README.md b/problems/delete-characters-to-make-fancy-string/README.md index a97b0bf67..786cb11c1 100644 --- a/problems/delete-characters-to-make-fancy-string/README.md +++ b/problems/delete-characters-to-make-fancy-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-for-k-virus-variants-to-spread "Minimum Time For K Virus Variants to Spread") diff --git a/problems/delete-duplicate-folders-in-system/README.md b/problems/delete-duplicate-folders-in-system/README.md index 1ea8b1a42..4bb81e72f 100644 --- a/problems/delete-duplicate-folders-in-system/README.md +++ b/problems/delete-duplicate-folders-in-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-compatibility-score-sum "Maximum Compatibility Score Sum") diff --git a/problems/delete-leaves-with-a-given-value/README.md b/problems/delete-leaves-with-a-given-value/README.md index e8074f8c2..d581caa4a 100644 --- a/problems/delete-leaves-with-a-given-value/README.md +++ b/problems/delete-leaves-with-a-given-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../print-words-vertically "Print Words Vertically") @@ -70,10 +70,10 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in ### 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-node-in-a-linked-list/README.md b/problems/delete-node-in-a-linked-list/README.md index 2348ae696..232dc471f 100644 --- a/problems/delete-node-in-a-linked-list/README.md +++ b/problems/delete-node-in-a-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-a-binary-tree "Lowest Common Ancestor of a Binary Tree") diff --git a/problems/delete-nodes-and-return-forest/README.md b/problems/delete-nodes-and-return-forest/README.md index 9d7a41d13..0260c45dd 100644 --- a/problems/delete-nodes-and-return-forest/README.md +++ b/problems/delete-nodes-and-return-forest/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../corporate-flight-bookings "Corporate Flight Bookings") diff --git a/problems/delete-tree-nodes/README.md b/problems/delete-tree-nodes/README.md index afe244584..c355e3823 100644 --- a/problems/delete-tree-nodes/README.md +++ b/problems/delete-tree-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-interval "Remove Interval") diff --git a/problems/delivering-boxes-from-storage-to-ports/README.md b/problems/delivering-boxes-from-storage-to-ports/README.md index a47b58504..a282ef700 100644 --- a/problems/delivering-boxes-from-storage-to-ports/README.md +++ b/problems/delivering-boxes-from-storage-to-ports/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-vi "Stone Game VI") diff --git a/problems/depth-of-bst-given-insertion-order/README.md b/problems/depth-of-bst-given-insertion-order/README.md index f7279a921..87f0d6196 100644 --- a/problems/depth-of-bst-given-insertion-order/README.md +++ b/problems/depth-of-bst-given-insertion-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-a-peak-element-ii "Find a Peak Element II") diff --git a/problems/describe-the-painting/README.md b/problems/describe-the-painting/README.md index 6df82efe4..edda7d60e 100644 --- a/problems/describe-the-painting/README.md +++ b/problems/describe-the-painting/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-the-smallest-unoccupied-chair "The Number of the Smallest Unoccupied Chair") diff --git a/problems/design-a-file-sharing-system/README.md b/problems/design-a-file-sharing-system/README.md index 08163d1c0..0eee8641a 100644 --- a/problems/design-a-file-sharing-system/README.md +++ b/problems/design-a-file-sharing-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-value-of-equation "Max Value of Equation") @@ -14,13 +14,10 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Design](../../tag/design/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Data Stream](../../tag/data-stream/README.md)] - -### Similar Questions - 1. [Design Twitter](../design-twitter) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
diff --git a/problems/design-a-leaderboard/README.md b/problems/design-a-leaderboard/README.md index b7b2e63b3..8d0f86afa 100644 --- a/problems/design-a-leaderboard/README.md +++ b/problems/design-a-leaderboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../array-transformation "Array Transformation") @@ -56,8 +56,8 @@ leaderboard.top(3); // returns 141 = 51 + 51 + 39; ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/design-a-stack-with-increment-operation/README.md b/problems/design-a-stack-with-increment-operation/README.md index 3266fbabb..136646831 100644 --- a/problems/design-a-stack-with-increment-operation/README.md +++ b/problems/design-a-stack-with-increment-operation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lucky-numbers-in-a-matrix "Lucky Numbers in a Matrix") diff --git a/problems/design-an-expression-tree-with-evaluate-function/README.md b/problems/design-an-expression-tree-with-evaluate-function/README.md index da44203bf..1a7b65ecc 100644 --- a/problems/design-an-expression-tree-with-evaluate-function/README.md +++ b/problems/design-an-expression-tree-with-evaluate-function/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../graph-connectivity-with-threshold "Graph Connectivity With Threshold") diff --git a/problems/design-an-ordered-stream/README.md b/problems/design-an-ordered-stream/README.md index 4b55be2b0..33f5fb0c2 100644 --- a/problems/design-an-ordered-stream/README.md +++ b/problems/design-an-ordered-stream/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distribute-repeating-integers "Distribute Repeating Integers") diff --git a/problems/design-authentication-manager/README.md b/problems/design-authentication-manager/README.md index 8bf9e9234..9a190e5aa 100644 --- a/problems/design-authentication-manager/README.md +++ b/problems/design-authentication-manager/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../second-largest-digit-in-a-string "Second Largest Digit in a String") diff --git a/problems/design-bounded-blocking-queue/README.md b/problems/design-bounded-blocking-queue/README.md index 3a2a2fab3..70fd07167 100644 --- a/problems/design-bounded-blocking-queue/README.md +++ b/problems/design-bounded-blocking-queue/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../make-array-strictly-increasing "Make Array Strictly Increasing") diff --git a/problems/design-browser-history/README.md b/problems/design-browser-history/README.md index 9a8ea0750..54bb7bfee 100644 --- a/problems/design-browser-history/README.md +++ b/problems/design-browser-history/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-k-strongest-values-in-an-array "The k Strongest Values in an Array") @@ -58,12 +58,12 @@ browserHistory.back(7); // You are in "google.com", ### Related Topics - [[Stack](../../tag/stack/README.md)] - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Linked List](../../tag/linked-list/README.md)] - [[Data Stream](../../tag/data-stream/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Design](../../tag/design/README.md)] [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] ### Hints
diff --git a/problems/design-circular-deque/README.md b/problems/design-circular-deque/README.md index 967350e2d..06669c2c1 100644 --- a/problems/design-circular-deque/README.md +++ b/problems/design-circular-deque/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../solve-the-equation "Solve the Equation") diff --git a/problems/design-circular-queue/README.md b/problems/design-circular-queue/README.md index 06ee8a6a0..ac1b86d00 100644 --- a/problems/design-circular-queue/README.md +++ b/problems/design-circular-queue/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../task-scheduler "Task Scheduler") diff --git a/problems/design-compressed-string-iterator/README.md b/problems/design-compressed-string-iterator/README.md index 4b87314c6..d6072bc36 100644 --- a/problems/design-compressed-string-iterator/README.md +++ b/problems/design-compressed-string-iterator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../consecutive-available-seats "Consecutive Available Seats") diff --git a/problems/design-front-middle-back-queue/README.md b/problems/design-front-middle-back-queue/README.md index be57778c1..2d57da3a1 100644 --- a/problems/design-front-middle-back-queue/README.md +++ b/problems/design-front-middle-back-queue/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-in-between-linked-lists "Merge In Between Linked Lists") @@ -64,16 +64,12 @@ q.popFront(); // return -1 -> [] (The queue is empty) ### Related Topics - [[Array](../../tag/array/README.md)] - [[Linked List](../../tag/linked-list/README.md)] [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Linked List](../../tag/linked-list/README.md)] [[Data Stream](../../tag/data-stream/README.md)] -### Similar Questions - 1. [Design Circular Deque](../design-circular-deque) (Medium) - 1. [Design Circular Queue](../design-circular-queue) (Medium) - ### Hints
Hint 1 diff --git a/problems/design-hit-counter/README.md b/problems/design-hit-counter/README.md index 48309965b..e094f0392 100644 --- a/problems/design-hit-counter/README.md +++ b/problems/design-hit-counter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bomb-enemy "Bomb Enemy") @@ -48,11 +48,11 @@ counter.getHits(301); What if the number of hits per second could be very large? Does your design scale?

### Related Topics - [[Design](../../tag/design/README.md)] - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] ### Similar Questions 1. [Logger Rate Limiter](../logger-rate-limiter) (Easy) diff --git a/problems/design-in-memory-file-system/README.md b/problems/design-in-memory-file-system/README.md index 06066a926..4c8354284 100644 --- a/problems/design-in-memory-file-system/README.md +++ b/problems/design-in-memory-file-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../erect-the-fence "Erect the Fence") @@ -47,10 +47,10 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] - [[String](../../tag/string/README.md)] [[Design](../../tag/design/README.md)] [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [LRU Cache](../lru-cache) (Medium) diff --git a/problems/design-log-storage-system/README.md b/problems/design-log-storage-system/README.md index 9537e98a4..1560bb852 100644 --- a/problems/design-log-storage-system/README.md +++ b/problems/design-log-storage-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-derangement-of-an-array "Find the Derangement of An Array") diff --git a/problems/design-most-recently-used-queue/README.md b/problems/design-most-recently-used-queue/README.md index 12dfa1e0a..b2b8f0d02 100644 --- a/problems/design-most-recently-used-queue/README.md +++ b/problems/design-most-recently-used-queue/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-subsequence-sum "Closest Subsequence Sum") @@ -14,16 +14,13 @@ ### Related Topics - [[Array](../../tag/array/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] -### Similar Questions - 1. [LRU Cache](../lru-cache) (Medium) - ### Hints
Hint 1 diff --git a/problems/design-movie-rental-system/README.md b/problems/design-movie-rental-system/README.md index bb43f98e6..7d30137c7 100644 --- a/problems/design-movie-rental-system/README.md +++ b/problems/design-movie-rental-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-alternating-subsequence-sum "Maximum Alternating Subsequence Sum") diff --git a/problems/design-parking-system/README.md b/problems/design-parking-system/README.md index eaca5e40e..c3e886f43 100644 --- a/problems/design-parking-system/README.md +++ b/problems/design-parking-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-nearest-right-node-in-binary-tree "Find Nearest Right Node in Binary Tree") @@ -49,8 +49,8 @@ parkingSystem.addCar(1); // return false because there is no available slot for ### Related Topics [[Design](../../tag/design/README.md)] - [[Simulation](../../tag/simulation/README.md)] [[Counting](../../tag/counting/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
diff --git a/problems/design-phone-directory/README.md b/problems/design-phone-directory/README.md index d8d66629f..b25857881 100644 --- a/problems/design-phone-directory/README.md +++ b/problems/design-phone-directory/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-smallest-element-in-a-sorted-matrix "Kth Smallest Element in a Sorted Matrix") diff --git a/problems/design-search-autocomplete-system/README.md b/problems/design-search-autocomplete-system/README.md index 6e35c7d5b..a42e4d98b 100644 --- a/problems/design-search-autocomplete-system/README.md +++ b/problems/design-search-autocomplete-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-circular-deque "Design Circular Deque") diff --git a/problems/design-skiplist/README.md b/problems/design-skiplist/README.md index c79f5f35d..c4e2f39fa 100644 --- a/problems/design-skiplist/README.md +++ b/problems/design-skiplist/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../monthly-transactions-ii "Monthly Transactions II") @@ -66,10 +66,5 @@ skiplist.search(1); // return False, 1 has already been erased. ### Related Topics - [[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) + [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index ad50b7a3d..3c3d61dd4 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-number-of-teams "Count Number of Teams") diff --git a/problems/destination-city/README.md b/problems/destination-city/README.md index 9bf4e8971..37239c418 100644 --- a/problems/destination-city/README.md +++ b/problems/destination-city/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../create-a-session-bar-chart "Create a Session Bar Chart") diff --git a/problems/detect-capital/README.md b/problems/detect-capital/README.md index 203f2448a..c37869020 100644 --- a/problems/detect-capital/README.md +++ b/problems/detect-capital/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../random-flip-matrix "Random Flip Matrix") diff --git a/problems/detect-cycles-in-2d-grid/README.md b/problems/detect-cycles-in-2d-grid/README.md index e48734252..da2157e5e 100644 --- a/problems/detect-cycles-in-2d-grid/README.md +++ b/problems/detect-cycles-in-2d-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-numbers-of-function-calls-to-make-target-array "Minimum Numbers of Function Calls to Make Target Array") 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 42cd38d62..e154bfa69 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-orders-and-customers-per-month "Unique Orders and Customers Per Month") @@ -72,9 +72,6 @@ [[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/detect-squares/README.md b/problems/detect-squares/README.md index 2d618bc66..982fcb70c 100644 --- a/problems/detect-squares/README.md +++ b/problems/detect-squares/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-beauty-in-the-array "Sum of Beauty in the Array") diff --git a/problems/determine-color-of-a-chessboard-square/README.md b/problems/determine-color-of-a-chessboard-square/README.md index dfe83e935..defbbb33c 100644 --- a/problems/determine-color-of-a-chessboard-square/README.md +++ b/problems/determine-color-of-a-chessboard-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-interview-candidates "Find Interview Candidates") diff --git a/problems/determine-if-string-halves-are-alike/README.md b/problems/determine-if-string-halves-are-alike/README.md index c087e409a..c436e1ff8 100644 --- a/problems/determine-if-string-halves-are-alike/README.md +++ b/problems/determine-if-string-halves-are-alike/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-adjacent-swaps-for-k-consecutive-ones "Minimum Adjacent Swaps for K Consecutive Ones") diff --git a/problems/determine-if-two-strings-are-close/README.md b/problems/determine-if-two-strings-are-close/README.md index 05e1a68f6..9da101df9 100644 --- a/problems/determine-if-two-strings-are-close/README.md +++ b/problems/determine-if-two-strings-are-close/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-an-ordered-stream "Design an Ordered Stream") @@ -81,6 +81,11 @@ 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 552837e15..3f86bc907 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-pairs-in-two-arrays "Count Pairs in Two Arrays") diff --git a/problems/diagonal-traverse-ii/README.md b/problems/diagonal-traverse-ii/README.md index e05a840e1..89e88c505 100644 --- a/problems/diagonal-traverse-ii/README.md +++ b/problems/diagonal-traverse-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-points-you-can-obtain-from-cards "Maximum Points You Can Obtain from Cards") diff --git a/problems/diagonal-traverse/README.md b/problems/diagonal-traverse/README.md index 47dfd76a5..54d674860 100644 --- a/problems/diagonal-traverse/README.md +++ b/problems/diagonal-traverse/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../random-point-in-non-overlapping-rectangles "Random Point in Non-overlapping Rectangles") @@ -43,3 +43,6 @@ [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Simulation](../../tag/simulation/README.md)] + +### Similar Questions + 1. [Decode the Slanted Ciphertext](../decode-the-slanted-ciphertext) (Medium) diff --git a/problems/diameter-of-n-ary-tree/README.md b/problems/diameter-of-n-ary-tree/README.md index fd9fe85c0..23080aa67 100644 --- a/problems/diameter-of-n-ary-tree/README.md +++ b/problems/diameter-of-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-a-value-of-a-mysterious-function-closest-to-target "Find a Value of a Mysterious Function Closest to Target") diff --git a/problems/dice-roll-simulation/README.md b/problems/dice-roll-simulation/README.md index 861c5d154..5bcd14155 100644 --- a/problems/dice-roll-simulation/README.md +++ b/problems/dice-roll-simulation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../queens-that-can-attack-the-king "Queens That Can Attack the King") @@ -53,6 +53,9 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Find Missing Observations](../find-missing-observations) (Medium) + ### Hints
Hint 1 diff --git a/problems/diet-plan-performance/README.md b/problems/diet-plan-performance/README.md index e13b90c53..8a830f600 100644 --- a/problems/diet-plan-performance/README.md +++ b/problems/diet-plan-performance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../prime-arrangements "Prime Arrangements") diff --git a/problems/different-ways-to-add-parentheses/README.md b/problems/different-ways-to-add-parentheses/README.md index 970b12558..7846b8a73 100644 --- a/problems/different-ways-to-add-parentheses/README.md +++ b/problems/different-ways-to-add-parentheses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../search-a-2d-matrix-ii "Search a 2D Matrix II") diff --git a/problems/dinner-plate-stacks/README.md b/problems/dinner-plate-stacks/README.md index 538937cca..3536498dd 100644 --- a/problems/dinner-plate-stacks/README.md +++ b/problems/dinner-plate-stacks/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-zero-sum-consecutive-nodes-from-linked-list "Remove Zero Sum Consecutive Nodes from Linked List") @@ -78,9 +78,9 @@ D.pop() // Returns -1. There are still no stacks. ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/distance-between-bus-stops/README.md b/problems/distance-between-bus-stops/README.md index 1d919d552..f94b2ff73 100644 --- a/problems/distance-between-bus-stops/README.md +++ b/problems/distance-between-bus-stops/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-ones "Maximum Number of Ones") diff --git a/problems/distant-barcodes/README.md b/problems/distant-barcodes/README.md index 2915f6b4b..cf6019f5a 100644 --- a/problems/distant-barcodes/README.md +++ b/problems/distant-barcodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../previous-permutation-with-one-swap "Previous Permutation With One Swap") diff --git a/problems/distinct-echo-substrings/README.md b/problems/distinct-echo-substrings/README.md index e5f514e7d..de3a4e081 100644 --- a/problems/distinct-echo-substrings/README.md +++ b/problems/distinct-echo-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-nodes-with-even-valued-grandparent "Sum of Nodes with Even-Valued Grandparent") diff --git a/problems/distinct-numbers-in-each-subarray/README.md b/problems/distinct-numbers-in-each-subarray/README.md index a6e1ecaf6..7f5aeec91 100644 --- a/problems/distinct-numbers-in-each-subarray/README.md +++ b/problems/distinct-numbers-in-each-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-interval-to-include-each-query "Minimum Interval to Include Each Query") diff --git a/problems/distinct-subsequences/README.md b/problems/distinct-subsequences/README.md index 4dddc80bc..56f06d216 100644 --- a/problems/distinct-subsequences/README.md +++ b/problems/distinct-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flatten-binary-tree-to-linked-list "Flatten Binary Tree to Linked List") @@ -15,7 +15,7 @@

A string's subsequence is a new string formed from the original string by deleting some (can be none) of the characters without disturbing the remaining characters' relative positions. (i.e., "ACE" is a subsequence of "ABCDE" while "AEC" is not).

-

It is guaranteed the answer fits on a 32-bit signed integer.

+

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

 

Example 1:

@@ -54,3 +54,6 @@ As shown below, there are 5 ways you can generate "bag" from S. ### Related Topics [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Number of Unique Good Subsequences](../number-of-unique-good-subsequences) (Hard) diff --git a/problems/distribute-candies-to-people/README.md b/problems/distribute-candies-to-people/README.md index 27495dffc..e593c51a1 100644 --- a/problems/distribute-candies-to-people/README.md +++ b/problems/distribute-candies-to-people/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-with-maximum-minimum-value "Path With Maximum Minimum Value") diff --git a/problems/distribute-candies/README.md b/problems/distribute-candies/README.md index 5d133bdfc..597d2572d 100644 --- a/problems/distribute-candies/README.md +++ b/problems/distribute-candies/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../winning-candidate "Winning Candidate") diff --git a/problems/distribute-coins-in-binary-tree/README.md b/problems/distribute-coins-in-binary-tree/README.md index 82f360eb4..bca1db8a7 100644 --- a/problems/distribute-coins-in-binary-tree/README.md +++ b/problems/distribute-coins-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-turbulent-subarray "Longest Turbulent Subarray") diff --git a/problems/distribute-repeating-integers/README.md b/problems/distribute-repeating-integers/README.md index f1649ed8b..aa9699270 100644 --- a/problems/distribute-repeating-integers/README.md +++ b/problems/distribute-repeating-integers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-jumps-to-reach-home "Minimum Jumps to Reach Home") diff --git a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md index 7b0bf98af..99aa7bbf4 100644 --- a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md +++ b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-numbers-with-even-number-of-digits "Find Numbers with Even Number of Digits") @@ -59,11 +59,14 @@ Note: This question is the same as 846: https://leetcode.com/problems/hand-of-straights/ ### 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)] +### Similar Questions + 1. [Split Array into Consecutive Subsequences](../split-array-into-consecutive-subsequences) (Medium) + ### Hints
Hint 1 diff --git a/problems/divide-array-into-increasing-sequences/README.md b/problems/divide-array-into-increasing-sequences/README.md index 9cafc4768..6863391eb 100644 --- a/problems/divide-array-into-increasing-sequences/README.md +++ b/problems/divide-array-into-increasing-sequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-average-subtree "Maximum Average Subtree") @@ -44,8 +44,8 @@ There is no way to divide the array using the conditions required. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/domino-and-tromino-tiling/README.md b/problems/domino-and-tromino-tiling/README.md index fe700add4..0aab6467f 100644 --- a/problems/domino-and-tromino-tiling/README.md +++ b/problems/domino-and-tromino-tiling/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../escape-the-ghosts "Escape The Ghosts") diff --git a/problems/dot-product-of-two-sparse-vectors/README.md b/problems/dot-product-of-two-sparse-vectors/README.md index 2e9db457c..0c36b471c 100644 --- a/problems/dot-product-of-two-sparse-vectors/README.md +++ b/problems/dot-product-of-two-sparse-vectors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-reorder-array-to-get-same-bst "Number of Ways to Reorder Array to Get Same BST") @@ -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/dota2-senate/README.md b/problems/dota2-senate/README.md index b1c725bee..9d40d16ad 100644 --- a/problems/dota2-senate/README.md +++ b/problems/dota2-senate/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-words "Replace Words") @@ -60,9 +60,9 @@ And in round 2, the third senator can just announce the victory since he is the ### Related Topics + [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Queue](../../tag/queue/README.md)] - [[String](../../tag/string/README.md)] ### Similar Questions 1. [Teemo Attacking](../teemo-attacking) (Easy) 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 new file mode 100644 index 000000000..1a73e08ea --- /dev/null +++ b/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../substrings-that-begin-and-end-with-the-same-letter "Substrings That Begin and End With the Same Letter") +                 +Next > + +## [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 "") + + diff --git a/problems/drop-type-1-orders-for-customers-with-type-0-orders/mysql_schemas.sql b/problems/drop-type-1-orders-for-customers-with-type-0-orders/mysql_schemas.sql new file mode 100644 index 000000000..22a499aa9 --- /dev/null +++ b/problems/drop-type-1-orders-for-customers-with-type-0-orders/mysql_schemas.sql @@ -0,0 +1,10 @@ +Create table If Not Exists Orders (order_id int, customer_id int, order_type int); +Truncate table Orders; +insert into Orders (order_id, customer_id, order_type) values ('1', '1', '0'); +insert into Orders (order_id, customer_id, order_type) values ('2', '1', '0'); +insert into Orders (order_id, customer_id, order_type) values ('11', '2', '0'); +insert into Orders (order_id, customer_id, order_type) values ('12', '2', '1'); +insert into Orders (order_id, customer_id, order_type) values ('21', '3', '1'); +insert into Orders (order_id, customer_id, order_type) values ('22', '3', '0'); +insert into Orders (order_id, customer_id, order_type) values ('31', '4', '1'); +insert into Orders (order_id, customer_id, order_type) values ('32', '4', '1'); diff --git a/problems/dungeon-game/README.md b/problems/dungeon-game/README.md index a1ad87bb9..481597181 100644 --- a/problems/dungeon-game/README.md +++ b/problems/dungeon-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-search-tree-iterator "Binary Search Tree Iterator") diff --git a/problems/duplicate-zeros/README.md b/problems/duplicate-zeros/README.md index b2a925bf9..c933127d7 100644 --- a/problems/duplicate-zeros/README.md +++ b/problems/duplicate-zeros/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../confusing-number-ii "Confusing Number II") 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 507213b79..b8408e61b 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-skips-to-arrive-at-meeting-on-time "Minimum Skips to Arrive at Meeting On Time") @@ -37,7 +37,7 @@ Otherwise, if both eggs survive, we know that f = 2. Input: n = 100 Output: 14 Explanation: One optimal strategy is: -- Drop the 1st egg at floor 9. If it breaks, we know f is between 0 and 8. Drop the 2nd egg starting from floor 1 and going up one at a time to find f within 7 more drops. Total drops is 1 + 7 = 8. +- Drop the 1st egg at floor 9. If it breaks, we know f is between 0 and 8. Drop the 2nd egg starting from floor 1 and going up one at a time to find f within 8 more drops. Total drops is 1 + 8 = 9. - If the 1st egg does not break, drop the 1st egg again at floor 22. If it breaks, we know f is between 9 and 21. Drop the 2nd egg starting from floor 10 and going up one at a time to find f within 12 more drops. Total drops is 2 + 12 = 14. - If the 1st egg does not break again, follow a similar process dropping the 1st egg from floors 34, 45, 55, 64, 72, 79, 85, 90, 94, 97, 99, and 100. Regardless of the outcome, it takes at most 14 drops to determine f. diff --git a/problems/element-appearing-more-than-25-in-sorted-array/README.md b/problems/element-appearing-more-than-25-in-sorted-array/README.md index 8ed66371b..f8ef3054c 100644 --- a/problems/element-appearing-more-than-25-in-sorted-array/README.md +++ b/problems/element-appearing-more-than-25-in-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../iterator-for-combination "Iterator for Combination") diff --git a/problems/eliminate-maximum-number-of-monsters/README.md b/problems/eliminate-maximum-number-of-monsters/README.md index 38a194480..6a752338f 100644 --- a/problems/eliminate-maximum-number-of-monsters/README.md +++ b/problems/eliminate-maximum-number-of-monsters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../build-array-from-permutation "Build Array from Permutation") diff --git a/problems/employee-bonus/README.md b/problems/employee-bonus/README.md index 3d3570294..5caf7f8e1 100644 --- a/problems/employee-bonus/README.md +++ b/problems/employee-bonus/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../out-of-boundary-paths "Out of Boundary Paths") diff --git a/problems/employee-bonus/mysql_schemas.sql b/problems/employee-bonus/mysql_schemas.sql index 2242c50c5..44404f355 100644 --- a/problems/employee-bonus/mysql_schemas.sql +++ b/problems/employee-bonus/mysql_schemas.sql @@ -1,10 +1,10 @@ -Create table If Not Exists Employee (EmpId int, Name varchar(255), Supervisor int, Salary int); -Create table If Not Exists Bonus (EmpId int, Bonus int); +Create table If Not Exists Employee (empId int, name varchar(255), supervisor int, salary int); +Create table If Not Exists Bonus (empId int, bonus int); Truncate table Employee; -insert into Employee (EmpId, Name, Supervisor, Salary) values ('3', 'Brad', 'None', '4000'); -insert into Employee (EmpId, Name, Supervisor, Salary) values ('1', 'John', '3', '1000'); -insert into Employee (EmpId, Name, Supervisor, Salary) values ('2', 'Dan', '3', '2000'); -insert into Employee (EmpId, Name, Supervisor, Salary) values ('4', 'Thomas', '3', '4000'); +insert into Employee (empId, name, supervisor, salary) values ('3', 'Brad', 'None', '4000'); +insert into Employee (empId, name, supervisor, salary) values ('1', 'John', '3', '1000'); +insert into Employee (empId, name, supervisor, salary) values ('2', 'Dan', '3', '2000'); +insert into Employee (empId, name, supervisor, salary) values ('4', 'Thomas', '3', '4000'); Truncate table Bonus; -insert into Bonus (EmpId, Bonus) values ('2', '500'); -insert into Bonus (EmpId, Bonus) values ('4', '2000'); +insert into Bonus (empId, bonus) values ('2', '500'); +insert into Bonus (empId, bonus) values ('4', '2000'); diff --git a/problems/employees-whose-manager-left-the-company/README.md b/problems/employees-whose-manager-left-the-company/README.md index 87587b2e7..56eee226f 100644 --- a/problems/employees-whose-manager-left-the-company/README.md +++ b/problems/employees-whose-manager-left-the-company/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-separate-numbers "Number of Ways to Separate Numbers") diff --git a/problems/employees-with-missing-information/README.md b/problems/employees-with-missing-information/README.md index 2b6a9253b..87a73e013 100644 --- a/problems/employees-with-missing-information/README.md +++ b/problems/employees-with-missing-information/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-longest-valid-obstacle-course-at-each-position "Find the Longest Valid Obstacle Course at Each Position") diff --git a/problems/encode-and-decode-tinyurl/README.md b/problems/encode-and-decode-tinyurl/README.md index 51741058f..66c905748 100644 --- a/problems/encode-and-decode-tinyurl/README.md +++ b/problems/encode-and-decode-tinyurl/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../game-play-analysis-iii "Game Play Analysis III") @@ -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-number/README.md b/problems/encode-number/README.md index a38a4b267..a64ac2153 100644 --- a/problems/encode-number/README.md +++ b/problems/encode-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-score-words-formed-by-letters "Maximum Score Words Formed by Letters") @@ -40,9 +40,9 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Convert to Base -2](../convert-to-base-2) (Medium) diff --git a/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md b/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md index 30b2a8af9..2d888a5e5 100644 --- a/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md +++ b/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-dessert-cost "Closest Dessert Cost") diff --git a/problems/erect-the-fence-ii/README.md b/problems/erect-the-fence-ii/README.md index 3b214df0e..4ca218a50 100644 --- a/problems/erect-the-fence-ii/README.md +++ b/problems/erect-the-fence-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-common-subpath "Longest Common Subpath") diff --git a/problems/erect-the-fence/README.md b/problems/erect-the-fence/README.md index 29da91e7a..3fde094a3 100644 --- a/problems/erect-the-fence/README.md +++ b/problems/erect-the-fence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../customer-placing-the-largest-number-of-orders "Customer Placing the Largest Number of Orders") diff --git a/problems/escape-a-large-maze/README.md b/problems/escape-a-large-maze/README.md index 50cdd6178..d8546cb79 100644 --- a/problems/escape-a-large-maze/README.md +++ b/problems/escape-a-large-maze/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../uncrossed-lines "Uncrossed Lines") diff --git a/problems/escape-the-ghosts/README.md b/problems/escape-the-ghosts/README.md index 971ab7c90..8457916e6 100644 --- a/problems/escape-the-ghosts/README.md +++ b/problems/escape-the-ghosts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rotated-digits "Rotated Digits") @@ -11,13 +11,13 @@ ## [789. Escape The Ghosts (Medium)](https://leetcode.com/problems/escape-the-ghosts "逃脱阻碍者") -

You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point [0, 0], and you are given a destination point target = [xtarget, ytarget], which you are trying to get to. There are several ghosts on the map with their starting positions given as an array ghosts, where ghosts[i] = [xi, yi] represents the starting position of the ith ghost. All inputs are integral coordinates.

+

You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point [0, 0], and you are given a destination point target = [xtarget, ytarget] that you are trying to get to. There are several ghosts on the map with their starting positions given as a 2D array ghosts, where ghosts[i] = [xi, yi] represents the starting position of the ith ghost. All inputs are integral coordinates.

-

Each turn, you and all the ghosts may independently choose to either move 1 unit in any of the four cardinal directions: north, east, south, or west or stay still. All actions happen simultaneously.

+

Each turn, you and all the ghosts may independently choose to either move 1 unit in any of the four cardinal directions: north, east, south, or west, or stay still. All actions happen simultaneously.

You escape if and only if you can reach the target before any ghost reaches you. If you reach any square (including the target) at the same time as a ghost, it does not count as an escape.

-

Return true if it is possible to escape, otherwise return false.

+

Return true if it is possible to escape regardless of how the ghosts move, otherwise return false.

 

Example 1:

diff --git a/problems/evaluate-reverse-polish-notation/README.md b/problems/evaluate-reverse-polish-notation/README.md index 568b78b2e..9db4857d2 100644 --- a/problems/evaluate-reverse-polish-notation/README.md +++ b/problems/evaluate-reverse-polish-notation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-points-on-a-line "Max Points on a Line") 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 75f157112..5e9c0c85e 100644 --- a/problems/evaluate-the-bracket-pairs-of-a-string/README.md +++ b/problems/evaluate-the-bracket-pairs-of-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-operations-to-reinitialize-a-permutation "Minimum Number of Operations to Reinitialize a Permutation") diff --git a/problems/even-odd-tree/README.md b/problems/even-odd-tree/README.md index e38eac346..2cbc1f3a2 100644 --- a/problems/even-odd-tree/README.md +++ b/problems/even-odd-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../special-array-with-x-elements-greater-than-or-equal-x "Special Array With X Elements Greater Than or Equal X") diff --git a/problems/exchange-seats/README.md b/problems/exchange-seats/README.md index 3aacfcb82..a75b1b85e 100644 --- a/problems/exchange-seats/README.md +++ b/problems/exchange-seats/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-factorization "Minimum Factorization") diff --git a/problems/exclusive-time-of-functions/README.md b/problems/exclusive-time-of-functions/README.md index 01008e61c..9c6b4fb4d 100644 --- a/problems/exclusive-time-of-functions/README.md +++ b/problems/exclusive-time-of-functions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-log-storage-system "Design Log Storage System") diff --git a/problems/expression-add-operators/README.md b/problems/expression-add-operators/README.md index c12108c67..eadb58d1c 100644 --- a/problems/expression-add-operators/README.md +++ b/problems/expression-add-operators/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../zigzag-iterator "Zigzag Iterator") diff --git a/problems/expressive-words/README.md b/problems/expressive-words/README.md index f4a2bcfd0..9e1612013 100644 --- a/problems/expressive-words/README.md +++ b/problems/expressive-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../soup-servings "Soup Servings") diff --git a/problems/factor-combinations/README.md b/problems/factor-combinations/README.md index 99da5532b..d31d61b22 100644 --- a/problems/factor-combinations/README.md +++ b/problems/factor-combinations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../meeting-rooms-ii "Meeting Rooms II") diff --git a/problems/factorial-trailing-zeroes/README.md b/problems/factorial-trailing-zeroes/README.md index d5a86fafa..502539b28 100644 --- a/problems/factorial-trailing-zeroes/README.md +++ b/problems/factorial-trailing-zeroes/README.md @@ -1,19 +1,19 @@ - - - + + + [< Previous](../excel-sheet-column-number "Excel Sheet Column Number")                  [Next >](../binary-search-tree-iterator "Binary Search Tree Iterator") -## [172. Factorial Trailing Zeroes (Easy)](https://leetcode.com/problems/factorial-trailing-zeroes "阶乘后的零") +## [172. Factorial Trailing Zeroes (Medium)](https://leetcode.com/problems/factorial-trailing-zeroes "阶乘后的零") -

Given an integer n, return the number of trailing zeroes in n!.

+

Given an integer n, return the number of trailing zeroes in n!.

-

Follow up: Could you write a solution that works in logarithmic time complexity?

+

Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1.

 

Example 1:

@@ -21,7 +21,7 @@
 Input: n = 3
 Output: 0
-Explanation: 3! = 6, no trailing zero.
+Explanation: 3! = 6, no trailing zero.
 

Example 2:

@@ -29,7 +29,7 @@
 Input: n = 5
 Output: 1
-Explanation: 5! = 120, one trailing zero.
+Explanation: 5! = 120, one trailing zero.
 

Example 3:

@@ -46,6 +46,9 @@
  • 0 <= n <= 104
  • +

     

    +

    Follow up: Could you write a solution that works in logarithmic time complexity?

    + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/falling-squares/README.md b/problems/falling-squares/README.md index dc7d38777..e1b6573d7 100644 --- a/problems/falling-squares/README.md +++ b/problems/falling-squares/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-to-k-equal-sum-subsets "Partition to K Equal Sum Subsets") @@ -56,8 +56,8 @@ Note that square 2 only brushes the right side of square 1, which does not count ### Related Topics - [[Array](../../tag/array/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions diff --git a/problems/fancy-sequence/README.md b/problems/fancy-sequence/README.md index 095f2502b..93301026d 100644 --- a/problems/fancy-sequence/README.md +++ b/problems/fancy-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-sets-of-k-non-overlapping-line-segments "Number of Sets of K Non-Overlapping Line Segments") @@ -58,9 +58,9 @@ fancy.getIndex(2); // return 20 ### Related Topics - [[Math](../../tag/math/README.md)] [[Design](../../tag/design/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/faulty-sensor/README.md b/problems/faulty-sensor/README.md index 3025254b5..6ae59d245 100644 --- a/problems/faulty-sensor/README.md +++ b/problems/faulty-sensor/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../finding-mk-average "Finding MK Average") diff --git a/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md b/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md index 352e8bb21..8f334288f 100644 --- a/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md +++ b/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-palindromic-subsequences "Remove Palindromic Subsequences") diff --git a/problems/final-value-of-variable-after-performing-operations/README.md b/problems/final-value-of-variable-after-performing-operations/README.md index ba929c144..acb1477c9 100644 --- a/problems/final-value-of-variable-after-performing-operations/README.md +++ b/problems/final-value-of-variable-after-performing-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-seniors-and-juniors-to-join-the-company-ii "The Number of Seniors and Juniors to Join the Company II") diff --git a/problems/find-a-peak-element-ii/README.md b/problems/find-a-peak-element-ii/README.md index 6f59efabd..cdf0afb44 100644 --- a/problems/find-a-peak-element-ii/README.md +++ b/problems/find-a-peak-element-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-earliest-and-latest-rounds-where-players-compete "The Earliest and Latest Rounds Where Players Compete") 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 c3cc0d0d1..93a511564 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-non-overlapping-substrings "Maximum Number of Non-Overlapping Substrings") @@ -53,10 +53,10 @@ ### Related Topics - [[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)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
    diff --git a/problems/find-all-anagrams-in-a-string/README.md b/problems/find-all-anagrams-in-a-string/README.md index bde000153..d9ea68ed6 100644 --- a/problems/find-all-anagrams-in-a-string/README.md +++ b/problems/find-all-anagrams-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-sum-iii "Path Sum III") diff --git a/problems/find-all-good-strings/README.md b/problems/find-all-good-strings/README.md index fbad6ebbf..266e3884f 100644 --- a/problems/find-all-good-strings/README.md +++ b/problems/find-all-good-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-underground-system "Design Underground System") diff --git a/problems/find-all-groups-of-farmland/README.md b/problems/find-all-groups-of-farmland/README.md index c44ea8517..f3390da7d 100644 --- a/problems/find-all-groups-of-farmland/README.md +++ b/problems/find-all-groups-of-farmland/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-middle-index-in-array "Find the Middle Index in Array") diff --git a/problems/find-all-numbers-disappeared-in-an-array/README.md b/problems/find-all-numbers-disappeared-in-an-array/README.md index a303d22e0..c05834526 100644 --- a/problems/find-all-numbers-disappeared-in-an-array/README.md +++ b/problems/find-all-numbers-disappeared-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-boomerangs "Number of Boomerangs") diff --git a/problems/find-all-the-lonely-nodes/README.md b/problems/find-all-the-lonely-nodes/README.md index a3379d1e5..d0bb2cb6d 100644 --- a/problems/find-all-the-lonely-nodes/README.md +++ b/problems/find-all-the-lonely-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../calculate-salaries "Calculate Salaries") @@ -19,10 +19,6 @@ [[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-array-given-subset-sums/README.md b/problems/find-array-given-subset-sums/README.md index 5a33915d9..70ed5cc1f 100644 --- a/problems/find-array-given-subset-sums/README.md +++ b/problems/find-array-given-subset-sums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-the-difference-between-target-and-chosen-elements "Minimize the Difference Between Target and Chosen Elements") diff --git a/problems/find-bottom-left-tree-value/README.md b/problems/find-bottom-left-tree-value/README.md index 6a72e27bc..0bddae477 100644 --- a/problems/find-bottom-left-tree-value/README.md +++ b/problems/find-bottom-left-tree-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../game-play-analysis-ii "Game Play Analysis II") diff --git a/problems/find-center-of-star-graph/README.md b/problems/find-center-of-star-graph/README.md index bdbc51763..62c53fe1e 100644 --- a/problems/find-center-of-star-graph/README.md +++ b/problems/find-center-of-star-graph/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-one-string-swap-can-make-strings-equal "Check if One String Swap Can Make Strings Equal") diff --git a/problems/find-customer-referee/README.md b/problems/find-customer-referee/README.md index b6fa01c91..1a32fee64 100644 --- a/problems/find-customer-referee/README.md +++ b/problems/find-customer-referee/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-operation-for-two-strings "Delete Operation for Two Strings") diff --git a/problems/find-customers-with-positive-revenue-this-year/README.md b/problems/find-customers-with-positive-revenue-this-year/README.md index 4f5d7a5ba..aff999682 100644 --- a/problems/find-customers-with-positive-revenue-this-year/README.md +++ b/problems/find-customers-with-positive-revenue-this-year/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-accepted-invitations "Maximum Number of Accepted Invitations") diff --git a/problems/find-cutoff-score-for-each-school/README.md b/problems/find-cutoff-score-for-each-school/README.md index 55fa6aafb..5009be138 100644 --- a/problems/find-cutoff-score-for-each-school/README.md +++ b/problems/find-cutoff-score-for-each-school/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-unique-good-subsequences "Number of Unique Good Subsequences") diff --git a/problems/find-distance-in-a-binary-tree/README.md b/problems/find-distance-in-a-binary-tree/README.md index 707c7eb48..3daa4c20d 100644 --- a/problems/find-distance-in-a-binary-tree/README.md +++ b/problems/find-distance-in-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../building-boxes "Building Boxes") @@ -14,10 +14,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)] ### Hints diff --git a/problems/find-duplicate-subtrees/README.md b/problems/find-duplicate-subtrees/README.md index 58f1f55fc..13bb973a2 100644 --- a/problems/find-duplicate-subtrees/README.md +++ b/problems/find-duplicate-subtrees/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../4-keys-keyboard "4 Keys Keyboard") @@ -57,4 +57,3 @@ 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-elements-in-a-contaminated-binary-tree/README.md b/problems/find-elements-in-a-contaminated-binary-tree/README.md index bfd81d4c5..c775ccfe2 100644 --- a/problems/find-elements-in-a-contaminated-binary-tree/README.md +++ b/problems/find-elements-in-a-contaminated-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shift-2d-grid "Shift 2D Grid") diff --git a/problems/find-eventual-safe-states/README.md b/problems/find-eventual-safe-states/README.md index e0916e64f..5ed0ba863 100644 --- a/problems/find-eventual-safe-states/README.md +++ b/problems/find-eventual-safe-states/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-swaps-to-make-sequences-increasing "Minimum Swaps To Make Sequences Increasing") diff --git a/problems/find-followers-count/README.md b/problems/find-followers-count/README.md index 19b344c7c..296bbf93d 100644 --- a/problems/find-followers-count/README.md +++ b/problems/find-followers-count/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cat-and-mouse-ii "Cat and Mouse II") diff --git a/problems/find-greatest-common-divisor-of-array/README.md b/problems/find-greatest-common-divisor-of-array/README.md index 6eac12499..0aca50aaa 100644 --- a/problems/find-greatest-common-divisor-of-array/README.md +++ b/problems/find-greatest-common-divisor-of-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../employees-whose-manager-left-the-company "Employees Whose Manager Left the Company") diff --git a/problems/find-if-path-exists-in-graph/README.md b/problems/find-if-path-exists-in-graph/README.md index 2c76e80ba..08b773042 100644 --- a/problems/find-if-path-exists-in-graph/README.md +++ b/problems/find-if-path-exists-in-graph/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../last-day-where-you-can-still-cross "Last Day Where You Can Still Cross")                  [Next >](../first-and-last-call-on-the-same-day "First and Last Call On the Same Day") -## [1971. Find if Path Exists in Graph (Easy)](https://leetcode.com/problems/find-if-path-exists-in-graph "") +## [1971. Find if Path Exists in Graph (Easy)](https://leetcode.com/problems/find-if-path-exists-in-graph "寻找图中是否存在路径")

    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.

    diff --git a/problems/find-in-mountain-array/README.md b/problems/find-in-mountain-array/README.md index c4c73ab6b..972eb7790 100644 --- a/problems/find-in-mountain-array/README.md +++ b/problems/find-in-mountain-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../car-pooling "Car Pooling") @@ -11,33 +11,30 @@ ## [1095. Find in Mountain Array (Hard)](https://leetcode.com/problems/find-in-mountain-array "山脉数组中查找目标值") -

    (This problem is an interactive problem.)

    +

    (This problem is an interactive problem.)

    -

    You may recall that an array A is a mountain array if and only if:

    +

    You may recall that an array arr is a mountain array if and only if:

      -
    • A.length >= 3
    • -
    • There exists some i with 0 < i < A.length - 1 such that: +
    • arr.length >= 3
    • +
    • There exists some i with 0 < i < arr.length - 1 such that:
        -
      • A[0] < A[1] < ... A[i-1] < A[i]
      • -
      • A[i] > A[i+1] > ... > A[A.length - 1]
      • +
      • arr[0] < arr[1] < ... < arr[i - 1] < arr[i]
      • +
      • arr[i] > arr[i + 1] > ... > arr[arr.length - 1]
    -

    Given a mountain array mountainArr, return the minimum index such that mountainArr.get(index) == target.  If such an index doesn't exist, return -1.

    +

    Given a mountain array mountainArr, return the minimum index such that mountainArr.get(index) == target. If such an index does not exist, return -1.

    -

    You can't access the mountain array directly.  You may only access the array using a MountainArray interface:

    +

    You cannot access the mountain array directly. You may only access the array using a MountainArray interface:

      -
    • MountainArray.get(k) returns the element of the array at index k (0-indexed).
    • -
    • MountainArray.length() returns the length of the array.
    • +
    • MountainArray.get(k) returns the element of the array at index k (0-indexed).
    • +
    • MountainArray.length() returns the length of the array.
    -

    Submissions making more than 100 calls to MountainArray.get will be judged Wrong Answer.  Also, any solutions that attempt to circumvent the judge will result in disqualification.

    - -
      -
    +

    Submissions making more than 100 calls to MountainArray.get will be judged Wrong Answer. Also, any solutions that attempt to circumvent the judge will result in disqualification.

     

    Example 1:

    @@ -59,9 +56,9 @@

    Constraints:

      -
    • 3 <= mountain_arr.length() <= 10000
    • -
    • 0 <= target <= 10^9
    • -
    • 0 <= mountain_arr.get(index) <= 10^9
    • +
    • 3 <= mountain_arr.length() <= 104
    • +
    • 0 <= target <= 109
    • +
    • 0 <= mountain_arr.get(index) <= 109
    ### Related Topics @@ -69,6 +66,10 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Interactive](../../tag/interactive/README.md)] +### Similar Questions + 1. [Peak Index in a Mountain Array](../peak-index-in-a-mountain-array) (Easy) + 1. [Minimum Number of Removals to Make Mountain Array](../minimum-number-of-removals-to-make-mountain-array) (Hard) + ### Hints
    Hint 1 diff --git a/problems/find-interview-candidates/README.md b/problems/find-interview-candidates/README.md index c7e04117a..660d053e7 100644 --- a/problems/find-interview-candidates/README.md +++ b/problems/find-interview-candidates/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-path-cost-in-a-hidden-grid "Minimum Path Cost in a Hidden Grid") diff --git a/problems/find-k-pairs-with-smallest-sums/README.md b/problems/find-k-pairs-with-smallest-sums/README.md index 93278e009..34da2c164 100644 --- a/problems/find-k-pairs-with-smallest-sums/README.md +++ b/problems/find-k-pairs-with-smallest-sums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../super-pow "Super Pow") 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 472812324..c6deb7db6 100644 --- a/problems/find-kth-bit-in-nth-binary-string/README.md +++ b/problems/find-kth-bit-in-nth-binary-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../make-the-string-great "Make The String Great") @@ -11,25 +11,25 @@ ## [1545. Find Kth Bit in Nth Binary String (Medium)](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") -

    Given two positive integers n and k, the binary string  Sn is formed as follows:

    +

    Given two positive integers n and k, the binary string Sn is formed as follows:

      -
    • S1 = "0"
    • -
    • Si = Si-1 + "1" + reverse(invert(Si-1)) for i > 1
    • +
    • S1 = "0"
    • +
    • 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:

      -
    • S= "0"
    • -
    • S= "011"
    • -
    • S= "0111001"
    • +
    • S1 = "0"
    • +
    • S2 = "011"
    • +
    • S3 = "0111001"
    • S4 = "011100110110001"
    -

    Return the kth bit in Sn. It is guaranteed that k is valid for the given n.

    +

    Return the kth bit in Sn. It is guaranteed that k is valid for the given n.

     

    Example 1:

    @@ -71,8 +71,8 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Hints
    diff --git a/problems/find-kth-largest-xor-coordinate-value/README.md b/problems/find-kth-largest-xor-coordinate-value/README.md index f69f71c83..09a8dc816 100644 --- a/problems/find-kth-largest-xor-coordinate-value/README.md +++ b/problems/find-kth-largest-xor-coordinate-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../change-minimum-characters-to-satisfy-one-of-three-conditions "Change Minimum Characters to Satisfy One of Three Conditions") diff --git a/problems/find-largest-value-in-each-tree-row/README.md b/problems/find-largest-value-in-each-tree-row/README.md index 4ef0b9546..28388634d 100644 --- a/problems/find-largest-value-in-each-tree-row/README.md +++ b/problems/find-largest-value-in-each-tree-row/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../freedom-trail "Freedom Trail") diff --git a/problems/find-latest-group-of-size-m/README.md b/problems/find-latest-group-of-size-m/README.md index 5251c6beb..7b8f9ad12 100644 --- a/problems/find-latest-group-of-size-m/README.md +++ b/problems/find-latest-group-of-size-m/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-coins-you-can-get "Maximum Number of Coins You Can Get") @@ -11,11 +11,13 @@ ## [1562. Find Latest Group of Size M (Medium)](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") -

    Given an array arr that represents a permutation of numbers from 1 to n. You have a binary string of size n that initially has all its bits set to zero.

    +

    Given an array arr that represents a permutation of numbers from 1 to n.

    -

    At each step i (assuming both the binary string and arr are 1-indexed) from 1 to n, the bit at position arr[i] is set to 1. You are given an integer m and you need to find the latest step at which there exists a group of ones of length m. A group of ones is a contiguous substring of 1s such that it cannot be extended in either direction.

    +

    You have a binary string of size n that initially has all its bits set to zero. At each step i (assuming both the binary string and arr are 1-indexed) from 1 to n, the bit at position arr[i] is set to 1.

    -

    Return the latest step at which there exists a group of ones of length exactly m. If no such group exists, return -1.

    +

    You are also given an integer m. Find the latest step at which there exists a group of ones of length m. A group of ones is a contiguous substring of 1's such that it cannot be extended in either direction.

    + +

    Return the latest step at which there exists a group of ones of length exactly m. If no such group exists, return -1.

     

    Example 1:

    @@ -64,10 +66,9 @@ No group of size 2 exists during any step.
    • n == arr.length
    • -
    • 1 <= n <= 10^5
    • +
    • 1 <= m <= n <= 105
    • 1 <= arr[i] <= n
    • -
    • All integers in arr are distinct.
    • -
    • 1 <= m <= arr.length
    • +
    • All integers in arr are distinct.
    ### Related Topics diff --git a/problems/find-longest-awesome-substring/README.md b/problems/find-longest-awesome-substring/README.md index 51ee2950c..35bff6ebc 100644 --- a/problems/find-longest-awesome-substring/README.md +++ b/problems/find-longest-awesome-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-insertions-to-balance-a-parentheses-string "Minimum Insertions to Balance a Parentheses String") @@ -50,14 +50,14 @@

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • s consists only of digits.
    ### 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)] ### Hints
    diff --git a/problems/find-lucky-integer-in-an-array/README.md b/problems/find-lucky-integer-in-an-array/README.md index 7f5d812a1..2308ca8e0 100644 --- a/problems/find-lucky-integer-in-an-array/README.md +++ b/problems/find-lucky-integer-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../capital-gainloss "Capital Gain/Loss") diff --git a/problems/find-median-given-frequency-of-numbers/README.md b/problems/find-median-given-frequency-of-numbers/README.md index 3450d3392..012bc7fbb 100644 --- a/problems/find-median-given-frequency-of-numbers/README.md +++ b/problems/find-median-given-frequency-of-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../managers-with-at-least-5-direct-reports "Managers with at Least 5 Direct Reports") diff --git a/problems/find-median-given-frequency-of-numbers/mysql_schemas.sql b/problems/find-median-given-frequency-of-numbers/mysql_schemas.sql index 09ba2b969..045c651e6 100644 --- a/problems/find-median-given-frequency-of-numbers/mysql_schemas.sql +++ b/problems/find-median-given-frequency-of-numbers/mysql_schemas.sql @@ -1,6 +1,6 @@ -Create table If Not Exists Numbers (Number int, Frequency int); +Create table If Not Exists Numbers (num int, frequency int); Truncate table Numbers; -insert into Numbers (Number, Frequency) values ('0', '7'); -insert into Numbers (Number, Frequency) values ('1', '1'); -insert into Numbers (Number, Frequency) values ('2', '3'); -insert into Numbers (Number, Frequency) values ('3', '1'); +insert into Numbers (num, frequency) values ('0', '7'); +insert into Numbers (num, frequency) values ('1', '1'); +insert into Numbers (num, frequency) values ('2', '3'); +insert into Numbers (num, frequency) values ('3', '1'); diff --git a/problems/find-minimum-time-to-finish-all-jobs/README.md b/problems/find-minimum-time-to-finish-all-jobs/README.md index 092bf7ddc..04d2f0c05 100644 --- a/problems/find-minimum-time-to-finish-all-jobs/README.md +++ b/problems/find-minimum-time-to-finish-all-jobs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-hamming-distance-after-swap-operations "Minimize Hamming Distance After Swap Operations") diff --git a/problems/find-missing-observations/README.md b/problems/find-missing-observations/README.md index 42f206e9c..7509a72d7 100644 --- a/problems/find-missing-observations/README.md +++ b/problems/find-missing-observations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-moves-to-convert-string "Minimum Moves to Convert String") diff --git a/problems/find-n-unique-integers-sum-up-to-zero/README.md b/problems/find-n-unique-integers-sum-up-to-zero/README.md index f7bf6803a..adcf4c9f1 100644 --- a/problems/find-n-unique-integers-sum-up-to-zero/README.md +++ b/problems/find-n-unique-integers-sum-up-to-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-team-size "Find the Team Size") 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 870808615..428b9c620 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-in-a-hidden-grid "Shortest Path in a Hidden Grid") diff --git a/problems/find-nearest-right-node-in-binary-tree/README.md b/problems/find-nearest-right-node-in-binary-tree/README.md index 2da65c22e..3202654d0 100644 --- a/problems/find-nearest-right-node-in-binary-tree/README.md +++ b/problems/find-nearest-right-node-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-achievable-transfer-requests "Maximum Number of Achievable Transfer Requests") 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 fc610d517..b13bbff63 100644 --- a/problems/find-numbers-with-even-number-of-digits/README.md +++ b/problems/find-numbers-with-even-number-of-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../weather-type-in-each-country "Weather Type in Each Country") @@ -11,7 +11,8 @@ ## [1295. Find Numbers with Even Number of Digits (Easy)](https://leetcode.com/problems/find-numbers-with-even-number-of-digits "统计位数为偶数的数字") -Given an array nums of integers, return how many of them contain an even number of digits. +

    Given an array nums of integers, return how many of them contain an even number of digits.

    +

     

    Example 1:

    @@ -41,7 +42,7 @@ Only 1771 contains an even number of digits.
    • 1 <= nums.length <= 500
    • -
    • 1 <= nums[i] <= 10^5
    • +
    • 1 <= nums[i] <= 105
    ### Related Topics diff --git a/problems/find-original-array-from-doubled-array/README.md b/problems/find-original-array-from-doubled-array/README.md index 9630bc2b1..82ef650df 100644 --- a/problems/find-original-array-from-doubled-array/README.md +++ b/problems/find-original-array-from-doubled-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-number-of-pairs-with-absolute-difference-k "Count Number of Pairs With Absolute Difference K") diff --git a/problems/find-positive-integer-solution-for-a-given-equation/README.md b/problems/find-positive-integer-solution-for-a-given-equation/README.md index 4c7eabb44..51ee21ffb 100644 --- a/problems/find-positive-integer-solution-for-a-given-equation/README.md +++ b/problems/find-positive-integer-solution-for-a-given-equation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../web-crawler "Web Crawler") diff --git a/problems/find-root-of-n-ary-tree/README.md b/problems/find-root-of-n-ary-tree/README.md index fc8c6cc86..86d931298 100644 --- a/problems/find-root-of-n-ary-tree/README.md +++ b/problems/find-root-of-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "Minimum Possible Integer After at Most K Adjacent Swaps On Digits") 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 237d5cb81..c18b61cd2 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-valid-matrix-given-row-and-column-sums "Find Valid Matrix Given Row and Column Sums") diff --git a/problems/find-smallest-common-element-in-all-rows/README.md b/problems/find-smallest-common-element-in-all-rows/README.md index e4947d6d1..e59271161 100644 --- a/problems/find-smallest-common-element-in-all-rows/README.md +++ b/problems/find-smallest-common-element-in-all-rows/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-knight-moves "Minimum Knight Moves") diff --git a/problems/find-smallest-letter-greater-than-target/README.md b/problems/find-smallest-letter-greater-than-target/README.md index ddcaa5c62..49127e3fe 100644 --- a/problems/find-smallest-letter-greater-than-target/README.md +++ b/problems/find-smallest-letter-greater-than-target/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../network-delay-time "Network Delay Time") diff --git a/problems/find-the-celebrity/README.md b/problems/find-the-celebrity/README.md index 9120109f5..41679c4a7 100644 --- a/problems/find-the-celebrity/README.md +++ b/problems/find-the-celebrity/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../paint-fence "Paint Fence") @@ -53,9 +53,9 @@ ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Graph](../../tag/graph/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] [[Interactive](../../tag/interactive/README.md)] ### Similar Questions diff --git a/problems/find-the-closest-palindrome/README.md b/problems/find-the-closest-palindrome/README.md index 712140264..59015a153 100644 --- a/problems/find-the-closest-palindrome/README.md +++ b/problems/find-the-closest-palindrome/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-tilt "Binary Tree Tilt") @@ -45,6 +45,9 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Next Palindrome Using Same Digits](../next-palindrome-using-same-digits) (Hard) + ### Hints
    Hint 1 diff --git a/problems/find-the-derangement-of-an-array/README.md b/problems/find-the-derangement-of-an-array/README.md index 9099e2f77..0bfe1bf04 100644 --- a/problems/find-the-derangement-of-an-array/README.md +++ b/problems/find-the-derangement-of-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-square-numbers "Sum of Square Numbers") diff --git a/problems/find-the-difference/README.md b/problems/find-the-difference/README.md index 4f2cd24a5..26f99b8ad 100644 --- a/problems/find-the-difference/README.md +++ b/problems/find-the-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-absolute-file-path "Longest Absolute File Path") @@ -57,9 +57,9 @@ ### 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)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/find-the-distance-value-between-two-arrays/README.md b/problems/find-the-distance-value-between-two-arrays/README.md index dfe1d8545..6bd0eda3c 100644 --- a/problems/find-the-distance-value-between-two-arrays/README.md +++ b/problems/find-the-distance-value-between-two-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../total-sales-amount-by-year "Total Sales Amount by Year") diff --git a/problems/find-the-highest-altitude/README.md b/problems/find-the-highest-altitude/README.md index b67880b44..d4cdabadb 100644 --- a/problems/find-the-highest-altitude/README.md +++ b/problems/find-the-highest-altitude/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-employees-which-report-to-each-employee "The Number of Employees Which Report to Each Employee") 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 5add4dacc..57eb5c872 100644 --- a/problems/find-the-index-of-the-large-integer/README.md +++ b/problems/find-the-index-of-the-large-integer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-most-recent-three-orders "The Most Recent Three Orders") diff --git a/problems/find-the-kth-largest-integer-in-the-array/README.md b/problems/find-the-kth-largest-integer-in-the-array/README.md index 30741df8a..26ca0ca05 100644 --- a/problems/find-the-kth-largest-integer-in-the-array/README.md +++ b/problems/find-the-kth-largest-integer-in-the-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-difference-between-highest-and-lowest-of-k-scores "Minimum Difference Between Highest and Lowest of K Scores") diff --git a/problems/find-the-longest-valid-obstacle-course-at-each-position/README.md b/problems/find-the-longest-valid-obstacle-course-at-each-position/README.md index b5af04369..92086d4ed 100644 --- a/problems/find-the-longest-valid-obstacle-course-at-each-position/README.md +++ b/problems/find-the-longest-valid-obstacle-course-at-each-position/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-swaps-to-make-the-string-balanced "Minimum Number of Swaps to Make the String Balanced") diff --git a/problems/find-the-middle-index-in-array/README.md b/problems/find-the-middle-index-in-array/README.md index e08db4f4b..c9372d3c6 100644 --- a/problems/find-the-middle-index-in-array/README.md +++ b/problems/find-the-middle-index-in-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-the-number-of-experiments "Count the Number of Experiments") 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 df7f6ef2a..aa3940150 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-index-with-equal-value "Smallest Index With Equal Value") diff --git a/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md b/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md index 93d2ee3fb..1d1f7e2c6 100644 --- a/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md +++ b/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-value-to-get-positive-step-by-step-sum "Minimum Value to Get Positive Step by Step Sum") diff --git a/problems/find-the-missing-ids/README.md b/problems/find-the-missing-ids/README.md index 36acbeda6..493874513 100644 --- a/problems/find-the-missing-ids/README.md +++ b/problems/find-the-missing-ids/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-two-expression-trees-are-equivalent "Check If Two Expression Trees are Equivalent") @@ -15,8 +15,3 @@ ### 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 2a2156173..918cfd3ad 100644 --- a/problems/find-the-most-competitive-subsequence/README.md +++ b/problems/find-the-most-competitive-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../richest-customer-wealth "Richest Customer Wealth") @@ -43,11 +43,15 @@ ### 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-quiet-students-in-all-exams/README.md b/problems/find-the-quiet-students-in-all-exams/README.md index 74d7ae0dd..82f0db71d 100644 --- a/problems/find-the-quiet-students-in-all-exams/README.md +++ b/problems/find-the-quiet-students-in-all-exams/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-paint-n-3-grid "Number of Ways to Paint N × 3 Grid") 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 b8d22252c..ff3a0bece 100644 --- a/problems/find-the-smallest-divisor-given-a-threshold/README.md +++ b/problems/find-the-smallest-divisor-given-a-threshold/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../group-the-people-given-the-group-size-they-belong-to "Group the People Given the Group Size They Belong To") diff --git a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md index 2d807b762..5521814a1 100644 --- a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md +++ b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "Minimum Number of Flips to Convert Binary Matrix to Zero Matrix") @@ -58,3 +58,7 @@ Number 10 is contained in the table. ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Report Contiguous Dates](../report-contiguous-dates) (Hard) + 1. [Find the Missing IDs](../find-the-missing-ids) (Medium) diff --git a/problems/find-the-student-that-will-replace-the-chalk/README.md b/problems/find-the-student-that-will-replace-the-chalk/README.md index e86b38815..ed3062efa 100644 --- a/problems/find-the-student-that-will-replace-the-chalk/README.md +++ b/problems/find-the-student-that-will-replace-the-chalk/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-all-the-integers-in-a-range-are-covered "Check if All the Integers in a Range Are Covered") @@ -63,8 +63,8 @@ Student number 1 does not have enough chalk, so they will have to replace it. ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Simulation](../../tag/simulation/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/find-the-subtasks-that-did-not-execute/README.md b/problems/find-the-subtasks-that-did-not-execute/README.md index 92270fe9b..8d94adad5 100644 --- a/problems/find-the-subtasks-that-did-not-execute/README.md +++ b/problems/find-the-subtasks-that-did-not-execute/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tree-of-coprimes "Tree of Coprimes") diff --git a/problems/find-the-team-size/README.md b/problems/find-the-team-size/README.md index ef0b10037..dd11cf0b0 100644 --- a/problems/find-the-team-size/README.md +++ b/problems/find-the-team-size/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../deepest-leaves-sum "Deepest Leaves Sum") diff --git a/problems/find-the-town-judge/README.md b/problems/find-the-town-judge/README.md index d801df3e8..ff1d47922 100644 --- a/problems/find-the-town-judge/README.md +++ b/problems/find-the-town-judge/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-squareful-arrays "Number of Squareful Arrays") 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 e8e735030..ab1c0c3a7 100644 --- a/problems/find-the-winner-of-an-array-game/README.md +++ b/problems/find-the-winner-of-an-array-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-good-triplets "Count Good Triplets") @@ -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.

    @@ -60,10 +60,10 @@ So we can see that 4 rounds will be played and 5 is the winner because it wins 2

    Constraints:

      -
    • 2 <= arr.length <= 10^5
    • -
    • 1 <= arr[i] <= 10^6
    • -
    • arr contains distinct integers.
    • -
    • 1 <= k <= 10^9
    • +
    • 2 <= arr.length <= 105
    • +
    • 1 <= arr[i] <= 106
    • +
    • arr contains distinct integers.
    • +
    • 1 <= k <= 109
    ### Related Topics 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 383ef9c03..72592a8ab 100644 --- a/problems/find-the-winner-of-the-circular-game/README.md +++ b/problems/find-the-winner-of-the-circular-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sign-of-the-product-of-an-array "Sign of the Product of an Array") diff --git a/problems/find-total-time-spent-by-each-employee/README.md b/problems/find-total-time-spent-by-each-employee/README.md index f0f8b247f..280619629 100644 --- a/problems/find-total-time-spent-by-each-employee/README.md +++ b/problems/find-total-time-spent-by-each-employee/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-distance-in-a-binary-tree "Find Distance in a Binary Tree") diff --git a/problems/find-unique-binary-string/README.md b/problems/find-unique-binary-string/README.md index b26bda5aa..986125758 100644 --- a/problems/find-unique-binary-string/README.md +++ b/problems/find-unique-binary-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-greatest-common-divisor-of-array "Find Greatest Common Divisor of Array") diff --git a/problems/find-users-with-valid-e-mails/README.md b/problems/find-users-with-valid-e-mails/README.md index a7378ffad..d28cde732 100644 --- a/problems/find-users-with-valid-e-mails/README.md +++ b/problems/find-users-with-valid-e-mails/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../move-sub-tree-of-n-ary-tree "Move Sub-Tree of N-Ary Tree") 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 40380151c..937b21680 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "Alert Using Same Key-Card Three or More Times in a One Hour Period") @@ -76,13 +76,10 @@ Another possible matrix is: [[1,2], ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] -### Similar Questions - 1. [Reconstruct a 2-Row Binary Matrix](../reconstruct-a-2-row-binary-matrix) (Medium) - ### Hints
    Hint 1 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 ea7db93de..a9fb045d4 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ships-in-a-rectangle "Number of Ships in a Rectangle") diff --git a/problems/find-words-that-can-be-formed-by-characters/README.md b/problems/find-words-that-can-be-formed-by-characters/README.md index 083f74b1f..86c08abca 100644 --- a/problems/find-words-that-can-be-formed-by-characters/README.md +++ b/problems/find-words-that-can-be-formed-by-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../market-analysis-ii "Market Analysis II") diff --git a/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md b/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md index 8eae2dff9..188930335 100644 --- a/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md +++ b/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../single-threaded-cpu "Single-Threaded CPU") diff --git a/problems/finding-mk-average/README.md b/problems/finding-mk-average/README.md index 0600c9f54..17b35c582 100644 --- a/problems/finding-mk-average/README.md +++ b/problems/finding-mk-average/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-sideway-jumps "Minimum Sideway Jumps") diff --git a/problems/finding-pairs-with-a-certain-sum/README.md b/problems/finding-pairs-with-a-certain-sum/README.md index eec73339b..db4adce8e 100644 --- a/problems/finding-pairs-with-a-certain-sum/README.md +++ b/problems/finding-pairs-with-a-certain-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-swaps-to-make-the-binary-string-alternating "Minimum Number of Swaps to Make the Binary String Alternating") diff --git a/problems/finding-the-users-active-minutes/README.md b/problems/finding-the-users-active-minutes/README.md index 6d76694ed..4b7acd96b 100644 --- a/problems/finding-the-users-active-minutes/README.md +++ b/problems/finding-the-users-active-minutes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../truncate-sentence "Truncate Sentence") 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 2ea7414aa..b8f2de048 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-if-path-exists-in-graph "Find if Path Exists in Graph") diff --git a/problems/first-bad-version/README.md b/problems/first-bad-version/README.md index 86a060793..8c880f141 100644 --- a/problems/first-bad-version/README.md +++ b/problems/first-bad-version/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-celebrity "Find the Celebrity") diff --git a/problems/first-day-where-you-have-been-in-all-the-rooms/README.md b/problems/first-day-where-you-have-been-in-all-the-rooms/README.md index 4ad9d3435..856a5085b 100644 --- a/problems/first-day-where-you-have-been-in-all-the-rooms/README.md +++ b/problems/first-day-where-you-have-been-in-all-the-rooms/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-weak-characters-in-the-game "The Number of Weak Characters in the Game") diff --git a/problems/first-missing-positive/README.md b/problems/first-missing-positive/README.md index f69d2437e..efea25ae1 100644 --- a/problems/first-missing-positive/README.md +++ b/problems/first-missing-positive/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../combination-sum-ii "Combination Sum II") diff --git a/problems/first-unique-number/README.md b/problems/first-unique-number/README.md index 9607addcc..5c9046d3d 100644 --- a/problems/first-unique-number/README.md +++ b/problems/first-unique-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../leftmost-column-with-at-least-a-one "Leftmost Column with at Least a One") diff --git a/problems/fix-names-in-a-table/README.md b/problems/fix-names-in-a-table/README.md index 838558462..3a3b17e11 100644 --- a/problems/fix-names-in-a-table/README.md +++ b/problems/fix-names-in-a-table/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../change-the-root-of-a-binary-tree "Change the Root of a Binary Tree") diff --git a/problems/fix-product-name-format/README.md b/problems/fix-product-name-format/README.md index 6393a7cc7..1ac7a026a 100644 --- a/problems/fix-product-name-format/README.md +++ b/problems/fix-product-name-format/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-longest-awesome-substring "Find Longest Awesome Substring") diff --git a/problems/flatten-a-multilevel-doubly-linked-list/README.md b/problems/flatten-a-multilevel-doubly-linked-list/README.md index 9bcd39aa9..45570d484 100644 --- a/problems/flatten-a-multilevel-doubly-linked-list/README.md +++ b/problems/flatten-a-multilevel-doubly-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../n-ary-tree-level-order-traversal "N-ary Tree Level Order Traversal") @@ -11,39 +11,31 @@ ## [430. Flatten a Multilevel Doubly Linked List (Medium)](https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list "扁平化多级双向链表") -

    You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a separate doubly linked list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as shown in the example below.

    +

    You are given a doubly linked list, which contains nodes that have a next pointer, a previous pointer, and an additional child pointer. This child pointer may or may not point to a separate doubly linked list, also containing these special nodes. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure as shown in the example below.

    -

    Flatten the list so that all the nodes appear in a single-level, doubly linked list. You are given the head of the first level of the list.

    +

    Given the head of the first level of the list, flatten the list so that all the nodes appear in a single-level, doubly linked list. Let curr be a node with a child list. The nodes in the child list should appear after curr and before curr.next in the flattened list.

    + +

    Return the head of the flattened list. The nodes in the list must have all of their child pointers set to null.

     

    Example 1:

    - +
     Input: head = [1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12]
     Output: [1,2,3,7,8,11,12,9,10,4,5,6]
    -Explanation:
    -
    -The multilevel linked list in the input is as follows:
    -
    -
    -
    +Explanation: The multilevel linked list in the input is shown.
     After flattening the multilevel linked list it becomes:
    -
    -
    +
     

    Example 2:

    - +
     Input: head = [1,2,null,3]
     Output: [1,3,2]
    -Explanation:
    -
    -The input multilevel linked list is as follows:
    -
    -  1---2---NULL
    -  |
    -  3---NULL
    +Explanation: The multilevel linked list in the input is shown.
    +After flattening the multilevel linked list it becomes:
    +
     

    Example 3:

    @@ -51,13 +43,21 @@ After flattening the multilevel linked list it becomes:
     Input: head = []
     Output: []
    +Explanation: There could be empty list in the input.
     

     

    +

    Constraints:

    -

    How multilevel linked list is represented in test case:

    +
      +
    • The number of Nodes will not exceed 1000.
    • +
    • 1 <= Node.val <= 105
    • +
    -

    We use the multilevel linked list from Example 1 above:

    +

     

    +

    How the multilevel linked list is represented in test cases:

    + +

    We use the multilevel linked list from Example 1 above:

      1---2---3---4---5---6--NULL
    @@ -74,26 +74,21 @@ After flattening the multilevel linked list it becomes:
     [11,12,null]
     
    -

    To serialize all levels together we will add nulls in each level to signify no node connects to the upper node of the previous level. The serialization becomes:

    +

    To serialize all levels together, we will add nulls in each level to signify no node connects to the upper node of the previous level. The serialization becomes:

    -[1,2,3,4,5,6,null]
    -[null,null,7,8,9,10,null]
    -[null,11,12,null]
    +[1,    2,    3, 4, 5, 6, null]
    +             |
    +[null, null, 7,    8, 9, 10, null]
    +                   |
    +[            null, 11, 12, null]
     

    Merging the serialization of each level and removing trailing nulls we obtain:

    -[1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12]
    - -

     

    -

    Constraints:

    - -
      -
    • The number of Nodes will not exceed 1000.
    • -
    • 1 <= Node.val <= 105
    • -
    +[1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12] + ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/flatten-nested-list-iterator/README.md b/problems/flatten-nested-list-iterator/README.md index 703ee263e..de96115b9 100644 --- a/problems/flatten-nested-list-iterator/README.md +++ b/problems/flatten-nested-list-iterator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-substring-with-at-most-k-distinct-characters "Longest Substring with At Most K Distinct Characters") diff --git a/problems/flip-binary-tree-to-match-preorder-traversal/README.md b/problems/flip-binary-tree-to-match-preorder-traversal/README.md index a1fb9274b..c9c6d7295 100644 --- a/problems/flip-binary-tree-to-match-preorder-traversal/README.md +++ b/problems/flip-binary-tree-to-match-preorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../powerful-integers "Powerful Integers") diff --git a/problems/flip-columns-for-maximum-number-of-equal-rows/README.md b/problems/flip-columns-for-maximum-number-of-equal-rows/README.md index 3e99da15b..a1bae20b6 100644 --- a/problems/flip-columns-for-maximum-number-of-equal-rows/README.md +++ b/problems/flip-columns-for-maximum-number-of-equal-rows/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../greatest-common-divisor-of-strings "Greatest Common Divisor of Strings") diff --git a/problems/flip-game/README.md b/problems/flip-game/README.md index 5a155f02b..944792052 100644 --- a/problems/flip-game/README.md +++ b/problems/flip-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nim-game "Nim Game") diff --git a/problems/flood-fill/README.md b/problems/flood-fill/README.md index 5951f4762..b47ff858f 100644 --- a/problems/flood-fill/README.md +++ b/problems/flood-fill/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../my-calendar-iii "My Calendar III") @@ -49,9 +49,9 @@ Note the bottom corner is not colored 2, because it is not 4-directionally conne ### 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)] ### Similar Questions diff --git a/problems/form-array-by-concatenating-subarrays-of-another-array/README.md b/problems/form-array-by-concatenating-subarrays-of-another-array/README.md index 2be6bddc1..6cc68179e 100644 --- a/problems/form-array-by-concatenating-subarrays-of-another-array/README.md +++ b/problems/form-array-by-concatenating-subarrays-of-another-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-nice-substring "Longest Nice Substring") @@ -59,8 +59,8 @@ They share a common elements nums[4] (0-indexed). ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[String Matching](../../tag/string-matching/README.md)] ### Hints 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 64067ce77..c79ccb267 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-good-nodes-in-binary-tree "Count Good Nodes in Binary Tree") diff --git a/problems/fraction-addition-and-subtraction/README.md b/problems/fraction-addition-and-subtraction/README.md index 1c8149557..56530a40d 100644 --- a/problems/fraction-addition-and-subtraction/README.md +++ b/problems/fraction-addition-and-subtraction/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tag-validator "Tag Validator") diff --git a/problems/frequency-of-the-most-frequent-element/README.md b/problems/frequency-of-the-most-frequent-element/README.md index 31f99ec46..82187cf4f 100644 --- a/problems/frequency-of-the-most-frequent-element/README.md +++ b/problems/frequency-of-the-most-frequent-element/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-digits-in-base-k "Sum of Digits in Base K") diff --git a/problems/friend-requests-ii-who-has-the-most-friends/README.md b/problems/friend-requests-ii-who-has-the-most-friends/README.md index 3603eb6ca..fc66fee5a 100644 --- a/problems/friend-requests-ii-who-has-the-most-friends/README.md +++ b/problems/friend-requests-ii-who-has-the-most-friends/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../human-traffic-of-stadium "Human Traffic of Stadium") diff --git a/problems/friend-requests-ii-who-has-the-most-friends/mysql_schemas.sql b/problems/friend-requests-ii-who-has-the-most-friends/mysql_schemas.sql index ef96415f0..331165b54 100644 --- a/problems/friend-requests-ii-who-has-the-most-friends/mysql_schemas.sql +++ b/problems/friend-requests-ii-who-has-the-most-friends/mysql_schemas.sql @@ -1,6 +1,6 @@ -Create table If Not Exists request_accepted ( requester_id INT NOT NULL, accepter_id INT NULL, accept_date DATE NULL); -Truncate table request_accepted; -insert into request_accepted (requester_id, accepter_id, accept_date) values ('1', '2', '2016/06/03'); -insert into request_accepted (requester_id, accepter_id, accept_date) values ('1', '3', '2016/06/08'); -insert into request_accepted (requester_id, accepter_id, accept_date) values ('2', '3', '2016/06/08'); -insert into request_accepted (requester_id, accepter_id, accept_date) values ('3', '4', '2016/06/09'); +Create table If Not Exists RequestAccepted (requester_id int not null, accepter_id int null, accept_date date null); +Truncate table RequestAccepted; +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('1', '2', '2016/06/03'); +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('1', '3', '2016/06/08'); +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('2', '3', '2016/06/08'); +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('3', '4', '2016/06/09'); diff --git a/problems/friendly-movies-streamed-last-month/README.md b/problems/friendly-movies-streamed-last-month/README.md index be49a97f7..406712a31 100644 --- a/problems/friendly-movies-streamed-last-month/README.md +++ b/problems/friendly-movies-streamed-last-month/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../parallel-courses-ii "Parallel Courses II") diff --git a/problems/friends-of-appropriate-ages/README.md b/problems/friends-of-appropriate-ages/README.md index acc6b20f9..2cb361627 100644 --- a/problems/friends-of-appropriate-ages/README.md +++ b/problems/friends-of-appropriate-ages/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../goat-latin "Goat Latin") diff --git a/problems/frog-jump/README.md b/problems/frog-jump/README.md index caa47c756..25614c52b 100644 --- a/problems/frog-jump/README.md +++ b/problems/frog-jump/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-k-digits "Remove K Digits") @@ -47,6 +47,3 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - -### Similar Questions - 1. [Minimum Sideway Jumps](../minimum-sideway-jumps) (Medium) diff --git a/problems/frog-position-after-t-seconds/README.md b/problems/frog-position-after-t-seconds/README.md index e65bc3e3d..a47663936 100644 --- a/problems/frog-position-after-t-seconds/README.md +++ b/problems/frog-position-after-t-seconds/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../time-needed-to-inform-all-employees "Time Needed to Inform All Employees") diff --git a/problems/fruit-into-baskets/README.md b/problems/fruit-into-baskets/README.md index 658ca0fad..5ddc874cb 100644 --- a/problems/fruit-into-baskets/README.md +++ b/problems/fruit-into-baskets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-permutations-for-di-sequence "Valid Permutations for DI Sequence") diff --git a/problems/furthest-building-you-can-reach/README.md b/problems/furthest-building-you-can-reach/README.md index 46e316b3f..0eb1d71a5 100644 --- a/problems/furthest-building-you-can-reach/README.md +++ b/problems/furthest-building-you-can-reach/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-sorted-vowel-strings "Count Sorted Vowel Strings") @@ -63,8 +63,8 @@ It is impossible to go beyond building 4 because you do not have any more bricks ### 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)] ### Hints diff --git a/problems/game-of-nim/README.md b/problems/game-of-nim/README.md index 3b3418858..fcbf6020d 100644 --- a/problems/game-of-nim/README.md +++ b/problems/game-of-nim/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-salary-categories "Count Salary Categories") diff --git a/problems/game-play-analysis-iv/README.md b/problems/game-play-analysis-iv/README.md index 1dbcc4898..78c3fc2e1 100644 --- a/problems/game-play-analysis-iv/README.md +++ b/problems/game-play-analysis-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-longest-consecutive-sequence-ii "Binary Tree Longest Consecutive Sequence II") diff --git a/problems/game-play-analysis-v/README.md b/problems/game-play-analysis-v/README.md index e1f8657bd..6de3e4488 100644 --- a/problems/game-play-analysis-v/README.md +++ b/problems/game-play-analysis-v/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../brace-expansion-ii "Brace Expansion II") diff --git a/problems/gas-station/README.md b/problems/gas-station/README.md index 23e9d83d9..be07ba5dd 100644 --- a/problems/gas-station/README.md +++ b/problems/gas-station/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clone-graph "Clone Graph") @@ -58,5 +58,5 @@ Therefore, you can't travel around the circuit once no matter where you star ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/gcd-sort-of-an-array/README.md b/problems/gcd-sort-of-an-array/README.md index 743271080..963bb3455 100644 --- a/problems/gcd-sort-of-an-array/README.md +++ b/problems/gcd-sort-of-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../first-day-where-you-have-been-in-all-the-rooms "First Day Where You Have Been in All the Rooms") diff --git a/problems/generalized-abbreviation/README.md b/problems/generalized-abbreviation/README.md index 3111ba7a4..017a197f6 100644 --- a/problems/generalized-abbreviation/README.md +++ b/problems/generalized-abbreviation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bulb-switcher "Bulb Switcher") @@ -26,9 +26,9 @@

     

    ### 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/generate-a-string-with-characters-that-have-odd-counts/README.md b/problems/generate-a-string-with-characters-that-have-odd-counts/README.md index a8034e1a7..f92d2f599 100644 --- a/problems/generate-a-string-with-characters-that-have-odd-counts/README.md +++ b/problems/generate-a-string-with-characters-that-have-odd-counts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-sum-bst-in-binary-tree "Maximum Sum BST in Binary Tree") diff --git a/problems/generate-random-point-in-a-circle/README.md b/problems/generate-random-point-in-a-circle/README.md index 701e687e8..3ba2759c5 100644 --- a/problems/generate-random-point-in-a-circle/README.md +++ b/problems/generate-random-point-in-a-circle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../total-hamming-distance "Total Hamming Distance") @@ -47,8 +47,8 @@ solution.randPoint(); // return [0.36572, 0.17248] ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Rejection Sampling](../../tag/rejection-sampling/README.md)] [[Randomized](../../tag/randomized/README.md)] diff --git a/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md b/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md index ca48ac971..0d8c4cfcf 100644 --- a/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md +++ b/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-maximum-pair-sum-in-array "Minimize Maximum Pair Sum in Array") diff --git a/problems/get-equal-substrings-within-budget/README.md b/problems/get-equal-substrings-within-budget/README.md index fb5cb6ac9..56d17a731 100644 --- a/problems/get-equal-substrings-within-budget/README.md +++ b/problems/get-equal-substrings-within-budget/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-number-of-occurrences "Unique Number of Occurrences") @@ -55,8 +55,8 @@ ### Related Topics [[String](../../tag/string/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)] ### Hints
    diff --git a/problems/get-highest-answer-rate-question/README.md b/problems/get-highest-answer-rate-question/README.md index 6da9aabb9..fe5999032 100644 --- a/problems/get-highest-answer-rate-question/README.md +++ b/problems/get-highest-answer-rate-question/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../employee-bonus "Employee Bonus") diff --git a/problems/get-highest-answer-rate-question/mysql_schemas.sql b/problems/get-highest-answer-rate-question/mysql_schemas.sql index ce07f2d2a..c0c01f73a 100644 --- a/problems/get-highest-answer-rate-question/mysql_schemas.sql +++ b/problems/get-highest-answer-rate-question/mysql_schemas.sql @@ -1,6 +1,6 @@ -Create table If Not Exists survey_log (id int, action varchar(255), question_id int, answer_id int, q_num int, timestamp int); -Truncate table survey_log; -insert into survey_log (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '285', 'None', '1', '123'); -insert into survey_log (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'answer', '285', '124124', '1', '124'); -insert into survey_log (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '369', 'None', '2', '125'); -insert into survey_log (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'skip', '369', 'None', '2', '126'); +Create table If Not Exists SurveyLog (id int, action varchar(255), question_id int, answer_id int, q_num int, timestamp int); +Truncate table SurveyLog; +insert into SurveyLog (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '285', 'None', '1', '123'); +insert into SurveyLog (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'answer', '285', '124124', '1', '124'); +insert into SurveyLog (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '369', 'None', '2', '125'); +insert into SurveyLog (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'skip', '369', 'None', '2', '126'); diff --git a/problems/get-maximum-in-generated-array/README.md b/problems/get-maximum-in-generated-array/README.md index 3e9575206..e5d390300 100644 --- a/problems/get-maximum-in-generated-array/README.md +++ b/problems/get-maximum-in-generated-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../hopper-company-queries-ii "Hopper Company Queries II") diff --git a/problems/get-the-maximum-score/README.md b/problems/get-the-maximum-score/README.md index d3b8f3baa..86d638303 100644 --- a/problems/get-the-maximum-score/README.md +++ b/problems/get-the-maximum-score/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-swaps-to-arrange-a-binary-grid "Minimum Swaps to Arrange a Binary Grid") @@ -16,16 +16,14 @@

    A valid path is defined as follows:

      -
    • Choose array nums1 or nums2 to traverse (from index-0).
    • +
    • Choose array nums1 or nums2 to traverse (from index-0).
    • Traverse the current array from left to right.
    • -
    • If you are reading any value that is present in nums1 and nums2 you are allowed to change your path to the other array. (Only one repeated value is considered in the valid path).
    • +
    • If you are reading any value that is present in nums1 and nums2 you are allowed to change your path to the other array. (Only one repeated value is considered in the valid path).
    -

    Score is defined as the sum of uniques values in a valid path.

    +

    The score is defined as the sum of uniques values in a valid path.

    -

    Return the maximum score you can obtain of all possible valid paths.

    - -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Return the maximum score you can obtain of all possible valid paths. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -69,9 +67,8 @@ Maximum sum is obtained with the path [6,7,8,9,10].

    Constraints:

      -
    • 1 <= nums1.length <= 10^5
    • -
    • 1 <= nums2.length <= 10^5
    • -
    • 1 <= nums1[i], nums2[i] <= 10^7
    • +
    • 1 <= nums1.length, nums2.length <= 105
    • +
    • 1 <= nums1[i], nums2[i] <= 107
    • nums1 and nums2 are strictly increasing.
    diff --git a/problems/global-and-local-inversions/README.md b/problems/global-and-local-inversions/README.md index fcf250992..37e03dcb7 100644 --- a/problems/global-and-local-inversions/README.md +++ b/problems/global-and-local-inversions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-max-distance-to-gas-station "Minimize Max Distance to Gas Station") diff --git a/problems/goal-parser-interpretation/README.md b/problems/goal-parser-interpretation/README.md index fbd323536..bb3dee44a 100644 --- a/problems/goal-parser-interpretation/README.md +++ b/problems/goal-parser-interpretation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../products-worth-over-invoices "Product's Worth Over Invoices") diff --git a/problems/goat-latin/README.md b/problems/goat-latin/README.md index 01ab02553..113402d0a 100644 --- a/problems/goat-latin/README.md +++ b/problems/goat-latin/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-trees-with-factors "Binary Trees With Factors") diff --git a/problems/grand-slam-titles/README.md b/problems/grand-slam-titles/README.md index a5325d294..f47024e06 100644 --- a/problems/grand-slam-titles/README.md +++ b/problems/grand-slam-titles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-pairs-of-nodes "Count Pairs Of Nodes") diff --git a/problems/graph-connectivity-with-threshold/README.md b/problems/graph-connectivity-with-threshold/README.md index 06834dd1c..c09292090 100644 --- a/problems/graph-connectivity-with-threshold/README.md +++ b/problems/graph-connectivity-with-threshold/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-team-with-no-conflicts "Best Team With No Conflicts") diff --git a/problems/graph-valid-tree/README.md b/problems/graph-valid-tree/README.md index 811f8946d..ffb6f3b79 100644 --- a/problems/graph-valid-tree/README.md +++ b/problems/graph-valid-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../single-number-iii "Single Number III") diff --git a/problems/greatest-common-divisor-of-strings/README.md b/problems/greatest-common-divisor-of-strings/README.md index 313d29097..fdacf33b8 100644 --- a/problems/greatest-common-divisor-of-strings/README.md +++ b/problems/greatest-common-divisor-of-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../product-sales-analysis-iii "Product Sales Analysis III") @@ -42,6 +42,9 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/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/greatest-sum-divisible-by-three/README.md b/problems/greatest-sum-divisible-by-three/README.md index 229e2df13..5e1039e36 100644 --- a/problems/greatest-sum-divisible-by-three/README.md +++ b/problems/greatest-sum-divisible-by-three/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-elements-in-a-contaminated-binary-tree "Find Elements in a Contaminated Binary Tree") @@ -49,9 +49,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/grid-game/README.md b/problems/grid-game/README.md index ee2968e0f..a18819ded 100644 --- a/problems/grid-game/README.md +++ b/problems/grid-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-difference-between-increasing-elements "Maximum Difference Between Increasing Elements") diff --git a/problems/group-anagrams/README.md b/problems/group-anagrams/README.md index a6b12a7c8..03735262a 100644 --- a/problems/group-anagrams/README.md +++ b/problems/group-anagrams/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rotate-image "Rotate Image") diff --git a/problems/group-employees-of-the-same-salary/README.md b/problems/group-employees-of-the-same-salary/README.md index c6e8894fe..f221375de 100644 --- a/problems/group-employees-of-the-same-salary/README.md +++ b/problems/group-employees-of-the-same-salary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-product-sum-of-two-arrays "Minimize Product Sum of Two Arrays") diff --git a/problems/group-shifted-strings/README.md b/problems/group-shifted-strings/README.md index 93d32366f..1c029e1c7 100644 --- a/problems/group-shifted-strings/README.md +++ b/problems/group-shifted-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strobogrammatic-number-iii "Strobogrammatic Number III") diff --git a/problems/group-the-people-given-the-group-size-they-belong-to/README.md b/problems/group-the-people-given-the-group-size-they-belong-to/README.md index 9626d08e9..dba3a9ead 100644 --- a/problems/group-the-people-given-the-group-size-they-belong-to/README.md +++ b/problems/group-the-people-given-the-group-size-they-belong-to/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subtract-the-product-and-sum-of-digits-of-an-integer "Subtract the Product and Sum of Digits of an Integer") diff --git a/problems/grumpy-bookstore-owner/README.md b/problems/grumpy-bookstore-owner/README.md index 66324b90c..046dc245c 100644 --- a/problems/grumpy-bookstore-owner/README.md +++ b/problems/grumpy-bookstore-owner/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../height-checker "Height Checker") diff --git a/problems/guess-the-majority-in-a-hidden-array/README.md b/problems/guess-the-majority-in-a-hidden-array/README.md index b04070742..633b3be7d 100644 --- a/problems/guess-the-majority-in-a-hidden-array/README.md +++ b/problems/guess-the-majority-in-a-hidden-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../get-the-maximum-score "Get the Maximum Score") diff --git a/problems/guess-the-word/README.md b/problems/guess-the-word/README.md index 91e225d77..488ba5ca4 100644 --- a/problems/guess-the-word/README.md +++ b/problems/guess-the-word/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-array-into-fibonacci-sequence "Split Array into Fibonacci Sequence") @@ -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)] - [[Game Theory](../../tag/game-theory/README.md)] [[Interactive](../../tag/interactive/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] diff --git a/problems/h-index-ii/README.md b/problems/h-index-ii/README.md index c569b3fab..4952cf45a 100644 --- a/problems/h-index-ii/README.md +++ b/problems/h-index-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../h-index "H-Index") diff --git a/problems/h-index/README.md b/problems/h-index/README.md index 5e924ef5d..1ac775cba 100644 --- a/problems/h-index/README.md +++ b/problems/h-index/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../integer-to-english-words "Integer to English Words") @@ -45,8 +45,8 @@ Since the researcher has 3 papers with at least 3 citations each and the remaini ### Related Topics [[Array](../../tag/array/README.md)] - [[Sorting](../../tag/sorting/README.md)] [[Counting Sort](../../tag/counting-sort/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [H-Index II](../h-index-ii) (Medium) diff --git a/problems/hand-of-straights/README.md b/problems/hand-of-straights/README.md index cfe25d437..676fad6b1 100644 --- a/problems/hand-of-straights/README.md +++ b/problems/hand-of-straights/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-mountain-in-array "Longest Mountain in Array") @@ -46,7 +46,7 @@

    Note: This question is the same as 1296: https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/

    ### 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)] diff --git a/problems/heaters/README.md b/problems/heaters/README.md index c5b3d4d06..ffacf380b 100644 --- a/problems/heaters/README.md +++ b/problems/heaters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ones-and-zeroes "Ones and Zeroes") @@ -53,5 +53,6 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/height-checker/README.md b/problems/height-checker/README.md index a0eebcf67..01ace7bdc 100644 --- a/problems/height-checker/README.md +++ b/problems/height-checker/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../actors-and-directors-who-cooperated-at-least-three-times "Actors and Directors Who Cooperated At Least Three Times") diff --git a/problems/highest-grade-for-each-student/README.md b/problems/highest-grade-for-each-student/README.md index 69c705d34..42134a56f 100644 --- a/problems/highest-grade-for-each-student/README.md +++ b/problems/highest-grade-for-each-student/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-nesting-depth-of-two-valid-parentheses-strings "Maximum Nesting Depth of Two Valid Parentheses Strings") diff --git a/problems/hopper-company-queries-i/README.md b/problems/hopper-company-queries-i/README.md index 4b5a7682e..da53acdea 100644 --- a/problems/hopper-company-queries-i/README.md +++ b/problems/hopper-company-queries-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../add-two-polynomials-represented-as-linked-lists "Add Two Polynomials Represented as Linked Lists") diff --git a/problems/hopper-company-queries-ii/README.md b/problems/hopper-company-queries-ii/README.md index 19fa94092..61349c63d 100644 --- a/problems/hopper-company-queries-ii/README.md +++ b/problems/hopper-company-queries-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-a-binary-tree-ii "Lowest Common Ancestor of a Binary Tree II") diff --git a/problems/hopper-company-queries-iii/README.md b/problems/hopper-company-queries-iii/README.md index 9f6fd1489..62a14af70 100644 --- a/problems/hopper-company-queries-iii/README.md +++ b/problems/hopper-company-queries-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-a-binary-tree-iii "Lowest Common Ancestor of a Binary Tree III") @@ -15,3 +15,8 @@ ### 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-ii/README.md b/problems/house-robber-ii/README.md index ec027ba76..221ff0d5e 100644 --- a/problems/house-robber-ii/README.md +++ b/problems/house-robber-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-search-ii "Word Search II") diff --git a/problems/house-robber-iii/README.md b/problems/house-robber-iii/README.md index 1eb529b55..4f3e1613f 100644 --- a/problems/house-robber-iii/README.md +++ b/problems/house-robber-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindrome-pairs "Palindrome Pairs") diff --git a/problems/how-many-apples-can-you-put-into-the-basket/README.md b/problems/how-many-apples-can-you-put-into-the-basket/README.md index 81d680a95..b933f4598 100644 --- a/problems/how-many-apples-can-you-put-into-the-basket/README.md +++ b/problems/how-many-apples-can-you-put-into-the-basket/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fizz-buzz-multithreaded "Fizz Buzz Multithreaded") @@ -41,8 +41,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/human-traffic-of-stadium/README.md b/problems/human-traffic-of-stadium/README.md index c12bb4e60..ffdab638f 100644 --- a/problems/human-traffic-of-stadium/README.md +++ b/problems/human-traffic-of-stadium/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../non-negative-integers-without-consecutive-ones "Non-negative Integers without Consecutive Ones") @@ -35,9 +35,11 @@ No two rows will have the same visit_date, and as the id increases, the dates in

    The query result format is in the following example.

     

    +

    Example 1:

    -Stadium table:
    +Input: 
    +Stadium table:
     +------+------------+-----------+
     | id   | visit_date | people    |
     +------+------------+-----------+
    @@ -50,8 +52,7 @@ No two rows will have the same visit_date, and as the id increases, the dates in
     | 7    | 2017-01-07 | 199       |
     | 8    | 2017-01-09 | 188       |
     +------+------------+-----------+
    -
    -Result table:
    +Output: 
     +------+------------+-----------+
     | id   | visit_date | people    |
     +------+------------+-----------+
    @@ -60,8 +61,10 @@ Result table:
     | 7    | 2017-01-07 | 199       |
     | 8    | 2017-01-09 | 188       |
     +------+------------+-----------+
    +Explanation: 
     The four rows with ids 5, 6, 7, and 8 have consecutive ids and each of them has >= 100 people attended. Note that row 8 was included even though the visit_date was not the next day after row 7.
    -The rows with ids 2 and 3 are not included because we need at least three consecutive ids.
    +The rows with ids 2 and 3 are not included because we need at least three consecutive ids. + ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/human-traffic-of-stadium/mysql_schemas.sql b/problems/human-traffic-of-stadium/mysql_schemas.sql index 735337369..b01b95410 100644 --- a/problems/human-traffic-of-stadium/mysql_schemas.sql +++ b/problems/human-traffic-of-stadium/mysql_schemas.sql @@ -1,10 +1,10 @@ -Create table If Not Exists stadium (id int, visit_date DATE NULL, people int); -Truncate table stadium; -insert into stadium (id, visit_date, people) values ('1', '2017-01-01', '10'); -insert into stadium (id, visit_date, people) values ('2', '2017-01-02', '109'); -insert into stadium (id, visit_date, people) values ('3', '2017-01-03', '150'); -insert into stadium (id, visit_date, people) values ('4', '2017-01-04', '99'); -insert into stadium (id, visit_date, people) values ('5', '2017-01-05', '145'); -insert into stadium (id, visit_date, people) values ('6', '2017-01-06', '1455'); -insert into stadium (id, visit_date, people) values ('7', '2017-01-07', '199'); -insert into stadium (id, visit_date, people) values ('8', '2017-01-09', '188'); +Create table If Not Exists Stadium (id int, visit_date DATE NULL, people int); +Truncate table Stadium; +insert into Stadium (id, visit_date, people) values ('1', '2017-01-01', '10'); +insert into Stadium (id, visit_date, people) values ('2', '2017-01-02', '109'); +insert into Stadium (id, visit_date, people) values ('3', '2017-01-03', '150'); +insert into Stadium (id, visit_date, people) values ('4', '2017-01-04', '99'); +insert into Stadium (id, visit_date, people) values ('5', '2017-01-05', '145'); +insert into Stadium (id, visit_date, people) values ('6', '2017-01-06', '1455'); +insert into Stadium (id, visit_date, people) values ('7', '2017-01-07', '199'); +insert into Stadium (id, visit_date, people) values ('8', '2017-01-09', '188'); diff --git a/problems/image-smoother/README.md b/problems/image-smoother/README.md index a664dcfbe..357df58ca 100644 --- a/problems/image-smoother/README.md +++ b/problems/image-smoother/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-9 "Remove 9") diff --git a/problems/implement-magic-dictionary/README.md b/problems/implement-magic-dictionary/README.md index 7237ddd01..212ba9254 100644 --- a/problems/implement-magic-dictionary/README.md +++ b/problems/implement-magic-dictionary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cut-off-trees-for-golf-event "Cut Off Trees for Golf Event") @@ -55,11 +55,11 @@ magicDictionary.search("leetcoded"); // return False ### 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)] ### Similar Questions 1. [Implement Trie (Prefix Tree)](../implement-trie-prefix-tree) (Medium) - 1. [Longest Word in Dictionary](../longest-word-in-dictionary) (Easy) + 1. [Longest Word in Dictionary](../longest-word-in-dictionary) (Medium) diff --git a/problems/implement-queue-using-stacks/README.md b/problems/implement-queue-using-stacks/README.md index 6a6b99560..6fc28351e 100644 --- a/problems/implement-queue-using-stacks/README.md +++ b/problems/implement-queue-using-stacks/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../power-of-two "Power of Two") diff --git a/problems/implement-trie-ii-prefix-tree/README.md b/problems/implement-trie-ii-prefix-tree/README.md index a4db81819..f7c7d2d56 100644 --- a/problems/implement-trie-ii-prefix-tree/README.md +++ b/problems/implement-trie-ii-prefix-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-pairs-with-xor-in-a-range "Count Pairs With XOR in a Range") diff --git a/problems/increasing-order-search-tree/README.md b/problems/increasing-order-search-tree/README.md index 166decb16..0d79507af 100644 --- a/problems/increasing-order-search-tree/README.md +++ b/problems/increasing-order-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../monotonic-array "Monotonic Array") diff --git a/problems/increasing-triplet-subsequence/README.md b/problems/increasing-triplet-subsequence/README.md index 232b97085..8c9db9595 100644 --- a/problems/increasing-triplet-subsequence/README.md +++ b/problems/increasing-triplet-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-bst-subtree "Largest BST Subtree") diff --git a/problems/incremental-memory-leak/README.md b/problems/incremental-memory-leak/README.md index d2ca85d65..17c716d16 100644 --- a/problems/incremental-memory-leak/README.md +++ b/problems/incremental-memory-leak/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sorting-the-sentence "Sorting the Sentence") diff --git a/problems/inorder-successor-in-bst-ii/README.md b/problems/inorder-successor-in-bst-ii/README.md index 3a0d8f6d5..296fe42ec 100644 --- a/problems/inorder-successor-in-bst-ii/README.md +++ b/problems/inorder-successor-in-bst-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fibonacci-number "Fibonacci Number") diff --git a/problems/inorder-successor-in-bst/README.md b/problems/inorder-successor-in-bst/README.md index 53a67debc..f81ac9086 100644 --- a/problems/inorder-successor-in-bst/README.md +++ b/problems/inorder-successor-in-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../peeking-iterator "Peeking Iterator") diff --git a/problems/insert-interval/README.md b/problems/insert-interval/README.md index c10a0a136..c40a05e55 100644 --- a/problems/insert-interval/README.md +++ b/problems/insert-interval/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-intervals "Merge Intervals") diff --git a/problems/insertion-sort-list/README.md b/problems/insertion-sort-list/README.md index 0f772bb2b..2e918925e 100644 --- a/problems/insertion-sort-list/README.md +++ b/problems/insertion-sort-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lru-cache "LRU Cache") diff --git a/problems/integer-break/README.md b/problems/integer-break/README.md index 0358214d1..0975fcec2 100644 --- a/problems/integer-break/README.md +++ b/problems/integer-break/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../power-of-four "Power of Four") @@ -43,6 +43,9 @@ [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Maximize Number of Nice Divisors](../maximize-number-of-nice-divisors) (Hard) + ### Hints
    Hint 1 diff --git a/problems/intersection-of-three-sorted-arrays/README.md b/problems/intersection-of-three-sorted-arrays/README.md index 5f337a0ef..4c336af5d 100644 --- a/problems/intersection-of-three-sorted-arrays/README.md +++ b/problems/intersection-of-three-sorted-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../team-scores-in-football-tournament "Team Scores in Football Tournament") diff --git a/problems/invalid-transactions/README.md b/problems/invalid-transactions/README.md index 0a84ff410..f8165e7ad 100644 --- a/problems/invalid-transactions/README.md +++ b/problems/invalid-transactions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../optimize-water-distribution-in-a-village "Optimize Water Distribution in a Village") diff --git a/problems/invalid-tweets/README.md b/problems/invalid-tweets/README.md index 098ac36fe..2c9eab577 100644 --- a/problems/invalid-tweets/README.md +++ b/problems/invalid-tweets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-palindromic-subsequence-ii "Longest Palindromic Subsequence II") diff --git a/problems/investments-in-2016/README.md b/problems/investments-in-2016/README.md index 23dfc1764..0d88b615d 100644 --- a/problems/investments-in-2016/README.md +++ b/problems/investments-in-2016/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-customer-referee "Find Customer Referee") diff --git a/problems/ip-to-cidr/README.md b/problems/ip-to-cidr/README.md index 1e4eb571f..be63e0887 100644 --- a/problems/ip-to-cidr/README.md +++ b/problems/ip-to-cidr/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-corner-rectangles "Number Of Corner Rectangles") @@ -63,8 +63,8 @@ that are outside the specified range.

    ### Related Topics - [[String](../../tag/string/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Restore IP Addresses](../restore-ip-addresses) (Medium) diff --git a/problems/is-subsequence/README.md b/problems/is-subsequence/README.md index 64a0597ae..a57e77471 100644 --- a/problems/is-subsequence/README.md +++ b/problems/is-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../perfect-rectangle "Perfect Rectangle") diff --git a/problems/iterator-for-combination/README.md b/problems/iterator-for-combination/README.md index a196371df..193a09a29 100644 --- a/problems/iterator-for-combination/README.md +++ b/problems/iterator-for-combination/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-start-and-end-number-of-continuous-ranges "Find the Start and End Number of Continuous Ranges") diff --git a/problems/jump-game-ii/README.md b/problems/jump-game-ii/README.md index 7a13e8b1d..986e4cccd 100644 --- a/problems/jump-game-ii/README.md +++ b/problems/jump-game-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../wildcard-matching "Wildcard Matching") @@ -44,9 +44,11 @@ ### 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. [Jump Game](../jump-game) (Medium) + 1. [Jump Game III](../jump-game-iii) (Medium) + 1. [Jump Game VII](../jump-game-vii) (Medium) diff --git a/problems/jump-game-vi/README.md b/problems/jump-game-vi/README.md index 7a6eecb5a..e18bac1d8 100644 --- a/problems/jump-game-vi/README.md +++ b/problems/jump-game-vi/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-erasure-value "Maximum Erasure Value") @@ -52,12 +52,16 @@ ### 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)] - [[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. [Sliding Window Maximum](../sliding-window-maximum) (Hard) + 1. [Jump Game VII](../jump-game-vii) (Medium) ### Hints
    diff --git a/problems/jump-game-vii/README.md b/problems/jump-game-vii/README.md index 68a2bd819..b8df8c8f6 100644 --- a/problems/jump-game-vii/README.md +++ b/problems/jump-game-vii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-speed-to-arrive-on-time "Minimum Speed to Arrive on Time") diff --git a/problems/k-concatenation-maximum-sum/README.md b/problems/k-concatenation-maximum-sum/README.md index 7217df2cb..bc3299b89 100644 --- a/problems/k-concatenation-maximum-sum/README.md +++ b/problems/k-concatenation-maximum-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-substrings-between-each-pair-of-parentheses "Reverse Substrings Between Each Pair of Parentheses") diff --git a/problems/k-inverse-pairs-array/README.md b/problems/k-inverse-pairs-array/README.md index e3078c854..965cf20b2 100644 --- a/problems/k-inverse-pairs-array/README.md +++ b/problems/k-inverse-pairs-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-of-three-numbers "Maximum Product of Three Numbers") diff --git a/problems/keys-and-rooms/README.md b/problems/keys-and-rooms/README.md index ba29f0504..0e91287a1 100644 --- a/problems/keys-and-rooms/README.md +++ b/problems/keys-and-rooms/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../magic-squares-in-grid "Magic Squares In Grid") @@ -55,3 +55,6 @@ Since we were able to visit every room, we return true. [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] + +### Similar Questions + 1. [Graph Valid Tree](../graph-valid-tree) (Medium) diff --git a/problems/kids-with-the-greatest-number-of-candies/README.md b/problems/kids-with-the-greatest-number-of-candies/README.md index 85ea93f67..248845bf8 100644 --- a/problems/kids-with-the-greatest-number-of-candies/README.md +++ b/problems/kids-with-the-greatest-number-of-candies/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree") diff --git a/problems/knight-dialer/README.md b/problems/knight-dialer/README.md index a3353836c..4184e20d6 100644 --- a/problems/knight-dialer/README.md +++ b/problems/knight-dialer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-bridge "Shortest Bridge") diff --git a/problems/knight-probability-in-chessboard/README.md b/problems/knight-probability-in-chessboard/README.md index 0de237ddb..6d64e64fb 100644 --- a/problems/knight-probability-in-chessboard/README.md +++ b/problems/knight-probability-in-chessboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-univalue-path "Longest Univalue Path") diff --git a/problems/koko-eating-bananas/README.md b/problems/koko-eating-bananas/README.md index 43eeda9ad..89ee52e14 100644 --- a/problems/koko-eating-bananas/README.md +++ b/problems/koko-eating-bananas/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../walking-robot-simulation "Walking Robot Simulation") diff --git a/problems/kth-ancestor-of-a-tree-node/README.md b/problems/kth-ancestor-of-a-tree-node/README.md index 45fab111e..b453b8438 100644 --- a/problems/kth-ancestor-of-a-tree-node/README.md +++ b/problems/kth-ancestor-of-a-tree-node/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-days-to-make-m-bouquets "Minimum Number of Days to Make m Bouquets") @@ -51,12 +51,12 @@ treeAncestor.getKthAncestor(6, 3); // returns -1 because there is no such ancest ### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/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)] [[Design](../../tag/design/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/kth-distinct-string-in-an-array/README.md b/problems/kth-distinct-string-in-an-array/README.md index f92f4b12e..ecdafd738 100644 --- a/problems/kth-distinct-string-in-an-array/README.md +++ b/problems/kth-distinct-string-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-separate-sentence-into-rows "Minimum Cost to Separate Sentence Into Rows") diff --git a/problems/kth-missing-positive-number/README.md b/problems/kth-missing-positive-number/README.md index 63e8ab069..243391cfb 100644 --- a/problems/kth-missing-positive-number/README.md +++ b/problems/kth-missing-positive-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../guess-the-majority-in-a-hidden-array "Guess the Majority in a Hidden Array") diff --git a/problems/kth-smallest-element-in-a-bst/README.md b/problems/kth-smallest-element-in-a-bst/README.md index f8eda47d2..baf52bc92 100644 --- a/problems/kth-smallest-element-in-a-bst/README.md +++ b/problems/kth-smallest-element-in-a-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../majority-element-ii "Majority Element II") @@ -11,7 +11,7 @@ ## [230. Kth Smallest Element in a BST (Medium)](https://leetcode.com/problems/kth-smallest-element-in-a-bst "二叉搜索树中第K小的元素") -

    Given the root of a binary search tree, and an integer k, return the kth (1-indexed) smallest element in the tree.

    +

    Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree.

     

    Example 1:

    @@ -38,7 +38,7 @@

     

    -Follow up: If the BST is modified often (i.e., we can do insert and delete operations) and you need to find the kth smallest frequently, how would you optimize? +

    Follow up: If the BST is modified often (i.e., we can do insert and delete operations) and you need to find the kth smallest frequently, how would you optimize?

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/kth-smallest-instructions/README.md b/problems/kth-smallest-instructions/README.md index 43d8a7e9e..5820b7981 100644 --- a/problems/kth-smallest-instructions/README.md +++ b/problems/kth-smallest-instructions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../furthest-building-you-can-reach "Furthest Building You Can Reach") diff --git a/problems/kth-smallest-number-in-multiplication-table/README.md b/problems/kth-smallest-number-in-multiplication-table/README.md index cda7f63f4..92bfa7196 100644 --- a/problems/kth-smallest-number-in-multiplication-table/README.md +++ b/problems/kth-smallest-number-in-multiplication-table/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../beautiful-arrangement-ii "Beautiful Arrangement II") diff --git a/problems/kth-smallest-product-of-two-sorted-arrays/README.md b/problems/kth-smallest-product-of-two-sorted-arrays/README.md index b15aac8f0..a603687f3 100644 --- a/problems/kth-smallest-product-of-two-sorted-arrays/README.md +++ b/problems/kth-smallest-product-of-two-sorted-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-time-when-the-network-becomes-idle "The Time When the Network Becomes Idle") diff --git a/problems/kth-smallest-subarray-sum/README.md b/problems/kth-smallest-subarray-sum/README.md index 12f5c8f9b..e58ecad9f 100644 --- a/problems/kth-smallest-subarray-sum/README.md +++ b/problems/kth-smallest-subarray-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../leetcodify-friends-recommendations "Leetcodify Friends Recommendations") diff --git a/problems/largest-bst-subtree/README.md b/problems/largest-bst-subtree/README.md index 1c4b2ebfa..69c9b4513 100644 --- a/problems/largest-bst-subtree/README.md +++ b/problems/largest-bst-subtree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reconstruct-itinerary "Reconstruct Itinerary") diff --git a/problems/largest-color-value-in-a-directed-graph/README.md b/problems/largest-color-value-in-a-directed-graph/README.md index 57ca403d2..9ca2b2ad1 100644 --- a/problems/largest-color-value-in-a-directed-graph/README.md +++ b/problems/largest-color-value-in-a-directed-graph/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-subarray-min-product "Maximum Subarray Min-Product") diff --git a/problems/largest-component-size-by-common-factor/README.md b/problems/largest-component-size-by-common-factor/README.md index 7750f88a9..a9303e864 100644 --- a/problems/largest-component-size-by-common-factor/README.md +++ b/problems/largest-component-size-by-common-factor/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flip-equivalent-binary-trees "Flip Equivalent Binary Trees") @@ -52,6 +52,6 @@ ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/largest-divisible-subset/README.md b/problems/largest-divisible-subset/README.md index 0f9a2ebe3..18b71216d 100644 --- a/problems/largest-divisible-subset/README.md +++ b/problems/largest-divisible-subset/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-perfect-square "Valid Perfect Square") diff --git a/problems/largest-magic-square/README.md b/problems/largest-magic-square/README.md index 59cda4a50..d0553679e 100644 --- a/problems/largest-magic-square/README.md +++ b/problems/largest-magic-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-student-that-will-replace-the-chalk "Find the Student that Will Replace the Chalk") @@ -50,6 +50,9 @@ 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-merge-of-two-strings/README.md b/problems/largest-merge-of-two-strings/README.md index d34b995e1..35fd263b1 100644 --- a/problems/largest-merge-of-two-strings/README.md +++ b/problems/largest-merge-of-two-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-score-from-removing-stones "Maximum Score From Removing Stones") @@ -61,9 +61,9 @@ ### 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/largest-number-after-mutating-substring/README.md b/problems/largest-number-after-mutating-substring/README.md index 1ad178a38..4dd0ddd4a 100644 --- a/problems/largest-number-after-mutating-substring/README.md +++ b/problems/largest-number-after-mutating-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-digits-of-string-after-convert "Sum of Digits of String After Convert") diff --git a/problems/largest-number/README.md b/problems/largest-number/README.md index 696779518..de24d869a 100644 --- a/problems/largest-number/README.md +++ b/problems/largest-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rank-scores "Rank Scores") @@ -53,6 +53,6 @@ ### Related Topics - [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/largest-odd-number-in-string/README.md b/problems/largest-odd-number-in-string/README.md index 791077f0c..71116c391 100644 --- a/problems/largest-odd-number-in-string/README.md +++ b/problems/largest-odd-number-in-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../depth-of-bst-given-insertion-order "Depth of BST Given Insertion Order") diff --git a/problems/largest-palindrome-product/README.md b/problems/largest-palindrome-product/README.md index b46bed414..0dd3baf0d 100644 --- a/problems/largest-palindrome-product/README.md +++ b/problems/largest-palindrome-product/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../generate-random-point-in-a-circle "Generate Random Point in a Circle") diff --git a/problems/largest-rectangle-in-histogram/README.md b/problems/largest-rectangle-in-histogram/README.md index 8c39df842..9257981d2 100644 --- a/problems/largest-rectangle-in-histogram/README.md +++ b/problems/largest-rectangle-in-histogram/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicates-from-sorted-list "Remove Duplicates from Sorted List") diff --git a/problems/largest-subarray-length-k/README.md b/problems/largest-subarray-length-k/README.md index 468e3c7c9..f4590c82e 100644 --- a/problems/largest-subarray-length-k/README.md +++ b/problems/largest-subarray-length-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-xor-with-an-element-from-array "Maximum XOR With an Element From Array") @@ -14,8 +14,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/largest-submatrix-with-rearrangements/README.md b/problems/largest-submatrix-with-rearrangements/README.md index 7c6e765e0..6c614e375 100644 --- a/problems/largest-submatrix-with-rearrangements/README.md +++ b/problems/largest-submatrix-with-rearrangements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tuple-with-same-product "Tuple with Same Product") diff --git a/problems/largest-substring-between-two-equal-characters/README.md b/problems/largest-substring-between-two-equal-characters/README.md index 69dbaf3e6..c707c3506 100644 --- a/problems/largest-substring-between-two-equal-characters/README.md +++ b/problems/largest-substring-between-two-equal-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-valid-triplets-that-can-represent-a-country "All Valid Triplets That Can Represent a Country") diff --git a/problems/largest-time-for-given-digits/README.md b/problems/largest-time-for-given-digits/README.md index ba0573dd8..73adf0242 100644 --- a/problems/largest-time-for-given-digits/README.md +++ b/problems/largest-time-for-given-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bag-of-tokens "Bag of Tokens") diff --git a/problems/largest-unique-number/README.md b/problems/largest-unique-number/README.md index ad2ebb845..ee87cb4c9 100644 --- a/problems/largest-unique-number/README.md +++ b/problems/largest-unique-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reported-posts-ii "Reported Posts II") diff --git a/problems/largest-values-from-labels/README.md b/problems/largest-values-from-labels/README.md index 86b4bc468..b29a41655 100644 --- a/problems/largest-values-from-labels/README.md +++ b/problems/largest-values-from-labels/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../duplicate-zeros "Duplicate Zeros") diff --git a/problems/last-day-where-you-can-still-cross/README.md b/problems/last-day-where-you-can-still-cross/README.md index 4f3148f3d..fbaecbd9f 100644 --- a/problems/last-day-where-you-can-still-cross/README.md +++ b/problems/last-day-where-you-can-still-cross/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-non-zero-product-of-the-array-elements "Minimum Non-Zero Product of the Array Elements") 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 f68c40999..2cd2780b0 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../can-make-arithmetic-progression-from-sequence "Can Make Arithmetic Progression From Sequence") @@ -78,8 +78,8 @@ Note that the last moment when an ant was on the plank is t = 4 second, after th ### Related Topics - [[Brainteaser](../../tag/brainteaser/README.md)] [[Array](../../tag/array/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/last-person-to-fit-in-the-bus/README.md b/problems/last-person-to-fit-in-the-bus/README.md index f2795f8aa..68645ff52 100644 --- a/problems/last-person-to-fit-in-the-bus/README.md +++ b/problems/last-person-to-fit-in-the-bus/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-items-by-groups-respecting-dependencies "Sort Items by Groups Respecting Dependencies") diff --git a/problems/last-stone-weight-ii/README.md b/problems/last-stone-weight-ii/README.md index 011157ea3..6a41ec950 100644 --- a/problems/last-stone-weight-ii/README.md +++ b/problems/last-stone-weight-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-string-chain "Longest String Chain") diff --git a/problems/last-stone-weight/README.md b/problems/last-stone-weight/README.md index 5ebb9e946..781736daf 100644 --- a/problems/last-stone-weight/README.md +++ b/problems/last-stone-weight/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../customers-who-bought-all-products "Customers Who Bought All Products") diff --git a/problems/last-substring-in-lexicographical-order/README.md b/problems/last-substring-in-lexicographical-order/README.md index 59cc6eebd..a0a54cd2d 100644 --- a/problems/last-substring-in-lexicographical-order/README.md +++ b/problems/last-substring-in-lexicographical-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../as-far-from-land-as-possible "As Far from Land as Possible") diff --git a/problems/latest-time-by-replacing-hidden-digits/README.md b/problems/latest-time-by-replacing-hidden-digits/README.md index d149d6f02..1410e84f9 100644 --- a/problems/latest-time-by-replacing-hidden-digits/README.md +++ b/problems/latest-time-by-replacing-hidden-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-ways-to-make-array-with-product "Count Ways to Make Array With Product") diff --git a/problems/league-statistics/README.md b/problems/league-statistics/README.md index 726bfab63..30c677001 100644 --- a/problems/league-statistics/README.md +++ b/problems/league-statistics/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-building-height "Maximum Building Height") diff --git a/problems/least-operators-to-express-number/README.md b/problems/least-operators-to-express-number/README.md index d85bbf369..b66220e68 100644 --- a/problems/least-operators-to-express-number/README.md +++ b/problems/least-operators-to-express-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-area-rectangle-ii "Minimum Area Rectangle II") diff --git a/problems/leetcodify-friends-recommendations/README.md b/problems/leetcodify-friends-recommendations/README.md index 1ea2a6933..cb786fb0e 100644 --- a/problems/leetcodify-friends-recommendations/README.md +++ b/problems/leetcodify-friends-recommendations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-ways-to-build-rooms-in-an-ant-colony "Count Ways to Build Rooms in an Ant Colony") diff --git a/problems/leetcodify-similar-friends/README.md b/problems/leetcodify-similar-friends/README.md index 8d1a914e4..f7168514e 100644 --- a/problems/leetcodify-similar-friends/README.md +++ b/problems/leetcodify-similar-friends/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-smallest-subarray-sum "Kth Smallest Subarray Sum") diff --git a/problems/leetflex-banned-accounts/README.md b/problems/leetflex-banned-accounts/README.md index 9abe49cd9..b6c7f5d38 100644 --- a/problems/leetflex-banned-accounts/README.md +++ b/problems/leetflex-banned-accounts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-subarray-sum-after-one-operation "Maximum Subarray Sum After One Operation") diff --git a/problems/letter-case-permutation/README.md b/problems/letter-case-permutation/README.md index 2b66690bb..1599aa88b 100644 --- a/problems/letter-case-permutation/README.md +++ b/problems/letter-case-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-distance-between-bst-nodes "Minimum Distance Between BST Nodes") diff --git a/problems/letter-combinations-of-a-phone-number/README.md b/problems/letter-combinations-of-a-phone-number/README.md index 6a7642720..9137185d6 100644 --- a/problems/letter-combinations-of-a-phone-number/README.md +++ b/problems/letter-combinations-of-a-phone-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../3sum-closest "3Sum Closest") diff --git a/problems/lexicographically-smallest-string-after-applying-operations/README.md b/problems/lexicographically-smallest-string-after-applying-operations/README.md index 5b989496f..d0c943cb6 100644 --- a/problems/lexicographically-smallest-string-after-applying-operations/README.md +++ b/problems/lexicographically-smallest-string-after-applying-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-substring-between-two-equal-characters "Largest Substring Between Two Equal Characters") diff --git a/problems/lfu-cache/README.md b/problems/lfu-cache/README.md index fd420a0ad..2f18a3838 100644 --- a/problems/lfu-cache/README.md +++ b/problems/lfu-cache/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../repeated-substring-pattern "Repeated Substring Pattern") diff --git a/problems/linked-list-cycle-ii/README.md b/problems/linked-list-cycle-ii/README.md index 40ac202cf..df0746b4d 100644 --- a/problems/linked-list-cycle-ii/README.md +++ b/problems/linked-list-cycle-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../linked-list-cycle "Linked List Cycle") diff --git a/problems/linked-list-cycle/README.md b/problems/linked-list-cycle/README.md index 1f86ca6c2..9a218076f 100644 --- a/problems/linked-list-cycle/README.md +++ b/problems/linked-list-cycle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-break-ii "Word Break II") diff --git a/problems/linked-list-in-binary-tree/README.md b/problems/linked-list-in-binary-tree/README.md index 20e9f3439..bd5ccf805 100644 --- a/problems/linked-list-in-binary-tree/README.md +++ b/problems/linked-list-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rank-teams-by-votes "Rank Teams by Votes") @@ -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/list-the-products-ordered-in-a-period/README.md b/problems/list-the-products-ordered-in-a-period/README.md index 5e2623670..d05f83a48 100644 --- a/problems/list-the-products-ordered-in-a-period/README.md +++ b/problems/list-the-products-ordered-in-a-period/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-taps-to-open-to-water-a-garden "Minimum Number of Taps to Open to Water a Garden") 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 707743592..ea4ae8c81 100644 --- a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md +++ b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../product-of-two-run-length-encoded-arrays "Product of Two Run-Length Encoded Arrays") diff --git a/problems/longest-absolute-file-path/README.md b/problems/longest-absolute-file-path/README.md index 2d20db2af..12ed18bb9 100644 --- a/problems/longest-absolute-file-path/README.md +++ b/problems/longest-absolute-file-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../first-unique-character-in-a-string "First Unique Character in a String") diff --git a/problems/longest-chunked-palindrome-decomposition/README.md b/problems/longest-chunked-palindrome-decomposition/README.md index 9efadd596..6c7f56e26 100644 --- a/problems/longest-chunked-palindrome-decomposition/README.md +++ b/problems/longest-chunked-palindrome-decomposition/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../snapshot-array "Snapshot Array") @@ -63,12 +63,12 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/longest-common-subpath/README.md b/problems/longest-common-subpath/README.md index d0905f5ff..45d219a2c 100644 --- a/problems/longest-common-subpath/README.md +++ b/problems/longest-common-subpath/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-good-numbers "Count Good Numbers") diff --git a/problems/longest-common-subsequence-between-sorted-arrays/README.md b/problems/longest-common-subsequence-between-sorted-arrays/README.md index 11ff4e046..3f9f604dc 100644 --- a/problems/longest-common-subsequence-between-sorted-arrays/README.md +++ b/problems/longest-common-subsequence-between-sorted-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../users-that-actively-request-confirmation-messages "Users That Actively Request Confirmation Messages") diff --git a/problems/longest-continuous-increasing-subsequence/README.md b/problems/longest-continuous-increasing-subsequence/README.md index dd958afd2..c3fe206ee 100644 --- a/problems/longest-continuous-increasing-subsequence/README.md +++ b/problems/longest-continuous-increasing-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-longest-increasing-subsequence "Number of Longest Increasing Subsequence") diff --git a/problems/longest-happy-prefix/README.md b/problems/longest-happy-prefix/README.md index e9dc543d9..673083037 100644 --- a/problems/longest-happy-prefix/README.md +++ b/problems/longest-happy-prefix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-there-is-a-valid-path-in-a-grid "Check if There is a Valid Path in a Grid") diff --git a/problems/longest-happy-string/README.md b/problems/longest-happy-string/README.md index f678998ac..bd6c6c74d 100644 --- a/problems/longest-happy-string/README.md +++ b/problems/longest-happy-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-steps-to-reduce-a-number-in-binary-representation-to-one "Number of Steps to Reduce a Number in Binary Representation to One") @@ -56,8 +56,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/longest-increasing-path-in-a-matrix/README.md b/problems/longest-increasing-path-in-a-matrix/README.md index 213f6ceaf..2561b5543 100644 --- a/problems/longest-increasing-path-in-a-matrix/README.md +++ b/problems/longest-increasing-path-in-a-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../odd-even-linked-list "Odd Even Linked List") @@ -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-line-of-consecutive-one-in-matrix/README.md b/problems/longest-line-of-consecutive-one-in-matrix/README.md index fb11d2954..a6ea512dd 100644 --- a/problems/longest-line-of-consecutive-one-in-matrix/README.md +++ b/problems/longest-line-of-consecutive-one-in-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../array-partition-i "Array Partition I") diff --git a/problems/longest-nice-substring/README.md b/problems/longest-nice-substring/README.md index 4448c532b..8d3fc5369 100644 --- a/problems/longest-nice-substring/README.md +++ b/problems/longest-nice-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../buildings-with-an-ocean-view "Buildings With an Ocean View") @@ -56,9 +56,9 @@ As there are multiple longest nice substrings, return "dD" since it oc ### 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)] [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints diff --git a/problems/longest-palindromic-subsequence-ii/README.md b/problems/longest-palindromic-subsequence-ii/README.md index 01a6261bd..7e5d73629 100644 --- a/problems/longest-palindromic-subsequence-ii/README.md +++ b/problems/longest-palindromic-subsequence-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-incompatibility "Minimum Incompatibility") diff --git a/problems/longest-palindromic-substring/README.md b/problems/longest-palindromic-substring/README.md index ef45a2370..9e3b74a31 100644 --- a/problems/longest-palindromic-substring/README.md +++ b/problems/longest-palindromic-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../median-of-two-sorted-arrays "Median of Two Sorted Arrays") diff --git a/problems/longest-repeating-character-replacement/README.md b/problems/longest-repeating-character-replacement/README.md index 42e657293..650562490 100644 --- a/problems/longest-repeating-character-replacement/README.md +++ b/problems/longest-repeating-character-replacement/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reconstruct-original-digits-from-english "Reconstruct Original Digits from English") diff --git a/problems/longest-repeating-substring/README.md b/problems/longest-repeating-substring/README.md index 73900af81..0f83a9c26 100644 --- a/problems/longest-repeating-substring/README.md +++ b/problems/longest-repeating-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lexicographically-smallest-equivalent-string "Lexicographically Smallest Equivalent String") diff --git a/problems/longest-string-chain/README.md b/problems/longest-string-chain/README.md index 1aeb2e1e1..d659234b5 100644 --- a/problems/longest-string-chain/README.md +++ b/problems/longest-string-chain/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-all-adjacent-duplicates-in-string "Remove All Adjacent Duplicates In String") 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 06ad49cf8..6da0a32b4 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-kth-factor-of-n "The kth Factor of n") diff --git a/problems/longest-subsequence-repeated-k-times/README.md b/problems/longest-subsequence-repeated-k-times/README.md index 3e8e416f0..eb18b2de0 100644 --- a/problems/longest-subsequence-repeated-k-times/README.md +++ b/problems/longest-subsequence-repeated-k-times/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../detect-squares "Detect Squares") diff --git a/problems/longest-substring-of-all-vowels-in-order/README.md b/problems/longest-substring-of-all-vowels-in-order/README.md index 19e072052..c3cb2938b 100644 --- a/problems/longest-substring-of-all-vowels-in-order/README.md +++ b/problems/longest-substring-of-all-vowels-in-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../frequency-of-the-most-frequent-element "Frequency of the Most Frequent Element") diff --git a/problems/longest-substring-with-at-least-k-repeating-characters/README.md b/problems/longest-substring-with-at-least-k-repeating-characters/README.md index 2186a91b8..399a1e0f2 100644 --- a/problems/longest-substring-with-at-least-k-repeating-characters/README.md +++ b/problems/longest-substring-with-at-least-k-repeating-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decode-string "Decode String") diff --git a/problems/longest-substring-with-at-most-k-distinct-characters/README.md b/problems/longest-substring-with-at-most-k-distinct-characters/README.md index 3acc212e7..b2e57c3fa 100644 --- a/problems/longest-substring-with-at-most-k-distinct-characters/README.md +++ b/problems/longest-substring-with-at-most-k-distinct-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nested-list-weight-sum "Nested List Weight Sum") diff --git a/problems/longest-substring-with-at-most-two-distinct-characters/README.md b/problems/longest-substring-with-at-most-two-distinct-characters/README.md index f0eb80c88..34675cf52 100644 --- a/problems/longest-substring-with-at-most-two-distinct-characters/README.md +++ b/problems/longest-substring-with-at-most-two-distinct-characters/README.md @@ -1,11 +1,11 @@ - - - + + + -[< Previous](../read-n-characters-given-read4-ii-call-multiple-times "Read N Characters Given Read4 II - Call multiple times") +[< Previous](../read-n-characters-given-read4-ii-call-multiple-times "Read N Characters Given read4 II - Call Multiple Times")                  [Next >](../intersection-of-two-linked-lists "Intersection of Two Linked Lists") diff --git a/problems/longest-turbulent-subarray/README.md b/problems/longest-turbulent-subarray/README.md index 7487ae651..f73561019 100644 --- a/problems/longest-turbulent-subarray/README.md +++ b/problems/longest-turbulent-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../squares-of-a-sorted-array "Squares of a Sorted Array") diff --git a/problems/longest-uncommon-subsequence-i/README.md b/problems/longest-uncommon-subsequence-i/README.md index 604a89b0e..eaafad4e9 100644 --- a/problems/longest-uncommon-subsequence-i/README.md +++ b/problems/longest-uncommon-subsequence-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../detect-capital "Detect Capital") diff --git a/problems/longest-well-performing-interval/README.md b/problems/longest-well-performing-interval/README.md index 808f061bf..d9318ddc4 100644 --- a/problems/longest-well-performing-interval/README.md +++ b/problems/longest-well-performing-interval/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-deepest-leaves "Lowest Common Ancestor of Deepest Leaves") diff --git a/problems/longest-word-in-dictionary-through-deleting/README.md b/problems/longest-word-in-dictionary-through-deleting/README.md index 2a5c3657c..4569d4553 100644 --- a/problems/longest-word-in-dictionary-through-deleting/README.md +++ b/problems/longest-word-in-dictionary-through-deleting/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../continuous-subarray-sum "Continuous Subarray Sum") @@ -45,4 +45,4 @@ [[Sorting](../../tag/sorting/README.md)] ### Similar Questions - 1. [Longest Word in Dictionary](../longest-word-in-dictionary) (Easy) + 1. [Longest Word in Dictionary](../longest-word-in-dictionary) (Medium) diff --git a/problems/longest-word-in-dictionary/README.md b/problems/longest-word-in-dictionary/README.md index b7d6e76d6..4af3ff4db 100644 --- a/problems/longest-word-in-dictionary/README.md +++ b/problems/longest-word-in-dictionary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-k-th-smallest-pair-distance "Find K-th Smallest Pair Distance") diff --git a/problems/longest-word-with-all-prefixes/README.md b/problems/longest-word-with-all-prefixes/README.md index 7dfc2a6ba..f43785bbb 100644 --- a/problems/longest-word-with-all-prefixes/README.md +++ b/problems/longest-word-with-all-prefixes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-color-value-in-a-directed-graph "Largest Color Value in a Directed Graph") diff --git a/problems/longest-zigzag-path-in-a-binary-tree/README.md b/problems/longest-zigzag-path-in-a-binary-tree/README.md index b61ea3691..9790e1013 100644 --- a/problems/longest-zigzag-path-in-a-binary-tree/README.md +++ b/problems/longest-zigzag-path-in-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-longest-substring-containing-vowels-in-even-counts "Find the Longest Substring Containing Vowels in Even Counts") diff --git a/problems/low-quality-problems/README.md b/problems/low-quality-problems/README.md index 735e73f63..9daaf212c 100644 --- a/problems/low-quality-problems/README.md +++ b/problems/low-quality-problems/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-ways-to-partition-an-array "Maximum Number of Ways to Partition an Array") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md index d4d4f6ea0..bd6b7bf17 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-smallest-instructions "Kth Smallest Instructions") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md index f0cf11398..856c04b3a 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../create-sorted-array-through-instructions "Create Sorted Array through Instructions") 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 ecc88fe56..026487e5f 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-deviation-in-array "Minimize Deviation in Array") @@ -18,14 +18,6 @@ [[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-deepest-leaves/README.md b/problems/lowest-common-ancestor-of-deepest-leaves/README.md index 723e47239..bb79771bb 100644 --- a/problems/lowest-common-ancestor-of-deepest-leaves/README.md +++ b/problems/lowest-common-ancestor-of-deepest-leaves/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../relative-sort-array "Relative Sort Array") @@ -60,12 +60,15 @@ Note that nodes 6, 0, and 8 are also leaf nodes, but the depth of them is 2, but

    Note: This question is the same as 865: https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/

    ### 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 + 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/lucky-numbers-in-a-matrix/README.md b/problems/lucky-numbers-in-a-matrix/README.md index 459c575c6..a48481978 100644 --- a/problems/lucky-numbers-in-a-matrix/README.md +++ b/problems/lucky-numbers-in-a-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree "Find a Corresponding Node of a Binary Tree in a Clone of That Tree") diff --git a/problems/magical-string/README.md b/problems/magical-string/README.md index 176c447fd..6b960806b 100644 --- a/problems/magical-string/README.md +++ b/problems/magical-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sliding-window-median "Sliding Window Median") diff --git a/problems/magnetic-force-between-two-balls/README.md b/problems/magnetic-force-between-two-balls/README.md index 7cf25a0cb..f9fc9e02f 100644 --- a/problems/magnetic-force-between-two-balls/README.md +++ b/problems/magnetic-force-between-two-balls/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-operations-to-make-array-equal "Minimum Operations to Make Array Equal") @@ -11,11 +11,11 @@ ## [1552. Magnetic Force Between Two Balls (Medium)](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") -

    In universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the ith basket is at position[i], Morty has m balls and needs to distribute the balls into the baskets such that the minimum magnetic force between any two balls is maximum.

    +

    In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the ith basket is at position[i], Morty has m balls and needs to distribute the balls into the baskets such that the minimum magnetic force between any two balls is maximum.

    -

    Rick stated that magnetic force between two different balls at positions x and y is |x - y|.

    +

    Rick stated that magnetic force between two different balls at positions x and y is |x - y|.

    -

    Given the integer array position and the integer m. Return the required force.

    +

    Given the integer array position and the integer m. Return the required force.

     

    Example 1:

    @@ -39,8 +39,8 @@
    • n == position.length
    • -
    • 2 <= n <= 10^5
    • -
    • 1 <= position[i] <= 10^9
    • +
    • 2 <= n <= 105
    • +
    • 1 <= position[i] <= 109
    • All integers in position are distinct.
    • 2 <= m <= position.length
    diff --git a/problems/make-sum-divisible-by-p/README.md b/problems/make-sum-divisible-by-p/README.md index 7339ec36b..ecef87f72 100644 --- a/problems/make-sum-divisible-by-p/README.md +++ b/problems/make-sum-divisible-by-p/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-sum-obtained-of-any-permutation "Maximum Sum Obtained of Any Permutation") @@ -71,9 +71,6 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] -### Similar Questions - 1. [Subarray Sums Divisible by K](../subarray-sums-divisible-by-k) (Medium) - ### Hints
    Hint 1 diff --git a/problems/make-the-string-great/README.md b/problems/make-the-string-great/README.md index 3512fd642..2f6e82d68 100644 --- a/problems/make-the-string-great/README.md +++ b/problems/make-the-string-great/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fix-product-name-format "Fix Product Name Format") @@ -13,11 +13,11 @@

    Given a string s of lower and upper case English letters.

    -

    A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:

    +

    A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:

    • 0 <= i <= s.length - 2
    • -
    • s[i] is a lower-case letter and s[i + 1] is the same letter but in upper-case or vice-versa.
    • +
    • s[i] is a lower-case letter and s[i + 1] is the same letter but in upper-case or vice-versa.

    To make the string good, you can choose two adjacent characters that make the string bad and remove them. You can keep doing this until the string becomes good.

    diff --git a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md index 1a20704bd..050bb69d1 100644 --- a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md +++ b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-restricted-paths-from-first-to-last-node "Number of Restricted Paths From First to Last Node") @@ -48,9 +48,9 @@ ### 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)] ### Hints
    diff --git a/problems/making-file-names-unique/README.md b/problems/making-file-names-unique/README.md index 52a57457b..dc950449f 100644 --- a/problems/making-file-names-unique/README.md +++ b/problems/making-file-names-unique/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../xor-operation-in-an-array "XOR Operation in an Array") diff --git a/problems/map-of-highest-peak/README.md b/problems/map-of-highest-peak/README.md index c5d8c841d..e87e23d08 100644 --- a/problems/map-of-highest-peak/README.md +++ b/problems/map-of-highest-peak/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../form-array-by-concatenating-subarrays-of-another-array "Form Array by Concatenating Subarrays of Another Array") @@ -65,8 +65,8 @@ Any height assignment that has a maximum height of 2 while still meeting the rul ### Related Topics - [[Array](../../tag/array/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/market-analysis-i/README.md b/problems/market-analysis-i/README.md index b5f72e68f..db202cb38 100644 --- a/problems/market-analysis-i/README.md +++ b/problems/market-analysis-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../online-majority-element-in-subarray "Online Majority Element In Subarray") diff --git a/problems/market-analysis-i/mysql_schemas.sql b/problems/market-analysis-i/mysql_schemas.sql index 31eafa569..82f724345 100644 --- a/problems/market-analysis-i/mysql_schemas.sql +++ b/problems/market-analysis-i/mysql_schemas.sql @@ -1,6 +1,6 @@ Create table If Not Exists Users (user_id int, join_date date, favorite_brand varchar(10)); -create table if not exists Orders (order_id int, order_date date, item_id int, buyer_id int, seller_id int); -create table if not exists Items (item_id int, item_brand varchar(10)); +Create table If Not Exists Orders (order_id int, order_date date, item_id int, buyer_id int, seller_id int); +Create table If Not Exists Items (item_id int, item_brand varchar(10)); Truncate table Users; insert into Users (user_id, join_date, favorite_brand) values ('1', '2018-01-01', 'Lenovo'); insert into Users (user_id, join_date, favorite_brand) values ('2', '2018-02-09', 'Samsung'); diff --git a/problems/market-analysis-ii/README.md b/problems/market-analysis-ii/README.md index f1c2f278c..90625782d 100644 --- a/problems/market-analysis-ii/README.md +++ b/problems/market-analysis-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../market-analysis-i "Market Analysis I") diff --git a/problems/market-analysis-ii/mysql_schemas.sql b/problems/market-analysis-ii/mysql_schemas.sql index 2932728aa..1eea2fa16 100644 --- a/problems/market-analysis-ii/mysql_schemas.sql +++ b/problems/market-analysis-ii/mysql_schemas.sql @@ -1,6 +1,6 @@ Create table If Not Exists Users (user_id int, join_date date, favorite_brand varchar(10)); -create table if not exists Orders (order_id int, order_date date, item_id int, buyer_id int, seller_id int); -create table if not exists Items (item_id int, item_brand varchar(10)); +Create table If Not Exists Orders (order_id int, order_date date, item_id int, buyer_id int, seller_id int); +Create table If Not Exists Items (item_id int, item_brand varchar(10)); Truncate table Users; insert into Users (user_id, join_date, favorite_brand) values ('1', '2019-01-01', 'Lenovo'); insert into Users (user_id, join_date, favorite_brand) values ('2', '2019-02-09', 'Samsung'); diff --git a/problems/masking-personal-information/README.md b/problems/masking-personal-information/README.md index 855d82be5..7269126a5 100644 --- a/problems/masking-personal-information/README.md +++ b/problems/masking-personal-information/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../positions-of-large-groups "Positions of Large Groups") diff --git a/problems/matrix-diagonal-sum/README.md b/problems/matrix-diagonal-sum/README.md index 36266ded8..f45ad0315 100644 --- a/problems/matrix-diagonal-sum/README.md +++ b/problems/matrix-diagonal-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../warehouse-manager "Warehouse Manager") diff --git a/problems/max-area-of-island/README.md b/problems/max-area-of-island/README.md index fdc129b02..670981ff1 100644 --- a/problems/max-area-of-island/README.md +++ b/problems/max-area-of-island/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-distinct-islands "Number of Distinct Islands") @@ -44,12 +44,13 @@ ### 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. [Island Perimeter](../island-perimeter) (Easy) + 1. [Largest Submatrix With Rearrangements](../largest-submatrix-with-rearrangements) (Medium) diff --git a/problems/max-chunks-to-make-sorted/README.md b/problems/max-chunks-to-make-sorted/README.md index f83c459f5..f5bbcec5d 100644 --- a/problems/max-chunks-to-make-sorted/README.md +++ b/problems/max-chunks-to-make-sorted/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-chunks-to-make-sorted-ii "Max Chunks To Make Sorted II") diff --git a/problems/max-number-of-k-sum-pairs/README.md b/problems/max-number-of-k-sum-pairs/README.md index 5f9d4e125..3fbe61087 100644 --- a/problems/max-number-of-k-sum-pairs/README.md +++ b/problems/max-number-of-k-sum-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../goal-parser-interpretation "Goal Parser Interpretation") @@ -52,10 +52,6 @@ There are no more pairs that sum up to 6, hence a total of 1 operation. [[Two Pointers](../../tag/two-pointers/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Two Sum](../two-sum) (Easy) - 1. [Count Good Meals](../count-good-meals) (Medium) - ### Hints
    Hint 1 diff --git a/problems/max-stack/README.md b/problems/max-stack/README.md index 82a74168f..638b9406a 100644 --- a/problems/max-stack/README.md +++ b/problems/max-stack/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../range-module "Range Module") diff --git a/problems/max-sum-of-rectangle-no-larger-than-k/README.md b/problems/max-sum-of-rectangle-no-larger-than-k/README.md index 6ecd97fc0..fd0a83635 100644 --- a/problems/max-sum-of-rectangle-no-larger-than-k/README.md +++ b/problems/max-sum-of-rectangle-no-larger-than-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-hit-counter "Design Hit Counter") diff --git a/problems/max-value-of-equation/README.md b/problems/max-value-of-equation/README.md index 09a54ceb8..485de6f96 100644 --- a/problems/max-value-of-equation/README.md +++ b/problems/max-value-of-equation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-subsequences-that-satisfy-the-given-sum-condition "Number of Subsequences That Satisfy the Given Sum Condition") @@ -48,14 +48,11 @@ No other pairs satisfy the condition, so we return the max of 4 and 1. ### Related Topics - [[Array](../../tag/array/README.md)] [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/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. [Count Pairs in Two Arrays](../count-pairs-in-two-arrays) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/maximal-network-rank/README.md b/problems/maximal-network-rank/README.md index 6526d1dc1..d5630d2b3 100644 --- a/problems/maximal-network-rank/README.md +++ b/problems/maximal-network-rank/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-nesting-depth-of-the-parentheses "Maximum Nesting Depth of the Parentheses") diff --git a/problems/maximal-rectangle/README.md b/problems/maximal-rectangle/README.md index 4f3f25908..0a5485bb9 100644 --- a/problems/maximal-rectangle/README.md +++ b/problems/maximal-rectangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-rectangle-in-histogram "Largest Rectangle in Histogram") @@ -61,9 +61,9 @@ ### 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-distance-to-closest-person/README.md b/problems/maximize-distance-to-closest-person/README.md index 53c48ce05..e998d48da 100644 --- a/problems/maximize-distance-to-closest-person/README.md +++ b/problems/maximize-distance-to-closest-person/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shifting-letters "Shifting Letters") diff --git a/problems/maximize-grid-happiness/README.md b/problems/maximize-grid-happiness/README.md index b06fc1fe4..55e3d6ec6 100644 --- a/problems/maximize-grid-happiness/README.md +++ b/problems/maximize-grid-happiness/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-operations-to-reduce-x-to-zero "Minimum Operations to Reduce X to Zero") @@ -69,9 +69,9 @@ The grid happiness is 90 + 80 + 90 = 260. ### 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)] [[Bitmask](../../tag/bitmask/README.md)] ### Hints diff --git a/problems/maximize-number-of-nice-divisors/README.md b/problems/maximize-number-of-nice-divisors/README.md index 962ddb55d..b325bd1cf 100644 --- a/problems/maximize-number-of-nice-divisors/README.md +++ b/problems/maximize-number-of-nice-divisors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../evaluate-the-bracket-pairs-of-a-string "Evaluate the Bracket Pairs of a String") @@ -48,11 +48,8 @@ There is not other value of n that has at most 5 prime factors and more nice div ### Related Topics - [[Math](../../tag/math/README.md)] [[Recursion](../../tag/recursion/README.md)] - -### Similar Questions - 1. [Integer Break](../integer-break) (Medium) + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/maximize-palindrome-length-from-subsequences/README.md b/problems/maximize-palindrome-length-from-subsequences/README.md index ecd3dcc68..d81e5e0b6 100644 --- a/problems/maximize-palindrome-length-from-subsequences/README.md +++ b/problems/maximize-palindrome-length-from-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-score-from-performing-multiplication-operations "Maximum Score from Performing Multiplication Operations") @@ -59,9 +59,6 @@ [[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/maximize-score-after-n-operations/README.md b/problems/maximize-score-after-n-operations/README.md index 15161e2ff..2435627b1 100644 --- a/problems/maximize-score-after-n-operations/README.md +++ b/problems/maximize-score-after-n-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-consecutive-values-you-can-make "Maximum Number of Consecutive Values You Can Make") diff --git a/problems/maximize-the-beauty-of-the-garden/README.md b/problems/maximize-the-beauty-of-the-garden/README.md index 5ac672d74..20133a4ef 100644 --- a/problems/maximize-the-beauty-of-the-garden/README.md +++ b/problems/maximize-the-beauty-of-the-garden/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../make-the-xor-of-all-segments-equal-to-zero "Make the XOR of All Segments Equal to Zero") @@ -14,8 +14,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/problems/maximize-the-confusion-of-an-exam/README.md b/problems/maximize-the-confusion-of-an-exam/README.md index ba4f6fa1d..f750e9c89 100644 --- a/problems/maximize-the-confusion-of-an-exam/README.md +++ b/problems/maximize-the-confusion-of-an-exam/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-pairs-of-strings-with-concatenation-equal-to-target "Number of Pairs of Strings With Concatenation Equal to Target") diff --git a/problems/maximum-absolute-sum-of-any-subarray/README.md b/problems/maximum-absolute-sum-of-any-subarray/README.md index 8c23314be..77031437a 100644 --- a/problems/maximum-absolute-sum-of-any-subarray/README.md +++ b/problems/maximum-absolute-sum-of-any-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-unique-elements "Sum of Unique Elements") @@ -51,9 +51,6 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] -### Similar Questions - 1. [Maximum Subarray](../maximum-subarray) (Easy) - ### Hints
    Hint 1 diff --git a/problems/maximum-alternating-subarray-sum/README.md b/problems/maximum-alternating-subarray-sum/README.md index ff48c4c69..0ae635e82 100644 --- a/problems/maximum-alternating-subarray-sum/README.md +++ b/problems/maximum-alternating-subarray-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-array-into-two-arrays-to-minimize-sum-difference "Partition Array Into Two Arrays to Minimize Sum Difference") diff --git a/problems/maximum-alternating-subsequence-sum/README.md b/problems/maximum-alternating-subsequence-sum/README.md index 93376d6f3..2265c28fd 100644 --- a/problems/maximum-alternating-subsequence-sum/README.md +++ b/problems/maximum-alternating-subsequence-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-all-occurrences-of-a-substring "Remove All Occurrences of a Substring") diff --git a/problems/maximum-ascending-subarray-sum/README.md b/problems/maximum-ascending-subarray-sum/README.md index 01261c083..33dd72404 100644 --- a/problems/maximum-ascending-subarray-sum/README.md +++ b/problems/maximum-ascending-subarray-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-score-after-n-operations "Maximize Score After N Operations") diff --git a/problems/maximum-average-pass-ratio/README.md b/problems/maximum-average-pass-ratio/README.md index d6491109e..d4bcfbbb9 100644 --- a/problems/maximum-average-pass-ratio/README.md +++ b/problems/maximum-average-pass-ratio/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-center-of-star-graph "Find Center of Star Graph") @@ -46,8 +46,8 @@ ### 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)] ### Hints diff --git a/problems/maximum-average-subarray-i/README.md b/problems/maximum-average-subarray-i/README.md index 46233ffdc..47c8abf56 100644 --- a/problems/maximum-average-subarray-i/README.md +++ b/problems/maximum-average-subarray-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-search-autocomplete-system "Design Search Autocomplete System") diff --git a/problems/maximum-average-subarray-ii/README.md b/problems/maximum-average-subarray-ii/README.md index 30b24b8d5..323fe56de 100644 --- a/problems/maximum-average-subarray-ii/README.md +++ b/problems/maximum-average-subarray-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-average-subarray-i "Maximum Average Subarray I") diff --git a/problems/maximum-average-subtree/README.md b/problems/maximum-average-subtree/README.md index c47644c8e..87f334554 100644 --- a/problems/maximum-average-subtree/README.md +++ b/problems/maximum-average-subtree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-vowels-from-a-string "Remove Vowels from a String") diff --git a/problems/maximum-binary-string-after-change/README.md b/problems/maximum-binary-string-after-change/README.md index 2f37d4d4a..07af7eb1a 100644 --- a/problems/maximum-binary-string-after-change/README.md +++ b/problems/maximum-binary-string-after-change/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-waiting-time "Average Waiting Time") @@ -59,8 +59,8 @@ ### Related Topics - [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/maximum-binary-tree/README.md b/problems/maximum-binary-tree/README.md index a3e73213f..c2a8af6e9 100644 --- a/problems/maximum-binary-tree/README.md +++ b/problems/maximum-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum-iv-input-is-a-bst "Two Sum IV - Input is a BST") diff --git a/problems/maximum-building-height/README.md b/problems/maximum-building-height/README.md index 011a85a98..00f21bae3 100644 --- a/problems/maximum-building-height/README.md +++ b/problems/maximum-building-height/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-substring-of-all-vowels-in-order "Longest Substring Of All Vowels in Order") 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 97727578b..7977327ee 100644 --- a/problems/maximum-candies-you-can-get-from-boxes/README.md +++ b/problems/maximum-candies-you-can-get-from-boxes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-occurrences-of-a-substring "Maximum Number of Occurrences of a Substring") @@ -84,8 +84,8 @@ Total number of candies collected = 7 + 4 + 5 = 16 candy. ### 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)] ### Hints
    diff --git a/problems/maximum-compatibility-score-sum/README.md b/problems/maximum-compatibility-score-sum/README.md index 7c86bc6c7..f0aa7c7a8 100644 --- a/problems/maximum-compatibility-score-sum/README.md +++ b/problems/maximum-compatibility-score-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-number-after-mutating-substring "Largest Number After Mutating Substring") diff --git a/problems/maximum-depth-of-n-ary-tree/README.md b/problems/maximum-depth-of-n-ary-tree/README.md index 77baede93..77172cb21 100644 --- a/problems/maximum-depth-of-n-ary-tree/README.md +++ b/problems/maximum-depth-of-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../logical-or-of-two-binary-grids-represented-as-quad-trees "Logical OR of Two Binary Grids Represented as Quad-Trees") @@ -51,3 +51,4 @@ ### Similar Questions 1. [Maximum Depth of Binary Tree](../maximum-depth-of-binary-tree) (Easy) + 1. [The Time When the Network Becomes Idle](../the-time-when-the-network-becomes-idle) (Medium) diff --git a/problems/maximum-difference-between-increasing-elements/README.md b/problems/maximum-difference-between-increasing-elements/README.md index c8e49c793..30cb293a1 100644 --- a/problems/maximum-difference-between-increasing-elements/README.md +++ b/problems/maximum-difference-between-increasing-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-height-of-buildings-in-each-segment "Average Height of Buildings in Each Segment") 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 c25f541de..6303a4c38 100644 --- a/problems/maximum-distance-between-a-pair-of-values/README.md +++ b/problems/maximum-distance-between-a-pair-of-values/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-population-year "Maximum Population Year") diff --git a/problems/maximum-distance-in-arrays/README.md b/problems/maximum-distance-in-arrays/README.md index 3822d27e7..b9bcdb2a2 100644 --- a/problems/maximum-distance-in-arrays/README.md +++ b/problems/maximum-distance-in-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../add-one-row-to-tree "Add One Row to Tree") diff --git a/problems/maximum-earnings-from-taxi/README.md b/problems/maximum-earnings-from-taxi/README.md index 499f3b764..94e38354e 100644 --- a/problems/maximum-earnings-from-taxi/README.md +++ b/problems/maximum-earnings-from-taxi/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-original-array-from-doubled-array "Find Original Array From Doubled Array") diff --git a/problems/maximum-element-after-decreasing-and-rearranging/README.md b/problems/maximum-element-after-decreasing-and-rearranging/README.md index cb31b4cfe..2ec14e72a 100644 --- a/problems/maximum-element-after-decreasing-and-rearranging/README.md +++ b/problems/maximum-element-after-decreasing-and-rearranging/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../seat-reservation-manager "Seat Reservation Manager") diff --git a/problems/maximum-equal-frequency/README.md b/problems/maximum-equal-frequency/README.md index 9557464da..8657085d5 100644 --- a/problems/maximum-equal-frequency/README.md +++ b/problems/maximum-equal-frequency/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../dice-roll-simulation "Dice Roll Simulation") diff --git a/problems/maximum-erasure-value/README.md b/problems/maximum-erasure-value/README.md index 949d2a397..212f859cf 100644 --- a/problems/maximum-erasure-value/README.md +++ b/problems/maximum-erasure-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reformat-phone-number "Reformat Phone Number") diff --git a/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md b/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md index e7e5e1380..fdb3b26d9 100644 --- a/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md +++ b/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-subtrees-with-max-distance-between-cities "Count Subtrees With Max Distance Between Cities") diff --git a/problems/maximum-gap/README.md b/problems/maximum-gap/README.md index a099a38f9..d0c7d9316 100644 --- a/problems/maximum-gap/README.md +++ b/problems/maximum-gap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../missing-ranges "Missing Ranges") diff --git a/problems/maximum-genetic-difference-query/README.md b/problems/maximum-genetic-difference-query/README.md index 856964ac8..dbd84060c 100644 --- a/problems/maximum-genetic-difference-query/README.md +++ b/problems/maximum-genetic-difference-query/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-points-with-cost "Maximum Number of Points with Cost") diff --git a/problems/maximum-height-by-stacking-cuboids/README.md b/problems/maximum-height-by-stacking-cuboids/README.md index ea1da246b..4c988381f 100644 --- a/problems/maximum-height-by-stacking-cuboids/README.md +++ b/problems/maximum-height-by-stacking-cuboids/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-vii "Stone Game VII") @@ -67,9 +67,6 @@ The maximum height of stacked cuboids is 6 * 17 = 102. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [The Number of Weak Characters in the Game](../the-number-of-weak-characters-in-the-game) (Medium) - ### Hints
    Hint 1 diff --git a/problems/maximum-ice-cream-bars/README.md b/problems/maximum-ice-cream-bars/README.md index 548ec3514..5fbc91a10 100644 --- a/problems/maximum-ice-cream-bars/README.md +++ b/problems/maximum-ice-cream-bars/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-the-sentence-is-pangram "Check if the Sentence Is Pangram") 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 72f94dbc1..7dd80565b 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../circular-permutation-in-binary-representation "Circular Permutation in Binary Representation") @@ -67,10 +67,10 @@ Maximum length is 4. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/maximum-length-of-pair-chain/README.md b/problems/maximum-length-of-pair-chain/README.md index c108321a1..a7e566c55 100644 --- a/problems/maximum-length-of-pair-chain/README.md +++ b/problems/maximum-length-of-pair-chain/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../set-mismatch "Set Mismatch") @@ -46,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)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 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 4ceae6c1b..09559fc46 100644 --- a/problems/maximum-length-of-subarray-with-positive-product/README.md +++ b/problems/maximum-length-of-subarray-with-positive-product/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../detect-pattern-of-length-m-repeated-k-or-more-times "Detect Pattern of Length M Repeated K or More Times") @@ -65,9 +65,9 @@ Notice that we cannot include 0 in the subarray since that'll make the produ ### 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-matrix-sum/README.md b/problems/maximum-matrix-sum/README.md index e913149e1..8eb766ade 100644 --- a/problems/maximum-matrix-sum/README.md +++ b/problems/maximum-matrix-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-to-type-word-using-special-typewriter "Minimum Time to Type Word Using Special Typewriter") diff --git a/problems/maximum-nesting-depth-of-the-parentheses/README.md b/problems/maximum-nesting-depth-of-the-parentheses/README.md index cda784e44..b4df75520 100644 --- a/problems/maximum-nesting-depth-of-the-parentheses/README.md +++ b/problems/maximum-nesting-depth-of-the-parentheses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-missing-ids "Find the Missing IDs") @@ -72,11 +72,8 @@ ### Related Topics - [[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) + [[String](../../tag/string/README.md)] ### 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 29be70abf..0b1c73b57 100644 --- a/problems/maximum-non-negative-product-in-a-matrix/README.md +++ b/problems/maximum-non-negative-product-in-a-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-a-string-into-the-max-number-of-unique-substrings "Split a String Into the Max Number of Unique Substrings") diff --git a/problems/maximum-number-of-accepted-invitations/README.md b/problems/maximum-number-of-accepted-invitations/README.md index b46d29238..ef403fdb6 100644 --- a/problems/maximum-number-of-accepted-invitations/README.md +++ b/problems/maximum-number-of-accepted-invitations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-different-subsequences-gcds "Number of Different Subsequences GCDs") diff --git a/problems/maximum-number-of-achievable-transfer-requests/README.md b/problems/maximum-number-of-achievable-transfer-requests/README.md index 8e0396600..144c6a30e 100644 --- a/problems/maximum-number-of-achievable-transfer-requests/README.md +++ b/problems/maximum-number-of-achievable-transfer-requests/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../throne-inheritance "Throne Inheritance") diff --git a/problems/maximum-number-of-balloons/README.md b/problems/maximum-number-of-balloons/README.md index 12d3bbfe9..b871476da 100644 --- a/problems/maximum-number-of-balloons/README.md +++ b/problems/maximum-number-of-balloons/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-bounded-blocking-queue "Design Bounded Blocking Queue") diff --git a/problems/maximum-number-of-balls-in-a-box/README.md b/problems/maximum-number-of-balls-in-a-box/README.md index da67222e1..a31e84d04 100644 --- a/problems/maximum-number-of-balls-in-a-box/README.md +++ b/problems/maximum-number-of-balls-in-a-box/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-total-time-spent-by-each-employee "Find Total Time Spent by Each Employee") diff --git a/problems/maximum-number-of-coins-you-can-get/README.md b/problems/maximum-number-of-coins-you-can-get/README.md index 7b7eae3e9..61ecb3167 100644 --- a/problems/maximum-number-of-coins-you-can-get/README.md +++ b/problems/maximum-number-of-coins-you-can-get/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../most-visited-sector-in-a-circular-track "Most Visited Sector in a Circular Track") @@ -11,19 +11,19 @@ ## [1561. Maximum Number of Coins You Can Get (Medium)](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") -

    There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:

    +

    There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:

      -
    • In each step, you will choose any 3 piles of coins (not necessarily consecutive).
    • -
    • Of your choice, Alice will pick the pile with the maximum number of coins.
    • -
    • You will pick the next pile with maximum number of coins.
    • +
    • In each step, you will choose any 3 piles of coins (not necessarily consecutive).
    • +
    • Of your choice, Alice will pick the pile with the maximum number of coins.
    • +
    • You will pick the next pile with the maximum number of coins.
    • Your friend Bob will pick the last pile.
    • -
    • Repeat until there are no more piles of coins.
    • +
    • Repeat until there are no more piles of coins.
    -

    Given an array of integers piles where piles[i] is the number of coins in the ith pile.

    +

    Given an array of integers piles where piles[i] is the number of coins in the ith pile.

    -

    Return the maximum number of coins which you can have.

    +

    Return the maximum number of coins that you can have.

     

    Example 1:

    @@ -55,9 +55,9 @@ On the other hand if we choose this arrangement (1, 2, 8), (2,

    Constraints:

      -
    • 3 <= piles.length <= 10^5
    • +
    • 3 <= piles.length <= 105
    • piles.length % 3 == 0
    • -
    • 1 <= piles[i] <= 10^4
    • +
    • 1 <= piles[i] <= 104
    ### Related Topics 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 684b0035e..7fdf0d08f 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-authentication-manager "Design Authentication Manager") 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 a757781c4..03a0c1879 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "People Whose List of Favorite Companies Is Not a Subset of Another List") @@ -61,9 +61,9 @@ ### 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/maximum-number-of-eaten-apples/README.md b/problems/maximum-number-of-eaten-apples/README.md index 31499bb00..2e29bdaa3 100644 --- a/problems/maximum-number-of-eaten-apples/README.md +++ b/problems/maximum-number-of-eaten-apples/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../determine-if-string-halves-are-alike "Determine if String Halves Are Alike") diff --git a/problems/maximum-number-of-events-that-can-be-attended-ii/README.md b/problems/maximum-number-of-events-that-can-be-attended-ii/README.md index e0d998f2a..dc8c37595 100644 --- a/problems/maximum-number-of-events-that-can-be-attended-ii/README.md +++ b/problems/maximum-number-of-events-that-can-be-attended-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-length-of-string-after-deleting-similar-ends "Minimum Length of String After Deleting Similar Ends") @@ -61,11 +61,6 @@ Notice that you cannot attend any other event as they overlap, and that you do < [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] -### Similar Questions - 1. [Maximum Number of Events That Can Be Attended](../maximum-number-of-events-that-can-be-attended) (Medium) - 1. [Maximum Earnings From Taxi](../maximum-earnings-from-taxi) (Medium) - 1. [Two Best Non-Overlapping Events](../two-best-non-overlapping-events) (Medium) - ### Hints
    Hint 1 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 c456f8a46..4559f8e33 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../product-of-the-last-k-numbers "Product of the Last K Numbers") diff --git a/problems/maximum-number-of-groups-getting-fresh-donuts/README.md b/problems/maximum-number-of-groups-getting-fresh-donuts/README.md index e4ab76574..415e129b0 100644 --- a/problems/maximum-number-of-groups-getting-fresh-donuts/README.md +++ b/problems/maximum-number-of-groups-getting-fresh-donuts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-nice-pairs-in-an-array "Count Nice Pairs in an Array") 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 a13a23574..6f963ba4b 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-kth-bit-in-nth-binary-string "Find Kth Bit in Nth Binary String") diff --git a/problems/maximum-number-of-non-overlapping-substrings/README.md b/problems/maximum-number-of-non-overlapping-substrings/README.md index 93e3be684..4c57eba84 100644 --- a/problems/maximum-number-of-non-overlapping-substrings/README.md +++ b/problems/maximum-number-of-non-overlapping-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-nodes-in-the-sub-tree-with-the-same-label "Number of Nodes in the Sub-Tree With the Same Label") 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 39e7f1bd0..3634859c2 100644 --- a/problems/maximum-number-of-occurrences-of-a-substring/README.md +++ b/problems/maximum-number-of-occurrences-of-a-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../divide-array-in-sets-of-k-consecutive-numbers "Divide Array in Sets of K Consecutive Numbers") diff --git a/problems/maximum-number-of-ones/README.md b/problems/maximum-number-of-ones/README.md index c6542fe02..dca5bed9c 100644 --- a/problems/maximum-number-of-ones/README.md +++ b/problems/maximum-number-of-ones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-distance-to-target-color "Shortest Distance to Target Color") diff --git a/problems/maximum-number-of-people-that-can-be-caught-in-tag/README.md b/problems/maximum-number-of-people-that-can-be-caught-in-tag/README.md index cec72556d..bdce1b715 100644 --- a/problems/maximum-number-of-people-that-can-be-caught-in-tag/README.md +++ b/problems/maximum-number-of-people-that-can-be-caught-in-tag/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-cutoff-score-for-each-school "Find Cutoff Score for Each School") diff --git a/problems/maximum-number-of-points-with-cost/README.md b/problems/maximum-number-of-points-with-cost/README.md index 1893a4388..971d5b4e4 100644 --- a/problems/maximum-number-of-points-with-cost/README.md +++ b/problems/maximum-number-of-points-with-cost/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../add-minimum-number-of-rungs "Add Minimum Number of Rungs") diff --git a/problems/maximum-number-of-removable-characters/README.md b/problems/maximum-number-of-removable-characters/README.md index f8996cff2..6dc55f65c 100644 --- a/problems/maximum-number-of-removable-characters/README.md +++ b/problems/maximum-number-of-removable-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../redistribute-characters-to-make-all-strings-equal "Redistribute Characters to Make All Strings Equal") 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 c3ba54efe..a917e8956 100644 --- a/problems/maximum-number-of-tasks-you-can-assign/README.md +++ b/problems/maximum-number-of-tasks-you-can-assign/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../most-beautiful-item-for-each-query "Most Beautiful Item for Each Query") diff --git a/problems/maximum-number-of-visible-points/README.md b/problems/maximum-number-of-visible-points/README.md index fdf1f0654..1dcf62a62 100644 --- a/problems/maximum-number-of-visible-points/README.md +++ b/problems/maximum-number-of-visible-points/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../even-odd-tree "Even Odd Tree") 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 ff2dbd569..8bc9d9ffb 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "Check If a Word Occurs As a Prefix of Any Word in a Sentence") diff --git a/problems/maximum-number-of-ways-to-partition-an-array/README.md b/problems/maximum-number-of-ways-to-partition-an-array/README.md index bee8e4c95..9ab28a83d 100644 --- a/problems/maximum-number-of-ways-to-partition-an-array/README.md +++ b/problems/maximum-number-of-ways-to-partition-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-the-confusion-of-an-exam "Maximize the Confusion of an Exam") 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 3cdeb2d18..60f444ba4 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../three-divisors "Three Divisors") diff --git a/problems/maximum-number-of-words-you-can-type/README.md b/problems/maximum-number-of-words-you-can-type/README.md index d7f882682..2426e2dd3 100644 --- a/problems/maximum-number-of-words-you-can-type/README.md +++ b/problems/maximum-number-of-words-you-can-type/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../confirmation-rate "Confirmation Rate") diff --git a/problems/maximum-of-absolute-value-expression/README.md b/problems/maximum-of-absolute-value-expression/README.md index b89071148..1ab54a71d 100644 --- a/problems/maximum-of-absolute-value-expression/README.md +++ b/problems/maximum-of-absolute-value-expression/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-tree-from-leaf-values "Minimum Cost Tree From Leaf Values") diff --git a/problems/maximum-of-minimum-values-in-all-subarrays/README.md b/problems/maximum-of-minimum-values-in-all-subarrays/README.md index 7df537e3f..2bad1050a 100644 --- a/problems/maximum-of-minimum-values-in-all-subarrays/README.md +++ b/problems/maximum-of-minimum-values-in-all-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strong-friendship "Strong Friendship") diff --git a/problems/maximum-path-quality-of-a-graph/README.md b/problems/maximum-path-quality-of-a-graph/README.md index 051e550b3..de1176b46 100644 --- a/problems/maximum-path-quality-of-a-graph/README.md +++ b/problems/maximum-path-quality-of-a-graph/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimized-maximum-of-products-distributed-to-any-store "Minimized Maximum of Products Distributed to Any Store") diff --git a/problems/maximum-performance-of-a-team/README.md b/problems/maximum-performance-of-a-team/README.md index 44da51136..4bf572f41 100644 --- a/problems/maximum-performance-of-a-team/README.md +++ b/problems/maximum-performance-of-a-team/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../balance-a-binary-search-tree "Balance a Binary Search Tree") 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 69ddfcb04..c5c74b84a 100644 --- a/problems/maximum-points-you-can-obtain-from-cards/README.md +++ b/problems/maximum-points-you-can-obtain-from-cards/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-score-after-splitting-a-string "Maximum Score After Splitting a String") diff --git a/problems/maximum-population-year/README.md b/problems/maximum-population-year/README.md index ebe6e3ffe..5c709dc10 100644 --- a/problems/maximum-population-year/README.md +++ b/problems/maximum-population-year/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-date-format "Convert Date Format") diff --git a/problems/maximum-product-difference-between-two-pairs/README.md b/problems/maximum-product-difference-between-two-pairs/README.md index 62728115c..c42a5e7f6 100644 --- a/problems/maximum-product-difference-between-two-pairs/README.md +++ b/problems/maximum-product-difference-between-two-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-movie-rental-system "Design Movie Rental System") diff --git a/problems/maximum-product-of-splitted-binary-tree/README.md b/problems/maximum-product-of-splitted-binary-tree/README.md index f9f32841c..0d7bea15e 100644 --- a/problems/maximum-product-of-splitted-binary-tree/README.md +++ b/problems/maximum-product-of-splitted-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reduce-array-size-to-the-half "Reduce Array Size to The Half") @@ -61,6 +61,9 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Count Nodes With the Highest Score](../count-nodes-with-the-highest-score) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/README.md b/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/README.md index f174e640a..e882747e2 100644 --- a/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/README.md +++ b/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-pairs-of-interchangeable-rectangles "Number of Pairs of Interchangeable Rectangles") diff --git a/problems/maximum-product-of-the-length-of-two-palindromic-substrings/README.md b/problems/maximum-product-of-the-length-of-two-palindromic-substrings/README.md index ede109cb0..9cdca3f6e 100644 --- a/problems/maximum-product-of-the-length-of-two-palindromic-substrings/README.md +++ b/problems/maximum-product-of-the-length-of-two-palindromic-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-total-space-wasted-with-k-resizing-operations "Minimum Total Space Wasted With K Resizing Operations") diff --git a/problems/maximum-product-of-two-elements-in-an-array/README.md b/problems/maximum-product-of-two-elements-in-an-array/README.md index e13c8b8ea..6780a411d 100644 --- a/problems/maximum-product-of-two-elements-in-an-array/README.md +++ b/problems/maximum-product-of-two-elements-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cherry-pickup-ii "Cherry Pickup II") diff --git a/problems/maximum-profit-in-job-scheduling/README.md b/problems/maximum-profit-in-job-scheduling/README.md index 3c4b4a932..8cb51b614 100644 --- a/problems/maximum-profit-in-job-scheduling/README.md +++ b/problems/maximum-profit-in-job-scheduling/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-the-substring-for-balanced-string "Replace the Substring for Balanced String") 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 29ba62fb4..f638ef1e3 100644 --- a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md +++ b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../crawler-log-folder "Crawler Log Folder") diff --git a/problems/maximum-repeating-substring/README.md b/problems/maximum-repeating-substring/README.md index 4a6ecdf62..96fe3070b 100644 --- a/problems/maximum-repeating-substring/README.md +++ b/problems/maximum-repeating-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fix-names-in-a-table "Fix Names in a Table") @@ -53,6 +53,9 @@ [[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-score-after-splitting-a-string/README.md b/problems/maximum-score-after-splitting-a-string/README.md index b6f1d3acb..589727c3a 100644 --- a/problems/maximum-score-after-splitting-a-string/README.md +++ b/problems/maximum-score-after-splitting-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../npv-queries "NPV Queries") diff --git a/problems/maximum-score-from-performing-multiplication-operations/README.md b/problems/maximum-score-from-performing-multiplication-operations/README.md index 8537c3b8b..bc78098df 100644 --- a/problems/maximum-score-from-performing-multiplication-operations/README.md +++ b/problems/maximum-score-from-performing-multiplication-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-operations-to-move-all-balls-to-each-box "Minimum Number of Operations to Move All Balls to Each Box") @@ -64,10 +64,6 @@ 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-stones/README.md b/problems/maximum-score-from-removing-stones/README.md index 96ed16df6..01389e015 100644 --- a/problems/maximum-score-from-removing-stones/README.md +++ b/problems/maximum-score-from-removing-stones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-array-is-sorted-and-rotated "Check if Array Is Sorted and Rotated") @@ -64,8 +64,8 @@ After that, there are fewer than two non-empty piles, so the game ends. ### Related Topics - [[Math](../../tag/math/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/maximum-score-from-removing-substrings/README.md b/problems/maximum-score-from-removing-substrings/README.md index 88b5b05a6..17c71631f 100644 --- a/problems/maximum-score-from-removing-substrings/README.md +++ b/problems/maximum-score-from-removing-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../calculate-money-in-leetcode-bank "Calculate Money in Leetcode Bank") @@ -58,9 +58,9 @@ 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)] ### Hints
    diff --git a/problems/maximum-score-of-a-good-subarray/README.md b/problems/maximum-score-of-a-good-subarray/README.md index 0d95a2e7d..edeb34460 100644 --- a/problems/maximum-score-of-a-good-subarray/README.md +++ b/problems/maximum-score-of-a-good-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-average-pass-ratio "Maximum Average Pass Ratio") @@ -44,15 +44,12 @@ ### 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 4423384c4..97452e4ff 100644 --- a/problems/maximum-score-words-formed-by-letters/README.md +++ b/problems/maximum-score-words-formed-by-letters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-closed-islands "Number of Closed Islands") @@ -60,11 +60,11 @@ Letter "e" can only be used once. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/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)] ### Hints diff --git a/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md b/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md index 9b67293a2..96e80a8cc 100644 --- a/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md +++ b/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sequential-digits "Sequential Digits") diff --git a/problems/maximum-students-taking-exam/README.md b/problems/maximum-students-taking-exam/README.md index c47343171..3e752af5f 100644 --- a/problems/maximum-students-taking-exam/README.md +++ b/problems/maximum-students-taking-exam/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tweet-counts-per-frequency "Tweet Counts Per Frequency") diff --git a/problems/maximum-subarray-min-product/README.md b/problems/maximum-subarray-min-product/README.md index 16ec5c983..79aac2c47 100644 --- a/problems/maximum-subarray-min-product/README.md +++ b/problems/maximum-subarray-min-product/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-distance-between-a-pair-of-values "Maximum Distance Between a Pair of Values") diff --git a/problems/maximum-subarray-sum-after-one-operation/README.md b/problems/maximum-subarray-sum-after-one-operation/README.md index 391cf4e8a..152758454 100644 --- a/problems/maximum-subarray-sum-after-one-operation/README.md +++ b/problems/maximum-subarray-sum-after-one-operation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindrome-partitioning-iv "Palindrome Partitioning IV") @@ -17,9 +17,6 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] -### Similar Questions - 1. [Maximum Subarray](../maximum-subarray) (Easy) - ### Hints
    Hint 1 diff --git a/problems/maximum-subarray-sum-with-one-deletion/README.md b/problems/maximum-subarray-sum-with-one-deletion/README.md index 3c9286232..3e76e709f 100644 --- a/problems/maximum-subarray-sum-with-one-deletion/README.md +++ b/problems/maximum-subarray-sum-with-one-deletion/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../day-of-the-week "Day of the Week") diff --git a/problems/maximum-sum-circular-subarray/README.md b/problems/maximum-sum-circular-subarray/README.md index d0207e9ad..278c2fad3 100644 --- a/problems/maximum-sum-circular-subarray/README.md +++ b/problems/maximum-sum-circular-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-only-letters "Reverse Only Letters") diff --git a/problems/maximum-sum-obtained-of-any-permutation/README.md b/problems/maximum-sum-obtained-of-any-permutation/README.md index a6863f609..a1d9a7bbb 100644 --- a/problems/maximum-sum-obtained-of-any-permutation/README.md +++ b/problems/maximum-sum-obtained-of-any-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-all-odd-length-subarrays "Sum of All Odd Length Subarrays") @@ -60,10 +60,10 @@ Total sum: 11 + 8 = 19, which is the best that you can do. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Sorting](../../tag/sorting/README.md)] + [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-transaction-each-day/README.md b/problems/maximum-transaction-each-day/README.md index 1931be985..977486d49 100644 --- a/problems/maximum-transaction-each-day/README.md +++ b/problems/maximum-transaction-each-day/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-operations-to-make-string-sorted "Minimum Number of Operations to Make String Sorted") diff --git a/problems/maximum-units-on-a-truck/README.md b/problems/maximum-units-on-a-truck/README.md index ab1d4df4a..3ead65713 100644 --- a/problems/maximum-units-on-a-truck/README.md +++ b/problems/maximum-units-on-a-truck/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../biggest-window-between-visits "Biggest Window Between Visits") diff --git a/problems/maximum-vacation-days/README.md b/problems/maximum-vacation-days/README.md index 3f8266116..6d4ea8813 100644 --- a/problems/maximum-vacation-days/README.md +++ b/problems/maximum-vacation-days/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../permutation-in-string "Permutation in String") diff --git a/problems/maximum-value-after-insertion/README.md b/problems/maximum-value-after-insertion/README.md index c643ca1ad..9d453f146 100644 --- a/problems/maximum-value-after-insertion/README.md +++ b/problems/maximum-value-after-insertion/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-word-equals-summation-of-two-words "Check if Word Equals Summation of Two Words") 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 a3840e9fe..b41ba72a4 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-orders-in-the-backlog "Number of Orders in the Backlog") diff --git a/problems/maximum-xor-for-each-query/README.md b/problems/maximum-xor-for-each-query/README.md index c2d67f4c1..77772fb9e 100644 --- a/problems/maximum-xor-for-each-query/README.md +++ b/problems/maximum-xor-for-each-query/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../queries-on-number-of-points-inside-a-circle "Queries on Number of Points Inside a Circle") @@ -64,8 +64,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/problems/maximum-xor-with-an-element-from-array/README.md b/problems/maximum-xor-with-an-element-from-array/README.md index eb4acccfb..daa3f0add 100644 --- a/problems/maximum-xor-with-an-element-from-array/README.md +++ b/problems/maximum-xor-with-an-element-from-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../where-will-the-ball-fall "Where Will the Ball Fall") 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 f87020608..82a728f5a 100644 --- a/problems/mean-of-array-after-removing-some-elements/README.md +++ b/problems/mean-of-array-after-removing-some-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-font-to-fit-a-sentence-in-a-screen "Maximum Font to Fit a Sentence in a Screen") diff --git a/problems/median-employee-salary/README.md b/problems/median-employee-salary/README.md index 1afeed80d..90ee0f2bb 100644 --- a/problems/median-employee-salary/README.md +++ b/problems/median-employee-salary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-vacation-days "Maximum Vacation Days") diff --git a/problems/median-employee-salary/mysql_schemas.sql b/problems/median-employee-salary/mysql_schemas.sql index dd828e723..5dd574292 100644 --- a/problems/median-employee-salary/mysql_schemas.sql +++ b/problems/median-employee-salary/mysql_schemas.sql @@ -1,19 +1,19 @@ -Create table If Not Exists Employee (Id int, Company varchar(255), Salary int); +Create table If Not Exists Employee (id int, company varchar(255), salary int); Truncate table Employee; -insert into Employee (Id, Company, Salary) values ('1', 'A', '2341'); -insert into Employee (Id, Company, Salary) values ('2', 'A', '341'); -insert into Employee (Id, Company, Salary) values ('3', 'A', '15'); -insert into Employee (Id, Company, Salary) values ('4', 'A', '15314'); -insert into Employee (Id, Company, Salary) values ('5', 'A', '451'); -insert into Employee (Id, Company, Salary) values ('6', 'A', '513'); -insert into Employee (Id, Company, Salary) values ('7', 'B', '15'); -insert into Employee (Id, Company, Salary) values ('8', 'B', '13'); -insert into Employee (Id, Company, Salary) values ('9', 'B', '1154'); -insert into Employee (Id, Company, Salary) values ('10', 'B', '1345'); -insert into Employee (Id, Company, Salary) values ('11', 'B', '1221'); -insert into Employee (Id, Company, Salary) values ('12', 'B', '234'); -insert into Employee (Id, Company, Salary) values ('13', 'C', '2345'); -insert into Employee (Id, Company, Salary) values ('14', 'C', '2645'); -insert into Employee (Id, Company, Salary) values ('15', 'C', '2645'); -insert into Employee (Id, Company, Salary) values ('16', 'C', '2652'); -insert into Employee (Id, Company, Salary) values ('17', 'C', '65'); +insert into Employee (id, company, salary) values ('1', 'A', '2341'); +insert into Employee (id, company, salary) values ('2', 'A', '341'); +insert into Employee (id, company, salary) values ('3', 'A', '15'); +insert into Employee (id, company, salary) values ('4', 'A', '15314'); +insert into Employee (id, company, salary) values ('5', 'A', '451'); +insert into Employee (id, company, salary) values ('6', 'A', '513'); +insert into Employee (id, company, salary) values ('7', 'B', '15'); +insert into Employee (id, company, salary) values ('8', 'B', '13'); +insert into Employee (id, company, salary) values ('9', 'B', '1154'); +insert into Employee (id, company, salary) values ('10', 'B', '1345'); +insert into Employee (id, company, salary) values ('11', 'B', '1221'); +insert into Employee (id, company, salary) values ('12', 'B', '234'); +insert into Employee (id, company, salary) values ('13', 'C', '2345'); +insert into Employee (id, company, salary) values ('14', 'C', '2645'); +insert into Employee (id, company, salary) values ('15', 'C', '2645'); +insert into Employee (id, company, salary) values ('16', 'C', '2652'); +insert into Employee (id, company, salary) values ('17', 'C', '65'); diff --git a/problems/merge-bsts-to-create-single-bst/README.md b/problems/merge-bsts-to-create-single-bst/README.md index 632bf3435..63d8f9678 100644 --- a/problems/merge-bsts-to-create-single-bst/README.md +++ b/problems/merge-bsts-to-create-single-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../painting-a-grid-with-three-different-colors "Painting a Grid With Three Different Colors") diff --git a/problems/merge-in-between-linked-lists/README.md b/problems/merge-in-between-linked-lists/README.md index 35e8f41ff..246908775 100644 --- a/problems/merge-in-between-linked-lists/README.md +++ b/problems/merge-in-between-linked-lists/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-repeating-substring "Maximum Repeating Substring") diff --git a/problems/merge-intervals/README.md b/problems/merge-intervals/README.md index 38bf97a47..d474da066 100644 --- a/problems/merge-intervals/README.md +++ b/problems/merge-intervals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game "Jump Game") diff --git a/problems/merge-strings-alternately/README.md b/problems/merge-strings-alternately/README.md index db11585b5..fa3b9c32b 100644 --- a/problems/merge-strings-alternately/README.md +++ b/problems/merge-strings-alternately/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-subtasks-that-did-not-execute "Find the Subtasks That Did Not Execute") @@ -61,9 +61,6 @@ 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 510475f65..a2105787a 100644 --- a/problems/merge-triplets-to-form-target-triplet/README.md +++ b/problems/merge-triplets-to-form-target-triplet/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-removable-characters "Maximum Number of Removable Characters") diff --git a/problems/merge-two-binary-trees/README.md b/problems/merge-two-binary-trees/README.md index 3419dd720..330e3191b 100644 --- a/problems/merge-two-binary-trees/README.md +++ b/problems/merge-two-binary-trees/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../add-bold-tag-in-string "Add Bold Tag in String") diff --git a/problems/merge-two-sorted-lists/README.md b/problems/merge-two-sorted-lists/README.md index e8bcebf0f..893f84595 100644 --- a/problems/merge-two-sorted-lists/README.md +++ b/problems/merge-two-sorted-lists/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-parentheses "Valid Parentheses") @@ -11,27 +11,31 @@ ## [21. Merge Two Sorted Lists (Easy)](https://leetcode.com/problems/merge-two-sorted-lists "合并两个有序链表") -

    Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists.

    +

    You are given the heads of two sorted linked lists list1 and list2.

    + +

    Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists.

    + +

    Return the head of the merged linked list.

     

    Example 1:

    -Input: l1 = [1,2,4], l2 = [1,3,4]
    +Input: list1 = [1,2,4], list2 = [1,3,4]
     Output: [1,1,2,3,4,4]
     

    Example 2:

    -Input: l1 = [], l2 = []
    +Input: list1 = [], list2 = []
     Output: []
     

    Example 3:

    -Input: l1 = [], l2 = [0]
    +Input: list1 = [], list2 = [0]
     Output: [0]
     
    @@ -41,7 +45,7 @@
    • The number of nodes in both lists is in the range [0, 50].
    • -100 <= Node.val <= 100
    • -
    • Both l1 and l2 are sorted in non-decreasing order.
    • +
    • Both list1 and list2 are sorted in non-decreasing order.
    ### Related Topics diff --git a/problems/min-cost-climbing-stairs/README.md b/problems/min-cost-climbing-stairs/README.md index ebc266e4d..9e47493b8 100644 --- a/problems/min-cost-climbing-stairs/README.md +++ b/problems/min-cost-climbing-stairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../prefix-and-suffix-search "Prefix and Suffix Search") @@ -21,17 +21,26 @@

    Example 1:

    -Input: cost = [10,15,20]
    +Input: cost = [10,15,20]
     Output: 15
    -Explanation: Cheapest is: start on cost[1], pay that cost, and go to the top.
    +Explanation: You will start at index 1.
    +- Pay 15 and climb two steps to reach the top.
    +The total cost is 15.
     

    Example 2:

    -Input: cost = [1,100,1,1,1,100,1,1,100,1]
    +Input: cost = [1,100,1,1,1,100,1,1,100,1]
     Output: 6
    -Explanation: Cheapest is: start on cost[0], and only step on 1s, skipping cost[3].
    +Explanation: You will start at index 0.
    +- Pay 1 and climb two steps to reach index 2.
    +- Pay 1 and climb two steps to reach index 4.
    +- Pay 1 and climb two steps to reach index 6.
    +- Pay 1 and climb one step to reach index 7.
    +- Pay 1 and climb two steps to reach index 9.
    +- Pay 1 and climb one step to reach the top.
    +The total cost is 6.
     

     

    diff --git a/problems/min-cost-to-connect-all-points/README.md b/problems/min-cost-to-connect-all-points/README.md index 02ad17018..6ad6e59f7 100644 --- a/problems/min-cost-to-connect-all-points/README.md +++ b/problems/min-cost-to-connect-all-points/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-unhappy-friends "Count Unhappy Friends") @@ -69,8 +69,8 @@ Notice that there is a unique path between every pair of points. ### Related Topics - [[Array](../../tag/array/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] ### Hints diff --git a/problems/min-stack/README.md b/problems/min-stack/README.md index 61955b7d8..13567cb2e 100644 --- a/problems/min-stack/README.md +++ b/problems/min-stack/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-minimum-in-rotated-sorted-array-ii "Find Minimum in Rotated Sorted Array II") @@ -17,7 +17,7 @@
    • MinStack() initializes the stack object.
    • -
    • void push(val) pushes the element val onto the stack.
    • +
    • void push(int val) pushes the element val onto the stack.
    • void pop() removes the element on the top of the stack.
    • int top() gets the top element of the stack.
    • int getMin() retrieves the minimum element in the stack.
    • diff --git a/problems/minesweeper/README.md b/problems/minesweeper/README.md index 9b7ee8f6a..618c0715f 100644 --- a/problems/minesweeper/README.md +++ b/problems/minesweeper/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../random-pick-with-weight "Random Pick with Weight") diff --git a/problems/minimize-deviation-in-array/README.md b/problems/minimize-deviation-in-array/README.md index 59de5ccf4..67f25aefa 100644 --- a/problems/minimize-deviation-in-array/README.md +++ b/problems/minimize-deviation-in-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-moves-to-make-array-complementary "Minimum Moves to Make Array Complementary") @@ -66,10 +66,10 @@
    ### 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/minimize-hamming-distance-after-swap-operations/README.md b/problems/minimize-hamming-distance-after-swap-operations/README.md index 2e92aaeec..56ca147c2 100644 --- a/problems/minimize-hamming-distance-after-swap-operations/README.md +++ b/problems/minimize-hamming-distance-after-swap-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../swapping-nodes-in-a-linked-list "Swapping Nodes in a Linked List") diff --git a/problems/minimize-malware-spread/README.md b/problems/minimize-malware-spread/README.md index d2c1090d5..0adf6f7bc 100644 --- a/problems/minimize-malware-spread/README.md +++ b/problems/minimize-malware-spread/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../3sum-with-multiplicity "3Sum With Multiplicity") @@ -48,8 +48,8 @@ ### 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)] diff --git a/problems/minimize-maximum-pair-sum-in-array/README.md b/problems/minimize-maximum-pair-sum-in-array/README.md index 8722e266c..dc7eeaccd 100644 --- a/problems/minimize-maximum-pair-sum-in-array/README.md +++ b/problems/minimize-maximum-pair-sum-in-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../substrings-of-size-three-with-distinct-characters "Substrings of Size Three with Distinct Characters") diff --git a/problems/minimize-product-sum-of-two-arrays/README.md b/problems/minimize-product-sum-of-two-arrays/README.md index 1cd2fb9c5..deb391bad 100644 --- a/problems/minimize-product-sum-of-two-arrays/README.md +++ b/problems/minimize-product-sum-of-two-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../calculate-special-bonus "Calculate Special Bonus") diff --git a/problems/minimize-the-difference-between-target-and-chosen-elements/README.md b/problems/minimize-the-difference-between-target-and-chosen-elements/README.md index 8729a0137..37fe28b71 100644 --- a/problems/minimize-the-difference-between-target-and-chosen-elements/README.md +++ b/problems/minimize-the-difference-between-target-and-chosen-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-unique-binary-string "Find Unique Binary String") diff --git a/problems/minimized-maximum-of-products-distributed-to-any-store/README.md b/problems/minimized-maximum-of-products-distributed-to-any-store/README.md index 0a00c12a9..3f1dcfa07 100644 --- a/problems/minimized-maximum-of-products-distributed-to-any-store/README.md +++ b/problems/minimized-maximum-of-products-distributed-to-any-store/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../vowels-of-all-substrings "Vowels of All Substrings") diff --git a/problems/minimum-absolute-difference-in-bst/README.md b/problems/minimum-absolute-difference-in-bst/README.md index ea4f41eb3..65dc1df78 100644 --- a/problems/minimum-absolute-difference-in-bst/README.md +++ b/problems/minimum-absolute-difference-in-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minesweeper "Minesweeper") diff --git a/problems/minimum-absolute-difference-queries/README.md b/problems/minimum-absolute-difference-queries/README.md index e7ef7ed6a..a87e08fff 100644 --- a/problems/minimum-absolute-difference-queries/README.md +++ b/problems/minimum-absolute-difference-queries/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-sub-islands "Count Sub Islands") diff --git a/problems/minimum-absolute-sum-difference/README.md b/problems/minimum-absolute-sum-difference/README.md index de66d4865..9fc9ca593 100644 --- a/problems/minimum-absolute-sum-difference/README.md +++ b/problems/minimum-absolute-sum-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../finding-the-users-active-minutes "Finding the Users Active Minutes") 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 cbbe3cb7c..94852b978 100644 --- a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md +++ b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-binary-string-after-change "Maximum Binary String After Change") @@ -50,14 +50,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] + [[Array](../../tag/array/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) + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md b/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md index 5866154fc..59c7fc47c 100644 --- a/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md +++ b/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../splitting-a-string-into-descending-consecutive-values "Splitting a String Into Descending Consecutive Values") diff --git a/problems/minimum-area-rectangle-ii/README.md b/problems/minimum-area-rectangle-ii/README.md index 3a6830dd7..c8fc5d698 100644 --- a/problems/minimum-area-rectangle-ii/README.md +++ b/problems/minimum-area-rectangle-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-width-ramp "Maximum Width Ramp") @@ -61,6 +61,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-area-rectangle/README.md b/problems/minimum-area-rectangle/README.md index 9776dd77d..45969bc7e 100644 --- a/problems/minimum-area-rectangle/README.md +++ b/problems/minimum-area-rectangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../range-sum-of-bst "Range Sum of BST") diff --git a/problems/minimum-changes-to-make-alternating-binary-string/README.md b/problems/minimum-changes-to-make-alternating-binary-string/README.md index af16901e6..88450664e 100644 --- a/problems/minimum-changes-to-make-alternating-binary-string/README.md +++ b/problems/minimum-changes-to-make-alternating-binary-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../recyclable-and-low-fat-products "Recyclable and Low Fat Products") diff --git a/problems/minimum-cost-for-tickets/README.md b/problems/minimum-cost-for-tickets/README.md index 6e7b201c6..3cf8ec9f0 100644 --- a/problems/minimum-cost-for-tickets/README.md +++ b/problems/minimum-cost-for-tickets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../triples-with-bitwise-and-equal-to-zero "Triples with Bitwise AND Equal To Zero") diff --git a/problems/minimum-cost-to-change-the-final-value-of-expression/README.md b/problems/minimum-cost-to-change-the-final-value-of-expression/README.md index 6cc6f3d6c..382e822b6 100644 --- a/problems/minimum-cost-to-change-the-final-value-of-expression/README.md +++ b/problems/minimum-cost-to-change-the-final-value-of-expression/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-magic-square "Largest Magic Square") diff --git a/problems/minimum-cost-to-connect-sticks/README.md b/problems/minimum-cost-to-connect-sticks/README.md index dc0733fe6..f2782da11 100644 --- a/problems/minimum-cost-to-connect-sticks/README.md +++ b/problems/minimum-cost-to-connect-sticks/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-file-system "Design File System") @@ -34,8 +34,8 @@ ### 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)] ### Similar Questions 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 7d2218d62..fa8b8b06d 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-non-negative-product-in-a-matrix "Maximum Non Negative Product in a Matrix") @@ -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)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Bitmask](../../tag/bitmask/README.md)] + [[Matrix](../../tag/matrix/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 2c0ac95df..bd27a000b 100644 --- a/problems/minimum-cost-to-cut-a-stick/README.md +++ b/problems/minimum-cost-to-cut-a-stick/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "Maximum Number of Non-Overlapping Subarrays With Sum Equals Target") @@ -13,13 +13,13 @@

    Given a wooden stick of length n units. The stick is labelled from 0 to n. For example, a stick of length 6 is labelled as follows:

    -

    Given an integer array cuts where cuts[i] denotes a position you should perform a cut at.

    +

    Given an integer array cuts where cuts[i] denotes a position you should perform a cut at.

    You should perform the cuts in order, you can change the order of the cuts as you wish.

    The cost of one cut is the length of the stick to be cut, the total cost is the sum of costs of all cuts. When you cut a stick, it will be split into two smaller sticks (i.e. the sum of their lengths is the length of the stick before the cut). Please refer to the first example for a better explanation.

    -

    Return the minimum total cost of the cuts.

    +

    Return the minimum total cost of the cuts.

     

    Example 1:

    @@ -45,10 +45,10 @@ There are much ordering with total cost <= 25, for example, the order [4, 6,

    Constraints:

      -
    • 2 <= n <= 10^6
    • +
    • 2 <= n <= 106
    • 1 <= cuts.length <= min(n - 1, 100)
    • 1 <= cuts[i] <= n - 1
    • -
    • All the integers in cuts array are distinct.
    • +
    • All the integers in cuts array are distinct.
    ### Related Topics 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 4081e86be..73dbdb11c 100644 --- a/problems/minimum-cost-to-reach-destination-in-time/README.md +++ b/problems/minimum-cost-to-reach-destination-in-time/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-game "Sum Game") 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 17d922a39..36029ae69 100644 --- a/problems/minimum-cost-to-separate-sentence-into-rows/README.md +++ b/problems/minimum-cost-to-separate-sentence-into-rows/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-category-of-each-member-in-the-store "The Category of Each Member in the Store") diff --git a/problems/minimum-cost-tree-from-leaf-values/README.md b/problems/minimum-cost-tree-from-leaf-values/README.md index 8472914f9..35cd83444 100644 --- a/problems/minimum-cost-tree-from-leaf-values/README.md +++ b/problems/minimum-cost-tree-from-leaf-values/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-with-alternating-colors "Shortest Path with Alternating Colors") diff --git a/problems/minimum-degree-of-a-connected-trio-in-a-graph/README.md b/problems/minimum-degree-of-a-connected-trio-in-a-graph/README.md index 7f3055dc2..039af768b 100644 --- a/problems/minimum-degree-of-a-connected-trio-in-a-graph/README.md +++ b/problems/minimum-degree-of-a-connected-trio-in-a-graph/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-limit-of-balls-in-a-bag "Minimum Limit of Balls in a Bag") diff --git a/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md b/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md index 07780cb5d..7bcb7dda0 100644 --- a/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md +++ b/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md @@ -1,8 +1,8 @@ - - - + + + [< 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") diff --git a/problems/minimum-deletions-to-make-character-frequencies-unique/README.md b/problems/minimum-deletions-to-make-character-frequencies-unique/README.md index 7832dcdcd..3fdb2db07 100644 --- a/problems/minimum-deletions-to-make-character-frequencies-unique/README.md +++ b/problems/minimum-deletions-to-make-character-frequencies-unique/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../get-maximum-in-generated-array "Get Maximum in Generated Array") @@ -52,8 +52,8 @@ Note that we only care about characters that are still in the string at the end ### Related Topics - [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-deletions-to-make-string-balanced/README.md b/problems/minimum-deletions-to-make-string-balanced/README.md index 1c757d15b..ced0f75da 100644 --- a/problems/minimum-deletions-to-make-string-balanced/README.md +++ b/problems/minimum-deletions-to-make-string-balanced/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../defuse-the-bomb "Defuse the Bomb") diff --git a/problems/minimum-depth-of-binary-tree/README.md b/problems/minimum-depth-of-binary-tree/README.md index e24eb7705..890e8b2ea 100644 --- a/problems/minimum-depth-of-binary-tree/README.md +++ b/problems/minimum-depth-of-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../balanced-binary-tree "Balanced Binary Tree") 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 f082e8fb3..e33c271fd 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../widest-pair-of-indices-with-equal-range-sum "Widest Pair of Indices With Equal Range Sum") 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 c97912c97..b999215c1 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../range-sum-of-sorted-subarray-sums "Range Sum of Sorted Subarray Sums") @@ -56,8 +56,8 @@ The difference between the maximum and minimum is 1-0 = 1. ### 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-difficulty-of-a-job-schedule/README.md b/problems/minimum-difficulty-of-a-job-schedule/README.md index 1efd0840f..1dcb96035 100644 --- a/problems/minimum-difficulty-of-a-job-schedule/README.md +++ b/problems/minimum-difficulty-of-a-job-schedule/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "Find the City With the Smallest Number of Neighbors at a Threshold Distance") diff --git a/problems/minimum-distance-to-the-target-element/README.md b/problems/minimum-distance-to-the-target-element/README.md index 184725e67..12fce50f8 100644 --- a/problems/minimum-distance-to-the-target-element/README.md +++ b/problems/minimum-distance-to-the-target-element/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-room "Closest Room") 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 ddc02a52b..b519e4090 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-operations-to-make-network-connected "Number of Operations to Make Network Connected") 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 7d9b5723f..dfbb7e274 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-binary-string-has-at-most-one-segment-of-ones "Check if Binary String Has at Most One Segment of Ones") @@ -44,8 +44,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/minimum-factorization/README.md b/problems/minimum-factorization/README.md index 7ce98b925..2de984add 100644 --- a/problems/minimum-factorization/README.md +++ b/problems/minimum-factorization/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-distance-in-arrays "Maximum Distance in Arrays") @@ -34,5 +34,5 @@ Output:

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-falling-path-sum-ii/README.md b/problems/minimum-falling-path-sum-ii/README.md index 5eabc469f..d0c06f521 100644 --- a/problems/minimum-falling-path-sum-ii/README.md +++ b/problems/minimum-falling-path-sum-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-covered-intervals "Remove Covered Intervals") @@ -50,9 +50,6 @@ 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-flips-to-make-a-or-b-equal-to-c/README.md b/problems/minimum-flips-to-make-a-or-b-equal-to-c/README.md index e9644a5ae..81c358c5a 100644 --- a/problems/minimum-flips-to-make-a-or-b-equal-to-c/README.md +++ b/problems/minimum-flips-to-make-a-or-b-equal-to-c/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-integer-to-the-sum-of-two-no-zero-integers "Convert Integer to the Sum of Two No-Zero Integers") diff --git a/problems/minimum-garden-perimeter-to-collect-enough-apples/README.md b/problems/minimum-garden-perimeter-to-collect-enough-apples/README.md index fe231b449..8b7b380b8 100644 --- a/problems/minimum-garden-perimeter-to-collect-enough-apples/README.md +++ b/problems/minimum-garden-perimeter-to-collect-enough-apples/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-weeks-for-which-you-can-work "Maximum Number of Weeks for Which You Can Work") diff --git a/problems/minimum-height-trees/README.md b/problems/minimum-height-trees/README.md index 0a7354288..5f5d66e2d 100644 --- a/problems/minimum-height-trees/README.md +++ b/problems/minimum-height-trees/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-time-to-buy-and-sell-stock-with-cooldown "Best Time to Buy and Sell Stock with Cooldown") diff --git a/problems/minimum-incompatibility/README.md b/problems/minimum-incompatibility/README.md index 7dbfed95f..cb789c363 100644 --- a/problems/minimum-incompatibility/README.md +++ b/problems/minimum-incompatibility/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../concatenation-of-consecutive-binary-numbers "Concatenation of Consecutive Binary Numbers") diff --git a/problems/minimum-index-sum-of-two-lists/README.md b/problems/minimum-index-sum-of-two-lists/README.md index c8c570aa8..846a3b8fa 100644 --- a/problems/minimum-index-sum-of-two-lists/README.md +++ b/problems/minimum-index-sum-of-two-lists/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../range-addition-ii "Range Addition II") diff --git a/problems/minimum-initial-energy-to-finish-tasks/README.md b/problems/minimum-initial-energy-to-finish-tasks/README.md index 88eac2a24..c8593ac98 100644 --- a/problems/minimum-initial-energy-to-finish-tasks/README.md +++ b/problems/minimum-initial-energy-to-finish-tasks/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ways-to-make-a-fair-array "Ways to Make a Fair Array") @@ -74,8 +74,8 @@ Starting with 27 energy, we finish the tasks in the following order: ### 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/minimum-insertion-steps-to-make-a-string-palindrome/README.md b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md index 03ff464ad..db3e86945 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../get-watched-videos-by-your-friends "Get Watched Videos by Your Friends") 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 540c98995..3fd4fb5b2 100644 --- a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md +++ b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../can-convert-string-in-k-moves "Can Convert String in K Moves") @@ -76,9 +76,12 @@ ### 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. [Minimum Number of Swaps to Make the String Balanced](../minimum-number-of-swaps-to-make-the-string-balanced) (Medium) ### Hints
    diff --git a/problems/minimum-interval-to-include-each-query/README.md b/problems/minimum-interval-to-include-each-query/README.md index df5948a15..4cfe2d11c 100644 --- a/problems/minimum-interval-to-include-each-query/README.md +++ b/problems/minimum-interval-to-include-each-query/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-adjacent-swaps-to-reach-the-kth-smallest-number "Minimum Adjacent Swaps to Reach the Kth Smallest Number") diff --git a/problems/minimum-jumps-to-reach-home/README.md b/problems/minimum-jumps-to-reach-home/README.md index cee72e6fb..d9e52ef2a 100644 --- a/problems/minimum-jumps-to-reach-home/README.md +++ b/problems/minimum-jumps-to-reach-home/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-deletions-to-make-string-balanced "Minimum Deletions to Make String Balanced") diff --git a/problems/minimum-length-of-string-after-deleting-similar-ends/README.md b/problems/minimum-length-of-string-after-deleting-similar-ends/README.md index 6bad2b22e..83de2d6e8 100644 --- a/problems/minimum-length-of-string-after-deleting-similar-ends/README.md +++ b/problems/minimum-length-of-string-after-deleting-similar-ends/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-absolute-sum-of-any-subarray "Maximum Absolute Sum of Any Subarray") diff --git a/problems/minimum-limit-of-balls-in-a-bag/README.md b/problems/minimum-limit-of-balls-in-a-bag/README.md index 996ff699d..85b5b54ac 100644 --- a/problems/minimum-limit-of-balls-in-a-bag/README.md +++ b/problems/minimum-limit-of-balls-in-a-bag/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-number-of-homogenous-substrings "Count Number of Homogenous Substrings") @@ -71,9 +71,6 @@ The bag with the most number of balls has 2 balls, so your penalty is 2 an you s [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] -### Similar Questions - 1. [Minimized Maximum of Products Distributed to Any Store](../minimized-maximum-of-products-distributed-to-any-store) (Medium) - ### Hints
    Hint 1 diff --git a/problems/minimum-moves-to-convert-string/README.md b/problems/minimum-moves-to-convert-string/README.md index 377145f1d..b05b55634 100644 --- a/problems/minimum-moves-to-convert-string/README.md +++ b/problems/minimum-moves-to-convert-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../low-quality-problems "Low-Quality Problems") diff --git a/problems/minimum-moves-to-equal-array-elements-ii/README.md b/problems/minimum-moves-to-equal-array-elements-ii/README.md index 6b7d83e00..93facd4a6 100644 --- a/problems/minimum-moves-to-equal-array-elements-ii/README.md +++ b/problems/minimum-moves-to-equal-array-elements-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../hamming-distance "Hamming Distance") diff --git a/problems/minimum-moves-to-equal-array-elements/README.md b/problems/minimum-moves-to-equal-array-elements/README.md index c1d2c38a3..b830f1c85 100644 --- a/problems/minimum-moves-to-equal-array-elements/README.md +++ b/problems/minimum-moves-to-equal-array-elements/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../minimum-number-of-arrows-to-burst-balloons "Minimum Number of Arrows to Burst Balloons")                  [Next >](../4sum-ii "4Sum II") -## [453. Minimum Moves to Equal Array Elements (Easy)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小操作次数使数组元素相等") +## [453. Minimum Moves to Equal Array Elements (Medium)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小操作次数使数组元素相等")

    Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal.

    diff --git a/problems/minimum-moves-to-make-array-complementary/README.md b/problems/minimum-moves-to-make-array-complementary/README.md index 23c4443a6..bac1b8a62 100644 --- a/problems/minimum-moves-to-make-array-complementary/README.md +++ b/problems/minimum-moves-to-make-array-complementary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-most-competitive-subsequence "Find the Most Competitive Subsequence") 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 b2674e4f4..486ed61bd 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../greatest-sum-divisible-by-three "Greatest Sum Divisible by Three") @@ -87,10 +87,10 @@ ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] - [[Matrix](../../tag/matrix/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/minimum-non-zero-product-of-the-array-elements/README.md b/problems/minimum-non-zero-product-of-the-array-elements/README.md index 627db8207..9652b9b39 100644 --- a/problems/minimum-non-zero-product-of-the-array-elements/README.md +++ b/problems/minimum-non-zero-product-of-the-array-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../array-with-elements-not-equal-to-average-of-neighbors "Array With Elements Not Equal to Average of Neighbors") 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 5ae12e99d..26163ef0f 100644 --- a/problems/minimum-number-of-days-to-disconnect-island/README.md +++ b/problems/minimum-number-of-days-to-disconnect-island/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-length-of-subarray-with-positive-product "Maximum Length of Subarray With Positive Product") @@ -75,9 +75,9 @@ Change land grid[1][1] and grid[0][2] to water and get 2 disconnected island. ### 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 a6032a7a1..2f250b084 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../magnetic-force-between-two-balls "Magnetic Force Between Two Balls") @@ -15,8 +15,8 @@
    • 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.

    @@ -67,7 +67,7 @@ You need at least 3 days to eat the 6 oranges.

    Constraints:

      -
    • 1 <= n <= 2*10^9
    • +
    • 1 <= n <= 2 * 109
    ### Related Topics 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 584cd0de2..79478879e 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../least-number-of-unique-integers-after-k-removals "Least Number of Unique Integers after K Removals") 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 e7067938d..0dcbfe47e 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-smallest-divisor-given-a-threshold "Find the Smallest Divisor Given a Threshold") diff --git a/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/README.md b/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/README.md index 5f1ca62a4..b039c7179 100644 --- a/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/README.md +++ b/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reduction-operations-to-make-the-array-elements-equal "Reduction Operations to Make the Array Elements Equal") diff --git a/problems/minimum-number-of-frogs-croaking/README.md b/problems/minimum-number-of-frogs-croaking/README.md index 4ad168c9b..55866e125 100644 --- a/problems/minimum-number-of-frogs-croaking/README.md +++ b/problems/minimum-number-of-frogs-croaking/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../display-table-of-food-orders-in-a-restaurant "Display Table of Food Orders in a Restaurant") 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 275f1e4fb..d2ff2706f 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-good-ways-to-split-a-string "Number of Good Ways to Split a String") diff --git a/problems/minimum-number-of-moves-to-seat-everyone/README.md b/problems/minimum-number-of-moves-to-seat-everyone/README.md index 8667b1d0c..16ab9e64b 100644 --- a/problems/minimum-number-of-moves-to-seat-everyone/README.md +++ b/problems/minimum-number-of-moves-to-seat-everyone/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-alternating-subarray-sum "Maximum Alternating Subarray Sum") diff --git a/problems/minimum-number-of-operations-to-make-array-continuous/README.md b/problems/minimum-number-of-operations-to-make-array-continuous/README.md index e9195c838..93bc9000d 100644 --- a/problems/minimum-number-of-operations-to-make-array-continuous/README.md +++ b/problems/minimum-number-of-operations-to-make-array-continuous/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-earnings-from-taxi "Maximum Earnings From Taxi") 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 8d1e43c2e..7aa3e5a7d 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-xor-for-each-query "Maximum XOR for Each Query") 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 39d2ee8a2..3f34200f4 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-strings-alternately "Merge Strings Alternately") @@ -50,9 +50,6 @@ [[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-operations-to-reinitialize-a-permutation/README.md b/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md index 9b41ba166..ed5e1cc09 100644 --- a/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md +++ b/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-different-integers-in-a-string "Number of Different Integers in a String") diff --git a/problems/minimum-number-of-people-to-teach/README.md b/problems/minimum-number-of-people-to-teach/README.md index 1dc39674f..7dd7bea79 100644 --- a/problems/minimum-number-of-people-to-teach/README.md +++ b/problems/minimum-number-of-people-to-teach/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-highest-altitude "Find the Highest Altitude") 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 732e11a35..7f2ca1d02 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-front-middle-back-queue "Design Front Middle Back Queue") @@ -66,17 +66,10 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] - -### Similar Questions - 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) - 1. [Longest Mountain in Array](../longest-mountain-in-array) (Medium) - 1. [Peak Index in a Mountain Array](../peak-index-in-a-mountain-array) (Easy) - 1. [Valid Mountain Array](../valid-mountain-array) (Easy) - 1. [Find in Mountain Array](../find-in-mountain-array) (Hard) ### Hints
    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 fdf8008a6..5038dbee9 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-n-and-its-double-exist "Check If N and Its Double Exist") @@ -69,6 +69,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Determine if Two Strings Are Close](../determine-if-two-strings-are-close) (Medium) + ### Hints
    Hint 1 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 6100faa01..179da70b9 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-all-subset-xor-totals "Sum of All Subset XOR Totals") diff --git a/problems/minimum-number-of-swaps-to-make-the-string-balanced/README.md b/problems/minimum-number-of-swaps-to-make-the-string-balanced/README.md index 116007468..04944ffd0 100644 --- a/problems/minimum-number-of-swaps-to-make-the-string-balanced/README.md +++ b/problems/minimum-number-of-swaps-to-make-the-string-balanced/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-stones-to-minimize-the-total "Remove Stones to Minimize the Total") 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 b6c6547fe..3f1157121 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-leaves-with-a-given-value "Delete Leaves With a Given Value") @@ -73,9 +73,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-number-of-vertices-to-reach-all-nodes/README.md b/problems/minimum-number-of-vertices-to-reach-all-nodes/README.md index 8dd361e1c..0732e0be0 100644 --- a/problems/minimum-number-of-vertices-to-reach-all-nodes/README.md +++ b/problems/minimum-number-of-vertices-to-reach-all-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../thousand-separator "Thousand Separator") diff --git a/problems/minimum-number-of-work-sessions-to-finish-the-tasks/README.md b/problems/minimum-number-of-work-sessions-to-finish-the-tasks/README.md index 68440f11a..7062502be 100644 --- a/problems/minimum-number-of-work-sessions-to-finish-the-tasks/README.md +++ b/problems/minimum-number-of-work-sessions-to-finish-the-tasks/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-kth-largest-integer-in-the-array "Find the Kth Largest Integer in the Array") 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 0dfac9e44..9fcfb0f7e 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-vertices-to-reach-all-nodes "Minimum Number of Vertices to Reach All Nodes") 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 b04d7fdaf..6daae4a00 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-visible-points "Maximum Number of Visible Points") diff --git a/problems/minimum-operations-to-convert-number/README.md b/problems/minimum-operations-to-convert-number/README.md index 090f581f2..941b3a389 100644 --- a/problems/minimum-operations-to-convert-number/README.md +++ b/problems/minimum-operations-to-convert-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-minimum-and-maximum-number-of-nodes-between-critical-points "Find the Minimum and Maximum Number of Nodes Between Critical Points") diff --git a/problems/minimum-operations-to-make-a-subsequence/README.md b/problems/minimum-operations-to-make-a-subsequence/README.md index 1f0095ead..2284fd92b 100644 --- a/problems/minimum-operations-to-make-a-subsequence/README.md +++ b/problems/minimum-operations-to-make-a-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ways-to-split-array-into-three-subarrays "Ways to Split Array Into Three Subarrays") diff --git a/problems/minimum-operations-to-make-a-uni-value-grid/README.md b/problems/minimum-operations-to-make-a-uni-value-grid/README.md index 7c9e2c738..e0b204b83 100644 --- a/problems/minimum-operations-to-make-a-uni-value-grid/README.md +++ b/problems/minimum-operations-to-make-a-uni-value-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-out-of-three "Two Out of Three") diff --git a/problems/minimum-operations-to-make-array-equal/README.md b/problems/minimum-operations-to-make-array-equal/README.md index a975cb28b..6b184beb4 100644 --- a/problems/minimum-operations-to-make-array-equal/README.md +++ b/problems/minimum-operations-to-make-array-equal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../three-consecutive-odds "Three Consecutive Odds") @@ -11,11 +11,11 @@ ## [1551. Minimum Operations to Make Array Equal (Medium)](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") -

    You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e. 0 <= i < n).

    +

    You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e., 0 <= i < n).

    -

    In one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] (i.e. perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the array equal. It is guaranteed that all the elements of the array can be made equal using some operations.

    +

    In one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] (i.e., perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the array equal. It is guaranteed that all the elements of the array can be made equal using some operations.

    -

    Given an integer n, the length of the array. Return the minimum number of operations needed to make all the elements of arr equal.

    +

    Given an integer n, the length of the array, return the minimum number of operations needed to make all the elements of arr equal.

     

    Example 1:

    @@ -39,7 +39,7 @@ In the second operation choose x = 2 and y = 0 again, thus arr = [3, 3, 3].

    Constraints:

      -
    • 1 <= n <= 10^4
    • +
    • 1 <= n <= 104
    ### Related Topics diff --git a/problems/minimum-operations-to-make-the-array-increasing/README.md b/problems/minimum-operations-to-make-the-array-increasing/README.md index e556d5320..ea365b974 100644 --- a/problems/minimum-operations-to-make-the-array-increasing/README.md +++ b/problems/minimum-operations-to-make-the-array-increasing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../faulty-sensor "Faulty Sensor") diff --git a/problems/minimum-operations-to-reduce-x-to-zero/README.md b/problems/minimum-operations-to-reduce-x-to-zero/README.md index 0b14663ae..a3e83af42 100644 --- a/problems/minimum-operations-to-reduce-x-to-zero/README.md +++ b/problems/minimum-operations-to-reduce-x-to-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../determine-if-two-strings-are-close "Determine if Two Strings Are Close") diff --git a/problems/minimum-path-cost-in-a-hidden-grid/README.md b/problems/minimum-path-cost-in-a-hidden-grid/README.md index 96b02ee45..cfccec590 100644 --- a/problems/minimum-path-cost-in-a-hidden-grid/README.md +++ b/problems/minimum-path-cost-in-a-hidden-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ad-free-sessions "Ad-Free Sessions") @@ -17,12 +17,8 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Interactive](../../tag/interactive/README.md)] - -### Similar Questions - 1. [Robot Room Cleaner](../robot-room-cleaner) (Hard) - 1. [Shortest Path in a Hidden Grid](../shortest-path-in-a-hidden-grid) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/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 b9c47d07b..370877ada 100644 --- a/problems/minimum-remove-to-make-valid-parentheses/README.md +++ b/problems/minimum-remove-to-make-valid-parentheses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-number-of-nice-subarrays "Count Number of Nice Subarrays") diff --git a/problems/minimum-sideway-jumps/README.md b/problems/minimum-sideway-jumps/README.md index 56fe5ea6c..e3df8214b 100644 --- a/problems/minimum-sideway-jumps/README.md +++ b/problems/minimum-sideway-jumps/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-winner-of-the-circular-game "Find the Winner of the Circular Game") @@ -66,9 +66,12 @@ Note that the frog can jump over obstacles only when making side jumps (as shown ### 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. [Frog Jump](../frog-jump) (Hard) ### Hints
    diff --git a/problems/minimum-size-subarray-sum/README.md b/problems/minimum-size-subarray-sum/README.md index 8d4323693..431ecc096 100644 --- a/problems/minimum-size-subarray-sum/README.md +++ b/problems/minimum-size-subarray-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../implement-trie-prefix-tree "Implement Trie (Prefix Tree)") 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 b40cb1c74..0e88486e6 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../process-tasks-using-servers "Process Tasks Using Servers") diff --git a/problems/minimum-space-wasted-from-packaging/README.md b/problems/minimum-space-wasted-from-packaging/README.md index 28578d552..a012e8bca 100644 --- a/problems/minimum-space-wasted-from-packaging/README.md +++ b/problems/minimum-space-wasted-from-packaging/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-flips-to-make-the-binary-string-alternating "Minimum Number of Flips to Make the Binary String Alternating") diff --git a/problems/minimum-speed-to-arrive-on-time/README.md b/problems/minimum-speed-to-arrive-on-time/README.md index adcbdfe4d..c9ecb7bc8 100644 --- a/problems/minimum-speed-to-arrive-on-time/README.md +++ b/problems/minimum-speed-to-arrive-on-time/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longer-contiguous-segments-of-ones-than-zeros "Longer Contiguous Segments of Ones than Zeros") diff --git a/problems/minimum-subsequence-in-non-increasing-order/README.md b/problems/minimum-subsequence-in-non-increasing-order/README.md index d93029247..af2af0779 100644 --- a/problems/minimum-subsequence-in-non-increasing-order/README.md +++ b/problems/minimum-subsequence-in-non-increasing-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reducing-dishes "Reducing Dishes") @@ -50,8 +50,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/minimum-swaps-to-arrange-a-binary-grid/README.md b/problems/minimum-swaps-to-arrange-a-binary-grid/README.md index 95ceaeb03..9a67343eb 100644 --- a/problems/minimum-swaps-to-arrange-a-binary-grid/README.md +++ b/problems/minimum-swaps-to-arrange-a-binary-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-winner-of-an-array-game "Find the Winner of an Array Game") @@ -11,7 +11,7 @@ ## [1536. Minimum Swaps to Arrange a Binary Grid (Medium)](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") -

    Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them.

    +

    Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them.

    A grid is said to be valid if all the cells above the main diagonal are zeros.

    @@ -46,10 +46,9 @@

    Constraints:

      -
    • n == grid.length
    • -
    • n == grid[i].length
    • -
    • 1 <= n <= 200
    • -
    • grid[i][j] is 0 or 1
    • +
    • n == grid.length == grid[i].length
    • +
    • 1 <= n <= 200
    • +
    • grid[i][j] is either 0 or 1
    ### Related Topics diff --git a/problems/minimum-swaps-to-group-all-1s-together/README.md b/problems/minimum-swaps-to-group-all-1s-together/README.md index 4035377a3..7709f2917 100644 --- a/problems/minimum-swaps-to-group-all-1s-together/README.md +++ b/problems/minimum-swaps-to-group-all-1s-together/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-a-number-is-majority-element-in-a-sorted-array "Check If a Number Is Majority Element in a Sorted Array") @@ -59,6 +59,9 @@ One possible solution that uses 3 swaps is [0,0,0,0,0,1,1,1,1,1,1]. [[Array](../../tag/array/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] +### Similar Questions + 1. [Minimum Adjacent Swaps for K Consecutive Ones](../minimum-adjacent-swaps-for-k-consecutive-ones) (Hard) + ### Hints
    Hint 1 diff --git a/problems/minimum-swaps-to-make-strings-equal/README.md b/problems/minimum-swaps-to-make-strings-equal/README.md index e50b97c41..c80adf70c 100644 --- a/problems/minimum-swaps-to-make-strings-equal/README.md +++ b/problems/minimum-swaps-to-make-strings-equal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindrome-removal "Palindrome Removal") 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 c91d81e7e..3b5cdd475 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-number-of-special-subsequences "Count Number of Special Subsequences") 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 a70b6db6b..72ac218db 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-triplets-that-can-form-two-arrays-of-equal-xor "Count Triplets That Can Form Two Arrays of Equal XOR") diff --git a/problems/minimum-time-to-type-word-using-special-typewriter/README.md b/problems/minimum-time-to-type-word-using-special-typewriter/README.md index 21d475e25..3fb98afb0 100644 --- a/problems/minimum-time-to-type-word-using-special-typewriter/README.md +++ b/problems/minimum-time-to-type-word-using-special-typewriter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-nodes-equal-to-sum-of-descendants "Count Nodes Equal to Sum of Descendants") diff --git a/problems/minimum-time-visiting-all-points/README.md b/problems/minimum-time-visiting-all-points/README.md index f66a2fe95..a30f21c83 100644 --- a/problems/minimum-time-visiting-all-points/README.md +++ b/problems/minimum-time-visiting-all-points/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../print-immutable-linked-list-in-reverse "Print Immutable Linked List in Reverse") diff --git a/problems/minimum-total-space-wasted-with-k-resizing-operations/README.md b/problems/minimum-total-space-wasted-with-k-resizing-operations/README.md index 9668b96ce..38cc07a1b 100644 --- a/problems/minimum-total-space-wasted-with-k-resizing-operations/README.md +++ b/problems/minimum-total-space-wasted-with-k-resizing-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-move-is-legal "Check if Move is Legal") diff --git a/problems/minimum-value-to-get-positive-step-by-step-sum/README.md b/problems/minimum-value-to-get-positive-step-by-step-sum/README.md index 97ef9c6ee..9d3ae86dc 100644 --- a/problems/minimum-value-to-get-positive-step-by-step-sum/README.md +++ b/problems/minimum-value-to-get-positive-step-by-step-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-quiet-students-in-all-exams "Find the Quiet Students in All Exams") @@ -24,13 +24,13 @@ Input: nums = [-3,2,-3,4,2] Output: 5 Explanation: If you choose startValue = 4, in the third iteration your step by step sum is less than 1. - step by step sum -  startValue = 4 | startValue = 5 | nums -  (4 -3 ) = 1 | (5 -3 ) = 2 | -3 -  (1 +2 ) = 3 | (2 +2 ) = 4 | 2 -  (3 -3 ) = 0 | (4 -3 ) = 1 | -3 -  (0 +4 ) = 4 | (1 +4 ) = 5 | 4 -  (4 +2 ) = 6 | (5 +2 ) = 7 | 2 +step by step sum +startValue = 4 | startValue = 5 | nums + (4 -3 ) = 1 | (5 -3 ) = 2 | -3 + (1 +2 ) = 3 | (2 +2 ) = 4 | 2 + (3 -3 ) = 0 | (4 -3 ) = 1 | -3 + (0 +4 ) = 4 | (1 +4 ) = 5 | 4 + (4 +2 ) = 6 | (5 +2 ) = 7 | 2

    Example 2:

    diff --git a/problems/minimum-window-substring/README.md b/problems/minimum-window-substring/README.md index 0135d2e32..8fd505163 100644 --- a/problems/minimum-window-substring/README.md +++ b/problems/minimum-window-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-colors "Sort Colors") @@ -66,6 +66,7 @@ Since the largest window of s only has one 'a', return empty string. 1. [Minimum Size Subarray Sum](../minimum-size-subarray-sum) (Medium) 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) 1. [Permutation in String](../permutation-in-string) (Medium) + 1. [Smallest Range Covering Elements from K Lists](../smallest-range-covering-elements-from-k-lists) (Hard) 1. [Minimum Window Subsequence](../minimum-window-subsequence) (Hard) ### Hints diff --git a/problems/minimum-xor-sum-of-two-arrays/README.md b/problems/minimum-xor-sum-of-two-arrays/README.md index 1b1ab001c..e2aefc089 100644 --- a/problems/minimum-xor-sum-of-two-arrays/README.md +++ b/problems/minimum-xor-sum-of-two-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../get-biggest-three-rhombus-sums-in-a-grid "Get Biggest Three Rhombus Sums in a Grid") diff --git a/problems/mirror-reflection/README.md b/problems/mirror-reflection/README.md index 38983a7f9..df9c98dfa 100644 --- a/problems/mirror-reflection/README.md +++ b/problems/mirror-reflection/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-hire-k-workers "Minimum Cost to Hire K Workers") @@ -43,5 +43,5 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/missing-element-in-sorted-array/README.md b/problems/missing-element-in-sorted-array/README.md index 9766f6cb3..096bf02d0 100644 --- a/problems/missing-element-in-sorted-array/README.md +++ b/problems/missing-element-in-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-paths-from-source-lead-to-destination "All Paths from Source Lead to Destination") diff --git a/problems/missing-number-in-arithmetic-progression/README.md b/problems/missing-number-in-arithmetic-progression/README.md index ed3d1c078..26c0e9499 100644 --- a/problems/missing-number-in-arithmetic-progression/README.md +++ b/problems/missing-number-in-arithmetic-progression/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../airplane-seat-assignment-probability "Airplane Seat Assignment Probability") diff --git a/problems/missing-number/README.md b/problems/missing-number/README.md index c6300790f..6537570f6 100644 --- a/problems/missing-number/README.md +++ b/problems/missing-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindrome-permutation-ii "Palindrome Permutation II") diff --git a/problems/monthly-transactions-i/README.md b/problems/monthly-transactions-i/README.md index e87c5b4e1..7eaff3dbd 100644 --- a/problems/monthly-transactions-i/README.md +++ b/problems/monthly-transactions-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../critical-connections-in-a-network "Critical Connections in a Network") diff --git a/problems/monthly-transactions-i/mysql_schemas.sql b/problems/monthly-transactions-i/mysql_schemas.sql index c5a883654..f46d70e2f 100644 --- a/problems/monthly-transactions-i/mysql_schemas.sql +++ b/problems/monthly-transactions-i/mysql_schemas.sql @@ -1,4 +1,4 @@ -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); Truncate table Transactions; insert into Transactions (id, country, state, amount, trans_date) values ('121', 'US', 'approved', '1000', '2018-12-18'); insert into Transactions (id, country, state, amount, trans_date) values ('122', 'US', 'declined', '2000', '2018-12-19'); diff --git a/problems/most-beautiful-item-for-each-query/README.md b/problems/most-beautiful-item-for-each-query/README.md index 8b0c0dcc5..4322b3b80 100644 --- a/problems/most-beautiful-item-for-each-query/README.md +++ b/problems/most-beautiful-item-for-each-query/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../walking-robot-simulation-ii "Walking Robot Simulation II") diff --git a/problems/most-profit-assigning-work/README.md b/problems/most-profit-assigning-work/README.md index 338226ddf..ff6912b7e 100644 --- a/problems/most-profit-assigning-work/README.md +++ b/problems/most-profit-assigning-work/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../friends-of-appropriate-ages "Friends Of Appropriate Ages") diff --git a/problems/most-stones-removed-with-same-row-or-column/README.md b/problems/most-stones-removed-with-same-row-or-column/README.md index 8a44c6396..5c81899d5 100644 --- a/problems/most-stones-removed-with-same-row-or-column/README.md +++ b/problems/most-stones-removed-with-same-row-or-column/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../validate-stack-sequences "Validate Stack Sequences") diff --git a/problems/most-visited-sector-in-a-circular-track/README.md b/problems/most-visited-sector-in-a-circular-track/README.md index aeadb51fb..dde19d99c 100644 --- a/problems/most-visited-sector-in-a-circular-track/README.md +++ b/problems/most-visited-sector-in-a-circular-track/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../detect-cycles-in-2d-grid "Detect Cycles in 2D Grid") @@ -11,11 +11,11 @@ ## [1560. Most Visited Sector in a Circular Track (Easy)](https://leetcode.com/problems/most-visited-sector-in-a-circular-track "圆形赛道上经过次数最多的扇区") -

    Given an integer n and an integer array rounds. We have a circular track which consists of n sectors labeled from 1 to n. A marathon will be held on this track, the marathon consists of m rounds. The ith round starts at sector rounds[i - 1] and ends at sector rounds[i]. For example, round 1 starts at sector rounds[0] and ends at sector rounds[1]

    +

    Given an integer n and an integer array rounds. We have a circular track which consists of n sectors labeled from 1 to n. A marathon will be held on this track, the marathon consists of m rounds. The ith round starts at sector rounds[i - 1] and ends at sector rounds[i]. For example, round 1 starts at sector rounds[0] and ends at sector rounds[1]

    Return an array of the most visited sectors sorted in ascending order.

    -

    Notice that you circulate the track in ascending order of sector numbers in the counter-clockwise direction (See the first example).

    +

    Notice that you circulate the track in ascending order of sector numbers in the counter-clockwise direction (See the first example).

     

    Example 1:

    diff --git a/problems/move-sub-tree-of-n-ary-tree/README.md b/problems/move-sub-tree-of-n-ary-tree/README.md index 7b3f55ebd..a6afdc459 100644 --- a/problems/move-sub-tree-of-n-ary-tree/README.md +++ b/problems/move-sub-tree-of-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-position-for-a-service-centre "Best Position for a Service Centre") @@ -17,6 +17,9 @@ [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] +### Similar Questions + 1. [Find Root of N-Ary Tree](../find-root-of-n-ary-tree) (Medium) + ### Hints
    Hint 1 diff --git a/problems/movie-rating/README.md b/problems/movie-rating/README.md index d4d0c2a2d..92060fa44 100644 --- a/problems/movie-rating/README.md +++ b/problems/movie-rating/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game-v "Jump Game V") diff --git a/problems/moving-average-from-data-stream/README.md b/problems/moving-average-from-data-stream/README.md index f918c4396..d114871ff 100644 --- a/problems/moving-average-from-data-stream/README.md +++ b/problems/moving-average-from-data-stream/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-vowels-of-a-string "Reverse Vowels of a String") diff --git a/problems/moving-stones-until-consecutive-ii/README.md b/problems/moving-stones-until-consecutive-ii/README.md index 036567f21..23713bb67 100644 --- a/problems/moving-stones-until-consecutive-ii/README.md +++ b/problems/moving-stones-until-consecutive-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-score-triangulation-of-polygon "Minimum Score Triangulation of Polygon") diff --git a/problems/moving-stones-until-consecutive/README.md b/problems/moving-stones-until-consecutive/README.md index e7de515ef..ed4929f36 100644 --- a/problems/moving-stones-until-consecutive/README.md +++ b/problems/moving-stones-until-consecutive/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stream-of-characters "Stream of Characters") @@ -58,8 +58,8 @@ ### Related Topics - [[Brainteaser](../../tag/brainteaser/README.md)] [[Math](../../tag/math/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] ### Hints
    diff --git a/problems/multiply-strings/README.md b/problems/multiply-strings/README.md index 5de23a000..0a72f5fdf 100644 --- a/problems/multiply-strings/README.md +++ b/problems/multiply-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../trapping-rain-water "Trapping Rain Water") diff --git a/problems/my-calendar-ii/README.md b/problems/my-calendar-ii/README.md index ff37dee7b..b7e248b90 100644 --- a/problems/my-calendar-ii/README.md +++ b/problems/my-calendar-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-different-palindromic-subsequences "Count Different Palindromic Subsequences") diff --git a/problems/n-ary-tree-level-order-traversal/README.md b/problems/n-ary-tree-level-order-traversal/README.md index b98d1f2b6..cf206b66c 100644 --- a/problems/n-ary-tree-level-order-traversal/README.md +++ b/problems/n-ary-tree-level-order-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../serialize-and-deserialize-n-ary-tree "Serialize and Deserialize N-ary Tree") diff --git a/problems/n-ary-tree-postorder-traversal/README.md b/problems/n-ary-tree-postorder-traversal/README.md index 6fb7c1ada..3e107347d 100644 --- a/problems/n-ary-tree-postorder-traversal/README.md +++ b/problems/n-ary-tree-postorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../n-ary-tree-preorder-traversal "N-ary Tree Preorder Traversal") diff --git a/problems/n-ary-tree-preorder-traversal/README.md b/problems/n-ary-tree-preorder-traversal/README.md index 748911d67..94fc226d9 100644 --- a/problems/n-ary-tree-preorder-traversal/README.md +++ b/problems/n-ary-tree-preorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-in-memory-file-system "Design In-Memory File System") diff --git a/problems/n-th-tribonacci-number/README.md b/problems/n-th-tribonacci-number/README.md index 43b0b3b94..aad681a58 100644 --- a/problems/n-th-tribonacci-number/README.md +++ b/problems/n-th-tribonacci-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../parallel-courses "Parallel Courses") diff --git a/problems/nearest-exit-from-entrance-in-maze/README.md b/problems/nearest-exit-from-entrance-in-maze/README.md index b3e3aabfe..6ecf2c2bf 100644 --- a/problems/nearest-exit-from-entrance-in-maze/README.md +++ b/problems/nearest-exit-from-entrance-in-maze/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-square-sum-triples "Count Square Sum Triples") diff --git a/problems/nested-list-weight-sum/README.md b/problems/nested-list-weight-sum/README.md index 11b69f5a6..68ee743ea 100644 --- a/problems/nested-list-weight-sum/README.md +++ b/problems/nested-list-weight-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../counting-bits "Counting Bits") @@ -38,4 +38,4 @@ ### Similar Questions 1. [Nested List Weight Sum II](../nested-list-weight-sum-ii) (Medium) 1. [Array Nesting](../array-nesting) (Medium) - 1. [Employee Importance](../employee-importance) (Easy) + 1. [Employee Importance](../employee-importance) (Medium) diff --git a/problems/new-21-game/README.md b/problems/new-21-game/README.md index a1643a0c3..71e615e07 100644 --- a/problems/new-21-game/README.md +++ b/problems/new-21-game/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../rectangle-overlap "Rectangle Overlap")                  [Next >](../push-dominoes "Push Dominoes") -## [837. New 21 Game (Medium)](https://leetcode.com/problems/new-21-game "新21点") +## [837. New 21 Game (Medium)](https://leetcode.com/problems/new-21-game "新 21 点")

    Alice plays the following game, loosely based on the card game "21".

    diff --git a/problems/next-closest-time/README.md b/problems/next-closest-time/README.md index 89431c6f1..668e17970 100644 --- a/problems/next-closest-time/README.md +++ b/problems/next-closest-time/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-palindrome-ii "Valid Palindrome II") diff --git a/problems/next-greater-element-i/README.md b/problems/next-greater-element-i/README.md index 834144f2f..3a5f0dc2f 100644 --- a/problems/next-greater-element-i/README.md +++ b/problems/next-greater-element-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../teemo-attacking "Teemo Attacking") diff --git a/problems/next-greater-element-ii/README.md b/problems/next-greater-element-ii/README.md index f5aad81ad..7bcd419b2 100644 --- a/problems/next-greater-element-ii/README.md +++ b/problems/next-greater-element-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ipo "IPO") @@ -42,8 +42,8 @@ The second 1's next greater number needs to search circularly, which is also ### Related Topics - [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions diff --git a/problems/next-greater-node-in-linked-list/README.md b/problems/next-greater-node-in-linked-list/README.md index ef5eff299..89037df98 100644 --- a/problems/next-greater-node-in-linked-list/README.md +++ b/problems/next-greater-node-in-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-prefix-divisible-by-5 "Binary Prefix Divisible By 5") diff --git a/problems/next-greater-numerically-balanced-number/README.md b/problems/next-greater-numerically-balanced-number/README.md index 4f7356902..338830ba3 100644 --- a/problems/next-greater-numerically-balanced-number/README.md +++ b/problems/next-greater-numerically-balanced-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-valid-words-in-a-sentence "Number of Valid Words in a Sentence") diff --git a/problems/next-palindrome-using-same-digits/README.md b/problems/next-palindrome-using-same-digits/README.md index 53bbc8357..5c062380d 100644 --- a/problems/next-palindrome-using-same-digits/README.md +++ b/problems/next-palindrome-using-same-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../league-statistics "League Statistics") diff --git a/problems/nim-game/README.md b/problems/nim-game/README.md index 777bf5b83..263994332 100644 --- a/problems/nim-game/README.md +++ b/problems/nim-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-pattern-ii "Word Pattern II") @@ -57,8 +57,8 @@ In all outcomes, your friend wins. ### Related Topics - [[Brainteaser](../../tag/brainteaser/README.md)] [[Math](../../tag/math/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] [[Game Theory](../../tag/game-theory/README.md)] ### Similar Questions diff --git a/problems/non-negative-integers-without-consecutive-ones/README.md b/problems/non-negative-integers-without-consecutive-ones/README.md index 5d571fa2b..f91c56fd0 100644 --- a/problems/non-negative-integers-without-consecutive-ones/README.md +++ b/problems/non-negative-integers-without-consecutive-ones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-index-sum-of-two-lists "Minimum Index Sum of Two Lists") diff --git a/problems/not-boring-movies/README.md b/problems/not-boring-movies/README.md index b778ac53b..98c86a8bc 100644 --- a/problems/not-boring-movies/README.md +++ b/problems/not-boring-movies/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../biggest-single-number "Biggest Single Number") diff --git a/problems/nth-digit/README.md b/problems/nth-digit/README.md index 2edcbf0c7..b2130eefe 100644 --- a/problems/nth-digit/README.md +++ b/problems/nth-digit/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../evaluate-division "Evaluate Division") diff --git a/problems/nth-magical-number/README.md b/problems/nth-magical-number/README.md index c7aaf6b59..841e0934d 100644 --- a/problems/nth-magical-number/README.md +++ b/problems/nth-magical-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game "Stone Game") diff --git a/problems/number-complement/README.md b/problems/number-complement/README.md index fab5c3486..63dd7a66c 100644 --- a/problems/number-complement/README.md +++ b/problems/number-complement/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../heaters "Heaters") diff --git a/problems/number-of-accounts-that-did-not-stream/README.md b/problems/number-of-accounts-that-did-not-stream/README.md index 6b45c40b6..d386e55a8 100644 --- a/problems/number-of-accounts-that-did-not-stream/README.md +++ b/problems/number-of-accounts-that-did-not-stream/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-score-of-students-solving-math-expression "The Score of Students Solving Math Expression") diff --git a/problems/number-of-boomerangs/README.md b/problems/number-of-boomerangs/README.md index 09da47c42..236720226 100644 --- a/problems/number-of-boomerangs/README.md +++ b/problems/number-of-boomerangs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../arithmetic-slices-ii-subsequence "Arithmetic Slices II - Subsequence") diff --git a/problems/number-of-calls-between-two-persons/README.md b/problems/number-of-calls-between-two-persons/README.md index 431f2c375..341c37f73 100644 --- a/problems/number-of-calls-between-two-persons/README.md +++ b/problems/number-of-calls-between-two-persons/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-distinct-substrings-in-a-string "Number of Distinct Substrings in a String") diff --git a/problems/number-of-closed-islands/README.md b/problems/number-of-closed-islands/README.md index 01c2cafea..1c2c4e1ee 100644 --- a/problems/number-of-closed-islands/README.md +++ b/problems/number-of-closed-islands/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reconstruct-a-2-row-binary-matrix "Reconstruct a 2-Row Binary Matrix") @@ -57,10 +57,10 @@ Islands in gray are closed because they are completely surrounded by water (grou ### 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)] ### Hints diff --git a/problems/number-of-comments-per-post/README.md b/problems/number-of-comments-per-post/README.md index f1c436468..b190512bd 100644 --- a/problems/number-of-comments-per-post/README.md +++ b/problems/number-of-comments-per-post/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tiling-a-rectangle-with-the-fewest-squares "Tiling a Rectangle with the Fewest Squares") diff --git a/problems/number-of-days-between-two-dates/README.md b/problems/number-of-days-between-two-dates/README.md index ade5f0f63..6f1fd8d63 100644 --- a/problems/number-of-days-between-two-dates/README.md +++ b/problems/number-of-days-between-two-dates/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-all-valid-pickup-and-delivery-options "Count All Valid Pickup and Delivery Options") diff --git a/problems/number-of-days-in-a-month/README.md b/problems/number-of-days-in-a-month/README.md index 467a2fab1..217dbebec 100644 --- a/problems/number-of-days-in-a-month/README.md +++ b/problems/number-of-days-in-a-month/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../building-h2o "Building H2O") 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 046d5f13e..8ef9457d8 100644 --- a/problems/number-of-dice-rolls-with-target-sum/README.md +++ b/problems/number-of-dice-rolls-with-target-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../day-of-the-year "Day of the Year") @@ -73,10 +73,6 @@ The answer must be returned modulo 10^9 + 7. ### 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-different-integers-in-a-string/README.md b/problems/number-of-different-integers-in-a-string/README.md index ef92569f3..0da225fa1 100644 --- a/problems/number-of-different-integers-in-a-string/README.md +++ b/problems/number-of-different-integers-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../implement-trie-ii-prefix-tree "Implement Trie II (Prefix Tree)") diff --git a/problems/number-of-different-subsequences-gcds/README.md b/problems/number-of-different-subsequences-gcds/README.md index e2b2407fc..3665c4ac0 100644 --- a/problems/number-of-different-subsequences-gcds/README.md +++ b/problems/number-of-different-subsequences-gcds/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-absolute-sum-difference "Minimum Absolute Sum Difference") 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 ed9bc0d15..cbf499178 100644 --- a/problems/number-of-distinct-substrings-in-a-string/README.md +++ b/problems/number-of-distinct-substrings-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../checking-existence-of-edge-length-limited-paths "Checking Existence of Edge Length Limited Paths") diff --git a/problems/number-of-equal-count-substrings/README.md b/problems/number-of-equal-count-substrings/README.md index 66252ff68..1b65042c0 100644 --- a/problems/number-of-equal-count-substrings/README.md +++ b/problems/number-of-equal-count-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../account-balance "Account Balance") diff --git a/problems/number-of-equivalent-domino-pairs/README.md b/problems/number-of-equivalent-domino-pairs/README.md index 0b18a70ad..188b4d506 100644 --- a/problems/number-of-equivalent-domino-pairs/README.md +++ b/problems/number-of-equivalent-domino-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../user-purchase-platform "User Purchase Platform") diff --git a/problems/number-of-good-leaf-nodes-pairs/README.md b/problems/number-of-good-leaf-nodes-pairs/README.md index 36b330f20..b7b4d21c1 100644 --- a/problems/number-of-good-leaf-nodes-pairs/README.md +++ b/problems/number-of-good-leaf-nodes-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bulb-switcher-iv "Bulb Switcher IV") diff --git a/problems/number-of-good-pairs/README.md b/problems/number-of-good-pairs/README.md index 13e548070..f7631e3ce 100644 --- a/problems/number-of-good-pairs/README.md +++ b/problems/number-of-good-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../customer-order-frequency "Customer Order Frequency") @@ -55,6 +55,7 @@ ### Similar Questions 1. [Number of Pairs of Interchangeable Rectangles](../number-of-pairs-of-interchangeable-rectangles) (Medium) + 1. [Substrings That Begin and End With the Same Letter](../substrings-that-begin-and-end-with-the-same-letter) (Medium) ### Hints
    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 3fe28aa73..93f58f1d9 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-sub-arrays-with-odd-sum "Number of Sub-arrays With Odd Sum") diff --git a/problems/number-of-islands/README.md b/problems/number-of-islands/README.md index 4b45db33a..f0a9b1b79 100644 --- a/problems/number-of-islands/README.md +++ b/problems/number-of-islands/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-right-side-view "Binary Tree Right Side View") diff --git a/problems/number-of-longest-increasing-subsequence/README.md b/problems/number-of-longest-increasing-subsequence/README.md index cb26b44e1..9baaae016 100644 --- a/problems/number-of-longest-increasing-subsequence/README.md +++ b/problems/number-of-longest-increasing-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bulb-switcher-ii "Bulb Switcher II") 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 b689df9f5..633560907 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../water-bottles "Water Bottles") diff --git a/problems/number-of-orders-in-the-backlog/README.md b/problems/number-of-orders-in-the-backlog/README.md index 3a917b5d9..dcfcdfae9 100644 --- a/problems/number-of-orders-in-the-backlog/README.md +++ b/problems/number-of-orders-in-the-backlog/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-ascending-subarray-sum "Maximum Ascending Subarray Sum") diff --git a/problems/number-of-pairs-of-interchangeable-rectangles/README.md b/problems/number-of-pairs-of-interchangeable-rectangles/README.md index ec9f4bd47..c03ce8bca 100644 --- a/problems/number-of-pairs-of-interchangeable-rectangles/README.md +++ b/problems/number-of-pairs-of-interchangeable-rectangles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-prefix-of-word "Reverse Prefix of Word") diff --git a/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/README.md b/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/README.md index 994bb5e99..07acd4a01 100644 --- a/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/README.md +++ b/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-1d-array-into-2d-array "Convert 1D Array Into 2D Array") diff --git a/problems/number-of-paths-with-max-score/README.md b/problems/number-of-paths-with-max-score/README.md index b18be23d3..773e71630 100644 --- a/problems/number-of-paths-with-max-score/README.md +++ b/problems/number-of-paths-with-max-score/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-mutated-array-closest-to-target "Sum of Mutated Array Closest to Target") diff --git a/problems/number-of-recent-calls/README.md b/problems/number-of-recent-calls/README.md index 5725fbc5e..d961559a0 100644 --- a/problems/number-of-recent-calls/README.md +++ b/problems/number-of-recent-calls/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../beautiful-array "Beautiful Array") diff --git a/problems/number-of-rectangles-that-can-form-the-largest-square/README.md b/problems/number-of-rectangles-that-can-form-the-largest-square/README.md index f478cd3a1..4e1dbdfa1 100644 --- a/problems/number-of-rectangles-that-can-form-the-largest-square/README.md +++ b/problems/number-of-rectangles-that-can-form-the-largest-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../checking-existence-of-edge-length-limited-paths-ii "Checking Existence of Edge Length Limited Paths II") diff --git a/problems/number-of-restricted-paths-from-first-to-last-node/README.md b/problems/number-of-restricted-paths-from-first-to-last-node/README.md index decd9b210..991d1a7a2 100644 --- a/problems/number-of-restricted-paths-from-first-to-last-node/README.md +++ b/problems/number-of-restricted-paths-from-first-to-last-node/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-elements-to-add-to-form-a-given-sum "Minimum Elements to Add to Form a Given Sum") @@ -54,11 +54,11 @@ ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    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 449b22cf6..693b07e4d 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../coordinate-with-maximum-network-quality "Coordinate With Maximum Network Quality") diff --git a/problems/number-of-ships-in-a-rectangle/README.md b/problems/number-of-ships-in-a-rectangle/README.md index 887639986..754422647 100644 --- a/problems/number-of-ships-in-a-rectangle/README.md +++ b/problems/number-of-ships-in-a-rectangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-tree-nodes "Delete Tree Nodes") diff --git a/problems/number-of-spaces-cleaning-robot-cleaned/README.md b/problems/number-of-spaces-cleaning-robot-cleaned/README.md index 7773d1791..f9fed2877 100644 --- a/problems/number-of-spaces-cleaning-robot-cleaned/README.md +++ b/problems/number-of-spaces-cleaning-robot-cleaned/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-an-original-string-exists-given-two-encoded-strings "Check if an Original String Exists Given Two Encoded Strings") diff --git a/problems/number-of-squareful-arrays/README.md b/problems/number-of-squareful-arrays/README.md index 862424300..bfd6778ee 100644 --- a/problems/number-of-squareful-arrays/README.md +++ b/problems/number-of-squareful-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-k-consecutive-bit-flips "Minimum Number of K Consecutive Bit Flips") @@ -42,11 +42,11 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/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/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 02d544edb..089c252a9 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-subsequence-in-non-increasing-order "Minimum Subsequence in Non-Increasing Order") 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 ea8c7d76e..ac1dab90c 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../movie-rating "Movie Rating") @@ -57,8 +57,8 @@ Step 4) 1 is odd; subtract 1 and obtain 0. ### Related Topics - [[Math](../../tag/math/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/number-of-strings-that-appear-as-substrings-in-word/README.md b/problems/number-of-strings-that-appear-as-substrings-in-word/README.md index 9715e0190..f5aec31f7 100644 --- a/problems/number-of-strings-that-appear-as-substrings-in-word/README.md +++ b/problems/number-of-strings-that-appear-as-substrings-in-word/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-searchable-numbers-in-an-unsorted-array "Binary Searchable Numbers in an Unsorted Array") 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 bf8575ed0..0251d8e4b 100644 --- a/problems/number-of-students-unable-to-eat-lunch/README.md +++ b/problems/number-of-students-unable-to-eat-lunch/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-calls-between-two-persons "Number of Calls Between Two Persons") @@ -60,14 +60,11 @@ 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 0f6665efe..4eead3055 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-steps-to-reduce-a-number-to-zero "Number of Steps to Reduce a Number to Zero") 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 71d637e99..cbb19a8a7 100644 --- a/problems/number-of-sub-arrays-with-odd-sum/README.md +++ b/problems/number-of-sub-arrays-with-odd-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-odd-numbers-in-an-interval-range "Count Odd Numbers in an Interval Range") diff --git a/problems/number-of-subarrays-with-bounded-maximum/README.md b/problems/number-of-subarrays-with-bounded-maximum/README.md index 24d460568..80823a666 100644 --- a/problems/number-of-subarrays-with-bounded-maximum/README.md +++ b/problems/number-of-subarrays-with-bounded-maximum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-tic-tac-toe-state "Valid Tic-Tac-Toe State") diff --git a/problems/number-of-substrings-with-only-1s/README.md b/problems/number-of-substrings-with-only-1s/README.md index 3d3b4c739..ac9643cdb 100644 --- a/problems/number-of-substrings-with-only-1s/README.md +++ b/problems/number-of-substrings-with-only-1s/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-good-pairs "Number of Good Pairs") @@ -59,10 +59,6 @@ [[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 8c57e66d2..423f88ca9 100644 --- a/problems/number-of-transactions-per-visit/README.md +++ b/problems/number-of-transactions-per-visit/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-difficulty-of-a-job-schedule "Minimum Difficulty of a Job Schedule") diff --git a/problems/number-of-trusted-contacts-of-a-customer/README.md b/problems/number-of-trusted-contacts-of-a-customer/README.md index 301d149f1..fc43743ce 100644 --- a/problems/number-of-trusted-contacts-of-a-customer/README.md +++ b/problems/number-of-trusted-contacts-of-a-customer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-multiple-of-three "Largest Multiple of Three") diff --git a/problems/number-of-unique-good-subsequences/README.md b/problems/number-of-unique-good-subsequences/README.md index a0aa82c51..7a678c170 100644 --- a/problems/number-of-unique-good-subsequences/README.md +++ b/problems/number-of-unique-good-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-work-sessions-to-finish-the-tasks "Minimum Number of Work Sessions to Finish the Tasks") 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 f4e33082d..dfb94f7e2 100644 --- a/problems/number-of-valid-move-combinations-on-chessboard/README.md +++ b/problems/number-of-valid-move-combinations-on-chessboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../plates-between-candles "Plates Between Candles") 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 9a884bf5c..624517eb4 100644 --- a/problems/number-of-valid-words-in-a-sentence/README.md +++ b/problems/number-of-valid-words-in-a-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-linked-list-already-sorted-using-absolute-values "Sort Linked List Already Sorted Using Absolute Values") diff --git a/problems/number-of-visible-people-in-a-queue/README.md b/problems/number-of-visible-people-in-a-queue/README.md index 03512d8cf..0cf9c4819 100644 --- a/problems/number-of-visible-people-in-a-queue/README.md +++ b/problems/number-of-visible-people-in-a-queue/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../describe-the-painting "Describe the Painting") diff --git a/problems/number-of-ways-of-cutting-a-pizza/README.md b/problems/number-of-ways-of-cutting-a-pizza/README.md index 7b9e1d165..67d6c62c9 100644 --- a/problems/number-of-ways-of-cutting-a-pizza/README.md +++ b/problems/number-of-ways-of-cutting-a-pizza/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-to-collect-all-apples-in-a-tree "Minimum Time to Collect All Apples in a Tree") @@ -54,9 +54,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)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/number-of-ways-to-arrive-at-destination/README.md b/problems/number-of-ways-to-arrive-at-destination/README.md index 0c6c974cf..84295ec95 100644 --- a/problems/number-of-ways-to-arrive-at-destination/README.md +++ b/problems/number-of-ways-to-arrive-at-destination/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-matrix-sum "Maximum Matrix Sum") 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 10c784b2b..209ae1f48 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-substrings-that-differ-by-one-character "Count Substrings That Differ by One Character") 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 0db030cab..5b1198fdb 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../html-entity-parser "HTML Entity Parser") diff --git a/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md b/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md index 4baf6cb24..d107b5fdd 100644 --- a/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md +++ b/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../finding-pairs-with-a-certain-sum "Finding Pairs With a Certain Sum") diff --git a/problems/number-of-ways-to-reconstruct-a-tree/README.md b/problems/number-of-ways-to-reconstruct-a-tree/README.md index 6596cef38..11533af4f 100644 --- a/problems/number-of-ways-to-reconstruct-a-tree/README.md +++ b/problems/number-of-ways-to-reconstruct-a-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-the-lexicographically-largest-valid-sequence "Construct the Lexicographically Largest Valid Sequence") 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 b6ad2d6f1..b6a36b36a 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-days-to-disconnect-island "Minimum Number of Days to Disconnect Island") diff --git a/problems/number-of-ways-to-separate-numbers/README.md b/problems/number-of-ways-to-separate-numbers/README.md index 350a57bf5..f305dec5b 100644 --- a/problems/number-of-ways-to-separate-numbers/README.md +++ b/problems/number-of-ways-to-separate-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-arrive-at-destination "Number of Ways to Arrive at Destination") 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 5d6b30520..cfdbf11da 100644 --- a/problems/number-of-ways-to-split-a-string/README.md +++ b/problems/number-of-ways-to-split-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../matrix-diagonal-sum "Matrix Diagonal Sum") diff --git a/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md b/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md index 2c012417f..5dfd4cae6 100644 --- a/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md +++ b/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../search-suggestions-system "Search Suggestions System") 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 5a33eb775..4a9a83b5e 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-all-s-to-avoid-consecutive-repeating-characters "Replace All ?'s to Avoid Consecutive Repeating Characters") diff --git a/problems/number-of-wonderful-substrings/README.md b/problems/number-of-wonderful-substrings/README.md index ec22793d8..0c236f651 100644 --- a/problems/number-of-wonderful-substrings/README.md +++ b/problems/number-of-wonderful-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cyclically-rotating-a-grid "Cyclically Rotating a Grid") diff --git a/problems/numbers-with-same-consecutive-differences/README.md b/problems/numbers-with-same-consecutive-differences/README.md index 0b47b74d0..b13d65569 100644 --- a/problems/numbers-with-same-consecutive-differences/README.md +++ b/problems/numbers-with-same-consecutive-differences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../vowel-spellchecker "Vowel Spellchecker") diff --git a/problems/odd-even-linked-list/README.md b/problems/odd-even-linked-list/README.md index ddd2c354e..febedeac1 100644 --- a/problems/odd-even-linked-list/README.md +++ b/problems/odd-even-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-of-range-sum "Count of Range Sum") diff --git a/problems/one-edit-distance/README.md b/problems/one-edit-distance/README.md index 8dff8f8f8..abc01c622 100644 --- a/problems/one-edit-distance/README.md +++ b/problems/one-edit-distance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../intersection-of-two-linked-lists "Intersection of Two Linked Lists") diff --git a/problems/online-majority-element-in-subarray/README.md b/problems/online-majority-element-in-subarray/README.md index bd81dbbcf..5dd0844bb 100644 --- a/problems/online-majority-element-in-subarray/README.md +++ b/problems/online-majority-element-in-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../swap-for-longest-repeated-character-substring "Swap For Longest Repeated Character Substring") diff --git a/problems/online-stock-span/README.md b/problems/online-stock-span/README.md index dd85693dc..169db46d1 100644 --- a/problems/online-stock-span/README.md +++ b/problems/online-stock-span/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rle-iterator "RLE Iterator") diff --git a/problems/operations-on-tree/README.md b/problems/operations-on-tree/README.md index 500941e2a..e249614a9 100644 --- a/problems/operations-on-tree/README.md +++ b/problems/operations-on-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-all-groups-of-farmland "Find All Groups of Farmland") diff --git a/problems/optimal-division/README.md b/problems/optimal-division/README.md index 7b4611e58..b24028aef 100644 --- a/problems/optimal-division/README.md +++ b/problems/optimal-division/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../student-attendance-record-ii "Student Attendance Record II") diff --git a/problems/optimize-water-distribution-in-a-village/README.md b/problems/optimize-water-distribution-in-a-village/README.md index f946b9978..29b3a78bd 100644 --- a/problems/optimize-water-distribution-in-a-village/README.md +++ b/problems/optimize-water-distribution-in-a-village/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-connect-sticks "Minimum Cost to Connect Sticks") diff --git a/problems/orders-with-maximum-quantity-above-average/README.md b/problems/orders-with-maximum-quantity-above-average/README.md index fcef76c7e..063bde62f 100644 --- a/problems/orders-with-maximum-quantity-above-average/README.md +++ b/problems/orders-with-maximum-quantity-above-average/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-rearrange-sticks-with-k-sticks-visible "Number of Ways to Rearrange Sticks With K Sticks Visible") diff --git a/problems/out-of-boundary-paths/README.md b/problems/out-of-boundary-paths/README.md index 72d8d9cc6..d870983f9 100644 --- a/problems/out-of-boundary-paths/README.md +++ b/problems/out-of-boundary-paths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distribute-candies "Distribute Candies") diff --git a/problems/output-contest-matches/README.md b/problems/output-contest-matches/README.md index a0e9342e8..d2ed16eb9 100644 --- a/problems/output-contest-matches/README.md +++ b/problems/output-contest-matches/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../diameter-of-binary-tree "Diameter of Binary Tree") @@ -56,6 +56,6 @@ Since the third round will generate the final winner, you need to output the ans

    ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] + [[Recursion](../../tag/recursion/README.md)] [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/pacific-atlantic-water-flow/README.md b/problems/pacific-atlantic-water-flow/README.md index 207dcce39..7e8c05bc0 100644 --- a/problems/pacific-atlantic-water-flow/README.md +++ b/problems/pacific-atlantic-water-flow/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-equal-subset-sum "Partition Equal Subset Sum") @@ -45,7 +45,7 @@ ### 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)] diff --git a/problems/page-recommendations-ii/README.md b/problems/page-recommendations-ii/README.md index 42de505c3..3e21532ec 100644 --- a/problems/page-recommendations-ii/README.md +++ b/problems/page-recommendations-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cutting-ribbons "Cutting Ribbons") diff --git a/problems/page-recommendations/README.md b/problems/page-recommendations/README.md index b4d9206b7..3faa1073c 100644 --- a/problems/page-recommendations/README.md +++ b/problems/page-recommendations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-moves-to-move-a-box-to-their-target-location "Minimum Moves to Move a Box to Their Target Location") diff --git a/problems/paint-house-ii/README.md b/problems/paint-house-ii/README.md index 5b98e6c02..79c853a1c 100644 --- a/problems/paint-house-ii/README.md +++ b/problems/paint-house-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ugly-number-ii "Ugly Number II") diff --git a/problems/paint-house/README.md b/problems/paint-house/README.md index e1249385d..4c8b8ad64 100644 --- a/problems/paint-house/README.md +++ b/problems/paint-house/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../verify-preorder-sequence-in-binary-search-tree "Verify Preorder Sequence in Binary Search Tree") diff --git a/problems/painting-a-grid-with-three-different-colors/README.md b/problems/painting-a-grid-with-three-different-colors/README.md index ad44f8278..381805838 100644 --- a/problems/painting-a-grid-with-three-different-colors/README.md +++ b/problems/painting-a-grid-with-three-different-colors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-length-3-palindromic-subsequences "Unique Length-3 Palindromic Subsequences") diff --git a/problems/palindrome-pairs/README.md b/problems/palindrome-pairs/README.md index 797531cba..7c370230a 100644 --- a/problems/palindrome-pairs/README.md +++ b/problems/palindrome-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../self-crossing "Self Crossing") @@ -47,10 +47,10 @@ ### Related Topics - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Trie](../../tag/trie/README.md)] ### Similar Questions 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) diff --git a/problems/palindrome-partitioning-iii/README.md b/problems/palindrome-partitioning-iii/README.md index 9838d87d8..b54eb04ff 100644 --- a/problems/palindrome-partitioning-iii/README.md +++ b/problems/palindrome-partitioning-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-square-submatrices-with-all-ones "Count Square Submatrices with All Ones") @@ -55,9 +55,6 @@ [[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-partitioning-iv/README.md b/problems/palindrome-partitioning-iv/README.md index e5baddac7..360b484e8 100644 --- a/problems/palindrome-partitioning-iv/README.md +++ b/problems/palindrome-partitioning-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../can-you-eat-your-favorite-candy-on-your-favorite-day "Can You Eat Your Favorite Candy on Your Favorite Day?") diff --git a/problems/palindrome-permutation/README.md b/problems/palindrome-permutation/README.md index 18ecea9e5..26442c494 100644 --- a/problems/palindrome-permutation/README.md +++ b/problems/palindrome-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../paint-house-ii "Paint House II") @@ -29,9 +29,9 @@ Output: true ### 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)] ### Similar Questions 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) diff --git a/problems/palindromic-substrings/README.md b/problems/palindromic-substrings/README.md index 7d549d549..878a0a02e 100644 --- a/problems/palindromic-substrings/README.md +++ b/problems/palindromic-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-length-of-pair-chain "Maximum Length of Pair Chain") diff --git a/problems/parallel-courses-iii/README.md b/problems/parallel-courses-iii/README.md index cfb2028ca..ca6fddca5 100644 --- a/problems/parallel-courses-iii/README.md +++ b/problems/parallel-courses-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-nodes-with-the-highest-score "Count Nodes With the Highest Score") diff --git a/problems/parallel-courses/README.md b/problems/parallel-courses/README.md index 98fde90aa..ce0d249ab 100644 --- a/problems/parallel-courses/README.md +++ b/problems/parallel-courses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../connecting-cities-with-minimum-cost "Connecting Cities With Minimum Cost") diff --git a/problems/parsing-a-boolean-expression/README.md b/problems/parsing-a-boolean-expression/README.md index 540f3d48f..9ab927c3f 100644 --- a/problems/parsing-a-boolean-expression/README.md +++ b/problems/parsing-a-boolean-expression/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../filling-bookcase-shelves "Filling Bookcase Shelves") @@ -62,9 +62,9 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Recursion](../../tag/recursion/README.md)] - [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/partition-array-into-disjoint-intervals/README.md b/problems/partition-array-into-disjoint-intervals/README.md index 38534622d..5a1693ed6 100644 --- a/problems/partition-array-into-disjoint-intervals/README.md +++ b/problems/partition-array-into-disjoint-intervals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../x-of-a-kind-in-a-deck-of-cards "X of a Kind in a Deck of Cards") @@ -51,3 +51,6 @@ ### Related Topics [[Array](../../tag/array/README.md)] + +### Similar Questions + 1. [Sum of Beauty in the Array](../sum-of-beauty-in-the-array) (Medium) diff --git a/problems/partition-array-into-three-parts-with-equal-sum/README.md b/problems/partition-array-into-three-parts-with-equal-sum/README.md index 9a728e44c..2acd962bb 100644 --- a/problems/partition-array-into-three-parts-with-equal-sum/README.md +++ b/problems/partition-array-into-three-parts-with-equal-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../numbers-with-repeated-digits "Numbers With Repeated Digits") diff --git a/problems/partition-array-into-two-arrays-to-minimize-sum-difference/README.md b/problems/partition-array-into-two-arrays-to-minimize-sum-difference/README.md index 9eb4c208e..2869b4b0e 100644 --- a/problems/partition-array-into-two-arrays-to-minimize-sum-difference/README.md +++ b/problems/partition-array-into-two-arrays-to-minimize-sum-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stock-price-fluctuation "Stock Price Fluctuation ") diff --git a/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md b/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md index 382809959..3b62f1968 100644 --- a/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md +++ b/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-of-matches-in-tournament "Count of Matches in Tournament") @@ -48,8 +48,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/pascals-triangle/README.md b/problems/pascals-triangle/README.md index bab942839..26b59095c 100644 --- a/problems/pascals-triangle/README.md +++ b/problems/pascals-triangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../populating-next-right-pointers-in-each-node-ii "Populating Next Right Pointers in Each Node II") diff --git a/problems/path-crossing/README.md b/problems/path-crossing/README.md index 7ad9cf22a..5c59e8448 100644 --- a/problems/path-crossing/README.md +++ b/problems/path-crossing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../friendly-movies-streamed-last-month "Friendly Movies Streamed Last Month") diff --git a/problems/path-in-zigzag-labelled-binary-tree/README.md b/problems/path-in-zigzag-labelled-binary-tree/README.md index 30164fa54..32eb5c01b 100644 --- a/problems/path-in-zigzag-labelled-binary-tree/README.md +++ b/problems/path-in-zigzag-labelled-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distribute-candies-to-people "Distribute Candies to People") @@ -42,8 +42,8 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] [[Math](../../tag/math/README.md)] + [[Tree](../../tag/tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/path-sum-iv/README.md b/problems/path-sum-iv/README.md index a1d262920..d0052c494 100644 --- a/problems/path-sum-iv/README.md +++ b/problems/path-sum-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../non-decreasing-array "Non-decreasing Array") @@ -56,9 +56,9 @@ The path sum is (3 + 1) = 4.

     

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Array](../../tag/array/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/path-with-maximum-gold/README.md b/problems/path-with-maximum-gold/README.md index b21af4df4..7b86e75cc 100644 --- a/problems/path-with-maximum-gold/README.md +++ b/problems/path-with-maximum-gold/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-arithmetic-subsequence-of-given-difference "Longest Arithmetic Subsequence of Given Difference") diff --git a/problems/path-with-maximum-minimum-value/README.md b/problems/path-with-maximum-minimum-value/README.md index ff4461a28..023f25b3f 100644 --- a/problems/path-with-maximum-minimum-value/README.md +++ b/problems/path-with-maximum-minimum-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-earliest-moment-when-everyone-become-friends "The Earliest Moment When Everyone Become Friends") @@ -56,15 +56,12 @@ The path with the maximum score is highlighted in yellow. ### 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)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] - -### Similar Questions - 1. [Path With Minimum Effort](../path-with-minimum-effort) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/path-with-maximum-probability/README.md b/problems/path-with-maximum-probability/README.md index ba83dc8d4..8a74476a7 100644 --- a/problems/path-with-maximum-probability/README.md +++ b/problems/path-with-maximum-probability/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-substrings-with-only-1s "Number of Substrings With Only 1s") @@ -63,8 +63,11 @@ ### Related Topics [[Graph](../../tag/graph/README.md)] - [[Shortest Path](../../tag/shortest-path/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + +### Similar Questions + 1. [Number of Ways to Arrive at Destination](../number-of-ways-to-arrive-at-destination) (Medium) ### Hints
    diff --git a/problems/path-with-minimum-effort/README.md b/problems/path-with-minimum-effort/README.md index 87fb8141a..b964c1049 100644 --- a/problems/path-with-minimum-effort/README.md +++ b/problems/path-with-minimum-effort/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../arithmetic-subarrays "Arithmetic Subarrays") diff --git a/problems/paths-in-maze-that-lead-to-same-room/README.md b/problems/paths-in-maze-that-lead-to-same-room/README.md new file mode 100644 index 000000000..40ea18453 --- /dev/null +++ b/problems/paths-in-maze-that-lead-to-same-room/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../process-restricted-friend-requests "Process Restricted Friend Requests") +                 +[Next >](../two-furthest-houses-with-different-colors "Two Furthest Houses With Different Colors") + +## [2077. Paths in Maze That Lead to Same Room (Medium)](https://leetcode.com/problems/paths-in-maze-that-lead-to-same-room "") + + + +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +If the path starts at room i, what properties must the other two rooms in the cycle have? +
    + +
    +Hint 2 +The other two rooms must be connected to room i, and must be connected to each other. +
    diff --git a/problems/patients-with-a-condition/README.md b/problems/patients-with-a-condition/README.md index 12471e948..27a1f5cd3 100644 --- a/problems/patients-with-a-condition/README.md +++ b/problems/patients-with-a-condition/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-increments-on-subarrays-to-form-a-target-array "Minimum Number of Increments on Subarrays to Form a Target Array") diff --git a/problems/peeking-iterator/README.md b/problems/peeking-iterator/README.md index 760699b87..c922a69d3 100644 --- a/problems/peeking-iterator/README.md +++ b/problems/peeking-iterator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../move-zeroes "Move Zeroes") @@ -11,17 +11,19 @@ ## [284. Peeking Iterator (Medium)](https://leetcode.com/problems/peeking-iterator "窥探迭代器") -

    Design an iterator that supports the peek operation on a list in addition to the hasNext and the next operations.

    +

    Design an iterator that supports the peek operation on an existing iterator in addition to the hasNext and the next operations.

    Implement the PeekingIterator class:

      -
    • PeekingIterator(int[] nums) Initializes the object with the given integer array nums.
    • +
    • PeekingIterator(Iterator<int> nums) Initializes the object with the given integer iterator iterator.
    • int next() Returns the next element in the array and moves the pointer to the next element.
    • -
    • bool hasNext() Returns true if there are still elements in the array.
    • +
    • boolean hasNext() Returns true if there are still elements in the array.
    • int peek() Returns the next element in the array without moving the pointer.
    +

    Note: Each language may have a different implementation of the constructor and Iterator, but they all support the int next() and boolean hasNext() functions.

    +

     

    Example 1:

    @@ -55,8 +57,8 @@ peekingIterator.hasNext(); // return False Follow up: How would you extend your design to be generic and work with all types, not just integer? ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Design](../../tag/design/README.md)] [[Iterator](../../tag/iterator/README.md)] ### Similar Questions diff --git a/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md b/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md index 86fdbf260..7c32ea78e 100644 --- a/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md +++ b/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rearrange-words-in-a-sentence "Rearrange Words in a Sentence") diff --git a/problems/percentage-of-users-attended-a-contest/README.md b/problems/percentage-of-users-attended-a-contest/README.md index 9afe97740..7773dffab 100644 --- a/problems/percentage-of-users-attended-a-contest/README.md +++ b/problems/percentage-of-users-attended-a-contest/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rank-transform-of-a-matrix "Rank Transform of a Matrix") @@ -15,6 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Queries Quality and Percentage](../queries-quality-and-percentage) (Easy) diff --git a/problems/perfect-rectangle/README.md b/problems/perfect-rectangle/README.md index 7967cfa49..8949f5f14 100644 --- a/problems/perfect-rectangle/README.md +++ b/problems/perfect-rectangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../elimination-game "Elimination Game") diff --git a/problems/perfect-squares/README.md b/problems/perfect-squares/README.md index f7a0cdd4b..75653ae8d 100644 --- a/problems/perfect-squares/README.md +++ b/problems/perfect-squares/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../first-bad-version "First Bad Version") diff --git a/problems/perform-string-shifts/README.md b/problems/perform-string-shifts/README.md index 87f73a5e4..b9c87caf9 100644 --- a/problems/perform-string-shifts/README.md +++ b/problems/perform-string-shifts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../counting-elements "Counting Elements") diff --git a/problems/permutation-in-string/README.md b/problems/permutation-in-string/README.md index a928de1f4..04f2c828a 100644 --- a/problems/permutation-in-string/README.md +++ b/problems/permutation-in-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reshape-the-matrix "Reshape the Matrix") diff --git a/problems/permutations-ii/README.md b/problems/permutations-ii/README.md index e4d819dcf..ec4163911 100644 --- a/problems/permutations-ii/README.md +++ b/problems/permutations-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../permutations "Permutations") diff --git a/problems/plates-between-candles/README.md b/problems/plates-between-candles/README.md index 1c6f57624..ae2f893fb 100644 --- a/problems/plates-between-candles/README.md +++ b/problems/plates-between-candles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-best-non-overlapping-events "Two Best Non-Overlapping Events") diff --git a/problems/power-of-four/README.md b/problems/power-of-four/README.md index 715bce265..925cd1c2b 100644 --- a/problems/power-of-four/README.md +++ b/problems/power-of-four/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flatten-nested-list-iterator "Flatten Nested List Iterator") @@ -37,9 +37,9 @@ Follow up: Could you solve it without loops/recursion? ### Related Topics - [[Math](../../tag/math/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Power of Two](../power-of-two) (Easy) diff --git a/problems/power-of-two/README.md b/problems/power-of-two/README.md index ad4c61126..8967dc809 100644 --- a/problems/power-of-two/README.md +++ b/problems/power-of-two/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-smallest-element-in-a-bst "Kth Smallest Element in a BST") @@ -64,9 +64,9 @@ Follow up: Could you solve it without loops/recursion? ### Related Topics - [[Math](../../tag/math/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/powx-n/README.md b/problems/powx-n/README.md index 8e1765ef7..b16dbab50 100644 --- a/problems/powx-n/README.md +++ b/problems/powx-n/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../group-anagrams "Group Anagrams") @@ -46,8 +46,8 @@ ### Related Topics - [[Math](../../tag/math/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Sqrt(x)](../sqrtx) (Easy) diff --git a/problems/previous-permutation-with-one-swap/README.md b/problems/previous-permutation-with-one-swap/README.md index 1f1162653..34691ac25 100644 --- a/problems/previous-permutation-with-one-swap/README.md +++ b/problems/previous-permutation-with-one-swap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../grumpy-bookstore-owner "Grumpy Bookstore Owner") diff --git a/problems/primary-department-for-each-employee/README.md b/problems/primary-department-for-each-employee/README.md index 0d304e075..cbceac426 100644 --- a/problems/primary-department-for-each-employee/README.md +++ b/problems/primary-department-for-each-employee/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-the-beauty-of-the-garden "Maximize the Beauty of the Garden") diff --git a/problems/print-binary-tree/README.md b/problems/print-binary-tree/README.md index 76ac13314..1cc4050d4 100644 --- a/problems/print-binary-tree/README.md +++ b/problems/print-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-binary-tree "Maximum Binary Tree") diff --git a/problems/print-immutable-linked-list-in-reverse/README.md b/problems/print-immutable-linked-list-in-reverse/README.md index dce74d494..28cd9038f 100644 --- a/problems/print-immutable-linked-list-in-reverse/README.md +++ b/problems/print-immutable-linked-list-in-reverse/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../page-recommendations "Page Recommendations") @@ -51,7 +51,7 @@ Constraints: - The value of each node in the linked list is between [-1000, 1000]. ### Related Topics - [[Stack](../../tag/stack/README.md)] - [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/print-words-vertically/README.md b/problems/print-words-vertically/README.md index 9a5204cdf..76e308fc7 100644 --- a/problems/print-words-vertically/README.md +++ b/problems/print-words-vertically/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-69-number "Maximum 69 Number") diff --git a/problems/print-zero-even-odd/README.md b/problems/print-zero-even-odd/README.md index 69bd1ec94..e053c905b 100644 --- a/problems/print-zero-even-odd/README.md +++ b/problems/print-zero-even-odd/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../print-foobar-alternately "Print FooBar Alternately") 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 fd3525ed7..40e16a1df 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reorder-routes-to-make-all-paths-lead-to-the-city-zero "Reorder Routes to Make All Paths Lead to the City Zero") @@ -11,13 +11,13 @@ ## [1467. Probability of a Two Boxes Having The Same Number of Distinct Balls (Hard)](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中球的颜色数相同的概率") -

    Given 2n balls of k distinct colors. You will be given an integer array balls of size k where balls[i] is the number of balls of color i

    +

    Given 2n balls of k distinct colors. You will be given an integer array balls of size k where balls[i] is the number of balls of color i.

    -

    All the balls will be shuffled uniformly at random, then we will distribute the first n balls to the first box and the remaining n balls to the other box (Please read the explanation of the second example carefully).

    +

    All the balls will be shuffled uniformly at random, then we will distribute the first n balls to the first box and the remaining n balls to the other box (Please read the explanation of the second example carefully).

    -

    Please note that the two boxes are considered different. For example, if we have two balls of colors a and b, and two boxes [] and (), then the distribution [a] (b) is considered different than the distribution [b] (a) (Please read the explanation of the first example carefully).

    +

    Please note that the two boxes are considered different. For example, if we have two balls of colors a and b, and two boxes [] and (), then the distribution [a] (b) is considered different than the distribution [b] (a) (Please read the explanation of the first example carefully).

    -

    We want to calculate the probability that the two boxes have the same number of distinct balls.

    +

    Return the probability that the two boxes have the same number of distinct balls. Answers within 10-5 of the actual value will be accepted as correct.

     

    Example 1:

    @@ -37,9 +37,9 @@ In both ways, the number of distinct colors in each box is equal. The probabilit Input: balls = [2,1,1] Output: 0.66667 Explanation: We have the set of balls [1, 1, 2, 3] -This set of balls will be shuffled randomly and we may have one of the 12 distinct shuffles with equale probability (i.e. 1/12): +This set of balls will be shuffled randomly and we may have one of the 12 distinct shuffles with equal probability (i.e. 1/12): [1,1 / 2,3], [1,1 / 3,2], [1,2 / 1,3], [1,2 / 3,1], [1,3 / 1,2], [1,3 / 2,1], [2,1 / 1,3], [2,1 / 3,1], [2,3 / 1,1], [3,1 / 1,2], [3,1 / 2,1], [3,2 / 1,1] -After that we add the first two balls to the first box and the second two balls to the second box. +After that, we add the first two balls to the first box and the second two balls to the second box. We can see that 8 of these 12 possible random distributions have the same number of distinct colors of balls in each box. Probability is 8/12 = 0.66667 @@ -76,7 +76,6 @@ Probability = 18 / 60 = 0.3
  • 1 <= balls.length <= 8
  • 1 <= balls[i] <= 6
  • sum(balls) is even.
  • -
  • Answers within 10^-5 of the actual value will be accepted as correct.
  • ### Related Topics diff --git a/problems/process-restricted-friend-requests/README.md b/problems/process-restricted-friend-requests/README.md index d2d91d28e..cd6c67d9f 100644 --- a/problems/process-restricted-friend-requests/README.md +++ b/problems/process-restricted-friend-requests/README.md @@ -1,13 +1,13 @@ - - - + + + [< Previous](../decode-the-slanted-ciphertext "Decode the Slanted Ciphertext")                  -Next > +[Next >](../paths-in-maze-that-lead-to-same-room "Paths in Maze That Lead to Same Room") ## [2076. Process Restricted Friend Requests (Hard)](https://leetcode.com/problems/process-restricted-friend-requests "处理含限制条件的好友请求") @@ -71,6 +71,10 @@ Request 3: Person 3 and person 4 cannot be friends since person 0 and person 1 w
  • uj != vj
  • +### Related Topics + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] + ### Hints
    Hint 1 diff --git a/problems/process-tasks-using-servers/README.md b/problems/process-tasks-using-servers/README.md index 5bd75a390..d2523efe7 100644 --- a/problems/process-tasks-using-servers/README.md +++ b/problems/process-tasks-using-servers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-value-after-insertion "Maximum Value after Insertion") diff --git a/problems/product-of-the-last-k-numbers/README.md b/problems/product-of-the-last-k-numbers/README.md index 045f7f54c..f09bf9ba2 100644 --- a/problems/product-of-the-last-k-numbers/README.md +++ b/problems/product-of-the-last-k-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-negative-numbers-in-a-sorted-matrix "Count Negative Numbers in a Sorted Matrix") @@ -59,10 +59,10 @@ productOfNumbers.getProduct(2); // return 32. The product of the last 2 numbers ### Related Topics - [[Array](../../tag/array/README.md)] - [[Math](../../tag/math/README.md)] [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Data Stream](../../tag/data-stream/README.md)] ### Hints diff --git a/problems/product-of-two-run-length-encoded-arrays/README.md b/problems/product-of-two-run-length-encoded-arrays/README.md index 9968ca9dd..60b12f2ad 100644 --- a/problems/product-of-two-run-length-encoded-arrays/README.md +++ b/problems/product-of-two-run-length-encoded-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../orders-with-maximum-quantity-above-average "Orders With Maximum Quantity Above Average") diff --git a/problems/product-price-at-a-given-date/README.md b/problems/product-price-at-a-given-date/README.md index baaa94e77..3a1cd5645 100644 --- a/problems/product-price-at-a-given-date/README.md +++ b/problems/product-price-at-a-given-date/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../last-substring-in-lexicographical-order "Last Substring in Lexicographical Order") diff --git a/problems/products-price-for-each-store/README.md b/problems/products-price-for-each-store/README.md index c71de0528..5d46b038f 100644 --- a/problems/products-price-for-each-store/README.md +++ b/problems/products-price-for-each-store/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../car-fleet-ii "Car Fleet II") diff --git a/problems/products-worth-over-invoices/README.md b/problems/products-worth-over-invoices/README.md index 1524ab49b..a73a4de86 100644 --- a/problems/products-worth-over-invoices/README.md +++ b/problems/products-worth-over-invoices/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-a-binary-tree-iv "Lowest Common Ancestor of a Binary Tree IV") diff --git a/problems/profitable-schemes/README.md b/problems/profitable-schemes/README.md index 5573231e3..f5e1c053b 100644 --- a/problems/profitable-schemes/README.md +++ b/problems/profitable-schemes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nth-magical-number "Nth Magical Number") diff --git a/problems/project-employees-i/README.md b/problems/project-employees-i/README.md index 55a182751..663cffab8 100644 --- a/problems/project-employees-i/README.md +++ b/problems/project-employees-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-submatrices-that-sum-to-target "Number of Submatrices That Sum to Target") @@ -77,3 +77,6 @@ The average experience years for the first project is (3 + 2 + 1) / 3 = 2.00 and ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Project Employees II](../project-employees-ii) (Easy) diff --git a/problems/project-employees-ii/README.md b/problems/project-employees-ii/README.md index 219af6dd1..bc5178900 100644 --- a/problems/project-employees-ii/README.md +++ b/problems/project-employees-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../project-employees-i "Project Employees I") diff --git a/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md b/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md index 074c5ea1c..80f6d4723 100644 --- a/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md +++ b/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-vowels-in-a-substring-of-given-length "Maximum Number of Vowels in a Substring of Given Length") diff --git a/problems/push-dominoes/README.md b/problems/push-dominoes/README.md index c4d6ee456..2d7a28c6f 100644 --- a/problems/push-dominoes/README.md +++ b/problems/push-dominoes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../new-21-game "New 21 Game") diff --git a/problems/put-boxes-into-the-warehouse-i/README.md b/problems/put-boxes-into-the-warehouse-i/README.md index 58ec067a0..a1d6f02d4 100644 --- a/problems/put-boxes-into-the-warehouse-i/README.md +++ b/problems/put-boxes-into-the-warehouse-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-v "Stone Game V") @@ -14,13 +14,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Put Boxes Into the Warehouse II](../put-boxes-into-the-warehouse-ii) (Medium) - ### Hints
    Hint 1 diff --git a/problems/put-boxes-into-the-warehouse-ii/README.md b/problems/put-boxes-into-the-warehouse-ii/README.md index ace8988c8..e6089dd71 100644 --- a/problems/put-boxes-into-the-warehouse-ii/README.md +++ b/problems/put-boxes-into-the-warehouse-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-max-number-of-edges-to-keep-graph-fully-traversable "Remove Max Number of Edges to Keep Graph Fully Traversable") @@ -14,13 +14,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/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/queens-that-can-attack-the-king/README.md b/problems/queens-that-can-attack-the-king/README.md index bb2c5afe0..9c4914988 100644 --- a/problems/queens-that-can-attack-the-king/README.md +++ b/problems/queens-that-can-attack-the-king/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-a-string-in-balanced-strings "Split a String in Balanced Strings") diff --git a/problems/queries-on-number-of-points-inside-a-circle/README.md b/problems/queries-on-number-of-points-inside-a-circle/README.md index ccef067ca..1ab1e0aab 100644 --- a/problems/queries-on-number-of-points-inside-a-circle/README.md +++ b/problems/queries-on-number-of-points-inside-a-circle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-operations-to-make-the-array-increasing "Minimum Operations to Make the Array Increasing") diff --git a/problems/queries-quality-and-percentage/README.md b/problems/queries-quality-and-percentage/README.md index 95eef1138..36250d98d 100644 --- a/problems/queries-quality-and-percentage/README.md +++ b/problems/queries-quality-and-percentage/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-moves-to-reach-target-with-rotations "Minimum Moves to Reach Target with Rotations") diff --git a/problems/queue-reconstruction-by-height/README.md b/problems/queue-reconstruction-by-height/README.md index e06f59238..2378a7f52 100644 --- a/problems/queue-reconstruction-by-height/README.md +++ b/problems/queue-reconstruction-by-height/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-a-number-to-hexadecimal "Convert a Number to Hexadecimal") @@ -49,8 +49,8 @@ Hence [[5,0],[7,0],[5,2],[6,1],[4,4],[7,1]] is the reconstructed queue. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/random-flip-matrix/README.md b/problems/random-flip-matrix/README.md index b743724f9..6af8b4746 100644 --- a/problems/random-flip-matrix/README.md +++ b/problems/random-flip-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../coin-change-2 "Coin Change 2") @@ -52,7 +52,7 @@ solution.flip(); // return [2, 0], [0,0], [1,0], and [2,0] should be equally li ### 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)] diff --git a/problems/random-point-in-non-overlapping-rectangles/README.md b/problems/random-point-in-non-overlapping-rectangles/README.md index bd9165205..3e58d9e56 100644 --- a/problems/random-point-in-non-overlapping-rectangles/README.md +++ b/problems/random-point-in-non-overlapping-rectangles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../next-greater-element-i "Next Greater Element I") diff --git a/problems/range-addition-ii/README.md b/problems/range-addition-ii/README.md index 957bdcd7f..8ed1babe6 100644 --- a/problems/range-addition-ii/README.md +++ b/problems/range-addition-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../friend-requests-i-overall-acceptance-rate "Friend Requests I: Overall Acceptance Rate") diff --git a/problems/range-addition/README.md b/problems/range-addition/README.md index 6c5eb4f18..595b65b0a 100644 --- a/problems/range-addition/README.md +++ b/problems/range-addition/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../plus-one-linked-list "Plus One Linked List") diff --git a/problems/range-frequency-queries/README.md b/problems/range-frequency-queries/README.md new file mode 100644 index 000000000..01668228f --- /dev/null +++ b/problems/range-frequency-queries/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../watering-plants "Watering Plants") +                 +[Next >](../sum-of-k-mirror-numbers "Sum of k-Mirror Numbers") + +## [2080. Range Frequency Queries (Medium)](https://leetcode.com/problems/range-frequency-queries "区间内查询数字的频率") + +

    Design a data structure to find the frequency of a given value in a given subarray.

    + +

    The frequency of a value in a subarray is the number of occurrences of that value in the subarray.

    + +

    Implement the RangeFreqQuery class:

    + +
      +
    • RangeFreqQuery(int[] arr) Constructs an instance of the class with the given 0-indexed integer array arr.
    • +
    • int query(int left, int right, int value) Returns the frequency of value in the subarray arr[left...right].
    • +
    + +

    A subarray is a contiguous sequence of elements within an array. arr[left...right] denotes the subarray that contains the elements of nums between indices left and right (inclusive).

    + +

     

    +

    Example 1:

    + +
    +Input
    +["RangeFreqQuery", "query", "query"]
    +[[[12, 33, 4, 56, 22, 2, 34, 33, 22, 12, 34, 56]], [1, 2, 4], [0, 11, 33]]
    +Output
    +[null, 1, 2]
    +
    +Explanation
    +RangeFreqQuery rangeFreqQuery = new RangeFreqQuery([12, 33, 4, 56, 22, 2, 34, 33, 22, 12, 34, 56]);
    +rangeFreqQuery.query(1, 2, 4); // return 1. The value 4 occurs 1 time in the subarray [33, 4]
    +rangeFreqQuery.query(0, 11, 33); // return 2. The value 33 occurs 2 times in the whole array.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 105
    • +
    • 1 <= arr[i], value <= 104
    • +
    • 0 <= left <= right < arr.length
    • +
    • At most 105 calls will be made to query
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +The queries must be answered efficiently to avoid time limit exceeded verdict. +
    + +
    +Hint 2 +Store the elements of the array in a data structure that helps answering the queries efficiently. +
    + +
    +Hint 3 +Use a hash table that stored for each value, the indices where that value appeared. +
    + +
    +Hint 4 +Use binary search over the indices of a value to find its range frequency. +
    diff --git a/problems/range-module/README.md b/problems/range-module/README.md index bbe8355dc..f4f13ff58 100644 --- a/problems/range-module/README.md +++ b/problems/range-module/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-time-to-buy-and-sell-stock-with-transaction-fee "Best Time to Buy and Sell Stock with Transaction Fee") diff --git a/problems/range-sum-of-bst/README.md b/problems/range-sum-of-bst/README.md index 0f677dbe8..db95e3008 100644 --- a/problems/range-sum-of-bst/README.md +++ b/problems/range-sum-of-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reorder-data-in-log-files "Reorder Data in Log Files") diff --git a/problems/range-sum-of-sorted-subarray-sums/README.md b/problems/range-sum-of-sorted-subarray-sums/README.md index cb299d5ef..6cc505677 100644 --- a/problems/range-sum-of-sorted-subarray-sums/README.md +++ b/problems/range-sum-of-sorted-subarray-sums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reformat-date "Reformat Date") diff --git a/problems/range-sum-query-immutable/README.md b/problems/range-sum-query-immutable/README.md index db9ae983d..450493ab6 100644 --- a/problems/range-sum-query-immutable/README.md +++ b/problems/range-sum-query-immutable/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-rectangle-enclosing-black-pixels "Smallest Rectangle Enclosing Black Pixels") @@ -52,8 +52,8 @@ numArray.sumRange(0, 5); // return (-2) + 0 + 3 + (-5) + 2 + (-1) = -3 ### Related Topics - [[Array](../../tag/array/README.md)] [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions diff --git a/problems/rank-teams-by-votes/README.md b/problems/rank-teams-by-votes/README.md index 1a25fb7a8..5c2dc2e62 100644 --- a/problems/rank-teams-by-votes/README.md +++ b/problems/rank-teams-by-votes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../how-many-numbers-are-smaller-than-the-current-number "How Many Numbers Are Smaller Than the Current Number") diff --git a/problems/rank-transform-of-a-matrix/README.md b/problems/rank-transform-of-a-matrix/README.md index bd173f55f..836561c15 100644 --- a/problems/rank-transform-of-a-matrix/README.md +++ b/problems/rank-transform-of-a-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-with-minimum-effort "Path With Minimum Effort") @@ -74,17 +74,13 @@ The rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] -### Similar Questions - 1. [Rank Transform of an Array](../rank-transform-of-an-array) (Easy) - 1. [GCD Sort of an Array](../gcd-sort-of-an-array) (Hard) - ### Hints
    Hint 1 diff --git a/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md b/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md index 77d25516f..4ceaafb65 100644 --- a/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md +++ b/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../read-n-characters-given-read4 "Read N Characters Given Read4") diff --git a/problems/rearrange-products-table/README.md b/problems/rearrange-products-table/README.md index 32103d604..834046e1b 100644 --- a/problems/rearrange-products-table/README.md +++ b/problems/rearrange-products-table/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-pairs-of-equal-substrings-with-minimum-difference "Count Pairs of Equal Substrings With Minimum Difference") @@ -15,6 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Product's Price for Each Store](../products-price-for-each-store) (Easy) diff --git a/problems/rearrange-spaces-between-words/README.md b/problems/rearrange-spaces-between-words/README.md index 4e8a32046..bd77b2d6f 100644 --- a/problems/rearrange-spaces-between-words/README.md +++ b/problems/rearrange-spaces-between-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strange-printer-ii "Strange Printer II") @@ -67,9 +67,6 @@ ### Related Topics [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Text Justification](../text-justification) (Hard) - ### Hints
    Hint 1 diff --git a/problems/reconstruct-a-2-row-binary-matrix/README.md b/problems/reconstruct-a-2-row-binary-matrix/README.md index 06655f5a4..99fabdd1a 100644 --- a/problems/reconstruct-a-2-row-binary-matrix/README.md +++ b/problems/reconstruct-a-2-row-binary-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cells-with-odd-values-in-a-matrix "Cells with Odd Values in a Matrix") @@ -61,10 +61,13 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Find Valid Matrix Given Row and Column Sums](../find-valid-matrix-given-row-and-column-sums) (Medium) + ### Hints
    Hint 1 diff --git a/problems/reconstruct-itinerary/README.md b/problems/reconstruct-itinerary/README.md index 39017661d..02269425d 100644 --- a/problems/reconstruct-itinerary/README.md +++ b/problems/reconstruct-itinerary/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../verify-preorder-serialization-of-a-binary-tree "Verify Preorder Serialization of a Binary Tree")                  [Next >](../largest-bst-subtree "Largest BST Subtree") -## [332. Reconstruct Itinerary (Medium)](https://leetcode.com/problems/reconstruct-itinerary "重新安排行程") +## [332. Reconstruct Itinerary (Hard)](https://leetcode.com/problems/reconstruct-itinerary "重新安排行程")

    You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it.

    @@ -53,3 +53,6 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Eulerian Circuit](../../tag/eulerian-circuit/README.md)] + +### Similar Questions + 1. [Longest Common Subpath](../longest-common-subpath) (Hard) diff --git a/problems/reconstruct-original-digits-from-english/README.md b/problems/reconstruct-original-digits-from-english/README.md index 84bd5fed4..b2233eee7 100644 --- a/problems/reconstruct-original-digits-from-english/README.md +++ b/problems/reconstruct-original-digits-from-english/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-word-square "Valid Word Square") diff --git a/problems/rectangle-area/README.md b/problems/rectangle-area/README.md index fb0602d4b..1aad627f3 100644 --- a/problems/rectangle-area/README.md +++ b/problems/rectangle-area/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-complete-tree-nodes "Count Complete Tree Nodes") @@ -40,8 +40,8 @@ ### Related Topics - [[Math](../../tag/math/README.md)] [[Geometry](../../tag/geometry/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Rectangle Overlap](../rectangle-overlap) (Easy) diff --git a/problems/recyclable-and-low-fat-products/README.md b/problems/recyclable-and-low-fat-products/README.md index ed3399698..1bb3bbf66 100644 --- a/problems/recyclable-and-low-fat-products/README.md +++ b/problems/recyclable-and-low-fat-products/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-most-recently-used-queue "Design Most Recently Used Queue") diff --git a/problems/redistribute-characters-to-make-all-strings-equal/README.md b/problems/redistribute-characters-to-make-all-strings-equal/README.md index 2534847db..267df957b 100644 --- a/problems/redistribute-characters-to-make-all-strings-equal/README.md +++ b/problems/redistribute-characters-to-make-all-strings-equal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-change-the-final-value-of-expression "Minimum Cost to Change the Final Value of Expression") diff --git a/problems/reduce-array-size-to-the-half/README.md b/problems/reduce-array-size-to-the-half/README.md index 9bd2bdd1e..3667f864d 100644 --- a/problems/reduce-array-size-to-the-half/README.md +++ b/problems/reduce-array-size-to-the-half/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-k-weakest-rows-in-a-matrix "The K Weakest Rows in a Matrix") diff --git a/problems/reducing-dishes/README.md b/problems/reducing-dishes/README.md index ce4c9a144..6e87b7e6c 100644 --- a/problems/reducing-dishes/README.md +++ b/problems/reducing-dishes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../circle-and-rectangle-overlapping "Circle and Rectangle Overlapping") diff --git a/problems/reduction-operations-to-make-the-array-elements-equal/README.md b/problems/reduction-operations-to-make-the-array-elements-equal/README.md index 033de883b..f165aae46 100644 --- a/problems/reduction-operations-to-make-the-array-elements-equal/README.md +++ b/problems/reduction-operations-to-make-the-array-elements-equal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../determine-whether-matrix-can-be-obtained-by-rotation "Determine Whether Matrix Can Be Obtained By Rotation") diff --git a/problems/reformat-date/README.md b/problems/reformat-date/README.md index 672285045..c75714512 100644 --- a/problems/reformat-date/README.md +++ b/problems/reformat-date/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-root-of-n-ary-tree "Find Root of N-Ary Tree") diff --git a/problems/reformat-department-table/README.md b/problems/reformat-department-table/README.md index 9c71adbca..22185b884 100644 --- a/problems/reformat-department-table/README.md +++ b/problems/reformat-department-table/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-valid-words-for-each-puzzle "Number of Valid Words for Each Puzzle") diff --git a/problems/reformat-phone-number/README.md b/problems/reformat-phone-number/README.md index 3efa683ad..0ee2dbf14 100644 --- a/problems/reformat-phone-number/README.md +++ b/problems/reformat-phone-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../daily-leads-and-partners "Daily Leads and Partners") diff --git a/problems/relative-ranks/README.md b/problems/relative-ranks/README.md index 15a17adc8..16519bc3b 100644 --- a/problems/relative-ranks/README.md +++ b/problems/relative-ranks/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-maze-ii "The Maze II") diff --git a/problems/remove-all-adjacent-duplicates-in-string/README.md b/problems/remove-all-adjacent-duplicates-in-string/README.md index 897bb8aad..47d5e9e54 100644 --- a/problems/remove-all-adjacent-duplicates-in-string/README.md +++ b/problems/remove-all-adjacent-duplicates-in-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../last-stone-weight "Last Stone Weight") diff --git a/problems/remove-all-occurrences-of-a-substring/README.md b/problems/remove-all-occurrences-of-a-substring/README.md index 107f284fc..f73fbe00d 100644 --- a/problems/remove-all-occurrences-of-a-substring/README.md +++ b/problems/remove-all-occurrences-of-a-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-one-element-to-make-the-array-strictly-increasing "Remove One Element to Make the Array Strictly Increasing") diff --git a/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/README.md b/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/README.md index e862d3493..c8b5cd729 100644 --- a/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/README.md +++ b/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-moves-to-seat-everyone "Minimum Number of Moves to Seat Everyone") diff --git a/problems/remove-covered-intervals/README.md b/problems/remove-covered-intervals/README.md index 8f1df2a61..b319a77a3 100644 --- a/problems/remove-covered-intervals/README.md +++ b/problems/remove-covered-intervals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../element-appearing-more-than-25-in-sorted-array "Element Appearing More Than 25% In Sorted Array") diff --git a/problems/remove-duplicate-letters/README.md b/problems/remove-duplicate-letters/README.md index d25ddda31..e61c74e31 100644 --- a/problems/remove-duplicate-letters/README.md +++ b/problems/remove-duplicate-letters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-of-smaller-numbers-after-self "Count of Smaller Numbers After Self") diff --git a/problems/remove-duplicates-from-an-unsorted-linked-list/README.md b/problems/remove-duplicates-from-an-unsorted-linked-list/README.md index 527659931..27ee4a822 100644 --- a/problems/remove-duplicates-from-an-unsorted-linked-list/README.md +++ b/problems/remove-duplicates-from-an-unsorted-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-xor-sum-of-all-pairs-bitwise-and "Find XOR Sum of All Pairs Bitwise AND") diff --git a/problems/remove-duplicates-from-sorted-array-ii/README.md b/problems/remove-duplicates-from-sorted-array-ii/README.md index 3a62a0ac8..8d14937d8 100644 --- a/problems/remove-duplicates-from-sorted-array-ii/README.md +++ b/problems/remove-duplicates-from-sorted-array-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-search "Word Search") diff --git a/problems/remove-duplicates-from-sorted-list-ii/README.md b/problems/remove-duplicates-from-sorted-list-ii/README.md index 5552c9248..fb75f2c4c 100644 --- a/problems/remove-duplicates-from-sorted-list-ii/README.md +++ b/problems/remove-duplicates-from-sorted-list-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../search-in-rotated-sorted-array-ii "Search in Rotated Sorted Array II") @@ -43,4 +43,3 @@ ### Similar Questions 1. [Remove Duplicates from Sorted List](../remove-duplicates-from-sorted-list) (Easy) - 1. [Remove Duplicates From an Unsorted Linked List](../remove-duplicates-from-an-unsorted-linked-list) (Medium) diff --git a/problems/remove-duplicates-from-sorted-list/README.md b/problems/remove-duplicates-from-sorted-list/README.md index 31a128b39..19e592c13 100644 --- a/problems/remove-duplicates-from-sorted-list/README.md +++ b/problems/remove-duplicates-from-sorted-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicates-from-sorted-list-ii "Remove Duplicates from Sorted List II") diff --git a/problems/remove-element/README.md b/problems/remove-element/README.md index bf7c534e0..6a3a4c92d 100644 --- a/problems/remove-element/README.md +++ b/problems/remove-element/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicates-from-sorted-array "Remove Duplicates from Sorted Array") diff --git a/problems/remove-invalid-parentheses/README.md b/problems/remove-invalid-parentheses/README.md index cf2197412..81d23cba2 100644 --- a/problems/remove-invalid-parentheses/README.md +++ b/problems/remove-invalid-parentheses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-increasing-subsequence "Longest Increasing Subsequence") diff --git a/problems/remove-k-digits/README.md b/problems/remove-k-digits/README.md index c382758d4..51f3dea55 100644 --- a/problems/remove-k-digits/README.md +++ b/problems/remove-k-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-watch "Binary Watch") 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 1b68f02c6..2073e3fc8 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters") 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 b10d2d94e..c8499e554 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../game-of-nim "Game of Nim") diff --git a/problems/remove-palindromic-subsequences/README.md b/problems/remove-palindromic-subsequences/README.md index 9b302fce5..9127113a0 100644 --- a/problems/remove-palindromic-subsequences/README.md +++ b/problems/remove-palindromic-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rank-transform-of-an-array "Rank Transform of an Array") diff --git a/problems/remove-stones-to-minimize-the-total/README.md b/problems/remove-stones-to-minimize-the-total/README.md index 41af10a76..64414e15e 100644 --- a/problems/remove-stones-to-minimize-the-total/README.md +++ b/problems/remove-stones-to-minimize-the-total/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-string-is-a-prefix-of-array "Check If String Is a Prefix of Array") diff --git a/problems/remove-sub-folders-from-the-filesystem/README.md b/problems/remove-sub-folders-from-the-filesystem/README.md index 01d6c85ed..18bd119aa 100644 --- a/problems/remove-sub-folders-from-the-filesystem/README.md +++ b/problems/remove-sub-folders-from-the-filesystem/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-it-is-a-straight-line "Check If It Is a Straight Line") @@ -11,11 +11,15 @@ ## [1233. Remove Sub-Folders from the Filesystem (Medium)](https://leetcode.com/problems/remove-sub-folders-from-the-filesystem "删除子文件夹") -

    Given a list of folders, remove all sub-folders in those folders and return in any order the folders after removing.

    +

    Given a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order.

    -

    If a folder[i] is located within another folder[j], it is called a sub-folder of it.

    +

    If a folder[i] is located within another folder[j], it is called a sub-folder of it.

    -

    The format of a path is one or more concatenated strings of the form: / followed by one or more lowercase English letters. For example, /leetcode and /leetcode/problems are valid paths while an empty string and / are not.

    +

    The format of a path is one or more concatenated strings of the form: '/' followed by one or more lowercase English letters.

    + +
      +
    • For example, "/leetcode" and "/leetcode/problems" are valid paths while an empty string and "/" are not.
    • +

     

    Example 1:

    @@ -45,11 +49,11 @@

    Constraints:

      -
    • 1 <= folder.length <= 4 * 10^4
    • +
    • 1 <= folder.length <= 4 * 104
    • 2 <= folder[i].length <= 100
    • -
    • folder[i] contains only lowercase letters and '/'
    • -
    • folder[i] always starts with character '/'
    • -
    • Each folder name is unique.
    • +
    • folder[i] contains only lowercase letters and '/'.
    • +
    • folder[i] always starts with the character '/'.
    • +
    • Each folder name is unique.
    ### Related Topics diff --git a/problems/remove-vowels-from-a-string/README.md b/problems/remove-vowels-from-a-string/README.md index ac8433ad8..35d9277c6 100644 --- a/problems/remove-vowels-from-a-string/README.md +++ b/problems/remove-vowels-from-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-days-in-a-month "Number of Days in a Month") 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 a3ee99f6e..239cd5e5b 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../compare-strings-by-frequency-of-the-smallest-character "Compare Strings by Frequency of the Smallest Character") @@ -52,9 +52,6 @@ [[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/reorganize-string/README.md b/problems/reorganize-string/README.md index 15bee45f9..dbc402d4e 100644 --- a/problems/reorganize-string/README.md +++ b/problems/reorganize-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../toeplitz-matrix "Toeplitz Matrix") diff --git a/problems/repeated-string-match/README.md b/problems/repeated-string-match/README.md index 8c8b15b2e..508494d61 100644 --- a/problems/repeated-string-match/README.md +++ b/problems/repeated-string-match/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../redundant-connection-ii "Redundant Connection II") diff --git a/problems/repeated-substring-pattern/README.md b/problems/repeated-substring-pattern/README.md index 0d1fe46bf..bbed9fa11 100644 --- a/problems/repeated-substring-pattern/README.md +++ b/problems/repeated-substring-pattern/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../poor-pigs "Poor Pigs") diff --git a/problems/replace-all-digits-with-characters/README.md b/problems/replace-all-digits-with-characters/README.md index 931c1dc3a..03ef8a3ed 100644 --- a/problems/replace-all-digits-with-characters/README.md +++ b/problems/replace-all-digits-with-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../suspicious-bank-accounts "Suspicious Bank Accounts") 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 26339c459..42bc3386d 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-all-possible-routes "Count All Possible Routes") diff --git a/problems/replace-elements-with-greatest-element-on-right-side/README.md b/problems/replace-elements-with-greatest-element-on-right-side/README.md index c8e5376fb..211f24d21 100644 --- a/problems/replace-elements-with-greatest-element-on-right-side/README.md +++ b/problems/replace-elements-with-greatest-element-on-right-side/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-candies-you-can-get-from-boxes "Maximum Candies You Can Get from Boxes") @@ -49,6 +49,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [Two Furthest Houses With Different Colors](../two-furthest-houses-with-different-colors) (Easy) + ### Hints
    Hint 1 diff --git a/problems/replace-employee-id-with-the-unique-identifier/README.md b/problems/replace-employee-id-with-the-unique-identifier/README.md index e1db601dd..ab56752eb 100644 --- a/problems/replace-employee-id-with-the-unique-identifier/README.md +++ b/problems/replace-employee-id-with-the-unique-identifier/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../frog-position-after-t-seconds "Frog Position After T Seconds") diff --git a/problems/replace-the-substring-for-balanced-string/README.md b/problems/replace-the-substring-for-balanced-string/README.md index 1697262d2..dd661d977 100644 --- a/problems/replace-the-substring-for-balanced-string/README.md +++ b/problems/replace-the-substring-for-balanced-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-sub-folders-from-the-filesystem "Remove Sub-Folders from the Filesystem") diff --git a/problems/replace-words/README.md b/problems/replace-words/README.md index 2b09cd90d..d8c027369 100644 --- a/problems/replace-words/README.md +++ b/problems/replace-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindromic-substrings "Palindromic Substrings") diff --git a/problems/report-contiguous-dates/README.md b/problems/report-contiguous-dates/README.md index 7eefc0968..8653cf4c4 100644 --- a/problems/report-contiguous-dates/README.md +++ b/problems/report-contiguous-dates/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-equal-frequency "Maximum Equal Frequency") @@ -88,3 +88,7 @@ From 2019-01-06 to 2019-01-06 all tasks succeeded and system state was "pre ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Find the Start and End Number of Continuous Ranges](../find-the-start-and-end-number-of-continuous-ranges) (Medium) + 1. [Find the Missing IDs](../find-the-missing-ids) (Medium) diff --git a/problems/reported-posts/README.md b/problems/reported-posts/README.md index 33a4f61ac..df69c7f59 100644 --- a/problems/reported-posts/README.md +++ b/problems/reported-posts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../highest-grade-for-each-student "Highest Grade For Each Student") diff --git a/problems/reshape-the-matrix/README.md b/problems/reshape-the-matrix/README.md index 391c47503..f453ed4fa 100644 --- a/problems/reshape-the-matrix/README.md +++ b/problems/reshape-the-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../array-nesting "Array Nesting") @@ -50,9 +50,6 @@ [[Matrix](../../tag/matrix/README.md)] [[Simulation](../../tag/simulation/README.md)] -### Similar Questions - 1. [Convert 1D Array Into 2D Array](../convert-1d-array-into-2d-array) (Easy) - ### Hints
    Hint 1 diff --git a/problems/restaurant-growth/README.md b/problems/restaurant-growth/README.md index dc5ce13bc..4375bf834 100644 --- a/problems/restaurant-growth/README.md +++ b/problems/restaurant-growth/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-distance-to-type-a-word-using-two-fingers "Minimum Distance to Type a Word Using Two Fingers") diff --git a/problems/restore-the-array-from-adjacent-pairs/README.md b/problems/restore-the-array-from-adjacent-pairs/README.md index 6e2e7ab50..8569f4741 100644 --- a/problems/restore-the-array-from-adjacent-pairs/README.md +++ b/problems/restore-the-array-from-adjacent-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-balls-in-a-box "Maximum Number of Balls in a Box") diff --git a/problems/reverse-nodes-in-even-length-groups/README.md b/problems/reverse-nodes-in-even-length-groups/README.md index 274f57c6f..1acbfaf3b 100644 --- a/problems/reverse-nodes-in-even-length-groups/README.md +++ b/problems/reverse-nodes-in-even-length-groups/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../time-needed-to-buy-tickets "Time Needed to Buy Tickets") diff --git a/problems/reverse-only-letters/README.md b/problems/reverse-only-letters/README.md index ee75bb83f..d614140f3 100644 --- a/problems/reverse-only-letters/README.md +++ b/problems/reverse-only-letters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-subsets "Word Subsets") diff --git a/problems/reverse-prefix-of-word/README.md b/problems/reverse-prefix-of-word/README.md index 0ac3b4e21..37f9b97e9 100644 --- a/problems/reverse-prefix-of-word/README.md +++ b/problems/reverse-prefix-of-word/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-greater-multiple-made-of-two-digits "Smallest Greater Multiple Made of Two Digits") diff --git a/problems/reverse-string-ii/README.md b/problems/reverse-string-ii/README.md index 4700b4759..0ae3f3651 100644 --- a/problems/reverse-string-ii/README.md +++ b/problems/reverse-string-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../single-element-in-a-sorted-array "Single Element in a Sorted Array") diff --git a/problems/reverse-string/README.md b/problems/reverse-string/README.md index cdbb71fcb..af5bd5a71 100644 --- a/problems/reverse-string/README.md +++ b/problems/reverse-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../integer-break "Integer Break") @@ -13,6 +13,8 @@

    Write a function that reverses a string. The input string is given as an array of characters s.

    +

    You must do this by modifying the input array in-place with O(1) extra memory.

    +

     

    Example 1:

    Input: s = ["h","e","l","l","o"]
    @@ -29,9 +31,6 @@
     	
  • s[i] is a printable ascii character.
  • -

     

    -

    Follow up: Do not allocate extra space for another array. You must do this by modifying the input array in-place with O(1) extra memory.

    - ### Related Topics [[Recursion](../../tag/recursion/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/reverse-subarray-to-maximize-array-value/README.md b/problems/reverse-subarray-to-maximize-array-value/README.md index f01437928..3ff6d629e 100644 --- a/problems/reverse-subarray-to-maximize-array-value/README.md +++ b/problems/reverse-subarray-to-maximize-array-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-the-matrix-diagonally "Sort the Matrix Diagonally") @@ -11,7 +11,7 @@ ## [1330. Reverse Subarray To Maximize Array Value (Hard)](https://leetcode.com/problems/reverse-subarray-to-maximize-array-value "翻转子数组得到最大的数组值") -

    You are given an integer array nums. The value of this array is defined as the sum of |nums[i]-nums[i+1]| for all 0 <= i < nums.length-1.

    +

    You are given an integer array nums. The value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1.

    You are allowed to select any subarray of the given array and reverse it. You can perform this operation only once.

    @@ -37,8 +37,8 @@

    Constraints:

      -
    • 1 <= nums.length <= 3*10^4
    • -
    • -10^5 <= nums[i] <= 10^5
    • +
    • 1 <= nums.length <= 3 * 104
    • +
    • -105 <= nums[i] <= 105
    ### Related Topics diff --git a/problems/reverse-substrings-between-each-pair-of-parentheses/README.md b/problems/reverse-substrings-between-each-pair-of-parentheses/README.md index 822cda347..b9b0748fe 100644 --- a/problems/reverse-substrings-between-each-pair-of-parentheses/README.md +++ b/problems/reverse-substrings-between-each-pair-of-parentheses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-balloons "Maximum Number of Balloons") @@ -58,8 +58,8 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] ### Hints
    diff --git a/problems/reverse-vowels-of-a-string/README.md b/problems/reverse-vowels-of-a-string/README.md index 415304e24..cdc3e5937 100644 --- a/problems/reverse-vowels-of-a-string/README.md +++ b/problems/reverse-vowels-of-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-string "Reverse String") diff --git a/problems/reverse-words-in-a-string-iii/README.md b/problems/reverse-words-in-a-string-iii/README.md index c0be62ca8..68b40c93c 100644 --- a/problems/reverse-words-in-a-string-iii/README.md +++ b/problems/reverse-words-in-a-string-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../next-greater-element-iii "Next Greater Element III") diff --git a/problems/richest-customer-wealth/README.md b/problems/richest-customer-wealth/README.md index 05169133b..b977f74c4 100644 --- a/problems/richest-customer-wealth/README.md +++ b/problems/richest-customer-wealth/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-removals-to-make-mountain-array "Minimum Number of Removals to Make Mountain Array") diff --git a/problems/rle-iterator/README.md b/problems/rle-iterator/README.md index 2a5a2eb27..2ebd53cc0 100644 --- a/problems/rle-iterator/README.md +++ b/problems/rle-iterator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../orderly-queue "Orderly Queue") diff --git a/problems/rotate-image/README.md b/problems/rotate-image/README.md index 5d95f313f..ad68bc8fe 100644 --- a/problems/rotate-image/README.md +++ b/problems/rotate-image/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../permutations-ii "Permutations II") @@ -58,6 +58,3 @@ [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Matrix](../../tag/matrix/README.md)] - -### Similar Questions - 1. [Determine Whether Matrix Can Be Obtained By Rotation](../determine-whether-matrix-can-be-obtained-by-rotation) (Easy) diff --git a/problems/rotating-the-box/README.md b/problems/rotating-the-box/README.md index 0d115c323..c7b5a2d59 100644 --- a/problems/rotating-the-box/README.md +++ b/problems/rotating-the-box/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../incremental-memory-leak "Incremental Memory Leak") diff --git a/problems/running-sum-of-1d-array/README.md b/problems/running-sum-of-1d-array/README.md index 14417c0f0..00ceb6f78 100644 --- a/problems/running-sum-of-1d-array/README.md +++ b/problems/running-sum-of-1d-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sales-by-day-of-the-week "Sales by Day of the Week") diff --git a/problems/running-total-for-different-genders/README.md b/problems/running-total-for-different-genders/README.md index cff1b7ccf..db8e732bc 100644 --- a/problems/running-total-for-different-genders/README.md +++ b/problems/running-total-for-different-genders/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../verbal-arithmetic-puzzle "Verbal Arithmetic Puzzle") diff --git a/problems/sales-analysis-i/README.md b/problems/sales-analysis-i/README.md index df00fb03c..7f9b0f947 100644 --- a/problems/sales-analysis-i/README.md +++ b/problems/sales-analysis-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-subsequence-of-distinct-characters "Smallest Subsequence of Distinct Characters") @@ -78,6 +78,3 @@ Both sellers with id 1 and 3 sold products with the most total price of 2800.

    - - - + + + [< Previous](../sales-analysis-i "Sales Analysis I") diff --git a/problems/sales-analysis-iii/README.md b/problems/sales-analysis-iii/README.md index d198a55f4..82d94eef2 100644 --- a/problems/sales-analysis-iii/README.md +++ b/problems/sales-analysis-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sales-analysis-ii "Sales Analysis II") diff --git a/problems/sales-person/README.md b/problems/sales-person/README.md index 85f7385bd..1c51029ea 100644 --- a/problems/sales-person/README.md +++ b/problems/sales-person/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-string-from-binary-tree "Construct String from Binary Tree") diff --git a/problems/sales-person/mysql_schemas.sql b/problems/sales-person/mysql_schemas.sql index 05b85ab4c..b583e9691 100644 --- a/problems/sales-person/mysql_schemas.sql +++ b/problems/sales-person/mysql_schemas.sql @@ -1,19 +1,19 @@ -Create table If Not Exists salesperson (sales_id int, name varchar(255), salary int,commission_rate int, hire_date varchar(255)); -Create table If Not Exists company (com_id int, name varchar(255), city varchar(255)); -Create table If Not Exists orders (order_id int, order_date varchar(255), com_id int, sales_id int, amount int); -Truncate table salesperson; -insert into salesperson (sales_id, name, salary, commission_rate, hire_date) values ('1', 'John', '100000', '6', '4/1/2006'); -insert into salesperson (sales_id, name, salary, commission_rate, hire_date) values ('2', 'Amy', '12000', '5', '5/1/2010'); -insert into salesperson (sales_id, name, salary, commission_rate, hire_date) values ('3', 'Mark', '65000', '12', '12/25/2008'); -insert into salesperson (sales_id, name, salary, commission_rate, hire_date) values ('4', 'Pam', '25000', '25', '1/1/2005'); -insert into salesperson (sales_id, name, salary, commission_rate, hire_date) values ('5', 'Alex', '5000', '10', '2/3/2007'); -Truncate table company; -insert into company (com_id, name, city) values ('1', 'RED', 'Boston'); -insert into company (com_id, name, city) values ('2', 'ORANGE', 'New York'); -insert into company (com_id, name, city) values ('3', 'YELLOW', 'Boston'); -insert into company (com_id, name, city) values ('4', 'GREEN', 'Austin'); -Truncate table orders; -insert into orders (order_id, order_date, com_id, sales_id, amount) values ('1', '1/1/2014', '3', '4', '10000'); -insert into orders (order_id, order_date, com_id, sales_id, amount) values ('2', '2/1/2014', '4', '5', '5000'); -insert into orders (order_id, order_date, com_id, sales_id, amount) values ('3', '3/1/2014', '1', '1', '50000'); -insert into orders (order_id, order_date, com_id, sales_id, amount) values ('4', '4/1/2014', '1', '4', '25000'); +Create table If Not Exists SalesPerson (sales_id int, name varchar(255), salary int, commission_rate int, hire_date date); +Create table If Not Exists Company (com_id int, name varchar(255), city varchar(255)); +Create table If Not Exists Orders (order_id int, order_date date, com_id int, sales_id int, amount int); +Truncate table SalesPerson; +insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('1', 'John', '100000', '6', '4/1/2006'); +insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('2', 'Amy', '12000', '5', '5/1/2010'); +insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('3', 'Mark', '65000', '12', '12/25/2008'); +insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('4', 'Pam', '25000', '25', '1/1/2005'); +insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('5', 'Alex', '5000', '10', '2/3/2007'); +Truncate table Company; +insert into Company (com_id, name, city) values ('1', 'RED', 'Boston'); +insert into Company (com_id, name, city) values ('2', 'ORANGE', 'New York'); +insert into Company (com_id, name, city) values ('3', 'YELLOW', 'Boston'); +insert into Company (com_id, name, city) values ('4', 'GREEN', 'Austin'); +Truncate table Orders; +insert into Orders (order_id, order_date, com_id, sales_id, amount) values ('1', '1/1/2014', '3', '4', '10000'); +insert into Orders (order_id, order_date, com_id, sales_id, amount) values ('2', '2/1/2014', '4', '5', '5000'); +insert into Orders (order_id, order_date, com_id, sales_id, amount) values ('3', '3/1/2014', '1', '1', '50000'); +insert into Orders (order_id, order_date, com_id, sales_id, amount) values ('4', '4/1/2014', '1', '4', '25000'); diff --git a/problems/score-after-flipping-matrix/README.md b/problems/score-after-flipping-matrix/README.md index 93e475da0..4fdce91e4 100644 --- a/problems/score-after-flipping-matrix/README.md +++ b/problems/score-after-flipping-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lemonade-change "Lemonade Change") diff --git a/problems/scramble-string/README.md b/problems/scramble-string/README.md index 0c661df9b..3dfafc5ac 100644 --- a/problems/scramble-string/README.md +++ b/problems/scramble-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-list "Partition List") diff --git a/problems/search-a-2d-matrix-ii/README.md b/problems/search-a-2d-matrix-ii/README.md index a0df5c561..ef44b3d7d 100644 --- a/problems/search-a-2d-matrix-ii/README.md +++ b/problems/search-a-2d-matrix-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sliding-window-maximum "Sliding Window Maximum") diff --git a/problems/search-in-rotated-sorted-array-ii/README.md b/problems/search-in-rotated-sorted-array-ii/README.md index 5e54861d2..8bf333932 100644 --- a/problems/search-in-rotated-sorted-array-ii/README.md +++ b/problems/search-in-rotated-sorted-array-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicates-from-sorted-array-ii "Remove Duplicates from Sorted Array II") diff --git a/problems/search-suggestions-system/README.md b/problems/search-suggestions-system/README.md index 6190a1717..e572da055 100644 --- a/problems/search-suggestions-system/README.md +++ b/problems/search-suggestions-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-servers-that-communicate "Count Servers that Communicate") @@ -66,9 +66,9 @@ After typing mou, mous and mouse the system suggests ["mouse","mo ### Related Topics - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Trie](../../tag/trie/README.md)] ### Hints
    diff --git a/problems/seat-reservation-manager/README.md b/problems/seat-reservation-manager/README.md index 44c1ac1ab..83f878644 100644 --- a/problems/seat-reservation-manager/README.md +++ b/problems/seat-reservation-manager/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-all-digits-with-characters "Replace All Digits with Characters") diff --git a/problems/second-degree-follower/README.md b/problems/second-degree-follower/README.md index 210dc64f2..da3878fbb 100644 --- a/problems/second-degree-follower/README.md +++ b/problems/second-degree-follower/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-distance-in-a-line "Shortest Distance in a Line") diff --git a/problems/second-degree-follower/mysql_schemas.sql b/problems/second-degree-follower/mysql_schemas.sql index 3f3df12bc..1dbb57626 100644 --- a/problems/second-degree-follower/mysql_schemas.sql +++ b/problems/second-degree-follower/mysql_schemas.sql @@ -1,6 +1,6 @@ -Create table If Not Exists follow (followee varchar(255), follower varchar(255)); -Truncate table follow; -insert into follow (followee, follower) values ('A', 'B'); -insert into follow (followee, follower) values ('B', 'C'); -insert into follow (followee, follower) values ('B', 'D'); -insert into follow (followee, follower) values ('D', 'E'); +Create table If Not Exists Follow (followee varchar(255), follower varchar(255)); +Truncate table Follow; +insert into Follow (followee, follower) values ('Alice', 'Bob'); +insert into Follow (followee, follower) values ('Bob', 'Cena'); +insert into Follow (followee, follower) values ('Bob', 'Donald'); +insert into Follow (followee, follower) values ('Donald', 'Edward'); diff --git a/problems/second-largest-digit-in-a-string/README.md b/problems/second-largest-digit-in-a-string/README.md index 458d94a57..e50360bbb 100644 --- a/problems/second-largest-digit-in-a-string/README.md +++ b/problems/second-largest-digit-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rearrange-products-table "Rearrange Products Table") diff --git a/problems/second-minimum-node-in-a-binary-tree/README.md b/problems/second-minimum-node-in-a-binary-tree/README.md index 7118b46e6..3dc88a88f 100644 --- a/problems/second-minimum-node-in-a-binary-tree/README.md +++ b/problems/second-minimum-node-in-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-swap "Maximum Swap") diff --git a/problems/second-minimum-time-to-reach-destination/README.md b/problems/second-minimum-time-to-reach-destination/README.md index 5fd12cc5b..b6cd23da1 100644 --- a/problems/second-minimum-time-to-reach-destination/README.md +++ b/problems/second-minimum-time-to-reach-destination/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-number-of-maximum-bitwise-or-subsets "Count Number of Maximum Bitwise-OR Subsets") diff --git a/problems/sell-diminishing-valued-colored-balls/README.md b/problems/sell-diminishing-valued-colored-balls/README.md index 0f152dc19..4f26b0d86 100644 --- a/problems/sell-diminishing-valued-colored-balls/README.md +++ b/problems/sell-diminishing-valued-colored-balls/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-deletions-to-make-character-frequencies-unique "Minimum Deletions to Make Character Frequencies Unique") @@ -63,10 +63,10 @@ The maximum total value is 3 + 2 + 5 + 4 + 3 + 2 = 19. ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/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/sellers-with-no-sales/README.md b/problems/sellers-with-no-sales/README.md index 965b59bb3..3d659cfa6 100644 --- a/problems/sellers-with-no-sales/README.md +++ b/problems/sellers-with-no-sales/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-servers-that-handled-most-number-of-requests "Find Servers That Handled Most Number of Requests") diff --git a/problems/sentence-similarity-iii/README.md b/problems/sentence-similarity-iii/README.md index 1adf040d6..02839ffad 100644 --- a/problems/sentence-similarity-iii/README.md +++ b/problems/sentence-similarity-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../determine-color-of-a-chessboard-square "Determine Color of a Chessboard Square") diff --git a/problems/sentence-similarity/README.md b/problems/sentence-similarity/README.md index 7daf23854..4c2e329ba 100644 --- a/problems/sentence-similarity/README.md +++ b/problems/sentence-similarity/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flood-fill "Flood Fill") diff --git a/problems/sequence-reconstruction/README.md b/problems/sequence-reconstruction/README.md index eb0ec0dc7..fab41cd33 100644 --- a/problems/sequence-reconstruction/README.md +++ b/problems/sequence-reconstruction/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../string-compression "String Compression") diff --git a/problems/sequential-digits/README.md b/problems/sequential-digits/README.md index 079552bd4..9dfeeb487 100644 --- a/problems/sequential-digits/README.md +++ b/problems/sequential-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-binary-number-in-a-linked-list-to-integer "Convert Binary Number in a Linked List to Integer") diff --git a/problems/serialize-and-deserialize-n-ary-tree/README.md b/problems/serialize-and-deserialize-n-ary-tree/README.md index a489aad6d..cacfe9ae5 100644 --- a/problems/serialize-and-deserialize-n-ary-tree/README.md +++ b/problems/serialize-and-deserialize-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-quad-tree "Construct Quad Tree") diff --git a/problems/set-mismatch/README.md b/problems/set-mismatch/README.md index 1186eb92f..4fd90d16f 100644 --- a/problems/set-mismatch/README.md +++ b/problems/set-mismatch/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-average-subarray-ii "Maximum Average Subarray II") diff --git a/problems/shifting-letters/README.md b/problems/shifting-letters/README.md index 443c20df6..8a9fdbb35 100644 --- a/problems/shifting-letters/README.md +++ b/problems/shifting-letters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-visiting-all-nodes "Shortest Path Visiting All Nodes") diff --git a/problems/shopping-offers/README.md b/problems/shopping-offers/README.md index 4eb605968..7203395b5 100644 --- a/problems/shopping-offers/README.md +++ b/problems/shopping-offers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-of-levels-in-binary-tree "Average of Levels in Binary Tree") diff --git a/problems/short-encoding-of-words/README.md b/problems/short-encoding-of-words/README.md index 533cd2c87..96b3b8a2a 100644 --- a/problems/short-encoding-of-words/README.md +++ b/problems/short-encoding-of-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../most-common-word "Most Common Word") diff --git a/problems/shortest-completing-word/README.md b/problems/shortest-completing-word/README.md index 11e367461..5501b8b5b 100644 --- a/problems/shortest-completing-word/README.md +++ b/problems/shortest-completing-word/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-number-at-least-twice-of-others "Largest Number At Least Twice of Others") diff --git a/problems/shortest-distance-in-a-line/README.md b/problems/shortest-distance-in-a-line/README.md index b26f0f20a..1d788e5d0 100644 --- a/problems/shortest-distance-in-a-line/README.md +++ b/problems/shortest-distance-in-a-line/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-distance-in-a-plane "Shortest Distance in a Plane") diff --git a/problems/shortest-distance-in-a-line/mysql_schemas.sql b/problems/shortest-distance-in-a-line/mysql_schemas.sql index 5c2505ad0..bef5a5599 100644 --- a/problems/shortest-distance-in-a-line/mysql_schemas.sql +++ b/problems/shortest-distance-in-a-line/mysql_schemas.sql @@ -1,5 +1,5 @@ -CREATE TABLE If Not Exists point (x INT NOT NULL, UNIQUE INDEX x_UNIQUE (x ASC)); -Truncate table point; -insert into point (x) values ('-1'); -insert into point (x) values ('0'); -insert into point (x) values ('2'); +Create Table If Not Exists Point (x int not null); +Truncate table Point; +insert into Point (x) values ('-1'); +insert into Point (x) values ('0'); +insert into Point (x) values ('2'); diff --git a/problems/shortest-distance-in-a-plane/README.md b/problems/shortest-distance-in-a-plane/README.md index 1c8e67ad1..3f758e57e 100644 --- a/problems/shortest-distance-in-a-plane/README.md +++ b/problems/shortest-distance-in-a-plane/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-triangle-number "Valid Triangle Number") diff --git a/problems/shortest-distance-in-a-plane/mysql_schemas.sql b/problems/shortest-distance-in-a-plane/mysql_schemas.sql index c66c065d4..fe36290c3 100644 --- a/problems/shortest-distance-in-a-plane/mysql_schemas.sql +++ b/problems/shortest-distance-in-a-plane/mysql_schemas.sql @@ -1,5 +1,5 @@ -CREATE TABLE If Not Exists point_2d (x INT NOT NULL, y INT NOT NULL); -Truncate table point_2d; -insert into point_2d (x, y) values ('-1', '-1'); -insert into point_2d (x, y) values ('0', '0'); -insert into point_2d (x, y) values ('-1', '-2'); +Create Table If Not Exists Point2D (x int not null, y int not null); +Truncate table Point2D; +insert into Point2D (x, y) values ('-1', '-1'); +insert into Point2D (x, y) values ('0', '0'); +insert into Point2D (x, y) values ('-1', '-2'); diff --git a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md index ece449fda..50024922b 100644 --- a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md +++ b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "Maximum Side Length of a Square with Sum Less than or Equal to Threshold") @@ -47,10 +47,13 @@ The shortest path with one obstacle elimination at position (3,2) is 6. Such pat ### 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. [Shortest Path to Get Food](../shortest-path-to-get-food) (Medium) + ### Hints
    Hint 1 diff --git a/problems/shortest-path-in-a-hidden-grid/README.md b/problems/shortest-path-in-a-hidden-grid/README.md index 499049657..9a8aae6c9 100644 --- a/problems/shortest-path-in-a-hidden-grid/README.md +++ b/problems/shortest-path-in-a-hidden-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../products-price-for-each-store "Product's Price for Each Store") diff --git a/problems/shortest-path-in-binary-matrix/README.md b/problems/shortest-path-in-binary-matrix/README.md index 45bb40cc7..2922b9f93 100644 --- a/problems/shortest-path-in-binary-matrix/README.md +++ b/problems/shortest-path-in-binary-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-values-from-labels "Largest Values From Labels") @@ -55,8 +55,8 @@ ### 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/shortest-path-to-get-all-keys/README.md b/problems/shortest-path-to-get-all-keys/README.md index a4447f698..8499f1d63 100644 --- a/problems/shortest-path-to-get-all-keys/README.md +++ b/problems/shortest-path-to-get-all-keys/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-nodes-distance-k-in-binary-tree "All Nodes Distance K in Binary Tree") diff --git a/problems/shortest-path-to-get-food/README.md b/problems/shortest-path-to-get-food/README.md index 602173318..1332ad811 100644 --- a/problems/shortest-path-to-get-food/README.md +++ b/problems/shortest-path-to-get-food/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-followers-count "Find Followers Count") diff --git a/problems/shortest-path-with-alternating-colors/README.md b/problems/shortest-path-with-alternating-colors/README.md index 3c2ac776e..4412b632c 100644 --- a/problems/shortest-path-with-alternating-colors/README.md +++ b/problems/shortest-path-with-alternating-colors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-equivalent-domino-pairs "Number of Equivalent Domino Pairs") 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 fac216680..0c1a1106f 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-split-a-string "Number of Ways to Split a String") @@ -11,11 +11,11 @@ ## [1574. Shortest Subarray to be Removed to Make Array Sorted (Medium)](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") -

    Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing.

    +

    Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing.

    -

    A subarray is a contiguous subsequence of the array.

    +

    Return the length of the shortest subarray to remove.

    -

    Return the length of the shortest subarray to remove.

    +

    A subarray is a contiguous subsequence of the array.

     

    Example 1:

    @@ -53,15 +53,15 @@ Another correct solution is to remove the subarray [3,10,4].

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • -
    • 0 <= arr[i] <= 10^9
    • +
    • 1 <= arr.length <= 105
    • +
    • 0 <= arr[i] <= 109
    ### 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-unsorted-continuous-subarray/README.md b/problems/shortest-unsorted-continuous-subarray/README.md index 0d387f824..4727ed77a 100644 --- a/problems/shortest-unsorted-continuous-subarray/README.md +++ b/problems/shortest-unsorted-continuous-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-student-number-in-departments "Count Student Number in Departments") diff --git a/problems/shortest-way-to-form-string/README.md b/problems/shortest-way-to-form-string/README.md index 6f660e72d..6a522ebee 100644 --- a/problems/shortest-way-to-form-string/README.md +++ b/problems/shortest-way-to-form-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distant-barcodes "Distant Barcodes") @@ -51,12 +51,13 @@ ### 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/shortest-word-distance/README.md b/problems/shortest-word-distance/README.md index 6748ea4e9..13002efde 100644 --- a/problems/shortest-word-distance/README.md +++ b/problems/shortest-word-distance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-anagram "Valid Anagram") diff --git a/problems/shuffle-string/README.md b/problems/shuffle-string/README.md index 197004674..83e038f81 100644 --- a/problems/shuffle-string/README.md +++ b/problems/shuffle-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../patients-with-a-condition "Patients With a Condition") diff --git a/problems/sign-of-the-product-of-an-array/README.md b/problems/sign-of-the-product-of-an-array/README.md index 6091454dd..2ce92356b 100644 --- a/problems/sign-of-the-product-of-an-array/README.md +++ b/problems/sign-of-the-product-of-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-customers-with-positive-revenue-this-year "Find Customers With Positive Revenue this Year") diff --git a/problems/similar-rgb-color/README.md b/problems/similar-rgb-color/README.md index 9c96687d1..da973a626 100644 --- a/problems/similar-rgb-color/README.md +++ b/problems/similar-rgb-color/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../champagne-tower "Champagne Tower") diff --git a/problems/simple-bank-system/README.md b/problems/simple-bank-system/README.md index 3d7d692e0..21519e1c9 100644 --- a/problems/simple-bank-system/README.md +++ b/problems/simple-bank-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-numbers-are-ascending-in-a-sentence "Check if Numbers Are Ascending in a Sentence") diff --git a/problems/simplified-fractions/README.md b/problems/simplified-fractions/README.md index 7c4753dfc..3b5c60dc4 100644 --- a/problems/simplified-fractions/README.md +++ b/problems/simplified-fractions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../consecutive-characters "Consecutive Characters") diff --git a/problems/single-element-in-a-sorted-array/README.md b/problems/single-element-in-a-sorted-array/README.md index 19496af4f..1a2a0ca96 100644 --- a/problems/single-element-in-a-sorted-array/README.md +++ b/problems/single-element-in-a-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-difference "Minimum Time Difference") @@ -11,9 +11,11 @@ ## [540. Single Element in a Sorted Array (Medium)](https://leetcode.com/problems/single-element-in-a-sorted-array "有序数组中的单一元素") -

    You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Find this single element that appears only once.

    +

    You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.

    -

    Follow up: Your solution should run in O(log n) time and O(1) space.

    +

    Return the single element that appears only once.

    + +

    Your solution must run in O(log n) time and O(1) space.

     

    Example 1:

    @@ -27,8 +29,8 @@

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • 0 <= nums[i] <= 10^5
    • +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 105
    ### Related Topics diff --git a/problems/single-number-ii/README.md b/problems/single-number-ii/README.md index fa41c7517..61038fb11 100644 --- a/problems/single-number-ii/README.md +++ b/problems/single-number-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../single-number "Single Number") @@ -33,8 +33,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Single Number](../single-number) (Easy) diff --git a/problems/single-threaded-cpu/README.md b/problems/single-threaded-cpu/README.md index 57b8e7761..4b61ed447 100644 --- a/problems/single-threaded-cpu/README.md +++ b/problems/single-threaded-cpu/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-ice-cream-bars "Maximum Ice Cream Bars") diff --git a/problems/sliding-puzzle/README.md b/problems/sliding-puzzle/README.md index d635f66ae..6b0fb4589 100644 --- a/problems/sliding-puzzle/README.md +++ b/problems/sliding-puzzle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../basic-calculator-iii "Basic Calculator III") @@ -67,8 +67,8 @@ After move 5: [[1,2,3],[4,5,0]] ### 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/sliding-window-median/README.md b/problems/sliding-window-median/README.md index 3b6027df7..af143bcb9 100644 --- a/problems/sliding-window-median/README.md +++ b/problems/sliding-window-median/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-palindrome-product "Largest Palindrome Product") @@ -51,7 +51,7 @@ Window position Median
    • 1 <= k <= nums.length <= 105
    • -
    • 231 <= nums[i] <= 231 - 1
    • +
    • -231 <= nums[i] <= 231 - 1
    ### Related Topics diff --git a/problems/slowest-key/README.md b/problems/slowest-key/README.md index a40c8a33e..96e1088ff 100644 --- a/problems/slowest-key/README.md +++ b/problems/slowest-key/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-an-expression-tree-with-evaluate-function "Design an Expression Tree With Evaluate Function") diff --git a/problems/smallest-common-region/README.md b/problems/smallest-common-region/README.md index 4ab4daf57..85f65043f 100644 --- a/problems/smallest-common-region/README.md +++ b/problems/smallest-common-region/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../encode-number "Encode Number") @@ -46,12 +46,12 @@ region2 = "New York" ### 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)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/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)] ### Similar Questions 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) 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 28004337d..2b62f9d3f 100644 --- a/problems/smallest-greater-multiple-made-of-two-digits/README.md +++ b/problems/smallest-greater-multiple-made-of-two-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../gcd-sort-of-an-array "GCD Sort of an Array") diff --git a/problems/smallest-index-with-equal-value/README.md b/problems/smallest-index-with-equal-value/README.md index c6d5572b7..580d8f059 100644 --- a/problems/smallest-index-with-equal-value/README.md +++ b/problems/smallest-index-with-equal-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-valid-move-combinations-on-chessboard "Number of Valid Move Combinations On Chessboard") diff --git a/problems/smallest-integer-divisible-by-k/README.md b/problems/smallest-integer-divisible-by-k/README.md index 6c044bdf0..295bc573d 100644 --- a/problems/smallest-integer-divisible-by-k/README.md +++ b/problems/smallest-integer-divisible-by-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-sightseeing-pair "Best Sightseeing Pair") diff --git a/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/README.md b/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/README.md index 78a814d9c..172effb70 100644 --- a/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/README.md +++ b/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-ix "Stone Game IX") diff --git a/problems/smallest-missing-genetic-value-in-each-subtree/README.md b/problems/smallest-missing-genetic-value-in-each-subtree/README.md index 46e0ba16e..0a4c2f101 100644 --- a/problems/smallest-missing-genetic-value-in-each-subtree/README.md +++ b/problems/smallest-missing-genetic-value-in-each-subtree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-of-the-length-of-two-palindromic-subsequences "Maximum Product of the Length of Two Palindromic Subsequences") 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 f0eef6e1d..c6b732dd2 100644 --- a/problems/smallest-range-covering-elements-from-k-lists/README.md +++ b/problems/smallest-range-covering-elements-from-k-lists/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-excel-sum-formula "Design Excel Sum Formula") diff --git a/problems/smallest-range-i/README.md b/problems/smallest-range-i/README.md index 025217ab3..124e529b4 100644 --- a/problems/smallest-range-i/README.md +++ b/problems/smallest-range-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-subarray-minimums "Sum of Subarray Minimums") diff --git a/problems/smallest-range-ii/README.md b/problems/smallest-range-ii/README.md index 8a6aaf9ed..8dbed5def 100644 --- a/problems/smallest-range-ii/README.md +++ b/problems/smallest-range-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../snakes-and-ladders "Snakes and Ladders") diff --git a/problems/smallest-string-starting-from-leaf/README.md b/problems/smallest-string-starting-from-leaf/README.md index 43b20a40a..2cacbb7f1 100644 --- a/problems/smallest-string-starting-from-leaf/README.md +++ b/problems/smallest-string-starting-from-leaf/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../vertical-order-traversal-of-a-binary-tree "Vertical Order Traversal of a Binary Tree") diff --git a/problems/smallest-string-with-a-given-numeric-value/README.md b/problems/smallest-string-with-a-given-numeric-value/README.md index 8763258c3..031de599d 100644 --- a/problems/smallest-string-with-a-given-numeric-value/README.md +++ b/problems/smallest-string-with-a-given-numeric-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-two-string-arrays-are-equivalent "Check If Two String Arrays are Equivalent") diff --git a/problems/smallest-string-with-swaps/README.md b/problems/smallest-string-with-swaps/README.md index c137301b4..4275dfbf4 100644 --- a/problems/smallest-string-with-swaps/README.md +++ b/problems/smallest-string-with-swaps/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ugly-number-iii "Ugly Number III") @@ -60,11 +60,15 @@ Swap s[0] and s[1], s = "abc" ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/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)] - [[Hash Table](../../tag/hash-table/README.md)] - [[String](../../tag/string/README.md)] + +### Similar Questions + 1. [Minimize Hamming Distance After Swap Operations](../minimize-hamming-distance-after-swap-operations) (Medium) + 1. [Process Restricted Friend Requests](../process-restricted-friend-requests) (Hard) ### Hints
    diff --git a/problems/smallest-subsequence-of-distinct-characters/README.md b/problems/smallest-subsequence-of-distinct-characters/README.md index 43c0c4660..8df56998f 100644 --- a/problems/smallest-subsequence-of-distinct-characters/README.md +++ b/problems/smallest-subsequence-of-distinct-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../insufficient-nodes-in-root-to-leaf-paths "Insufficient Nodes in Root to Leaf Paths") @@ -11,9 +11,7 @@ ## [1081. Smallest Subsequence of Distinct Characters (Medium)](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters "不同字符的最小子序列") -

    Return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once.

    - -

    Note: This question is the same as 316: https://leetcode.com/problems/remove-duplicate-letters/

    +

    Given a string s, return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once.

     

    Example 1:

    @@ -38,6 +36,9 @@
  • s consists of lowercase English letters.
  • +

     

    +Note: This question is the same as 316: https://leetcode.com/problems/remove-duplicate-letters/ + ### Related Topics [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/smallest-sufficient-team/README.md b/problems/smallest-sufficient-team/README.md index cf1bd21ec..eca83514e 100644 --- a/problems/smallest-sufficient-team/README.md +++ b/problems/smallest-sufficient-team/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-well-performing-interval "Longest Well-Performing Interval") @@ -49,11 +49,15 @@ ### 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)] +### Similar Questions + 1. [The Number of Good Subsets](../the-number-of-good-subsets) (Hard) + 1. [Minimum Number of Work Sessions to Finish the Tasks](../minimum-number-of-work-sessions-to-finish-the-tasks) (Medium) + ### Hints
    Hint 1 diff --git a/problems/solve-the-equation/README.md b/problems/solve-the-equation/README.md index 15c84e9ab..b3c314bab 100644 --- a/problems/solve-the-equation/README.md +++ b/problems/solve-the-equation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decode-ways-ii "Decode Ways II") diff --git a/problems/sort-array-by-increasing-frequency/README.md b/problems/sort-array-by-increasing-frequency/README.md index 9c21983ff..9ed63490c 100644 --- a/problems/sort-array-by-increasing-frequency/README.md +++ b/problems/sort-array-by-increasing-frequency/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../hopper-company-queries-i "Hopper Company Queries I") @@ -51,6 +51,9 @@ [[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-array-by-parity/README.md b/problems/sort-array-by-parity/README.md index ebad65e3c..62b5fbb01 100644 --- a/problems/sort-array-by-parity/README.md +++ b/problems/sort-array-by-parity/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fruit-into-baskets "Fruit Into Baskets") diff --git a/problems/sort-features-by-popularity/README.md b/problems/sort-features-by-popularity/README.md index 0964c24dd..6dd77659d 100644 --- a/problems/sort-features-by-popularity/README.md +++ b/problems/sort-features-by-popularity/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-palindrome-length-from-subsequences "Maximize Palindrome Length From Subsequences") @@ -19,10 +19,6 @@ [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) - 1. [Top K Frequent Words](../top-k-frequent-words) (Medium) - ### Hints
    Hint 1 diff --git a/problems/sort-items-by-groups-respecting-dependencies/README.md b/problems/sort-items-by-groups-respecting-dependencies/README.md index b82eaa3cf..f6a849031 100644 --- a/problems/sort-items-by-groups-respecting-dependencies/README.md +++ b/problems/sort-items-by-groups-respecting-dependencies/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-string-with-swaps "Smallest String With Swaps") 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 ea2daefe8..787f6c9e5 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../second-minimum-time-to-reach-destination "Second Minimum Time to Reach Destination") diff --git a/problems/sort-the-matrix-diagonally/README.md b/problems/sort-the-matrix-diagonally/README.md index de6bdde4e..2105b4213 100644 --- a/problems/sort-the-matrix-diagonally/README.md +++ b/problems/sort-the-matrix-diagonally/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../break-a-palindrome "Break a Palindrome") @@ -42,8 +42,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/sorting-the-sentence/README.md b/problems/sorting-the-sentence/README.md index 5a48c1d7e..bf34188c7 100644 --- a/problems/sorting-the-sentence/README.md +++ b/problems/sorting-the-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-word-with-all-prefixes "Longest Word With All Prefixes") diff --git a/problems/soup-servings/README.md b/problems/soup-servings/README.md index 1ec57cf30..f49525fb8 100644 --- a/problems/soup-servings/README.md +++ b/problems/soup-servings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-increase-to-keep-city-skyline "Max Increase to Keep City Skyline") diff --git a/problems/sparse-matrix-multiplication/README.md b/problems/sparse-matrix-multiplication/README.md index 6679df3d3..3656b4858 100644 --- a/problems/sparse-matrix-multiplication/README.md +++ b/problems/sparse-matrix-multiplication/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-height-trees "Minimum Height Trees") 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 ee02ba5e1..421305253 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sellers-with-no-sales "Sellers With No Sales") diff --git a/problems/special-positions-in-a-binary-matrix/README.md b/problems/special-positions-in-a-binary-matrix/README.md index 36f6711a1..a3e5ee837 100644 --- a/problems/special-positions-in-a-binary-matrix/README.md +++ b/problems/special-positions-in-a-binary-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../customer-who-visited-but-did-not-make-any-transactions "Customer Who Visited but Did Not Make Any Transactions") diff --git a/problems/spiral-matrix/README.md b/problems/spiral-matrix/README.md index c1b018a6b..90e6207f2 100644 --- a/problems/spiral-matrix/README.md +++ b/problems/spiral-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-subarray "Maximum Subarray") diff --git a/problems/split-a-string-in-balanced-strings/README.md b/problems/split-a-string-in-balanced-strings/README.md index 949a4f46d..e2cb832da 100644 --- a/problems/split-a-string-in-balanced-strings/README.md +++ b/problems/split-a-string-in-balanced-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-vowels-permutation "Count Vowels Permutation") diff --git a/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md b/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md index 0006e7742..1bdc20e26 100644 --- a/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md +++ b/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rearrange-spaces-between-words "Rearrange Spaces Between Words") diff --git a/problems/split-array-into-consecutive-subsequences/README.md b/problems/split-array-into-consecutive-subsequences/README.md index 7487fd286..26dc3b3e0 100644 --- a/problems/split-array-into-consecutive-subsequences/README.md +++ b/problems/split-array-into-consecutive-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-k-closest-elements "Find K Closest Elements") diff --git a/problems/split-array-into-fibonacci-sequence/README.md b/problems/split-array-into-fibonacci-sequence/README.md index 8e3310bea..bf63e8c47 100644 --- a/problems/split-array-into-fibonacci-sequence/README.md +++ b/problems/split-array-into-fibonacci-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../keys-and-rooms "Keys and Rooms") diff --git a/problems/split-bst/README.md b/problems/split-bst/README.md index 69e6d4f6b..143d477ad 100644 --- a/problems/split-bst/README.md +++ b/problems/split-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../global-and-local-inversions "Global and Local Inversions") diff --git a/problems/split-two-strings-to-make-palindrome/README.md b/problems/split-two-strings-to-make-palindrome/README.md index 0077e76a5..8684258eb 100644 --- a/problems/split-two-strings-to-make-palindrome/README.md +++ b/problems/split-two-strings-to-make-palindrome/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximal-network-rank "Maximal Network Rank") 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 a371b2796..936b7ddf8 100644 --- a/problems/splitting-a-string-into-descending-consecutive-values/README.md +++ b/problems/splitting-a-string-into-descending-consecutive-values/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-distance-to-the-target-element "Minimum Distance to the Target Element") diff --git a/problems/squirrel-simulation/README.md b/problems/squirrel-simulation/README.md index 49ddc5a3e..dcb935bcb 100644 --- a/problems/squirrel-simulation/README.md +++ b/problems/squirrel-simulation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subtree-of-another-tree "Subtree of Another Tree") diff --git a/problems/stickers-to-spell-word/README.md b/problems/stickers-to-spell-word/README.md index 4612eabd5..344c35177 100644 --- a/problems/stickers-to-spell-word/README.md +++ b/problems/stickers-to-spell-word/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../employee-importance "Employee Importance") diff --git a/problems/stock-price-fluctuation/README.md b/problems/stock-price-fluctuation/README.md index 49dacf30f..85f72ad28 100644 --- a/problems/stock-price-fluctuation/README.md +++ b/problems/stock-price-fluctuation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-operations-to-make-a-uni-value-grid "Minimum Operations to Make a Uni-Value Grid") diff --git a/problems/stone-game-iv/README.md b/problems/stone-game-iv/README.md index 5777800a0..e54c3fc94 100644 --- a/problems/stone-game-iv/README.md +++ b/problems/stone-game-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-difference-between-largest-and-smallest-value-in-three-moves "Minimum Difference Between Largest and Smallest Value in Three Moves") diff --git a/problems/stone-game-ix/README.md b/problems/stone-game-ix/README.md index 543ba198a..d3a199649 100644 --- a/problems/stone-game-ix/README.md +++ b/problems/stone-game-ix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-missing-observations "Find Missing Observations") diff --git a/problems/stone-game-v/README.md b/problems/stone-game-v/README.md index 018a99134..79aa9c07c 100644 --- a/problems/stone-game-v/README.md +++ b/problems/stone-game-v/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-latest-group-of-size-m "Find Latest Group of Size M") @@ -11,9 +11,9 @@ ## [1563. Stone Game V (Hard)](https://leetcode.com/problems/stone-game-v "石子游戏 V") -

    There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.

    +

    There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.

    -

    In each round of the game, Alice divides the row into two non-empty rows (i.e. left row and right row), then Bob calculates the value of each row which is the sum of the values of all the stones in this row. Bob throws away the row which has the maximum value, and Alice's score increases by the value of the remaining row. If the value of the two rows are equal, Bob lets Alice decide which row will be thrown away. The next round starts with the remaining row.

    +

    In each round of the game, Alice divides the row into two non-empty rows (i.e. left row and right row), then Bob calculates the value of each row which is the sum of the values of all the stones in this row. Bob throws away the row which has the maximum value, and Alice's score increases by the value of the remaining row. If the value of the two rows are equal, Bob lets Alice decide which row will be thrown away. The next round starts with the remaining row.

    The game ends when there is only one stone remaining. Alice's is initially zero.

    @@ -49,7 +49,7 @@ The last round Alice has only one choice to divide the row which is [2], [3]. Bo
    • 1 <= stoneValue.length <= 500
    • -
    • 1 <= stoneValue[i] <= 10^6
    • +
    • 1 <= stoneValue[i] <= 106
    ### Related Topics diff --git a/problems/stone-game-vi/README.md b/problems/stone-game-vi/README.md index 4295171bb..5d868a7e1 100644 --- a/problems/stone-game-vi/README.md +++ b/problems/stone-game-vi/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-absolute-differences-in-a-sorted-array "Sum of Absolute Differences in a Sorted Array") @@ -70,22 +70,12 @@ Bob wins. ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Greedy](../../tag/greedy/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/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 VII](../stone-game-vii) (Medium) - 1. [Stone Game VIII](../stone-game-viii) (Hard) - 1. [Stone Game IX](../stone-game-ix) (Medium) ### Hints
    diff --git a/problems/stone-game-vii/README.md b/problems/stone-game-vii/README.md index c2614f1d6..c84453367 100644 --- a/problems/stone-game-vii/README.md +++ b/problems/stone-game-vii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partitioning-into-minimum-number-of-deci-binary-numbers "Partitioning Into Minimum Number Of Deci-Binary Numbers") @@ -55,6 +55,17 @@ 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/stone-game-viii/README.md b/problems/stone-game-viii/README.md index 45ec75bbc..5fa74e2c5 100644 --- a/problems/stone-game-viii/README.md +++ b/problems/stone-game-viii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game-vii "Jump Game VII") diff --git a/problems/strange-printer-ii/README.md b/problems/strange-printer-ii/README.md index d352ac2dd..efef2f8b8 100644 --- a/problems/strange-printer-ii/README.md +++ b/problems/strange-printer-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../make-sum-divisible-by-p "Make Sum Divisible by P") diff --git a/problems/strange-printer/README.md b/problems/strange-printer/README.md index 2d6df9e37..c94739d6a 100644 --- a/problems/strange-printer/README.md +++ b/problems/strange-printer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../equal-tree-partition "Equal Tree Partition") diff --git a/problems/string-compression-ii/README.md b/problems/string-compression-ii/README.md index 9929ee6c8..5fb6dc2db 100644 --- a/problems/string-compression-ii/README.md +++ b/problems/string-compression-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-good-leaf-nodes-pairs "Number of Good Leaf Nodes Pairs") diff --git a/problems/string-transforms-into-another-string/README.md b/problems/string-transforms-into-another-string/README.md index a3e6c6cf3..4e1724a91 100644 --- a/problems/string-transforms-into-another-string/README.md +++ b/problems/string-transforms-into-another-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../analyze-user-website-visit-pattern "Analyze User Website Visit Pattern") diff --git a/problems/strings-differ-by-one-character/README.md b/problems/strings-differ-by-one-character/README.md index 6fea70d9f..16a62cb47 100644 --- a/problems/strings-differ-by-one-character/README.md +++ b/problems/strings-differ-by-one-character/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-days-to-eat-n-oranges "Minimum Number of Days to Eat N Oranges") @@ -16,8 +16,8 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/strobogrammatic-number-ii/README.md b/problems/strobogrammatic-number-ii/README.md index f40c678c5..b6bd42690 100644 --- a/problems/strobogrammatic-number-ii/README.md +++ b/problems/strobogrammatic-number-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strobogrammatic-number "Strobogrammatic Number") @@ -30,6 +30,7 @@ ### Similar Questions 1. [Strobogrammatic Number](../strobogrammatic-number) (Easy) 1. [Strobogrammatic Number III](../strobogrammatic-number-iii) (Hard) + 1. [Sum of k-Mirror Numbers](../sum-of-k-mirror-numbers) (Hard) ### Hints
    diff --git a/problems/strong-friendship/README.md b/problems/strong-friendship/README.md index 8be710f81..d02716190 100644 --- a/problems/strong-friendship/README.md +++ b/problems/strong-friendship/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-duplicate-folders-in-system "Delete Duplicate Folders in System") diff --git a/problems/strong-password-checker/README.md b/problems/strong-password-checker/README.md index 5bcd0b817..e52efecb5 100644 --- a/problems/strong-password-checker/README.md +++ b/problems/strong-password-checker/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../battleships-in-a-board "Battleships in a Board") @@ -49,6 +49,6 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/student-attendance-record-i/README.md b/problems/student-attendance-record-i/README.md index e360626a9..edbe92853 100644 --- a/problems/student-attendance-record-i/README.md +++ b/problems/student-attendance-record-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../game-play-analysis-iv "Game Play Analysis IV") diff --git a/problems/students-and-examinations/README.md b/problems/students-and-examinations/README.md index 7247b28a6..e9b327fe4 100644 --- a/problems/students-and-examinations/README.md +++ b/problems/students-and-examinations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../traffic-light-controlled-intersection "Traffic Light Controlled Intersection") diff --git a/problems/students-report-by-geography/README.md b/problems/students-report-by-geography/README.md index 73a5919e9..1d661e8f6 100644 --- a/problems/students-report-by-geography/README.md +++ b/problems/students-report-by-geography/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-two-binary-trees "Merge Two Binary Trees") diff --git a/problems/students-report-by-geography/mysql_schemas.sql b/problems/students-report-by-geography/mysql_schemas.sql index d3da4c6a5..271a37487 100644 --- a/problems/students-report-by-geography/mysql_schemas.sql +++ b/problems/students-report-by-geography/mysql_schemas.sql @@ -1,6 +1,6 @@ -Create table If Not Exists student (name varchar(50), continent varchar(7)); -Truncate table student; -insert into student (name, continent) values ('Jane', 'America'); -insert into student (name, continent) values ('Pascal', 'Europe'); -insert into student (name, continent) values ('Xi', 'Asia'); -insert into student (name, continent) values ('Jack', 'America'); +Create table If Not Exists Student (name varchar(50), continent varchar(7)); +Truncate table Student; +insert into Student (name, continent) values ('Jane', 'America'); +insert into Student (name, continent) values ('Pascal', 'Europe'); +insert into Student (name, continent) values ('Xi', 'Asia'); +insert into Student (name, continent) values ('Jack', 'America'); diff --git a/problems/students-with-invalid-departments/README.md b/problems/students-with-invalid-departments/README.md index 19cb5a74c..ea308e0fa 100644 --- a/problems/students-with-invalid-departments/README.md +++ b/problems/students-with-invalid-departments/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-students-taking-exam "Maximum Students Taking Exam") diff --git a/problems/subdomain-visit-count/README.md b/problems/subdomain-visit-count/README.md index 846e45858..700b534f3 100644 --- a/problems/subdomain-visit-count/README.md +++ b/problems/subdomain-visit-count/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../chalkboard-xor-game "Chalkboard XOR Game") diff --git a/problems/subrectangle-queries/README.md b/problems/subrectangle-queries/README.md index 3f4bd973f..fd1f45944 100644 --- a/problems/subrectangle-queries/README.md +++ b/problems/subrectangle-queries/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../final-prices-with-a-special-discount-in-a-shop "Final Prices With a Special Discount in a Shop") @@ -94,8 +94,8 @@ subrectangleQueries.getValue(2, 2); // return 20 ### Related Topics - [[Array](../../tag/array/README.md)] [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/substring-with-concatenation-of-all-words/README.md b/problems/substring-with-concatenation-of-all-words/README.md index 29eca0990..a24d4771a 100644 --- a/problems/substring-with-concatenation-of-all-words/README.md +++ b/problems/substring-with-concatenation-of-all-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../divide-two-integers "Divide Two Integers") 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 84a9ab14d..ee678eb6c 100644 --- a/problems/substrings-of-size-three-with-distinct-characters/README.md +++ b/problems/substrings-of-size-three-with-distinct-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../group-employees-of-the-same-salary "Group Employees of the Same Salary") @@ -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)] - [[Counting](../../tag/counting/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Counting](../../tag/counting/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 new file mode 100644 index 000000000..d3d18e50a --- /dev/null +++ b/problems/substrings-that-begin-and-end-with-the-same-letter/README.md @@ -0,0 +1,40 @@ + + + + + + + +[< Previous](../the-number-of-rich-customers "The Number of Rich Customers") +                 +[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 "") + + + +### Hints +
    +Hint 1 +In the string "abacad", the letter "a" appears 3 times. How many substrings begin with the first "a" and end with any "a"? +
    + +
    +Hint 2 +There are 3 substrings ("a", "aba", and "abaca"). How many substrings begin with the second "a" and end with any "a"? How about the third? +
    + +
    +Hint 3 +2 substrings begin with the second "a" ("a", and "aca") and 1 substring begins with the third "a" ("a"). +
    + +
    +Hint 4 +There is a total of 3 + 2 + 1 = 6 substrings that begin and end with "a". +
    + +
    +Hint 5 +If a character appears i times in the string, there are i * (i + 1) / 2 substrings that begin and end with that character. +
    diff --git a/problems/subtract-the-product-and-sum-of-digits-of-an-integer/README.md b/problems/subtract-the-product-and-sum-of-digits-of-an-integer/README.md index e4546b616..bff43a94f 100644 --- a/problems/subtract-the-product-and-sum-of-digits-of-an-integer/README.md +++ b/problems/subtract-the-product-and-sum-of-digits-of-an-integer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../students-and-examinations "Students and Examinations") diff --git a/problems/subtree-removal-game-with-fibonacci-tree/README.md b/problems/subtree-removal-game-with-fibonacci-tree/README.md index bb7bf2a9e..07cd9d6f4 100644 --- a/problems/subtree-removal-game-with-fibonacci-tree/README.md +++ b/problems/subtree-removal-game-with-fibonacci-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-seniors-and-juniors-to-join-the-company "The Number of Seniors and Juniors to Join the Company") diff --git a/problems/sum-game/README.md b/problems/sum-game/README.md index fc9526ea6..013d6e38e 100644 --- a/problems/sum-game/README.md +++ b/problems/sum-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nearest-exit-from-entrance-in-maze "Nearest Exit from Entrance in Maze") diff --git a/problems/sum-of-absolute-differences-in-a-sorted-array/README.md b/problems/sum-of-absolute-differences-in-a-sorted-array/README.md index 203d0d8ac..8d6a3c30c 100644 --- a/problems/sum-of-absolute-differences-in-a-sorted-array/README.md +++ b/problems/sum-of-absolute-differences-in-a-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-the-number-of-consistent-strings "Count the Number of Consistent Strings") diff --git a/problems/sum-of-all-odd-length-subarrays/README.md b/problems/sum-of-all-odd-length-subarrays/README.md index 33302a523..89cc61509 100644 --- a/problems/sum-of-all-odd-length-subarrays/README.md +++ b/problems/sum-of-all-odd-length-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bank-account-summary-ii "Bank Account Summary II") diff --git a/problems/sum-of-all-subset-xor-totals/README.md b/problems/sum-of-all-subset-xor-totals/README.md index be0743994..1fa7a407f 100644 --- a/problems/sum-of-all-subset-xor-totals/README.md +++ b/problems/sum-of-all-subset-xor-totals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-floored-pairs "Sum of Floored Pairs") diff --git a/problems/sum-of-beauty-in-the-array/README.md b/problems/sum-of-beauty-in-the-array/README.md index 09e6a56b5..f6a1c02c1 100644 --- a/problems/sum-of-beauty-in-the-array/README.md +++ b/problems/sum-of-beauty-in-the-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../final-value-of-variable-after-performing-operations "Final Value of Variable After Performing Operations") diff --git a/problems/sum-of-beauty-of-all-substrings/README.md b/problems/sum-of-beauty-of-all-substrings/README.md index 1d2667a17..8e5cea5de 100644 --- a/problems/sum-of-beauty-of-all-substrings/README.md +++ b/problems/sum-of-beauty-of-all-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-number-is-a-sum-of-powers-of-three "Check if Number is a Sum of Powers of Three") diff --git a/problems/sum-of-digits-in-base-k/README.md b/problems/sum-of-digits-in-base-k/README.md index 709e3d543..8ae9cb78f 100644 --- a/problems/sum-of-digits-in-base-k/README.md +++ b/problems/sum-of-digits-in-base-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicates-from-an-unsorted-linked-list "Remove Duplicates From an Unsorted Linked List") diff --git a/problems/sum-of-digits-of-string-after-convert/README.md b/problems/sum-of-digits-of-string-after-convert/README.md index 9e5090d5b..a8fba598f 100644 --- a/problems/sum-of-digits-of-string-after-convert/README.md +++ b/problems/sum-of-digits-of-string-after-convert/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-visible-people-in-a-queue "Number of Visible People in a Queue") diff --git a/problems/sum-of-even-numbers-after-queries/README.md b/problems/sum-of-even-numbers-after-queries/README.md index d10a592e5..392687112 100644 --- a/problems/sum-of-even-numbers-after-queries/README.md +++ b/problems/sum-of-even-numbers-after-queries/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../string-without-aaa-or-bbb "String Without AAA or BBB") diff --git a/problems/sum-of-floored-pairs/README.md b/problems/sum-of-floored-pairs/README.md index 84a0bad5d..10d72bc34 100644 --- a/problems/sum-of-floored-pairs/README.md +++ b/problems/sum-of-floored-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rotating-the-box "Rotating the Box") diff --git a/problems/sum-of-k-mirror-numbers/README.md b/problems/sum-of-k-mirror-numbers/README.md new file mode 100644 index 000000000..3d18182e4 --- /dev/null +++ b/problems/sum-of-k-mirror-numbers/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../range-frequency-queries "Range Frequency Queries") +                 +[Next >](../the-number-of-rich-customers "The Number of Rich Customers") + +## [2081. Sum of k-Mirror Numbers (Hard)](https://leetcode.com/problems/sum-of-k-mirror-numbers "k 镜像数字的和") + +

    A k-mirror number is a positive integer without leading zeros that reads the same both forward and backward in base-10 as well as in base-k.

    + +
      +
    • For example, 9 is a 2-mirror number. The representation of 9 in base-10 and base-2 are 9 and 1001 respectively, which read the same both forward and backward.
    • +
    • On the contrary, 4 is not a 2-mirror number. The representation of 4 in base-2 is 100, which does not read the same both forward and backward.
    • +
    + +

    Given the base k and the number n, return the sum of the n smallest k-mirror numbers.

    + +

     

    +

    Example 1:

    + +
    +Input: k = 2, n = 5
    +Output: 25
    +Explanation:
    +The 5 smallest 2-mirror numbers and their representations in base-2 are listed as follows:
    +  base-10    base-2
    +    1          1
    +    3          11
    +    5          101
    +    7          111
    +    9          1001
    +Their sum = 1 + 3 + 5 + 7 + 9 = 25. 
    +
    + +

    Example 2:

    + +
    +Input: k = 3, n = 7
    +Output: 499
    +Explanation:
    +The 7 smallest 3-mirror numbers are and their representations in base-3 are listed as follows:
    +  base-10    base-3
    +    1          1
    +    2          2
    +    4          11
    +    8          22
    +    121        11111
    +    151        12121
    +    212        21212
    +Their sum = 1 + 2 + 4 + 8 + 121 + 151 + 212 = 499.
    +
    + +

    Example 3:

    + +
    +Input: k = 7, n = 17
    +Output: 20379000
    +Explanation: The 17 smallest 7-mirror numbers are:
    +1, 2, 3, 4, 5, 6, 8, 121, 171, 242, 292, 16561, 65656, 2137312, 4602064, 6597956, 6958596
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= k <= 9
    • +
    • 1 <= n <= 30
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + +### Hints +
    +Hint 1 +Since we need to reduce search space, instead of checking if every number is a palindrome in base-10, can we try to "generate" the palindromic numbers? +
    + +
    +Hint 2 +If you are provided with a d digit number, how can you generate a palindrome with 2*d or 2*d - 1 digit? +
    + +
    +Hint 3 +Try brute-forcing and checking if the palindrome you generated is a "k-Mirror" number. +
    diff --git a/problems/sum-of-mutated-array-closest-to-target/README.md b/problems/sum-of-mutated-array-closest-to-target/README.md index 140b8fb86..490eaebb2 100644 --- a/problems/sum-of-mutated-array-closest-to-target/README.md +++ b/problems/sum-of-mutated-array-closest-to-target/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-elements-with-greatest-element-on-right-side "Replace Elements with Greatest Element on Right Side") diff --git a/problems/sum-of-nodes-with-even-valued-grandparent/README.md b/problems/sum-of-nodes-with-even-valued-grandparent/README.md index 2a0c7f7ed..fdcf237f6 100644 --- a/problems/sum-of-nodes-with-even-valued-grandparent/README.md +++ b/problems/sum-of-nodes-with-even-valued-grandparent/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../matrix-block-sum "Matrix Block Sum") diff --git a/problems/sum-of-root-to-leaf-binary-numbers/README.md b/problems/sum-of-root-to-leaf-binary-numbers/README.md index 8ea2c7e73..b74243c58 100644 --- a/problems/sum-of-root-to-leaf-binary-numbers/README.md +++ b/problems/sum-of-root-to-leaf-binary-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-outermost-parentheses "Remove Outermost Parentheses") diff --git a/problems/sum-of-special-evenly-spaced-elements-in-array/README.md b/problems/sum-of-special-evenly-spaced-elements-in-array/README.md index 8ce6a2aaf..0ef13bf98 100644 --- a/problems/sum-of-special-evenly-spaced-elements-in-array/README.md +++ b/problems/sum-of-special-evenly-spaced-elements-in-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-operations-to-make-a-subsequence "Minimum Operations to Make a Subsequence") diff --git a/problems/sum-of-square-numbers/README.md b/problems/sum-of-square-numbers/README.md index f4a3e2a16..1a6589b9a 100644 --- a/problems/sum-of-square-numbers/README.md +++ b/problems/sum-of-square-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-range-covering-elements-from-k-lists "Smallest Range Covering Elements from K Lists") diff --git a/problems/sum-of-unique-elements/README.md b/problems/sum-of-unique-elements/README.md index 869dd2a26..b4d997c06 100644 --- a/problems/sum-of-unique-elements/README.md +++ b/problems/sum-of-unique-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../leetflex-banned-accounts "Leetflex Banned Accounts") diff --git a/problems/sum-root-to-leaf-numbers/README.md b/problems/sum-root-to-leaf-numbers/README.md index 5421831d0..808108913 100644 --- a/problems/sum-root-to-leaf-numbers/README.md +++ b/problems/sum-root-to-leaf-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-consecutive-sequence "Longest Consecutive Sequence") diff --git a/problems/super-palindromes/README.md b/problems/super-palindromes/README.md index e48447ffa..85d5a43b7 100644 --- a/problems/super-palindromes/README.md +++ b/problems/super-palindromes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-array-by-parity "Sort Array By Parity") diff --git a/problems/super-ugly-number/README.md b/problems/super-ugly-number/README.md index 2e149110e..ab12d29e0 100644 --- a/problems/super-ugly-number/README.md +++ b/problems/super-ugly-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../burst-balloons "Burst Balloons") diff --git a/problems/super-washing-machines/README.md b/problems/super-washing-machines/README.md index 27d42a2d7..4fcb527d0 100644 --- a/problems/super-washing-machines/README.md +++ b/problems/super-washing-machines/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-palindromic-subsequence "Longest Palindromic Subsequence") diff --git a/problems/surrounded-regions/README.md b/problems/surrounded-regions/README.md index 46f86f00e..b0fdb237d 100644 --- a/problems/surrounded-regions/README.md +++ b/problems/surrounded-regions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-root-to-leaf-numbers "Sum Root to Leaf Numbers") diff --git a/problems/suspicious-bank-accounts/README.md b/problems/suspicious-bank-accounts/README.md index e76384a0c..5d8cdf1ff 100644 --- a/problems/suspicious-bank-accounts/README.md +++ b/problems/suspicious-bank-accounts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../next-palindrome-using-same-digits "Next Palindrome Using Same Digits") diff --git a/problems/swap-for-longest-repeated-character-substring/README.md b/problems/swap-for-longest-repeated-character-substring/README.md index 0d76e2af0..117c95cdd 100644 --- a/problems/swap-for-longest-repeated-character-substring/README.md +++ b/problems/swap-for-longest-repeated-character-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-dice-rolls-with-target-sum "Number of Dice Rolls With Target Sum") diff --git a/problems/swap-nodes-in-pairs/README.md b/problems/swap-nodes-in-pairs/README.md index 698a6f723..25b2d137f 100644 --- a/problems/swap-nodes-in-pairs/README.md +++ b/problems/swap-nodes-in-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-k-sorted-lists "Merge k Sorted Lists") @@ -44,8 +44,9 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Reverse Nodes in k-Group](../reverse-nodes-in-k-group) (Hard) + 1. [Swapping Nodes in a Linked List](../swapping-nodes-in-a-linked-list) (Medium) diff --git a/problems/swap-salary/README.md b/problems/swap-salary/README.md index d81d80e0c..3f9a113dc 100644 --- a/problems/swap-salary/README.md +++ b/problems/swap-salary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../exchange-seats "Exchange Seats") @@ -29,15 +29,17 @@ The table contains information about an employee.

     

    -

    Write an SQL query to swap all 'f' and 'm' values (i.e., change all 'f' values to 'm' and vice versa) with a single update statement and no intermediate temp table(s).

    +

    Write an SQL query to swap all 'f' and 'm' values (i.e., change all 'f' values to 'm' and vice versa) with a single update statement and no intermediate temporary tables.

    -

    Note that you must write a single update statement, DO NOT write any select statement for this problem.

    +

    Note that you must write a single update statement, do not write any select statement for this problem.

    -

    The query result format is in the following example:

    +

    The query result format is in the following example.

     

    +

    Example 1:

    +Input: 
     Salary table:
     +----+------+-----+--------+
     | id | name | sex | salary |
    @@ -47,8 +49,7 @@ Salary table:
     | 3  | C    | m   | 5500   |
     | 4  | D    | f   | 500    |
     +----+------+-----+--------+
    -
    -Result table:
    +Output: 
     +----+------+-----+--------+
     | id | name | sex | salary |
     +----+------+-----+--------+
    @@ -57,6 +58,7 @@ Result table:
     | 3  | C    | f   | 5500   |
     | 4  | D    | m   | 500    |
     +----+------+-----+--------+
    +Explanation: 
     (1, A) and (3, C) were changed from 'm' to 'f'.
     (2, B) and (4, D) were changed from 'f' to 'm'.
     
    diff --git a/problems/swap-salary/mysql_schemas.sql b/problems/swap-salary/mysql_schemas.sql index ba43d5f9b..dd8dccfe3 100644 --- a/problems/swap-salary/mysql_schemas.sql +++ b/problems/swap-salary/mysql_schemas.sql @@ -1,4 +1,4 @@ -create table if not exists salary(id int, name varchar(100), sex char(1), salary int); +Create table If Not Exists Salary (id int, name varchar(100), sex char(1), salary int); Truncate table salary; insert into salary (id, name, sex, salary) values ('1', 'A', 'm', '2500'); insert into salary (id, name, sex, salary) values ('2', 'B', 'f', '1500'); diff --git a/problems/swapping-nodes-in-a-linked-list/README.md b/problems/swapping-nodes-in-a-linked-list/README.md index c5d03018f..6ec21a3ad 100644 --- a/problems/swapping-nodes-in-a-linked-list/README.md +++ b/problems/swapping-nodes-in-a-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decode-xored-array "Decode XORed Array") diff --git a/problems/swim-in-rising-water/README.md b/problems/swim-in-rising-water/README.md index 8022b876b..b70685f53 100644 --- a/problems/swim-in-rising-water/README.md +++ b/problems/swim-in-rising-water/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../swap-adjacent-in-lr-string "Swap Adjacent in LR String") diff --git a/problems/tag-validator/README.md b/problems/tag-validator/README.md index ece5590a6..f210a6fe3 100644 --- a/problems/tag-validator/README.md +++ b/problems/tag-validator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../n-ary-tree-postorder-traversal "N-ary Tree Postorder Traversal") diff --git a/problems/task-scheduler/README.md b/problems/task-scheduler/README.md index 553d94755..1b9a40e12 100644 --- a/problems/task-scheduler/README.md +++ b/problems/task-scheduler/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../not-boring-movies "Not Boring Movies") diff --git a/problems/team-scores-in-football-tournament/README.md b/problems/team-scores-in-football-tournament/README.md index a177899e6..ea77aa03e 100644 --- a/problems/team-scores-in-football-tournament/README.md +++ b/problems/team-scores-in-football-tournament/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../queries-quality-and-percentage "Queries Quality and Percentage") diff --git a/problems/teemo-attacking/README.md b/problems/teemo-attacking/README.md index 96399dae9..2698808e4 100644 --- a/problems/teemo-attacking/README.md +++ b/problems/teemo-attacking/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../target-sum "Target Sum") diff --git a/problems/tenth-line/README.md b/problems/tenth-line/README.md index ef6093c1d..83cca284d 100644 --- a/problems/tenth-line/README.md +++ b/problems/tenth-line/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../transpose-file "Transpose File") diff --git a/problems/ternary-expression-parser/README.md b/problems/ternary-expression-parser/README.md index cee11673f..9ada653a3 100644 --- a/problems/ternary-expression-parser/README.md +++ b/problems/ternary-expression-parser/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-all-anagrams-in-a-string "Find All Anagrams in a String") @@ -65,9 +65,9 @@

    ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Recursion](../../tag/recursion/README.md)] - [[String](../../tag/string/README.md)] ### Similar Questions 1. [Mini Parser](../mini-parser) (Medium) diff --git a/problems/the-category-of-each-member-in-the-store/README.md b/problems/the-category-of-each-member-in-the-store/README.md index 7de23d89c..2f2569f3c 100644 --- a/problems/the-category-of-each-member-in-the-store/README.md +++ b/problems/the-category-of-each-member-in-the-store/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../parallel-courses-iii "Parallel Courses III") diff --git a/problems/the-dining-philosophers/README.md b/problems/the-dining-philosophers/README.md index 7736dfd1b..8199b4c4e 100644 --- a/problems/the-dining-philosophers/README.md +++ b/problems/the-dining-philosophers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../report-contiguous-dates "Report Contiguous Dates") diff --git a/problems/the-earliest-and-latest-rounds-where-players-compete/README.md b/problems/the-earliest-and-latest-rounds-where-players-compete/README.md index 3ac0a467c..21a5d1e92 100644 --- a/problems/the-earliest-and-latest-rounds-where-players-compete/README.md +++ b/problems/the-earliest-and-latest-rounds-where-players-compete/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-triplets-to-form-target-triplet "Merge Triplets to Form Target Triplet") 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 c9fbad8c2..5dd41821e 100644 --- a/problems/the-earliest-moment-when-everyone-become-friends/README.md +++ b/problems/the-earliest-moment-when-everyone-become-friends/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-k-length-substrings-with-no-repeated-characters "Find K-Length Substrings With No Repeated Characters") 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 944e8d4cd..2249537cb 100644 --- a/problems/the-k-strongest-values-in-an-array/README.md +++ b/problems/the-k-strongest-values-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shuffle-the-array "Shuffle the Array") diff --git a/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md b/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md index b65772ab3..099a3b76a 100644 --- a/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md +++ b/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "Find the Minimum Number of Fibonacci Numbers Whose Sum Is K") diff --git a/problems/the-k-weakest-rows-in-a-matrix/README.md b/problems/the-k-weakest-rows-in-a-matrix/README.md index 7b28b9018..7c502a569 100644 --- a/problems/the-k-weakest-rows-in-a-matrix/README.md +++ b/problems/the-k-weakest-rows-in-a-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-transactions-per-visit "Number of Transactions per Visit") diff --git a/problems/the-kth-factor-of-n/README.md b/problems/the-kth-factor-of-n/README.md index a375f78b4..50dfaa95a 100644 --- a/problems/the-kth-factor-of-n/README.md +++ b/problems/the-kth-factor-of-n/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-salary-excluding-the-minimum-and-maximum-salary "Average Salary Excluding the Minimum and Maximum Salary") diff --git a/problems/the-latest-login-in-2020/README.md b/problems/the-latest-login-in-2020/README.md index eb9ffbf02..09cab9b9a 100644 --- a/problems/the-latest-login-in-2020/README.md +++ b/problems/the-latest-login-in-2020/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-space-wasted-from-packaging "Minimum Space Wasted From Packaging") diff --git a/problems/the-maze-ii/README.md b/problems/the-maze-ii/README.md index 12ba31289..d9bc886f6 100644 --- a/problems/the-maze-ii/README.md +++ b/problems/the-maze-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../base-7 "Base 7") 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 dce0cb341..876cd2c83 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-connect-two-groups-of-points "Minimum Cost to Connect Two Groups of Points") diff --git a/problems/the-most-recent-orders-for-each-product/README.md b/problems/the-most-recent-orders-for-each-product/README.md index bfc7647a8..9eb2bee4d 100644 --- a/problems/the-most-recent-orders-for-each-product/README.md +++ b/problems/the-most-recent-orders-for-each-product/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-most-similar-path-in-a-graph "The Most Similar Path in a Graph") diff --git a/problems/the-most-recent-three-orders/README.md b/problems/the-most-recent-three-orders/README.md index 83b306e13..992bd55db 100644 --- a/problems/the-most-recent-three-orders/README.md +++ b/problems/the-most-recent-three-orders/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../string-compression-ii "String Compression II") diff --git a/problems/the-most-similar-path-in-a-graph/README.md b/problems/the-most-similar-path-in-a-graph/README.md index 3a95c19ae..f1f57b715 100644 --- a/problems/the-most-similar-path-in-a-graph/README.md +++ b/problems/the-most-similar-path-in-a-graph/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-cut-a-stick "Minimum Cost to Cut a Stick") diff --git a/problems/the-number-of-employees-which-report-to-each-employee/README.md b/problems/the-number-of-employees-which-report-to-each-employee/README.md index 7900b68ce..8251eb140 100644 --- a/problems/the-number-of-employees-which-report-to-each-employee/README.md +++ b/problems/the-number-of-employees-which-report-to-each-employee/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-to-get-food "Shortest Path to Get Food") 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 fc09fbe71..72715c1e9 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 @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-odd-number-in-string "Largest Odd Number in String") diff --git a/problems/the-number-of-good-subsets/README.md b/problems/the-number-of-good-subsets/README.md index a49615a4b..14eac458b 100644 --- a/problems/the-number-of-good-subsets/README.md +++ b/problems/the-number-of-good-subsets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../operations-on-tree "Operations on Tree") diff --git a/problems/the-number-of-rich-customers/README.md b/problems/the-number-of-rich-customers/README.md new file mode 100644 index 000000000..c9d106c47 --- /dev/null +++ b/problems/the-number-of-rich-customers/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../sum-of-k-mirror-numbers "Sum of k-Mirror Numbers") +                 +[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 "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-number-of-rich-customers/mysql_schemas.sql b/problems/the-number-of-rich-customers/mysql_schemas.sql new file mode 100644 index 000000000..63d1df440 --- /dev/null +++ b/problems/the-number-of-rich-customers/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Store (bill_id int, customer_id int, amount int); +Truncate table Store; +insert into Store (bill_id, customer_id, amount) values ('6', '1', '549'); +insert into Store (bill_id, customer_id, amount) values ('8', '1', '834'); +insert into Store (bill_id, customer_id, amount) values ('4', '2', '394'); +insert into Store (bill_id, customer_id, amount) values ('11', '3', '657'); +insert into Store (bill_id, customer_id, amount) values ('13', '3', '257'); diff --git a/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/README.md b/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/README.md index 59dee44be..3ce1b5c42 100644 --- a/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/README.md +++ b/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-operations-to-make-array-continuous "Minimum Number of Operations to Make Array Continuous") diff --git a/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md b/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md index 5d2216554..b6d5ea3a4 100644 --- a/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md +++ b/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-missing-genetic-value-in-each-subtree "Smallest Missing Genetic Value in Each Subtree") diff --git a/problems/the-number-of-the-smallest-unoccupied-chair/README.md b/problems/the-number-of-the-smallest-unoccupied-chair/README.md index e19e8b297..c5e38453c 100644 --- a/problems/the-number-of-the-smallest-unoccupied-chair/README.md +++ b/problems/the-number-of-the-smallest-unoccupied-chair/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-all-characters-have-equal-number-of-occurrences "Check if All Characters Have Equal Number of Occurrences") diff --git a/problems/the-number-of-weak-characters-in-the-game/README.md b/problems/the-number-of-weak-characters-in-the-game/README.md index 608bbc54e..86f87d699 100644 --- a/problems/the-number-of-weak-characters-in-the-game/README.md +++ b/problems/the-number-of-weak-characters-in-the-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-special-quadruplets "Count Special Quadruplets") 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 f2e092b53..d4f8632b1 100644 --- a/problems/the-score-of-students-solving-math-expression/README.md +++ b/problems/the-score-of-students-solving-math-expression/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-word-can-be-placed-in-crossword "Check if Word Can Be Placed In Crossword") diff --git a/problems/the-time-when-the-network-becomes-idle/README.md b/problems/the-time-when-the-network-becomes-idle/README.md index 5c13d9e49..e3b5677b0 100644 --- a/problems/the-time-when-the-network-becomes-idle/README.md +++ b/problems/the-time-when-the-network-becomes-idle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-colored-pieces-if-both-neighbors-are-the-same-color "Remove Colored Pieces if Both Neighbors are the Same Color") diff --git a/problems/the-winner-university/README.md b/problems/the-winner-university/README.md index e294f698f..aa1d5cf91 100644 --- a/problems/the-winner-university/README.md +++ b/problems/the-winner-university/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-tasks-you-can-assign "Maximum Number of Tasks You Can Assign") diff --git a/problems/thousand-separator/README.md b/problems/thousand-separator/README.md index 40056c61b..66c20c984 100644 --- a/problems/thousand-separator/README.md +++ b/problems/thousand-separator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bank-account-summary "Bank Account Summary") @@ -11,7 +11,7 @@ ## [1556. Thousand Separator (Easy)](https://leetcode.com/problems/thousand-separator "千位分隔数") -

    Given an integer n, add a dot (".") as the thousands separator and return it in string format.

    +

    Given an integer n, add a dot (".") as the thousands separator and return it in string format.

     

    Example 1:

    @@ -46,7 +46,7 @@

    Constraints:

      -
    • 0 <= n < 2^31
    • +
    • 0 <= n < 231
    ### Related Topics diff --git a/problems/three-consecutive-odds/README.md b/problems/three-consecutive-odds/README.md index 89b1e53d8..fae398752 100644 --- a/problems/three-consecutive-odds/README.md +++ b/problems/three-consecutive-odds/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-most-recent-orders-for-each-product "The Most Recent Orders for Each Product") diff --git a/problems/three-divisors/README.md b/problems/three-divisors/README.md index ba9064fd6..259c755b3 100644 --- a/problems/three-divisors/README.md +++ b/problems/three-divisors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-the-pairs-with-the-maximum-number-of-common-followers "All the Pairs With the Maximum Number of Common Followers") diff --git a/problems/three-equal-parts/README.md b/problems/three-equal-parts/README.md index 847224192..275dd7810 100644 --- a/problems/three-equal-parts/README.md +++ b/problems/three-equal-parts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flip-string-to-monotone-increasing "Flip String to Monotone Increasing") diff --git a/problems/throne-inheritance/README.md b/problems/throne-inheritance/README.md index 781baf8df..1c639babc 100644 --- a/problems/throne-inheritance/README.md +++ b/problems/throne-inheritance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-profit-of-operating-a-centennial-wheel "Maximum Profit of Operating a Centennial Wheel") @@ -81,13 +81,10 @@ 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)] - -### Similar Questions - 1. [Operations on Tree](../operations-on-tree) (Medium) + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/tiling-a-rectangle-with-the-fewest-squares/README.md b/problems/tiling-a-rectangle-with-the-fewest-squares/README.md index d7912de1a..1c2d357e2 100644 --- a/problems/tiling-a-rectangle-with-the-fewest-squares/README.md +++ b/problems/tiling-a-rectangle-with-the-fewest-squares/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-length-of-a-concatenated-string-with-unique-characters "Maximum Length of a Concatenated String with Unique Characters") diff --git a/problems/time-based-key-value-store/README.md b/problems/time-based-key-value-store/README.md index 9eb998f86..3905deed8 100644 --- a/problems/time-based-key-value-store/README.md +++ b/problems/time-based-key-value-store/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-paths-iii "Unique Paths III") diff --git a/problems/time-needed-to-buy-tickets/README.md b/problems/time-needed-to-buy-tickets/README.md index 841c55630..5fd112421 100644 --- a/problems/time-needed-to-buy-tickets/README.md +++ b/problems/time-needed-to-buy-tickets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-winner-university "The Winner University") diff --git a/problems/to-lower-case/README.md b/problems/to-lower-case/README.md index 16573fc70..5b2bc0157 100644 --- a/problems/to-lower-case/README.md +++ b/problems/to-lower-case/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../insert-into-a-sorted-circular-linked-list "Insert into a Sorted Circular Linked List") diff --git a/problems/toeplitz-matrix/README.md b/problems/toeplitz-matrix/README.md index 65ec493f2..c9dffec1b 100644 --- a/problems/toeplitz-matrix/README.md +++ b/problems/toeplitz-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../couples-holding-hands "Couples Holding Hands") diff --git a/problems/top-k-frequent-words/README.md b/problems/top-k-frequent-words/README.md index abcce3c55..333a0533c 100644 --- a/problems/top-k-frequent-words/README.md +++ b/problems/top-k-frequent-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stickers-to-spell-word "Stickers to Spell Word") diff --git a/problems/top-travellers/README.md b/problems/top-travellers/README.md index a0727269f..8e18a5b3a 100644 --- a/problems/top-travellers/README.md +++ b/problems/top-travellers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-iii "Stone Game III") diff --git a/problems/toss-strange-coins/README.md b/problems/toss-strange-coins/README.md index 6cbfe92fc..045ee166b 100644 --- a/problems/toss-strange-coins/README.md +++ b/problems/toss-strange-coins/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../meeting-scheduler "Meeting Scheduler") diff --git a/problems/total-hamming-distance/README.md b/problems/total-hamming-distance/README.md index 8f56b545d..6ec41c314 100644 --- a/problems/total-hamming-distance/README.md +++ b/problems/total-hamming-distance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-complement "Number Complement") @@ -44,9 +44,9 @@ HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2 ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Hamming Distance](../hamming-distance) (Easy) diff --git a/problems/tournament-winners/README.md b/problems/tournament-winners/README.md index 717780007..0453627de 100644 --- a/problems/tournament-winners/README.md +++ b/problems/tournament-winners/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../monthly-transactions-i "Monthly Transactions I") diff --git a/problems/traffic-light-controlled-intersection/README.md b/problems/traffic-light-controlled-intersection/README.md index 6c358b949..818d55bd4 100644 --- a/problems/traffic-light-controlled-intersection/README.md +++ b/problems/traffic-light-controlled-intersection/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindrome-partitioning-iii "Palindrome Partitioning III") diff --git a/problems/transpose-file/README.md b/problems/transpose-file/README.md index dfc56ba85..4555a5929 100644 --- a/problems/transpose-file/README.md +++ b/problems/transpose-file/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-phone-numbers "Valid Phone Numbers") diff --git a/problems/transpose-matrix/README.md b/problems/transpose-matrix/README.md index 1afcf2daa..df3a7aaa6 100644 --- a/problems/transpose-matrix/README.md +++ b/problems/transpose-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../prime-palindrome "Prime Palindrome") diff --git a/problems/trapping-rain-water-ii/README.md b/problems/trapping-rain-water-ii/README.md index 4455c7d46..d7f037184 100644 --- a/problems/trapping-rain-water-ii/README.md +++ b/problems/trapping-rain-water-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../queue-reconstruction-by-height "Queue Reconstruction by Height") @@ -20,7 +20,7 @@ Input: heightMap = [[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]] Output: 4 Explanation: After the rain, water is trapped between the blocks. -We have two small pounds 1 and 3 units trapped. +We have two small ponds 1 and 3 units trapped. The total volume of water trapped is 4. @@ -42,10 +42,10 @@ The total volume of water trapped is 4. ### Related Topics - [[Array](../../tag/array/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Trapping Rain Water](../trapping-rain-water) (Hard) diff --git a/problems/tree-diameter/README.md b/problems/tree-diameter/README.md index 05ef3b089..2deb63430 100644 --- a/problems/tree-diameter/README.md +++ b/problems/tree-diameter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-a-leaderboard "Design A Leaderboard") @@ -53,6 +53,9 @@ A longest path of the tree is the path 3 - 2 - 1 - 4 - 5. [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] +### Similar Questions + 1. [Count Subtrees With Max Distance Between Cities](../count-subtrees-with-max-distance-between-cities) (Hard) + ### Hints
    Hint 1 diff --git a/problems/tree-node/README.md b/problems/tree-node/README.md index bc70c3fcd..fb7de2645 100644 --- a/problems/tree-node/README.md +++ b/problems/tree-node/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sales-person "Sales Person") diff --git a/problems/tree-node/mysql_schemas.sql b/problems/tree-node/mysql_schemas.sql index 4511b7280..85a4aefaa 100644 --- a/problems/tree-node/mysql_schemas.sql +++ b/problems/tree-node/mysql_schemas.sql @@ -1,7 +1,7 @@ -Create table If Not Exists tree (id int, p_id int); -Truncate table tree; -insert into tree (id, p_id) values ('1', 'None'); -insert into tree (id, p_id) values ('2', '1'); -insert into tree (id, p_id) values ('3', '1'); -insert into tree (id, p_id) values ('4', '2'); -insert into tree (id, p_id) values ('5', '2'); +Create table If Not Exists Tree (id int, p_id int); +Truncate table Tree; +insert into Tree (id, p_id) values ('1', 'None'); +insert into Tree (id, p_id) values ('2', '1'); +insert into Tree (id, p_id) values ('3', '1'); +insert into Tree (id, p_id) values ('4', '2'); +insert into Tree (id, p_id) values ('5', '2'); diff --git a/problems/tree-of-coprimes/README.md b/problems/tree-of-coprimes/README.md index d1a8325d0..14026bb81 100644 --- a/problems/tree-of-coprimes/README.md +++ b/problems/tree-of-coprimes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../map-of-highest-peak "Map of Highest Peak") diff --git a/problems/triangle-judgement/README.md b/problems/triangle-judgement/README.md index e1ddb081d..c2e4a3e2d 100644 --- a/problems/triangle-judgement/README.md +++ b/problems/triangle-judgement/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-duplicate-file-in-system "Find Duplicate File in System") diff --git a/problems/triangle-judgement/mysql_schemas.sql b/problems/triangle-judgement/mysql_schemas.sql index 11cad442d..3f64d0d37 100644 --- a/problems/triangle-judgement/mysql_schemas.sql +++ b/problems/triangle-judgement/mysql_schemas.sql @@ -1,4 +1,4 @@ -Create table If Not Exists triangle (x int, y int, z int); -Truncate table triangle; -insert into triangle (x, y, z) values ('13', '15', '30'); -insert into triangle (x, y, z) values ('10', '20', '15'); +Create table If Not Exists Triangle (x int, y int, z int); +Truncate table Triangle; +insert into Triangle (x, y, z) values ('13', '15', '30'); +insert into Triangle (x, y, z) values ('10', '20', '15'); diff --git a/problems/triples-with-bitwise-and-equal-to-zero/README.md b/problems/triples-with-bitwise-and-equal-to-zero/README.md index f8188c11b..289e966c4 100644 --- a/problems/triples-with-bitwise-and-equal-to-zero/README.md +++ b/problems/triples-with-bitwise-and-equal-to-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../time-based-key-value-store "Time Based Key-Value Store") @@ -59,6 +59,6 @@ ### 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)] diff --git a/problems/truncate-sentence/README.md b/problems/truncate-sentence/README.md index 73f173b14..80201d24e 100644 --- a/problems/truncate-sentence/README.md +++ b/problems/truncate-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-groups-getting-fresh-donuts "Maximum Number of Groups Getting Fresh Donuts") diff --git a/problems/tuple-with-same-product/README.md b/problems/tuple-with-same-product/README.md index b286e0912..89f9e7bd6 100644 --- a/problems/tuple-with-same-product/README.md +++ b/problems/tuple-with-same-product/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-rectangles-that-can-form-the-largest-square "Number Of Rectangles That Can Form The Largest Square") diff --git a/problems/tweet-counts-per-frequency/README.md b/problems/tweet-counts-per-frequency/README.md index f928815fb..ec49dcb06 100644 --- a/problems/tweet-counts-per-frequency/README.md +++ b/problems/tweet-counts-per-frequency/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-steps-to-make-two-strings-anagram "Minimum Number of Steps to Make Two Strings Anagram") diff --git a/problems/two-best-non-overlapping-events/README.md b/problems/two-best-non-overlapping-events/README.md index 85ace1a73..4526374a2 100644 --- a/problems/two-best-non-overlapping-events/README.md +++ b/problems/two-best-non-overlapping-events/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-distinct-string-in-an-array "Kth Distinct String in an Array") diff --git a/problems/two-furthest-houses-with-different-colors/README.md b/problems/two-furthest-houses-with-different-colors/README.md new file mode 100644 index 000000000..0cb4b8ae4 --- /dev/null +++ b/problems/two-furthest-houses-with-different-colors/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../paths-in-maze-that-lead-to-same-room "Paths in Maze That Lead to Same Room") +                 +[Next >](../watering-plants "Watering Plants") + +## [2078. Two Furthest Houses With Different Colors (Easy)](https://leetcode.com/problems/two-furthest-houses-with-different-colors "两栋颜色不同且距离最远的房子") + +

    There are n houses evenly lined up on the street, and each house is beautifully painted. You are given a 0-indexed integer array colors of length n, where colors[i] represents the color of the ith house.

    + +

    Return the maximum distance between two houses with different colors.

    + +

    The distance between the ith and jth houses is abs(i - j), where abs(x) is the absolute value of x.

    + +

     

    +

    Example 1:

    + +
    +Input: colors = [1,1,1,6,1,1,1]
    +Output: 3
    +Explanation: In the above image, color 1 is blue, and color 6 is red.
    +The furthest two houses with different colors are house 0 and house 3.
    +House 0 has color 1, and house 3 has color 6. The distance between them is abs(0 - 3) = 3.
    +Note that houses 3 and 6 can also produce the optimal answer.
    +
    + +

    Example 2:

    + +
    +Input: colors = [1,8,3,8,3]
    +Output: 4
    +Explanation: In the above image, color 1 is blue, color 8 is yellow, and color 3 is green.
    +The furthest two houses with different colors are house 0 and house 4.
    +House 0 has color 1, and house 4 has color 3. The distance between them is abs(0 - 4) = 4.
    +
    + +

    Example 3:

    + +
    +Input: colors = [0,1]
    +Output: 1
    +Explanation: The furthest two houses with different colors are house 0 and house 1.
    +House 0 has color 0, and house 1 has color 1. The distance between them is abs(0 - 1) = 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == colors.length
    • +
    • 2 <= n <= 100
    • +
    • 0 <= colors[i] <= 100
    • +
    • Test data are generated such that at least two houses have different colors.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +The constraints are small. Can you try the combination of every two houses? +
    + +
    +Hint 2 +Greedily, the maximum distance will come from either the pair of the leftmost house and possibly some house on the right with a different color, or the pair of the rightmost house and possibly some house on the left with a different color. +
    diff --git a/problems/two-out-of-three/README.md b/problems/two-out-of-three/README.md index fa79fcd67..176e64f08 100644 --- a/problems/two-out-of-three/README.md +++ b/problems/two-out-of-three/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-subarrays-with-more-ones-than-zeros "Count Subarrays With More Ones Than Zeros") diff --git a/problems/two-sum-bsts/README.md b/problems/two-sum-bsts/README.md index a4e10f687..a8e816200 100644 --- a/problems/two-sum-bsts/README.md +++ b/problems/two-sum-bsts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../intersection-of-three-sorted-arrays "Intersection of Three Sorted Arrays") diff --git a/problems/two-sum-iv-input-is-a-bst/README.md b/problems/two-sum-iv-input-is-a-bst/README.md index 4f5748895..098f7ab54 100644 --- a/problems/two-sum-iv-input-is-a-bst/README.md +++ b/problems/two-sum-iv-input-is-a-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-duplicate-subtrees "Find Duplicate Subtrees") @@ -70,6 +70,6 @@ ### Similar Questions 1. [Two Sum](../two-sum) (Easy) - 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) (Easy) 1. [Two Sum III - Data structure design](../two-sum-iii-data-structure-design) (Easy) 1. [Two Sum BSTs](../two-sum-bsts) (Medium) diff --git a/problems/two-sum-less-than-k/README.md b/problems/two-sum-less-than-k/README.md index f925185a8..396a01979 100644 --- a/problems/two-sum-less-than-k/README.md +++ b/problems/two-sum-less-than-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unpopular-books "Unpopular Books") @@ -51,7 +51,7 @@ In this case it's not possible to get a pair sum less that 15. ### Similar Questions 1. [Two Sum](../two-sum) (Easy) - 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) (Easy) 1. [3Sum Smaller](../3sum-smaller) (Medium) 1. [Subarray Product Less Than K](../subarray-product-less-than-k) (Medium) diff --git a/problems/ugly-number-iii/README.md b/problems/ugly-number-iii/README.md index b08dd80e8..0790cc0c7 100644 --- a/problems/ugly-number-iii/README.md +++ b/problems/ugly-number-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-absolute-difference "Minimum Absolute Difference") diff --git a/problems/uncommon-words-from-two-sentences/README.md b/problems/uncommon-words-from-two-sentences/README.md index f94135705..f4921ce8a 100644 --- a/problems/uncommon-words-from-two-sentences/README.md +++ b/problems/uncommon-words-from-two-sentences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../projection-area-of-3d-shapes "Projection Area of 3D Shapes") diff --git a/problems/unique-email-addresses/README.md b/problems/unique-email-addresses/README.md index 06949920b..755ffc50b 100644 --- a/problems/unique-email-addresses/README.md +++ b/problems/unique-email-addresses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-malware-spread-ii "Minimize Malware Spread II") diff --git a/problems/unique-length-3-palindromic-subsequences/README.md b/problems/unique-length-3-palindromic-subsequences/README.md index 8a0332d26..842141df7 100644 --- a/problems/unique-length-3-palindromic-subsequences/README.md +++ b/problems/unique-length-3-palindromic-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../concatenation-of-array "Concatenation of Array") diff --git a/problems/unique-morse-code-words/README.md b/problems/unique-morse-code-words/README.md index 0e40378c8..cc8a0767d 100644 --- a/problems/unique-morse-code-words/README.md +++ b/problems/unique-morse-code-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bricks-falling-when-hit "Bricks Falling When Hit") diff --git a/problems/unique-number-of-occurrences/README.md b/problems/unique-number-of-occurrences/README.md index 7b6144b8a..9340795c8 100644 --- a/problems/unique-number-of-occurrences/README.md +++ b/problems/unique-number-of-occurrences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-skiplist "Design Skiplist") diff --git a/problems/unique-orders-and-customers-per-month/README.md b/problems/unique-orders-and-customers-per-month/README.md index 3bf932182..be33a1b8b 100644 --- a/problems/unique-orders-and-customers-per-month/README.md +++ b/problems/unique-orders-and-customers-per-month/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../put-boxes-into-the-warehouse-i "Put Boxes Into the Warehouse I") diff --git a/problems/unique-paths-iii/README.md b/problems/unique-paths-iii/README.md index 852b22a75..23d0cdfc2 100644 --- a/problems/unique-paths-iii/README.md +++ b/problems/unique-paths-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distribute-coins-in-binary-tree "Distribute Coins in Binary Tree") @@ -67,9 +67,9 @@ Note that the starting and ending square can be anywhere in the grid. ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions diff --git a/problems/univalued-binary-tree/README.md b/problems/univalued-binary-tree/README.md index a0f8bd91b..2c9f33f16 100644 --- a/problems/univalued-binary-tree/README.md +++ b/problems/univalued-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../least-operators-to-express-number "Least Operators to Express Number") @@ -43,3 +43,6 @@ [[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 + 1. [Find All The Lonely Nodes](../find-all-the-lonely-nodes) (Easy) diff --git a/problems/unpopular-books/README.md b/problems/unpopular-books/README.md index 4cd9e3c91..3eae0fff4 100644 --- a/problems/unpopular-books/README.md +++ b/problems/unpopular-books/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../game-play-analysis-v "Game Play Analysis V") diff --git a/problems/user-activity-for-the-past-30-days-ii/README.md b/problems/user-activity-for-the-past-30-days-ii/README.md index 17466257b..798f30669 100644 --- a/problems/user-activity-for-the-past-30-days-ii/README.md +++ b/problems/user-activity-for-the-past-30-days-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../user-activity-for-the-past-30-days-i "User Activity for the Past 30 Days I") diff --git a/problems/user-purchase-platform/README.md b/problems/user-purchase-platform/README.md index 7b5fe2a5e..6fce28e7c 100644 --- a/problems/user-purchase-platform/README.md +++ b/problems/user-purchase-platform/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../active-businesses "Active Businesses") diff --git a/problems/users-that-actively-request-confirmation-messages/README.md b/problems/users-that-actively-request-confirmation-messages/README.md index 291046281..1b94ef273 100644 --- a/problems/users-that-actively-request-confirmation-messages/README.md +++ b/problems/users-that-actively-request-confirmation-messages/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-genetic-difference-query "Maximum Genetic Difference Query") diff --git a/problems/utf-8-validation/README.md b/problems/utf-8-validation/README.md index 2655a7631..cbbf134ce 100644 --- a/problems/utf-8-validation/README.md +++ b/problems/utf-8-validation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../is-subsequence "Is Subsequence") @@ -64,8 +64,8 @@ But the second continuation byte does not start with 10, so it is invalid. ### Related Topics - [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/valid-anagram/README.md b/problems/valid-anagram/README.md index f4b1d90dd..782c3336d 100644 --- a/problems/valid-anagram/README.md +++ b/problems/valid-anagram/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../different-ways-to-add-parentheses "Different Ways to Add Parentheses") diff --git a/problems/valid-boomerang/README.md b/problems/valid-boomerang/README.md index f7e813c3d..5cd0d3c99 100644 --- a/problems/valid-boomerang/README.md +++ b/problems/valid-boomerang/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../escape-a-large-maze "Escape a Large Maze") diff --git a/problems/valid-parenthesis-string/README.md b/problems/valid-parenthesis-string/README.md index c95daefdb..b4ce17b44 100644 --- a/problems/valid-parenthesis-string/README.md +++ b/problems/valid-parenthesis-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../map-sum-pairs "Map Sum Pairs") diff --git a/problems/valid-perfect-square/README.md b/problems/valid-perfect-square/README.md index d014f8517..cc1cf1509 100644 --- a/problems/valid-perfect-square/README.md +++ b/problems/valid-perfect-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-leaves-of-binary-tree "Find Leaves of Binary Tree") diff --git a/problems/valid-phone-numbers/README.md b/problems/valid-phone-numbers/README.md index e12d2952a..0f7a3f58e 100644 --- a/problems/valid-phone-numbers/README.md +++ b/problems/valid-phone-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-frequency "Word Frequency") diff --git a/problems/valid-square/README.md b/problems/valid-square/README.md index b3ff9993f..0d0c4f5cb 100644 --- a/problems/valid-square/README.md +++ b/problems/valid-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fraction-addition-and-subtraction "Fraction Addition and Subtraction") diff --git a/problems/valid-tic-tac-toe-state/README.md b/problems/valid-tic-tac-toe-state/README.md index e9993467e..fde5d893b 100644 --- a/problems/valid-tic-tac-toe-state/README.md +++ b/problems/valid-tic-tac-toe-state/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../preimage-size-of-factorial-zeroes-function "Preimage Size of Factorial Zeroes Function") diff --git a/problems/valid-triangle-number/README.md b/problems/valid-triangle-number/README.md index 5cd750359..abf3295a3 100644 --- a/problems/valid-triangle-number/README.md +++ b/problems/valid-triangle-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../triangle-judgement "Triangle Judgement") diff --git a/problems/validate-binary-search-tree/README.md b/problems/validate-binary-search-tree/README.md index 47b796017..889fb70ee 100644 --- a/problems/validate-binary-search-tree/README.md +++ b/problems/validate-binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../interleaving-string "Interleaving String") diff --git a/problems/validate-binary-tree-nodes/README.md b/problems/validate-binary-tree-nodes/README.md index c6ad1fd5a..a972d39a9 100644 --- a/problems/validate-binary-tree-nodes/README.md +++ b/problems/validate-binary-tree-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-days-between-two-dates "Number of Days Between Two Dates") diff --git a/problems/verbal-arithmetic-puzzle/README.md b/problems/verbal-arithmetic-puzzle/README.md index a3b625841..9982377e8 100644 --- a/problems/verbal-arithmetic-puzzle/README.md +++ b/problems/verbal-arithmetic-puzzle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game-iii "Jump Game III") diff --git a/problems/verify-preorder-sequence-in-binary-search-tree/README.md b/problems/verify-preorder-sequence-in-binary-search-tree/README.md index e9f1f0553..1eabfacad 100644 --- a/problems/verify-preorder-sequence-in-binary-search-tree/README.md +++ b/problems/verify-preorder-sequence-in-binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../factor-combinations "Factor Combinations") @@ -44,8 +44,8 @@ Could you do it using only constant space complexity?

    [[Tree](../../tag/tree/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Recursion](../../tag/recursion/README.md)] - [[Binary Tree](../../tag/binary-tree/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Easy) diff --git a/problems/verify-preorder-serialization-of-a-binary-tree/README.md b/problems/verify-preorder-serialization-of-a-binary-tree/README.md index 48029e149..b598c3005 100644 --- a/problems/verify-preorder-serialization-of-a-binary-tree/README.md +++ b/problems/verify-preorder-serialization-of-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../patching-array "Patching Array") diff --git a/problems/vertical-order-traversal-of-a-binary-tree/README.md b/problems/vertical-order-traversal-of-a-binary-tree/README.md index 9c6cd7974..b82b15314 100644 --- a/problems/vertical-order-traversal-of-a-binary-tree/README.md +++ b/problems/vertical-order-traversal-of-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../interval-list-intersections "Interval List Intersections") @@ -65,8 +65,8 @@ Note that the solution remains the same since 5 and 6 are in the same location a ### 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/vowels-of-all-substrings/README.md b/problems/vowels-of-all-substrings/README.md index b16c802cf..3d35932cd 100644 --- a/problems/vowels-of-all-substrings/README.md +++ b/problems/vowels-of-all-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-vowel-substrings-of-a-string "Count Vowel Substrings of a String") diff --git a/problems/walking-robot-simulation-ii/README.md b/problems/walking-robot-simulation-ii/README.md index 681dc572e..89f18a29f 100644 --- a/problems/walking-robot-simulation-ii/README.md +++ b/problems/walking-robot-simulation-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-whether-two-strings-are-almost-equivalent "Check Whether Two Strings are Almost Equivalent") diff --git a/problems/warehouse-manager/README.md b/problems/warehouse-manager/README.md index 33d84cfec..1bd5e33f8 100644 --- a/problems/warehouse-manager/README.md +++ b/problems/warehouse-manager/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../dot-product-of-two-sparse-vectors "Dot Product of Two Sparse Vectors") diff --git a/problems/water-bottles/README.md b/problems/water-bottles/README.md index 5df550788..a12dce419 100644 --- a/problems/water-bottles/README.md +++ b/problems/water-bottles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-users-with-valid-e-mails "Find Users With Valid E-Mails") diff --git a/problems/watering-plants/README.md b/problems/watering-plants/README.md new file mode 100644 index 000000000..a130195d4 --- /dev/null +++ b/problems/watering-plants/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../two-furthest-houses-with-different-colors "Two Furthest Houses With Different Colors") +                 +[Next >](../range-frequency-queries "Range Frequency Queries") + +## [2079. Watering Plants (Medium)](https://leetcode.com/problems/watering-plants "给植物浇水") + +

    You want to water n plants in your garden with a watering can. 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. There is a river at x = -1 that you can refill your watering can at.

    + +

    Each plant needs a specific amount of water. You will water the plants in the following way:

    + +
      +
    • Water the plants in order from left to right.
    • +
    • After watering the current plant, if you do not have enough water to completely water the next plant, return to the river to fully refill the watering can.
    • +
    • You cannot refill the watering can early.
    • +
    + +

    You are initially at the river (i.e., x = -1). It takes one step to move one unit on the x-axis.

    + +

    Given a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and an integer capacity representing the watering can capacity, return the number of steps needed to water all the plants.

    + +

     

    +

    Example 1:

    + +
    +Input: plants = [2,2,3,3], capacity = 5
    +Output: 14
    +Explanation: Start at the river with a full watering can:
    +- Walk to plant 0 (1 step) and water it. Watering can has 3 units of water.
    +- Walk to plant 1 (1 step) and water it. Watering can has 1 unit of water.
    +- Since you cannot completely water plant 2, walk back to the river to refill (2 steps).
    +- Walk to plant 2 (3 steps) and water it. Watering can has 2 units of water.
    +- Since you cannot completely water plant 3, walk back to the river to refill (3 steps).
    +- Walk to plant 3 (4 steps) and water it.
    +Steps needed = 1 + 1 + 2 + 3 + 3 + 4 = 14.
    +
    + +

    Example 2:

    + +
    +Input: plants = [1,1,1,4,2,3], capacity = 4
    +Output: 30
    +Explanation: Start at the river with a full watering can:
    +- Water plants 0, 1, and 2 (3 steps). Return to river (3 steps).
    +- Water plant 3 (4 steps). Return to river (4 steps).
    +- Water plant 4 (5 steps). Return to river (5 steps).
    +- Water plant 5 (6 steps).
    +Steps needed = 3 + 3 + 4 + 4 + 5 + 5 + 6 = 30.
    +
    + +

    Example 3:

    + +
    +Input: plants = [7,7,7,7,7,7,7], capacity = 8
    +Output: 49
    +Explanation: You have to refill before watering each plant.
    +Steps needed = 1 + 1 + 2 + 2 + 3 + 3 + 4 + 4 + 5 + 5 + 6 + 6 + 7 = 49.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == plants.length
    • +
    • 1 <= n <= 1000
    • +
    • 1 <= plants[i] <= 106
    • +
    • max(plants[i]) <= capacity <= 109
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Simulate the process. +
    + +
    +Hint 2 +Return to refill the container once you meet a plant that needs more water than you have. +
    diff --git a/problems/ways-to-make-a-fair-array/README.md b/problems/ways-to-make-a-fair-array/README.md index 6915c63e6..b09a128d7 100644 --- a/problems/ways-to-make-a-fair-array/README.md +++ b/problems/ways-to-make-a-fair-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-string-with-a-given-numeric-value "Smallest String With A Given Numeric Value") 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 79d91c75e..543aad389 100644 --- a/problems/ways-to-split-array-into-three-subarrays/README.md +++ b/problems/ways-to-split-array-into-three-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-good-meals "Count Good Meals") diff --git a/problems/web-crawler-multithreaded/README.md b/problems/web-crawler-multithreaded/README.md index aea83a6c6..40b986e48 100644 --- a/problems/web-crawler-multithreaded/README.md +++ b/problems/web-crawler-multithreaded/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-comments-per-post "Number of Comments per Post") diff --git a/problems/web-crawler/README.md b/problems/web-crawler/README.md index edd39af60..e6bd65041 100644 --- a/problems/web-crawler/README.md +++ b/problems/web-crawler/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-profit-in-job-scheduling "Maximum Profit in Job Scheduling") @@ -93,11 +93,14 @@ startUrl = "http://news.google.com" ### Related Topics + [[String](../../tag/string/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[String](../../tag/string/README.md)] [[Interactive](../../tag/interactive/README.md)] +### Similar Questions + 1. [Web Crawler Multithreaded](../web-crawler-multithreaded) (Medium) + ### Hints
    Hint 1 diff --git a/problems/where-will-the-ball-fall/README.md b/problems/where-will-the-ball-fall/README.md index 130043f1b..62d5babec 100644 --- a/problems/where-will-the-ball-fall/README.md +++ b/problems/where-will-the-ball-fall/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-eaten-apples "Maximum Number of Eaten Apples") @@ -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/widest-pair-of-indices-with-equal-range-sum/README.md b/problems/widest-pair-of-indices-with-equal-range-sum/README.md index e0979d352..03bb08145 100644 --- a/problems/widest-pair-of-indices-with-equal-range-sum/README.md +++ b/problems/widest-pair-of-indices-with-equal-range-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-array-given-subset-sums "Find Array Given Subset Sums") diff --git a/problems/widest-vertical-area-between-two-points-containing-no-points/README.md b/problems/widest-vertical-area-between-two-points-containing-no-points/README.md index 6f79021ca..9e0d052f3 100644 --- a/problems/widest-vertical-area-between-two-points-containing-no-points/README.md +++ b/problems/widest-vertical-area-between-two-points-containing-no-points/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-array-by-increasing-frequency "Sort Array by Increasing Frequency") diff --git a/problems/wildcard-matching/README.md b/problems/wildcard-matching/README.md index d9d3561f2..1230d3ff7 100644 --- a/problems/wildcard-matching/README.md +++ b/problems/wildcard-matching/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../multiply-strings "Multiply Strings") @@ -70,10 +70,10 @@ ### Related Topics - [[String](../../tag/string/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Regular Expression Matching](../regular-expression-matching) (Hard) diff --git a/problems/word-break-ii/README.md b/problems/word-break-ii/README.md index 7cb8189ef..2442e9ffc 100644 --- a/problems/word-break-ii/README.md +++ b/problems/word-break-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-break "Word Break") @@ -50,12 +50,12 @@ ### Related Topics - [[Trie](../../tag/trie/README.md)] - [[Memoization](../../tag/memoization/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Memoization](../../tag/memoization/README.md)] ### Similar Questions 1. [Word Break](../word-break) (Medium) diff --git a/problems/word-break/README.md b/problems/word-break/README.md index 1f1e3d229..13cb790a8 100644 --- a/problems/word-break/README.md +++ b/problems/word-break/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../copy-list-with-random-pointer "Copy List with Random Pointer") diff --git a/problems/word-frequency/README.md b/problems/word-frequency/README.md index 4ffb16244..6948c18ae 100644 --- a/problems/word-frequency/README.md +++ b/problems/word-frequency/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-1-bits "Number of 1 Bits") diff --git a/problems/word-ladder-ii/README.md b/problems/word-ladder-ii/README.md index 947eec7f7..fd36368df 100644 --- a/problems/word-ladder-ii/README.md +++ b/problems/word-ladder-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-palindrome "Valid Palindrome") diff --git a/problems/word-ladder/README.md b/problems/word-ladder/README.md index 410e3dd19..8a73d975c 100644 --- a/problems/word-ladder/README.md +++ b/problems/word-ladder/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-ladder-ii "Word Ladder II") diff --git a/problems/word-pattern/README.md b/problems/word-pattern/README.md index 043632042..9a39a81df 100644 --- a/problems/word-pattern/README.md +++ b/problems/word-pattern/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../game-of-life "Game of Life") diff --git a/problems/word-search-ii/README.md b/problems/word-search-ii/README.md index 10b6d62b4..65fb04542 100644 --- a/problems/word-search-ii/README.md +++ b/problems/word-search-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-add-and-search-words-data-structure "Design Add and Search Words Data Structure") @@ -45,10 +45,10 @@ ### 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)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions diff --git a/problems/word-squares/README.md b/problems/word-squares/README.md index 86cd4ce96..05908d666 100644 --- a/problems/word-squares/README.md +++ b/problems/word-squares/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-repeating-character-replacement "Longest Repeating Character Replacement") diff --git a/problems/xor-queries-of-a-subarray/README.md b/problems/xor-queries-of-a-subarray/README.md index 5b92b9e83..90df382e7 100644 --- a/problems/xor-queries-of-a-subarray/README.md +++ b/problems/xor-queries-of-a-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decrypt-string-from-alphabet-to-integer-mapping "Decrypt String from Alphabet to Integer Mapping") @@ -11,7 +11,12 @@ ## [1310. XOR Queries of a Subarray (Medium)](https://leetcode.com/problems/xor-queries-of-a-subarray "子数组异或查询") -Given the array arr of positive integers and the array queries where queries[i] = [Li, Ri], for each query i compute the XOR of elements from Li to Ri (that is, arr[Li] xor arr[Li+1] xor ... xor arr[Ri] ). Return an array containing the result for the given queries. +

    You are given an array arr of positive integers. You are also given the array queries where queries[i] = [lefti, righti].

    + +

    For each query i compute the XOR of elements from lefti to righti (that is, arr[lefti] XOR arr[lefti + 1] XOR ... XOR arr[righti] ).

    + +

    Return an array answer where answer[i] is the answer to the ith query.

    +

     

    Example 1:

    @@ -42,11 +47,10 @@ The XOR values for queries are:

    Constraints:

      -
    • 1 <= arr.length <= 3 * 10^4
    • -
    • 1 <= arr[i] <= 10^9
    • -
    • 1 <= queries.length <= 3 * 10^4
    • +
    • 1 <= arr.length, queries.length <= 3 * 104
    • +
    • 1 <= arr[i] <= 109
    • queries[i].length == 2
    • -
    • 0 <= queries[i][0] <= queries[i][1] < arr.length
    • +
    • 0 <= lefti <= righti < arr.length
    ### Related Topics diff --git a/problems/zigzag-iterator/README.md b/problems/zigzag-iterator/README.md index 7ca1fe411..9c3ae3609 100644 --- a/problems/zigzag-iterator/README.md +++ b/problems/zigzag-iterator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../wiggle-sort "Wiggle Sort") diff --git a/readme/1-300.md b/readme/1-300.md index fa535c2e6..a4db89dcb 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -1,78 +1,78 @@ - - - + + + -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![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][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]
    diff --git a/readme/1201-1500.md b/readme/1201-1500.md index bacd2ea5c..8b5c5123a 100644 --- a/readme/1201-1500.md +++ b/readme/1201-1500.md @@ -1,78 +1,78 @@ - - - + + + -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![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][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]
    diff --git a/readme/301-600.md b/readme/301-600.md index 4ebd07acb..d0b689921 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -1,78 +1,78 @@ - - - + + + -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![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][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]
    diff --git a/readme/601-900.md b/readme/601-900.md index 269a32bb0..5ceafc962 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -1,78 +1,78 @@ - - - + + + -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![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][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]
    @@ -314,7 +314,7 @@ LeetCode Problems' Solutions | 834 | [Sum of Distances in Tree](https://leetcode.com/problems/sum-of-distances-in-tree "树中距离之和") | [Go](../problems/sum-of-distances-in-tree) | Hard | | 835 | [Image Overlap](https://leetcode.com/problems/image-overlap "图像重叠") | [Go](../problems/image-overlap) | Medium | | 836 | [Rectangle Overlap](https://leetcode.com/problems/rectangle-overlap "矩形重叠") | [Go](../problems/rectangle-overlap) | Easy | -| 837 | [New 21 Game](https://leetcode.com/problems/new-21-game "新21点") | [Go](../problems/new-21-game) | Medium | +| 837 | [New 21 Game](https://leetcode.com/problems/new-21-game "新 21 点") | [Go](../problems/new-21-game) | Medium | | 838 | [Push Dominoes](https://leetcode.com/problems/push-dominoes "推多米诺") | [Go](../problems/push-dominoes) | Medium | | 839 | [Similar String Groups](https://leetcode.com/problems/similar-string-groups "相似字符串组") | [Go](../problems/similar-string-groups) | Hard | | 840 | [Magic Squares In Grid](https://leetcode.com/problems/magic-squares-in-grid "矩阵中的幻方") | [Go](../problems/magic-squares-in-grid) | Medium | diff --git a/readme/901-1200.md b/readme/901-1200.md index a21552f13..56787b7be 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -1,78 +1,78 @@ - - - + + + -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![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][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]
    diff --git a/tag/README.md b/tag/README.md index 0aab38cdc..a260ae4a8 100644 --- a/tag/README.md +++ b/tag/README.md @@ -1,50 +1,50 @@ - - - + + + ## 话题分类 | # | Topic | 话题 | | # | Topic | 话题 | | :-: | - | :-: | - | :-: | - | :-: | -| 1 | [Array](array/README.md) | [数组](https://openset.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://openset.github.io/tags/dynamic-programming/) | -| 3 | [String](string/README.md) | [字符串](https://openset.github.io/tags/string/) | | 4 | [Math](math/README.md) | [数学](https://openset.github.io/tags/math/) | -| 5 | [Greedy](greedy/README.md) | [贪心](https://openset.github.io/tags/greedy/) | | 6 | [Depth-First Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | -| 7 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 8 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | -| 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-First Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | -| 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | -| 13 | [Backtracking](backtracking/README.md) | [回溯](https://openset.github.io/tags/backtracking/) | | 14 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | -| 15 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | -| 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | -| 19 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 20 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | -| 21 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [滑动窗口](https://openset.github.io/tags/sliding-window/) | -| 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Divide and Conquer](divide-and-conquer/README.md) | [分治](https://openset.github.io/tags/divide-and-conquer/) | -| 25 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 26 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | -| 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | -| 29 | [Line Sweep](line-sweep/README.md) | [扫描线](https://openset.github.io/tags/line-sweep/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | -| 31 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 32 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | -| 33 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 34 | [Dequeue](dequeue/README.md) | [Dequeue](https://openset.github.io/tags/dequeue/) | -| 35 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 36 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | -| 37 | [Rolling Hash](rolling-hash/README.md) | [滚动哈希](https://openset.github.io/tags/rolling-hash/) | | 38 | [Suffix Array](suffix-array/README.md) | [后缀数组](https://openset.github.io/tags/suffix-array/) | -| 39 | [Rejection Sampling](rejection-sampling/README.md) | [拒绝采样](https://openset.github.io/tags/rejection-sampling/) | | 40 | [Reservoir Sampling](reservoir-sampling/README.md) | [水塘抽样](https://openset.github.io/tags/reservoir-sampling/) | -| 41 | [Meet In The Middle](meet-in-the-middle/README.md) | [Meet In The Middle](https://openset.github.io/tags/meet-in-the-middle/) | | 42 | [Memoization](memoization/README.md) | [记忆化搜索](https://openset.github.io/tags/memoization/) | -| 43 | [OOP](oop/README.md) | [OOP](https://openset.github.io/tags/oop/) | | 44 | [Sorting](sorting/README.md) | [排序](https://openset.github.io/tags/sorting/) | -| 45 | [Heap (Priority Queue)](heap-priority-queue/README.md) | [堆(优先队列)](https://openset.github.io/tags/heap-priority-queue/) | | 46 | [Ordered Set](ordered-set/README.md) | [有序集合](https://openset.github.io/tags/ordered-set/) | -| 47 | [Hash Function](hash-function/README.md) | [哈希函数](https://openset.github.io/tags/hash-function/) | | 48 | [String Matching](string-matching/README.md) | [字符串匹配](https://openset.github.io/tags/string-matching/) | -| 49 | [Randomized](randomized/README.md) | [随机化](https://openset.github.io/tags/randomized/) | | 50 | [Prefix Sum](prefix-sum/README.md) | [前缀和](https://openset.github.io/tags/prefix-sum/) | -| 51 | [Probability and Statistics](probability-and-statistics/README.md) | [概率与统计](https://openset.github.io/tags/probability-and-statistics/) | | 52 | [Simulation](simulation/README.md) | [模拟](https://openset.github.io/tags/simulation/) | -| 53 | [Monotonic Queue](monotonic-queue/README.md) | [单调队列](https://openset.github.io/tags/monotonic-queue/) | | 54 | [Data Stream](data-stream/README.md) | [数据流](https://openset.github.io/tags/data-stream/) | -| 55 | [Counting](counting/README.md) | [计数](https://openset.github.io/tags/counting/) | | 56 | [Matrix](matrix/README.md) | [矩阵](https://openset.github.io/tags/matrix/) | -| 57 | [Iterator](iterator/README.md) | [迭代器](https://openset.github.io/tags/iterator/) | | 58 | [Quickselect](quickselect/README.md) | [快速选择](https://openset.github.io/tags/quickselect/) | -| 59 | [Merge Sort](merge-sort/README.md) | [归并排序](https://openset.github.io/tags/merge-sort/) | | 60 | [Binary Tree](binary-tree/README.md) | [二叉树](https://openset.github.io/tags/binary-tree/) | -| 61 | [Combinatorics](combinatorics/README.md) | [组合数学](https://openset.github.io/tags/combinatorics/) | | 62 | [Shortest Path](shortest-path/README.md) | [最短路](https://openset.github.io/tags/shortest-path/) | -| 63 | [Interactive](interactive/README.md) | [交互](https://openset.github.io/tags/interactive/) | | 64 | [Bucket Sort](bucket-sort/README.md) | [桶排序](https://openset.github.io/tags/bucket-sort/) | -| 65 | [Counting Sort](counting-sort/README.md) | [计数排序](https://openset.github.io/tags/counting-sort/) | | 66 | [Radix Sort](radix-sort/README.md) | [基数排序](https://openset.github.io/tags/radix-sort/) | -| 67 | [Monotonic Stack](monotonic-stack/README.md) | [单调栈](https://openset.github.io/tags/monotonic-stack/) | | 68 | [Minimum Spanning Tree](minimum-spanning-tree/README.md) | [最小生成树](https://openset.github.io/tags/minimum-spanning-tree/) | -| 69 | [Strongly Connected Component](strongly-connected-component/README.md) | [强连通分量](https://openset.github.io/tags/strongly-connected-component/) | | 70 | [Game Theory](game-theory/README.md) | [博弈](https://openset.github.io/tags/game-theory/) | -| 71 | [Bitmask](bitmask/README.md) | [状态压缩](https://openset.github.io/tags/bitmask/) | | 72 | [Concurrency](concurrency/README.md) | [多线程](https://openset.github.io/tags/concurrency/) | -| 73 | [Doubly-Linked List](doubly-linked-list/README.md) | [双向链表](https://openset.github.io/tags/doubly-linked-list/) | | 74 | [Enumeration](enumeration/README.md) | [枚举](https://openset.github.io/tags/enumeration/) | -| 75 | [Number Theory](number-theory/README.md) | [数论](https://openset.github.io/tags/number-theory/) | | 76 | [Biconnected Component](biconnected-component/README.md) | [双连通分量](https://openset.github.io/tags/biconnected-component/) | -| 77 | [Eulerian Circuit](eulerian-circuit/README.md) | [欧拉回路](https://openset.github.io/tags/eulerian-circuit/) | \ No newline at end of file +| 1 | [Array](array/README.md) | [数组](https://awesee.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://awesee.github.io/tags/dynamic-programming/) | +| 3 | [String](string/README.md) | [字符串](https://awesee.github.io/tags/string/) | | 4 | [Math](math/README.md) | [数学](https://awesee.github.io/tags/math/) | +| 5 | [Greedy](greedy/README.md) | [贪心](https://awesee.github.io/tags/greedy/) | | 6 | [Depth-First Search](depth-first-search/README.md) | [深度优先搜索](https://awesee.github.io/tags/depth-first-search/) | +| 7 | [Tree](tree/README.md) | [树](https://awesee.github.io/tags/tree/) | | 8 | [Hash Table](hash-table/README.md) | [哈希表](https://awesee.github.io/tags/hash-table/) | +| 9 | [Binary Search](binary-search/README.md) | [二分查找](https://awesee.github.io/tags/binary-search/) | | 10 | [Breadth-First Search](breadth-first-search/README.md) | [广度优先搜索](https://awesee.github.io/tags/breadth-first-search/) | +| 11 | [Sort](sort/README.md) | [排序](https://awesee.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://awesee.github.io/tags/two-pointers/) | +| 13 | [Backtracking](backtracking/README.md) | [回溯](https://awesee.github.io/tags/backtracking/) | | 14 | [Design](design/README.md) | [设计](https://awesee.github.io/tags/design/) | +| 15 | [Stack](stack/README.md) | [栈](https://awesee.github.io/tags/stack/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://awesee.github.io/tags/bit-manipulation/) | +| 17 | [Graph](graph/README.md) | [图](https://awesee.github.io/tags/graph/) | | 18 | [Heap](heap/README.md) | [堆](https://awesee.github.io/tags/heap/) | +| 19 | [Linked List](linked-list/README.md) | [链表](https://awesee.github.io/tags/linked-list/) | | 20 | [Recursion](recursion/README.md) | [递归](https://awesee.github.io/tags/recursion/) | +| 21 | [Union Find](union-find/README.md) | [并查集](https://awesee.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [滑动窗口](https://awesee.github.io/tags/sliding-window/) | +| 23 | [Trie](trie/README.md) | [字典树](https://awesee.github.io/tags/trie/) | | 24 | [Divide and Conquer](divide-and-conquer/README.md) | [分治](https://awesee.github.io/tags/divide-and-conquer/) | +| 25 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://awesee.github.io/tags/ordered-map/) | | 26 | [Segment Tree](segment-tree/README.md) | [线段树](https://awesee.github.io/tags/segment-tree/) | +| 27 | [Queue](queue/README.md) | [队列](https://awesee.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://awesee.github.io/tags/geometry/) | +| 29 | [Line Sweep](line-sweep/README.md) | [扫描线](https://awesee.github.io/tags/line-sweep/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://awesee.github.io/tags/binary-indexed-tree/) | +| 31 | [Minimax](minimax/README.md) | [极小化极大](https://awesee.github.io/tags/minimax/) | | 32 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://awesee.github.io/tags/brainteaser/) | +| 33 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://awesee.github.io/tags/topological-sort/) | | 34 | [Dequeue](dequeue/README.md) | [Dequeue](https://awesee.github.io/tags/dequeue/) | +| 35 | [Random](random/README.md) | [Random](https://awesee.github.io/tags/random/) | | 36 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://awesee.github.io/tags/binary-search-tree/) | +| 37 | [Rolling Hash](rolling-hash/README.md) | [滚动哈希](https://awesee.github.io/tags/rolling-hash/) | | 38 | [Suffix Array](suffix-array/README.md) | [后缀数组](https://awesee.github.io/tags/suffix-array/) | +| 39 | [Rejection Sampling](rejection-sampling/README.md) | [拒绝采样](https://awesee.github.io/tags/rejection-sampling/) | | 40 | [Reservoir Sampling](reservoir-sampling/README.md) | [水塘抽样](https://awesee.github.io/tags/reservoir-sampling/) | +| 41 | [Meet In The Middle](meet-in-the-middle/README.md) | [Meet In The Middle](https://awesee.github.io/tags/meet-in-the-middle/) | | 42 | [Memoization](memoization/README.md) | [记忆化搜索](https://awesee.github.io/tags/memoization/) | +| 43 | [OOP](oop/README.md) | [OOP](https://awesee.github.io/tags/oop/) | | 44 | [Sorting](sorting/README.md) | [排序](https://awesee.github.io/tags/sorting/) | +| 45 | [Heap (Priority Queue)](heap-priority-queue/README.md) | [堆(优先队列)](https://awesee.github.io/tags/heap-priority-queue/) | | 46 | [Ordered Set](ordered-set/README.md) | [有序集合](https://awesee.github.io/tags/ordered-set/) | +| 47 | [Hash Function](hash-function/README.md) | [哈希函数](https://awesee.github.io/tags/hash-function/) | | 48 | [String Matching](string-matching/README.md) | [字符串匹配](https://awesee.github.io/tags/string-matching/) | +| 49 | [Randomized](randomized/README.md) | [随机化](https://awesee.github.io/tags/randomized/) | | 50 | [Prefix Sum](prefix-sum/README.md) | [前缀和](https://awesee.github.io/tags/prefix-sum/) | +| 51 | [Probability and Statistics](probability-and-statistics/README.md) | [概率与统计](https://awesee.github.io/tags/probability-and-statistics/) | | 52 | [Simulation](simulation/README.md) | [模拟](https://awesee.github.io/tags/simulation/) | +| 53 | [Monotonic Queue](monotonic-queue/README.md) | [单调队列](https://awesee.github.io/tags/monotonic-queue/) | | 54 | [Data Stream](data-stream/README.md) | [数据流](https://awesee.github.io/tags/data-stream/) | +| 55 | [Counting](counting/README.md) | [计数](https://awesee.github.io/tags/counting/) | | 56 | [Matrix](matrix/README.md) | [矩阵](https://awesee.github.io/tags/matrix/) | +| 57 | [Iterator](iterator/README.md) | [迭代器](https://awesee.github.io/tags/iterator/) | | 58 | [Quickselect](quickselect/README.md) | [快速选择](https://awesee.github.io/tags/quickselect/) | +| 59 | [Merge Sort](merge-sort/README.md) | [归并排序](https://awesee.github.io/tags/merge-sort/) | | 60 | [Binary Tree](binary-tree/README.md) | [二叉树](https://awesee.github.io/tags/binary-tree/) | +| 61 | [Combinatorics](combinatorics/README.md) | [组合数学](https://awesee.github.io/tags/combinatorics/) | | 62 | [Shortest Path](shortest-path/README.md) | [最短路](https://awesee.github.io/tags/shortest-path/) | +| 63 | [Interactive](interactive/README.md) | [交互](https://awesee.github.io/tags/interactive/) | | 64 | [Bucket Sort](bucket-sort/README.md) | [桶排序](https://awesee.github.io/tags/bucket-sort/) | +| 65 | [Counting Sort](counting-sort/README.md) | [计数排序](https://awesee.github.io/tags/counting-sort/) | | 66 | [Radix Sort](radix-sort/README.md) | [基数排序](https://awesee.github.io/tags/radix-sort/) | +| 67 | [Monotonic Stack](monotonic-stack/README.md) | [单调栈](https://awesee.github.io/tags/monotonic-stack/) | | 68 | [Minimum Spanning Tree](minimum-spanning-tree/README.md) | [最小生成树](https://awesee.github.io/tags/minimum-spanning-tree/) | +| 69 | [Strongly Connected Component](strongly-connected-component/README.md) | [强连通分量](https://awesee.github.io/tags/strongly-connected-component/) | | 70 | [Game Theory](game-theory/README.md) | [博弈](https://awesee.github.io/tags/game-theory/) | +| 71 | [Bitmask](bitmask/README.md) | [状态压缩](https://awesee.github.io/tags/bitmask/) | | 72 | [Concurrency](concurrency/README.md) | [多线程](https://awesee.github.io/tags/concurrency/) | +| 73 | [Doubly-Linked List](doubly-linked-list/README.md) | [双向链表](https://awesee.github.io/tags/doubly-linked-list/) | | 74 | [Enumeration](enumeration/README.md) | [枚举](https://awesee.github.io/tags/enumeration/) | +| 75 | [Number Theory](number-theory/README.md) | [数论](https://awesee.github.io/tags/number-theory/) | | 76 | [Biconnected Component](biconnected-component/README.md) | [双连通分量](https://awesee.github.io/tags/biconnected-component/) | +| 77 | [Eulerian Circuit](eulerian-circuit/README.md) | [欧拉回路](https://awesee.github.io/tags/eulerian-circuit/) | \ No newline at end of file diff --git a/tag/array/README.md b/tag/array/README.md index 0ed39d8a2..90abb510d 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -1,14 +1,17 @@ - - - + + + ## [话题分类](../README.md) > 数组 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 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 | | 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 | | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 502c29958..b864fa7ec 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 回溯 diff --git a/tag/biconnected-component/README.md b/tag/biconnected-component/README.md index 24393482a..04440ac7e 100644 --- a/tag/biconnected-component/README.md +++ b/tag/biconnected-component/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 双连通分量 diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index 9efbf1687..350e34ae8 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 树状数组 diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 7960c1f8f..3a558f6de 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 二叉搜索树 diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index be5e9e54a..3205ba91a 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 二分查找 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 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 | | 2064 | [分配给商店的最多商品的最小值](../../problems/minimized-maximum-of-products-distributed-to-any-store) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/binary-tree/README.md b/tag/binary-tree/README.md index db723ee96..9cea043e7 100644 --- a/tag/binary-tree/README.md +++ b/tag/binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 二叉树 diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 8e7e9b5ee..f008e795e 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 位运算 diff --git a/tag/bitmask/README.md b/tag/bitmask/README.md index b15c69aa3..056368cdd 100644 --- a/tag/bitmask/README.md +++ b/tag/bitmask/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 状态压缩 diff --git a/tag/brainteaser/README.md b/tag/brainteaser/README.md index c0b3910d8..c19f7f1e2 100644 --- a/tag/brainteaser/README.md +++ b/tag/brainteaser/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 脑筋急转弯 diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index ce91b4628..54cf36cd5 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 广度优先搜索 @@ -14,7 +14,7 @@ | 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 | -| 1971 | [Find if Path Exists in Graph](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | +| 1971 | [寻找图中是否存在路径](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | | 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/bucket-sort/README.md b/tag/bucket-sort/README.md index b136e2646..57c6c0ff4 100644 --- a/tag/bucket-sort/README.md +++ b/tag/bucket-sort/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 桶排序 diff --git a/tag/combinatorics/README.md b/tag/combinatorics/README.md index 2e59a4103..c3322fa15 100644 --- a/tag/combinatorics/README.md +++ b/tag/combinatorics/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 组合数学 diff --git a/tag/concurrency/README.md b/tag/concurrency/README.md index b06421577..6ad20643a 100644 --- a/tag/concurrency/README.md +++ b/tag/concurrency/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 多线程 diff --git a/tag/counting-sort/README.md b/tag/counting-sort/README.md index 5fd0c4b31..80437a981 100644 --- a/tag/counting-sort/README.md +++ b/tag/counting-sort/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 计数排序 diff --git a/tag/counting/README.md b/tag/counting/README.md index 1ffc4d5bf..111d9c1de 100644 --- a/tag/counting/README.md +++ b/tag/counting/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 计数 diff --git a/tag/data-stream/README.md b/tag/data-stream/README.md index b733a60f3..1f6d61328 100644 --- a/tag/data-stream/README.md +++ b/tag/data-stream/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 数据流 diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index da3b6896e..6174bf935 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 深度优先搜索 @@ -12,7 +12,7 @@ | 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 | -| 1971 | [Find if Path Exists in Graph](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | +| 1971 | [寻找图中是否存在路径](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | | 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 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 | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/dequeue/README.md b/tag/dequeue/README.md index 337f59d12..f86e5c7c7 100644 --- a/tag/dequeue/README.md +++ b/tag/dequeue/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > Dequeue diff --git a/tag/design/README.md b/tag/design/README.md index 1bcdb3140..e62692267 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 设计 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 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 | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 3d2028983..6e1eebbbb 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 分治 diff --git a/tag/doubly-linked-list/README.md b/tag/doubly-linked-list/README.md index 9cb65f12b..104be93b5 100644 --- a/tag/doubly-linked-list/README.md +++ b/tag/doubly-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 双向链表 diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 9b51c3b2c..e156b1010 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 动态规划 @@ -211,7 +211,7 @@ | 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 837 | [新21点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 837 | [新 21 点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 828 | [统计子串中的唯一字符](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 823 | [带因子的二叉树](../../problems/binary-trees-with-factors) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/enumeration/README.md b/tag/enumeration/README.md index f2c725d05..cfa2fed90 100644 --- a/tag/enumeration/README.md +++ b/tag/enumeration/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 枚举 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 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 | | 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/eulerian-circuit/README.md b/tag/eulerian-circuit/README.md index 4a15e673d..f48b4407a 100644 --- a/tag/eulerian-circuit/README.md +++ b/tag/eulerian-circuit/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 欧拉回路 diff --git a/tag/game-theory/README.md b/tag/game-theory/README.md index f47303880..50c4354cf 100644 --- a/tag/game-theory/README.md +++ b/tag/game-theory/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 博弈 diff --git a/tag/geometry/README.md b/tag/geometry/README.md index d63defc50..3bb8dcf8f 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 几何 diff --git a/tag/graph/README.md b/tag/graph/README.md index d40bb1c01..2c116d55e 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -1,20 +1,22 @@ - - - + + + ## [话题分类](../README.md) > 图 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 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 | | 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 | [Find if Path Exists in Graph](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | +| 1971 | [寻找图中是否存在路径](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | | 1928 | [规定时间内到达终点的最小花费](../../problems/minimum-cost-to-reach-destination-in-time) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/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 | | 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index b992d5bed..0d5ade543 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 贪心 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 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 | | 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 | diff --git a/tag/hash-function/README.md b/tag/hash-function/README.md index 9b5971506..7061229ce 100644 --- a/tag/hash-function/README.md +++ b/tag/hash-function/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 哈希函数 diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index b3e559827..ac840e676 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 哈希表 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 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 | diff --git a/tag/heap-priority-queue/README.md b/tag/heap-priority-queue/README.md index f27a28295..c5868632c 100644 --- a/tag/heap-priority-queue/README.md +++ b/tag/heap-priority-queue/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 堆(优先队列) diff --git a/tag/heap/README.md b/tag/heap/README.md index 39b134930..48c257e6f 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 堆 diff --git a/tag/interactive/README.md b/tag/interactive/README.md index d089e633f..542b0fb48 100644 --- a/tag/interactive/README.md +++ b/tag/interactive/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 交互 diff --git a/tag/iterator/README.md b/tag/iterator/README.md index d7569eef4..641c321ca 100644 --- a/tag/iterator/README.md +++ b/tag/iterator/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 迭代器 diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index ca06abe3c..8cd80d13e 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 扫描线 diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index f7822a978..c58530bba 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 链表 diff --git a/tag/math/README.md b/tag/math/README.md index 9c7ca9107..053a05c92 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 数学 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 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 | | 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 | @@ -199,7 +200,7 @@ | 858 | [镜面反射](../../problems/mirror-reflection) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | | 843 | [猜猜这个单词](../../problems/guess-the-word) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] [[交互](../interactive/README.md)] | Hard | | 840 | [矩阵中的幻方](../../problems/magic-squares-in-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 837 | [新21点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 837 | [新 21 点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 836 | [矩形重叠](../../problems/rectangle-overlap) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | | 829 | [连续整数求和](../../problems/consecutive-numbers-sum) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | diff --git a/tag/matrix/README.md b/tag/matrix/README.md index 997dc3f2b..f1af6860d 100644 --- a/tag/matrix/README.md +++ b/tag/matrix/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 矩阵 diff --git a/tag/meet-in-the-middle/README.md b/tag/meet-in-the-middle/README.md index e22e2978d..0b779f115 100644 --- a/tag/meet-in-the-middle/README.md +++ b/tag/meet-in-the-middle/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > Meet In The Middle diff --git a/tag/memoization/README.md b/tag/memoization/README.md index f1f07257d..377f20f06 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 记忆化搜索 diff --git a/tag/merge-sort/README.md b/tag/merge-sort/README.md index 29614f7df..87b8fff12 100644 --- a/tag/merge-sort/README.md +++ b/tag/merge-sort/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 归并排序 diff --git a/tag/minimax/README.md b/tag/minimax/README.md index dd3b3951d..2b0194212 100644 --- a/tag/minimax/README.md +++ b/tag/minimax/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 极小化极大 diff --git a/tag/minimum-spanning-tree/README.md b/tag/minimum-spanning-tree/README.md index 936ea815d..8fcbd0882 100644 --- a/tag/minimum-spanning-tree/README.md +++ b/tag/minimum-spanning-tree/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 最小生成树 diff --git a/tag/monotonic-queue/README.md b/tag/monotonic-queue/README.md index 2297ba064..79f7a4226 100644 --- a/tag/monotonic-queue/README.md +++ b/tag/monotonic-queue/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 单调队列 diff --git a/tag/monotonic-stack/README.md b/tag/monotonic-stack/README.md index b53323820..69ccccc69 100644 --- a/tag/monotonic-stack/README.md +++ b/tag/monotonic-stack/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 单调栈 diff --git a/tag/number-theory/README.md b/tag/number-theory/README.md index 82435c8d2..47d79b04e 100644 --- a/tag/number-theory/README.md +++ b/tag/number-theory/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 数论 diff --git a/tag/oop/README.md b/tag/oop/README.md index 4871b5c65..4920fb050 100644 --- a/tag/oop/README.md +++ b/tag/oop/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > OOP diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 52afd5989..bce1a6995 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > Ordered Map diff --git a/tag/ordered-set/README.md b/tag/ordered-set/README.md index 435f180e2..7665f8456 100644 --- a/tag/ordered-set/README.md +++ b/tag/ordered-set/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 有序集合 diff --git a/tag/prefix-sum/README.md b/tag/prefix-sum/README.md index a5638d976..82e3e9c76 100644 --- a/tag/prefix-sum/README.md +++ b/tag/prefix-sum/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 前缀和 diff --git a/tag/probability-and-statistics/README.md b/tag/probability-and-statistics/README.md index b2b07bfb3..e96a3f6ad 100644 --- a/tag/probability-and-statistics/README.md +++ b/tag/probability-and-statistics/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 概率与统计 @@ -13,6 +13,6 @@ | 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | -| 837 | [新21点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 837 | [新 21 点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 808 | [分汤](../../problems/soup-servings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[数学](../math/README.md)] [[拒绝采样](../rejection-sampling/README.md)] [[概率与统计](../probability-and-statistics/README.md)] [[随机化](../randomized/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 3f3d21fda..d76a040d3 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 队列 diff --git a/tag/quickselect/README.md b/tag/quickselect/README.md index 02d685efc..758e2f111 100644 --- a/tag/quickselect/README.md +++ b/tag/quickselect/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 快速选择 diff --git a/tag/radix-sort/README.md b/tag/radix-sort/README.md index c7e8486e7..859147d07 100644 --- a/tag/radix-sort/README.md +++ b/tag/radix-sort/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 基数排序 diff --git a/tag/random/README.md b/tag/random/README.md index 72a82d98f..66c8e79c0 100644 --- a/tag/random/README.md +++ b/tag/random/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > Random diff --git a/tag/randomized/README.md b/tag/randomized/README.md index 3e12f223b..c991c6b5f 100644 --- a/tag/randomized/README.md +++ b/tag/randomized/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 随机化 diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 4b9f00891..9e3769198 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 递归 diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md index ba0e34fee..7dda478a0 100644 --- a/tag/rejection-sampling/README.md +++ b/tag/rejection-sampling/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 拒绝采样 diff --git a/tag/reservoir-sampling/README.md b/tag/reservoir-sampling/README.md index 34b47a93f..719ab9946 100644 --- a/tag/reservoir-sampling/README.md +++ b/tag/reservoir-sampling/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 水塘抽样 diff --git a/tag/rolling-hash/README.md b/tag/rolling-hash/README.md index b4076acbc..85629bdc3 100644 --- a/tag/rolling-hash/README.md +++ b/tag/rolling-hash/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 滚动哈希 diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index 55fd9bddb..872832452 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 线段树 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 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 | | 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 | diff --git a/tag/shortest-path/README.md b/tag/shortest-path/README.md index 1b0378a62..a1cacef5d 100644 --- a/tag/shortest-path/README.md +++ b/tag/shortest-path/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 最短路 diff --git a/tag/simulation/README.md b/tag/simulation/README.md index 550c95a99..de5ff39b9 100644 --- a/tag/simulation/README.md +++ b/tag/simulation/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 模拟 diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index fe8902785..888c73f17 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 滑动窗口 @@ -49,7 +49,7 @@ | 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 904 | [水果成篮](../../problems/fruit-into-baskets) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 837 | [新21点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 837 | [新 21 点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | | 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 49e4c7112..420418d41 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 排序 diff --git a/tag/sorting/README.md b/tag/sorting/README.md index 0b4e358dd..1e795d316 100644 --- a/tag/sorting/README.md +++ b/tag/sorting/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 排序 diff --git a/tag/stack/README.md b/tag/stack/README.md index cd27a9446..7fe784c89 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 栈 diff --git a/tag/string-matching/README.md b/tag/string-matching/README.md index 67472968a..304b8dd22 100644 --- a/tag/string-matching/README.md +++ b/tag/string-matching/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 字符串匹配 diff --git a/tag/string/README.md b/tag/string/README.md index a013be18a..f61110315 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 字符串 diff --git a/tag/strongly-connected-component/README.md b/tag/strongly-connected-component/README.md index d32a1515e..10e0277ac 100644 --- a/tag/strongly-connected-component/README.md +++ b/tag/strongly-connected-component/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 强连通分量 diff --git a/tag/suffix-array/README.md b/tag/suffix-array/README.md index 4e956db05..de556bab0 100644 --- a/tag/suffix-array/README.md +++ b/tag/suffix-array/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 后缀数组 diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index 5ef75237a..f3fc7304f 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 拓扑排序 diff --git a/tag/tree/README.md b/tag/tree/README.md index 6db4f7127..a4f396b09 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 树 diff --git a/tag/trie/README.md b/tag/trie/README.md index 4221d14ad..1b00eff9c 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 字典树 diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index ac1e57620..b676b857d 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 双指针 diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 9cd25bba1..b13c5ebf0 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 并查集 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 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 | | 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | From 170643058e306cb821920bf7378f0c16ca48a070 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 27 Nov 2021 21:33:58 +0800 Subject: [PATCH 2/5] U: main --- .github/workflows/go.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 77fe0b084..288780793 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -2,9 +2,9 @@ name: Go on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: From d600c7dfd9b5227d61efe60d3d46e056cc5d4888 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 27 Nov 2021 21:43:50 +0800 Subject: [PATCH 3/5] U: main --- internal/base/base.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/base/base.go b/internal/base/base.go index 63c94a469..3b1b4451f 100644 --- a/internal/base/base.go +++ b/internal/base/base.go @@ -13,7 +13,7 @@ import ( ) // URL - base.URL -const URL = "https://github.com/awesee/leetcode/tree/master" +const URL = "https://github.com/awesee/leetcode/tree/main" // CmdName - base.CmdName var CmdName = filepath.Base(os.Args[0]) From ce6b5442cd7b9f7bc216be589e4ab481e67642dc Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 16 Feb 2022 15:49:36 +0800 Subject: [PATCH 4/5] 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.

    + +
      +
    • For example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained.
    • +
    + +

    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:

    + +
      +
    • 0 <= num <= 106
    • +
    + +### 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:

    + +
      +
    • 1 <= left <= right <= 104
    • +
    + +### 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.

    + +
      +
    • For example, given s = "EnjoyYourCoffee" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at indices 5 and 9 respectively. Thus, we obtain "Enjoy Your Coffee".
    • +
    + +

    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:

    + +
      +
    • 1 <= s.length <= 3 * 105
    • +
    • s consists only of lowercase and uppercase English letters.
    • +
    • 1 <= spaces.length <= 3 * 105
    • +
    • 0 <= spaces[i] <= s.length - 1
    • +
    • All the values of spaces are strictly increasing.
    • +
    + +### 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:

    • 1 <= keyName.length, keyTime.length <= 105
    • keyName.length == keyTime.length
    • -
    • keyTime[i] is in the format "HH:MM".
    • +
    • keyTime[i] is in the format "HH:MM".
    • [keyName[i], keyTime[i]] is unique.
    • 1 <= keyName[i].length <= 10
    • keyName[i] contains only lowercase English letters.
    • diff --git a/problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md b/problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md new file mode 100644 index 000000000..3e8ea2eca --- /dev/null +++ b/problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md @@ -0,0 +1,92 @@ + + + + + + + +[< Previous](../keep-multiplying-found-values-by-two "Keep Multiplying Found Values by Two") +                 +[Next >](../find-substring-with-given-hash-value "Find Substring With Given Hash Value") + +## [2155. All Divisions With the Highest Score of a Binary Array (Medium)](https://leetcode.com/problems/all-divisions-with-the-highest-score-of-a-binary-array "分组得分最高的所有下标") + +

      You are given a 0-indexed binary array nums of length n. nums can be divided at index i (where 0 <= i <= n) into two arrays (possibly empty) numsleft and numsright:

      + +
        +
      • numsleft has all the elements of nums between index 0 and i - 1 (inclusive), while numsright has all the elements of nums between index i and n - 1 (inclusive).
      • +
      • If i == 0, numsleft is empty, while numsright has all the elements of nums.
      • +
      • If i == n, numsleft has all the elements of nums, while numsright is empty.
      • +
      + +

      The division score of an index i is the sum of the number of 0's in numsleft and the number of 1's in numsright.

      + +

      Return all distinct indices that have the highest possible division score. You may return the answer in any order.

      + +

       

      +

      Example 1:

      + +
      +Input: nums = [0,0,1,0]
      +Output: [2,4]
      +Explanation: Division at index
      +- 0: numsleft is []. numsright is [0,0,1,0]. The score is 0 + 1 = 1.
      +- 1: numsleft is [0]. numsright is [0,1,0]. The score is 1 + 1 = 2.
      +- 2: numsleft is [0,0]. numsright is [1,0]. The score is 2 + 1 = 3.
      +- 3: numsleft is [0,0,1]. numsright is [0]. The score is 2 + 0 = 2.
      +- 4: numsleft is [0,0,1,0]. numsright is []. The score is 3 + 0 = 3.
      +Indices 2 and 4 both have the highest possible division score 3.
      +Note the answer [4,2] would also be accepted.
      + +

      Example 2:

      + +
      +Input: nums = [0,0,0]
      +Output: [3]
      +Explanation: Division at index
      +- 0: numsleft is []. numsright is [0,0,0]. The score is 0 + 0 = 0.
      +- 1: numsleft is [0]. numsright is [0,0]. The score is 1 + 0 = 1.
      +- 2: numsleft is [0,0]. numsright is [0]. The score is 2 + 0 = 2.
      +- 3: numsleft is [0,0,0]. numsright is []. The score is 3 + 0 = 3.
      +Only index 3 has the highest possible division score 3.
      +
      + +

      Example 3:

      + +
      +Input: nums = [1,1]
      +Output: [0]
      +Explanation: Division at index
      +- 0: numsleft is []. numsright is [1,1]. The score is 0 + 2 = 2.
      +- 1: numsleft is [1]. numsright is [1]. The score is 0 + 1 = 1.
      +- 2: numsleft is [1,1]. numsright is []. The score is 0 + 0 = 0.
      +Only index 0 has the highest possible division score 2.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • n == nums.length
      • +
      • 1 <= n <= 105
      • +
      • nums[i] is either 0 or 1.
      • +
      + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
      +Hint 1 +When you iterate the array, maintain the number of zeros and ones on the left side. Can you quickly calculate the number of ones on the right side? +
      + +
      +Hint 2 +The number of ones on the right side equals the number of ones in the whole array minus the number of ones on the left side. +
      + +
      +Hint 3 +Alternatively, you can quickly calculate it by using a prefix sum array. +
      diff --git a/problems/all-elements-in-two-binary-search-trees/README.md b/problems/all-elements-in-two-binary-search-trees/README.md index 3489830b3..add402354 100644 --- a/problems/all-elements-in-two-binary-search-trees/README.md +++ b/problems/all-elements-in-two-binary-search-trees/README.md @@ -11,9 +11,7 @@ ## [1305. All Elements in Two Binary Search Trees (Medium)](https://leetcode.com/problems/all-elements-in-two-binary-search-trees "两棵二叉搜索树中的所有元素") -

      Given two binary search trees root1 and root2.

      - -

      Return a list containing all the integers from both trees sorted in ascending order.

      +

      Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order.

       

      Example 1:

      @@ -24,27 +22,6 @@

      Example 2:

      - -
      -Input: root1 = [0,-10,10], root2 = [5,1,7,0,2]
      -Output: [-10,0,0,1,2,5,7,10]
      -
      - -

      Example 3:

      - -
      -Input: root1 = [], root2 = [5,1,7,0,2]
      -Output: [0,1,2,5,7]
      -
      - -

      Example 4:

      - -
      -Input: root1 = [0,-10,10], root2 = []
      -Output: [-10,0,10]
      -
      - -

      Example 5:

       Input: root1 = [1,null,8], root2 = [8,1]
      @@ -55,8 +32,8 @@
       

      Constraints:

        -
      • Each tree has at most 5000 nodes.
      • -
      • Each node's value is between [-10^5, 10^5].
      • +
      • The number of nodes in each tree is in the range [0, 5000].
      • +
      • -105 <= Node.val <= 105
      ### Related Topics diff --git a/problems/all-oone-data-structure/README.md b/problems/all-oone-data-structure/README.md index c4c565fc7..b1bf3b3fc 100644 --- a/problems/all-oone-data-structure/README.md +++ b/problems/all-oone-data-structure/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../encode-n-ary-tree-to-binary-tree "Encode N-ary Tree to Binary Tree") @@ -55,7 +55,7 @@ allOne.getMinKey(); // return "leet"
    ### 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:

      -
    • n == houses.length
    • -
    • 1 <= n <= 100
    • -
    • 1 <= houses[i] <= 10^4
    • -
    • 1 <= k <= n
    • -
    • Array houses contain unique integers.
    • +
    • 1 <= k <= houses.length <= 100
    • +
    • 1 <= houses[i] <= 104
    • +
    • All the integers of houses are unique.
    ### 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 | From 80696833dcdc4c66c75ba36f77f9847f1d51fecb Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 16 Feb 2022 15:49:36 +0800 Subject: [PATCH 5/5] 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.

    + +
      +
    • For example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained.
    • +
    + +

    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:

    + +
      +
    • 0 <= num <= 106
    • +
    + +### 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:

    + +
      +
    • 1 <= left <= right <= 104
    • +
    + +### 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.

    + +
      +
    • For example, given s = "EnjoyYourCoffee" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at indices 5 and 9 respectively. Thus, we obtain "Enjoy Your Coffee".
    • +
    + +

    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:

    + +
      +
    • 1 <= s.length <= 3 * 105
    • +
    • s consists only of lowercase and uppercase English letters.
    • +
    • 1 <= spaces.length <= 3 * 105
    • +
    • 0 <= spaces[i] <= s.length - 1
    • +
    • All the values of spaces are strictly increasing.
    • +
    + +### 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:

    • 1 <= keyName.length, keyTime.length <= 105
    • keyName.length == keyTime.length
    • -
    • keyTime[i] is in the format "HH:MM".
    • +
    • keyTime[i] is in the format "HH:MM".
    • [keyName[i], keyTime[i]] is unique.
    • 1 <= keyName[i].length <= 10
    • keyName[i] contains only lowercase English letters.
    • diff --git a/problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md b/problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md new file mode 100644 index 000000000..3e8ea2eca --- /dev/null +++ b/problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md @@ -0,0 +1,92 @@ + + + + + + + +[< Previous](../keep-multiplying-found-values-by-two "Keep Multiplying Found Values by Two") +                 +[Next >](../find-substring-with-given-hash-value "Find Substring With Given Hash Value") + +## [2155. All Divisions With the Highest Score of a Binary Array (Medium)](https://leetcode.com/problems/all-divisions-with-the-highest-score-of-a-binary-array "分组得分最高的所有下标") + +

      You are given a 0-indexed binary array nums of length n. nums can be divided at index i (where 0 <= i <= n) into two arrays (possibly empty) numsleft and numsright:

      + +
        +
      • numsleft has all the elements of nums between index 0 and i - 1 (inclusive), while numsright has all the elements of nums between index i and n - 1 (inclusive).
      • +
      • If i == 0, numsleft is empty, while numsright has all the elements of nums.
      • +
      • If i == n, numsleft has all the elements of nums, while numsright is empty.
      • +
      + +

      The division score of an index i is the sum of the number of 0's in numsleft and the number of 1's in numsright.

      + +

      Return all distinct indices that have the highest possible division score. You may return the answer in any order.

      + +

       

      +

      Example 1:

      + +
      +Input: nums = [0,0,1,0]
      +Output: [2,4]
      +Explanation: Division at index
      +- 0: numsleft is []. numsright is [0,0,1,0]. The score is 0 + 1 = 1.
      +- 1: numsleft is [0]. numsright is [0,1,0]. The score is 1 + 1 = 2.
      +- 2: numsleft is [0,0]. numsright is [1,0]. The score is 2 + 1 = 3.
      +- 3: numsleft is [0,0,1]. numsright is [0]. The score is 2 + 0 = 2.
      +- 4: numsleft is [0,0,1,0]. numsright is []. The score is 3 + 0 = 3.
      +Indices 2 and 4 both have the highest possible division score 3.
      +Note the answer [4,2] would also be accepted.
      + +

      Example 2:

      + +
      +Input: nums = [0,0,0]
      +Output: [3]
      +Explanation: Division at index
      +- 0: numsleft is []. numsright is [0,0,0]. The score is 0 + 0 = 0.
      +- 1: numsleft is [0]. numsright is [0,0]. The score is 1 + 0 = 1.
      +- 2: numsleft is [0,0]. numsright is [0]. The score is 2 + 0 = 2.
      +- 3: numsleft is [0,0,0]. numsright is []. The score is 3 + 0 = 3.
      +Only index 3 has the highest possible division score 3.
      +
      + +

      Example 3:

      + +
      +Input: nums = [1,1]
      +Output: [0]
      +Explanation: Division at index
      +- 0: numsleft is []. numsright is [1,1]. The score is 0 + 2 = 2.
      +- 1: numsleft is [1]. numsright is [1]. The score is 0 + 1 = 1.
      +- 2: numsleft is [1,1]. numsright is []. The score is 0 + 0 = 0.
      +Only index 0 has the highest possible division score 2.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • n == nums.length
      • +
      • 1 <= n <= 105
      • +
      • nums[i] is either 0 or 1.
      • +
      + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
      +Hint 1 +When you iterate the array, maintain the number of zeros and ones on the left side. Can you quickly calculate the number of ones on the right side? +
      + +
      +Hint 2 +The number of ones on the right side equals the number of ones in the whole array minus the number of ones on the left side. +
      + +
      +Hint 3 +Alternatively, you can quickly calculate it by using a prefix sum array. +
      diff --git a/problems/all-elements-in-two-binary-search-trees/README.md b/problems/all-elements-in-two-binary-search-trees/README.md index 3489830b3..add402354 100644 --- a/problems/all-elements-in-two-binary-search-trees/README.md +++ b/problems/all-elements-in-two-binary-search-trees/README.md @@ -11,9 +11,7 @@ ## [1305. All Elements in Two Binary Search Trees (Medium)](https://leetcode.com/problems/all-elements-in-two-binary-search-trees "两棵二叉搜索树中的所有元素") -

      Given two binary search trees root1 and root2.

      - -

      Return a list containing all the integers from both trees sorted in ascending order.

      +

      Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order.

       

      Example 1:

      @@ -24,27 +22,6 @@

      Example 2:

      - -
      -Input: root1 = [0,-10,10], root2 = [5,1,7,0,2]
      -Output: [-10,0,0,1,2,5,7,10]
      -
      - -

      Example 3:

      - -
      -Input: root1 = [], root2 = [5,1,7,0,2]
      -Output: [0,1,2,5,7]
      -
      - -

      Example 4:

      - -
      -Input: root1 = [0,-10,10], root2 = []
      -Output: [-10,0,10]
      -
      - -

      Example 5:

       Input: root1 = [1,null,8], root2 = [8,1]
      @@ -55,8 +32,8 @@
       

      Constraints:

        -
      • Each tree has at most 5000 nodes.
      • -
      • Each node's value is between [-10^5, 10^5].
      • +
      • The number of nodes in each tree is in the range [0, 5000].
      • +
      • -105 <= Node.val <= 105
      ### Related Topics diff --git a/problems/all-oone-data-structure/README.md b/problems/all-oone-data-structure/README.md index c4c565fc7..b1bf3b3fc 100644 --- a/problems/all-oone-data-structure/README.md +++ b/problems/all-oone-data-structure/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../encode-n-ary-tree-to-binary-tree "Encode N-ary Tree to Binary Tree") @@ -55,7 +55,7 @@ allOne.getMinKey(); // return "leet"
    ### 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:

      -
    • n == houses.length
    • -
    • 1 <= n <= 100
    • -
    • 1 <= houses[i] <= 10^4
    • -
    • 1 <= k <= n
    • -
    • Array houses contain unique integers.
    • +
    • 1 <= k <= houses.length <= 100
    • +
    • 1 <= houses[i] <= 104
    • +
    • All the integers of houses are unique.
    ### 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 |