offcode 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -2
- package/data/index.json +1 -0
- package/data/problems/01-matrix.json +1 -0
- package/data/problems/1-bit-and-2-bit-characters.json +1 -0
- package/data/problems/132-pattern.json +1 -0
- package/data/problems/2-keys-keyboard.json +1 -0
- package/data/problems/24-game.json +1 -0
- package/data/problems/3sum-closest.json +1 -0
- package/data/problems/3sum-smaller.json +1 -0
- package/data/problems/3sum-with-multiplicity.json +1 -0
- package/data/problems/3sum.json +1 -0
- package/data/problems/4-keys-keyboard.json +1 -0
- package/data/problems/4sum-ii.json +1 -0
- package/data/problems/4sum.json +1 -0
- package/data/problems/accounts-merge.json +1 -0
- package/data/problems/add-binary.json +1 -0
- package/data/problems/add-bold-tag-in-string.json +1 -0
- package/data/problems/add-digits.json +1 -0
- package/data/problems/add-one-row-to-tree.json +1 -0
- package/data/problems/add-strings.json +1 -0
- package/data/problems/add-to-array-form-of-integer.json +1 -0
- package/data/problems/add-two-numbers-ii.json +1 -0
- package/data/problems/add-two-numbers.json +1 -0
- package/data/problems/additive-number.json +1 -0
- package/data/problems/advantage-shuffle.json +1 -0
- package/data/problems/alien-dictionary.json +1 -0
- package/data/problems/all-nodes-distance-k-in-binary-tree.json +1 -0
- package/data/problems/all-oone-data-structure.json +1 -0
- package/data/problems/all-paths-from-source-to-target.json +1 -0
- package/data/problems/all-possible-full-binary-trees.json +1 -0
- package/data/problems/ambiguous-coordinates.json +1 -0
- package/data/problems/android-unlock-patterns.json +1 -0
- package/data/problems/arithmetic-slices-ii-subsequence.json +1 -0
- package/data/problems/arithmetic-slices.json +1 -0
- package/data/problems/arranging-coins.json +1 -0
- package/data/problems/array-nesting.json +1 -0
- package/data/problems/array-of-doubled-pairs.json +1 -0
- package/data/problems/array-partition.json +1 -0
- package/data/problems/assign-cookies.json +1 -0
- package/data/problems/asteroid-collision.json +1 -0
- package/data/problems/available-captures-for-rook.json +1 -0
- package/data/problems/average-of-levels-in-binary-tree.json +1 -0
- package/data/problems/backspace-string-compare.json +1 -0
- package/data/problems/bag-of-tokens.json +1 -0
- package/data/problems/balanced-binary-tree.json +1 -0
- package/data/problems/base-7.json +1 -0
- package/data/problems/baseball-game.json +1 -0
- package/data/problems/basic-absolute-value.json +1 -0
- package/data/problems/basic-array-max.json +1 -0
- package/data/problems/basic-array-min.json +1 -0
- package/data/problems/basic-array-sum-rec.json +1 -0
- package/data/problems/basic-array-sum.json +1 -0
- package/data/problems/basic-average-floor.json +1 -0
- package/data/problems/basic-bubble-sort.json +1 -0
- package/data/problems/basic-calculator-ii.json +1 -0
- package/data/problems/basic-calculator-iii.json +1 -0
- package/data/problems/basic-calculator-iv.json +1 -0
- package/data/problems/basic-calculator.json +1 -0
- package/data/problems/basic-collatz-steps.json +1 -0
- package/data/problems/basic-contains-value.json +1 -0
- package/data/problems/basic-count-above.json +1 -0
- package/data/problems/basic-count-char.json +1 -0
- package/data/problems/basic-count-digits.json +1 -0
- package/data/problems/basic-count-evens.json +1 -0
- package/data/problems/basic-count-pairs.json +1 -0
- package/data/problems/basic-count-vowels.json +1 -0
- package/data/problems/basic-count-words.json +1 -0
- package/data/problems/basic-countdown.json +1 -0
- package/data/problems/basic-double-array.json +1 -0
- package/data/problems/basic-factorial-rec.json +1 -0
- package/data/problems/basic-factorial.json +1 -0
- package/data/problems/basic-fibonacci.json +1 -0
- package/data/problems/basic-find-index.json +1 -0
- package/data/problems/basic-gcd.json +1 -0
- package/data/problems/basic-grade-letter.json +1 -0
- package/data/problems/basic-has-duplicate.json +1 -0
- package/data/problems/basic-is-even.json +1 -0
- package/data/problems/basic-is-leap-year.json +1 -0
- package/data/problems/basic-is-sorted.json +1 -0
- package/data/problems/basic-max-frequency.json +1 -0
- package/data/problems/basic-max-of-three.json +1 -0
- package/data/problems/basic-max-of-two.json +1 -0
- package/data/problems/basic-palindrome-text.json +1 -0
- package/data/problems/basic-power-rec.json +1 -0
- package/data/problems/basic-power.json +1 -0
- package/data/problems/basic-repeat-string.json +1 -0
- package/data/problems/basic-reverse-array.json +1 -0
- package/data/problems/basic-reverse-number.json +1 -0
- package/data/problems/basic-reverse-text-rec.json +1 -0
- package/data/problems/basic-reverse-text.json +1 -0
- package/data/problems/basic-second-largest.json +1 -0
- package/data/problems/basic-sort-two.json +1 -0
- package/data/problems/basic-staircase.json +1 -0
- package/data/problems/basic-string-length.json +1 -0
- package/data/problems/basic-sum-1-to-n.json +1 -0
- package/data/problems/basic-sum-digits-rec.json +1 -0
- package/data/problems/basic-sum-multiples.json +1 -0
- package/data/problems/basic-sum-of-digits.json +1 -0
- package/data/problems/basic-temperature-advice.json +1 -0
- package/data/problems/basic-to-upper.json +1 -0
- package/data/problems/basic-triangle-sum.json +1 -0
- package/data/problems/battleships-in-a-board.json +1 -0
- package/data/problems/beautiful-arrangement-ii.json +1 -0
- package/data/problems/beautiful-arrangement.json +1 -0
- package/data/problems/beautiful-array.json +1 -0
- package/data/problems/best-meeting-point.json +1 -0
- package/data/problems/best-time-to-buy-and-sell-stock-ii.json +1 -0
- package/data/problems/best-time-to-buy-and-sell-stock-iii.json +1 -0
- package/data/problems/best-time-to-buy-and-sell-stock-iv.json +1 -0
- package/data/problems/best-time-to-buy-and-sell-stock-with-cooldown.json +1 -0
- package/data/problems/best-time-to-buy-and-sell-stock-with-transaction-fee.json +1 -0
- package/data/problems/best-time-to-buy-and-sell-stock.json +1 -0
- package/data/problems/binary-gap.json +1 -0
- package/data/problems/binary-number-with-alternating-bits.json +1 -0
- package/data/problems/binary-search-tree-iterator.json +1 -0
- package/data/problems/binary-search.json +1 -0
- package/data/problems/binary-subarrays-with-sum.json +1 -0
- package/data/problems/binary-tree-cameras.json +1 -0
- package/data/problems/binary-tree-inorder-traversal.json +1 -0
- package/data/problems/binary-tree-level-order-traversal-ii.json +1 -0
- package/data/problems/binary-tree-level-order-traversal.json +1 -0
- package/data/problems/binary-tree-longest-consecutive-sequence-ii.json +1 -0
- package/data/problems/binary-tree-longest-consecutive-sequence.json +1 -0
- package/data/problems/binary-tree-maximum-path-sum.json +1 -0
- package/data/problems/binary-tree-paths.json +1 -0
- package/data/problems/binary-tree-postorder-traversal.json +1 -0
- package/data/problems/binary-tree-preorder-traversal.json +1 -0
- package/data/problems/binary-tree-pruning.json +1 -0
- package/data/problems/binary-tree-right-side-view.json +1 -0
- package/data/problems/binary-tree-tilt.json +1 -0
- package/data/problems/binary-tree-upside-down.json +1 -0
- package/data/problems/binary-tree-vertical-order-traversal.json +1 -0
- package/data/problems/binary-tree-zigzag-level-order-traversal.json +1 -0
- package/data/problems/binary-trees-with-factors.json +1 -0
- package/data/problems/binary-watch.json +1 -0
- package/data/problems/bitwise-and-of-numbers-range.json +1 -0
- package/data/problems/bitwise-ors-of-subarrays.json +1 -0
- package/data/problems/boats-to-save-people.json +1 -0
- package/data/problems/bold-words-in-string.json +1 -0
- package/data/problems/bomb-enemy.json +1 -0
- package/data/problems/boundary-of-binary-tree.json +1 -0
- package/data/problems/brick-wall.json +1 -0
- package/data/problems/bricks-falling-when-hit.json +1 -0
- package/data/problems/broken-calculator.json +1 -0
- package/data/problems/buddy-strings.json +1 -0
- package/data/problems/build-a-matrix-with-conditions.json +1 -0
- package/data/problems/bulb-switcher-ii.json +1 -0
- package/data/problems/bulb-switcher.json +1 -0
- package/data/problems/bulls-and-cows.json +1 -0
- package/data/problems/burst-balloons.json +1 -0
- package/data/problems/bus-routes.json +1 -0
- package/data/problems/can-i-win.json +1 -0
- package/data/problems/can-place-flowers.json +1 -0
- package/data/problems/candy-crush.json +1 -0
- package/data/problems/candy.json +1 -0
- package/data/problems/capacity-to-ship-packages-within-d-days.json +1 -0
- package/data/problems/car-fleet.json +1 -0
- package/data/problems/car-pooling.json +1 -0
- package/data/problems/card-flipping-game.json +1 -0
- package/data/problems/cat-and-mouse.json +1 -0
- package/data/problems/chalkboard-xor-game.json +1 -0
- package/data/problems/champagne-tower.json +1 -0
- package/data/problems/cheapest-flights-within-k-stops.json +1 -0
- package/data/problems/check-completeness-of-a-binary-tree.json +1 -0
- package/data/problems/cherry-pickup.json +1 -0
- package/data/problems/circular-array-loop.json +1 -0
- package/data/problems/climbing-stairs.json +1 -0
- package/data/problems/clone-graph.json +1 -0
- package/data/problems/closest-binary-search-tree-value-ii.json +1 -0
- package/data/problems/closest-binary-search-tree-value.json +1 -0
- package/data/problems/closest-leaf-in-a-binary-tree.json +1 -0
- package/data/problems/coin-change-ii.json +1 -0
- package/data/problems/coin-change.json +1 -0
- package/data/problems/coin-path.json +1 -0
- package/data/problems/combination-sum-ii.json +1 -0
- package/data/problems/combination-sum-iii.json +1 -0
- package/data/problems/combination-sum-iv.json +1 -0
- package/data/problems/combination-sum.json +1 -0
- package/data/problems/combinations.json +1 -0
- package/data/problems/compare-version-numbers.json +1 -0
- package/data/problems/complete-binary-tree-inserter.json +1 -0
- package/data/problems/complex-number-multiplication.json +1 -0
- package/data/problems/concatenated-words.json +1 -0
- package/data/problems/concatenation-of-array.json +1 -0
- package/data/problems/consecutive-numbers-sum.json +1 -0
- package/data/problems/construct-binary-tree-from-inorder-and-postorder-traversal.json +1 -0
- package/data/problems/construct-binary-tree-from-preorder-and-inorder-traversal.json +1 -0
- package/data/problems/construct-binary-tree-from-preorder-and-postorder-traversal.json +1 -0
- package/data/problems/construct-binary-tree-from-string.json +1 -0
- package/data/problems/construct-quad-tree.json +1 -0
- package/data/problems/construct-string-from-binary-tree.json +1 -0
- package/data/problems/construct-the-rectangle.json +1 -0
- package/data/problems/contain-virus.json +1 -0
- package/data/problems/container-with-most-water.json +1 -0
- package/data/problems/contains-duplicate-ii.json +1 -0
- package/data/problems/contains-duplicate-iii.json +1 -0
- package/data/problems/contains-duplicate.json +1 -0
- package/data/problems/contiguous-array.json +1 -0
- package/data/problems/continuous-subarray-sum.json +1 -0
- package/data/problems/convert-a-number-to-hexadecimal.json +1 -0
- package/data/problems/convert-binary-search-tree-to-sorted-doubly-linked-list.json +1 -0
- package/data/problems/convert-bst-to-greater-tree.json +1 -0
- package/data/problems/convert-sorted-array-to-binary-search-tree.json +1 -0
- package/data/problems/convert-sorted-list-to-binary-search-tree.json +1 -0
- package/data/problems/convex-polygon.json +1 -0
- package/data/problems/copy-list-with-random-pointer.json +1 -0
- package/data/problems/count-and-say.json +1 -0
- package/data/problems/count-binary-substrings.json +1 -0
- package/data/problems/count-complete-tree-nodes.json +1 -0
- package/data/problems/count-different-palindromic-subsequences.json +1 -0
- package/data/problems/count-good-nodes-in-binary-tree.json +1 -0
- package/data/problems/count-numbers-with-unique-digits.json +1 -0
- package/data/problems/count-of-range-sum.json +1 -0
- package/data/problems/count-of-smaller-numbers-after-self.json +1 -0
- package/data/problems/count-primes.json +1 -0
- package/data/problems/count-the-repetitions.json +1 -0
- package/data/problems/count-unique-characters-of-all-substrings-of-a-given-string.json +1 -0
- package/data/problems/count-univalue-subtrees.json +1 -0
- package/data/problems/counting-bits.json +1 -0
- package/data/problems/couples-holding-hands.json +1 -0
- package/data/problems/course-schedule-ii.json +1 -0
- package/data/problems/course-schedule-iii.json +1 -0
- package/data/problems/course-schedule-iv.json +1 -0
- package/data/problems/course-schedule.json +1 -0
- package/data/problems/cousins-in-binary-tree.json +1 -0
- package/data/problems/cracking-the-safe.json +1 -0
- package/data/problems/create-maximum-number.json +1 -0
- package/data/problems/custom-sort-string.json +1 -0
- package/data/problems/cut-off-trees-for-golf-event.json +1 -0
- package/data/problems/daily-temperatures.json +1 -0
- package/data/problems/data-stream-as-disjoint-intervals.json +1 -0
- package/data/problems/decode-string.json +1 -0
- package/data/problems/decode-ways-ii.json +1 -0
- package/data/problems/decode-ways.json +1 -0
- package/data/problems/decoded-string-at-index.json +1 -0
- package/data/problems/degree-of-an-array.json +1 -0
- package/data/problems/delete-and-earn.json +1 -0
- package/data/problems/delete-columns-to-make-sorted-ii.json +1 -0
- package/data/problems/delete-columns-to-make-sorted-iii.json +1 -0
- package/data/problems/delete-columns-to-make-sorted.json +1 -0
- package/data/problems/delete-leaves-with-a-given-value.json +1 -0
- package/data/problems/delete-node-in-a-bst.json +1 -0
- package/data/problems/delete-node-in-a-linked-list.json +1 -0
- package/data/problems/delete-operation-for-two-strings.json +1 -0
- package/data/problems/design-add-and-search-words-data-structure.json +1 -0
- package/data/problems/design-circular-deque.json +1 -0
- package/data/problems/design-circular-queue.json +1 -0
- package/data/problems/design-compressed-string-iterator.json +1 -0
- package/data/problems/design-excel-sum-formula.json +1 -0
- package/data/problems/design-hashmap.json +1 -0
- package/data/problems/design-hashset.json +1 -0
- package/data/problems/design-hit-counter.json +1 -0
- package/data/problems/design-in-memory-file-system.json +1 -0
- package/data/problems/design-linked-list.json +1 -0
- package/data/problems/design-log-storage-system.json +1 -0
- package/data/problems/design-phone-directory.json +1 -0
- package/data/problems/design-search-autocomplete-system.json +1 -0
- package/data/problems/design-snake-game.json +1 -0
- package/data/problems/design-tic-tac-toe.json +1 -0
- package/data/problems/design-twitter.json +1 -0
- package/data/problems/detect-capital.json +1 -0
- package/data/problems/detect-squares.json +1 -0
- package/data/problems/di-string-match.json +1 -0
- package/data/problems/diagonal-traverse.json +1 -0
- package/data/problems/diameter-of-binary-tree.json +1 -0
- package/data/problems/different-ways-to-add-parentheses.json +1 -0
- package/data/problems/distinct-subsequences-ii.json +1 -0
- package/data/problems/distinct-subsequences.json +1 -0
- package/data/problems/distribute-candies.json +1 -0
- package/data/problems/distribute-coins-in-binary-tree.json +1 -0
- package/data/problems/divide-two-integers.json +1 -0
- package/data/problems/domino-and-tromino-tiling.json +1 -0
- package/data/problems/dota2-senate.json +1 -0
- package/data/problems/dungeon-game.json +1 -0
- package/data/problems/edit-distance.json +1 -0
- package/data/problems/elimination-game.json +1 -0
- package/data/problems/employee-free-time.json +1 -0
- package/data/problems/employee-importance.json +1 -0
- package/data/problems/encode-and-decode-strings.json +1 -0
- package/data/problems/encode-and-decode-tinyurl.json +1 -0
- package/data/problems/encode-n-ary-tree-to-binary-tree.json +1 -0
- package/data/problems/encode-string-with-shortest-length.json +1 -0
- package/data/problems/equal-rational-numbers.json +1 -0
- package/data/problems/equal-tree-partition.json +1 -0
- package/data/problems/erect-the-fence.json +1 -0
- package/data/problems/escape-the-ghosts.json +1 -0
- package/data/problems/evaluate-division.json +1 -0
- package/data/problems/evaluate-reverse-polish-notation.json +1 -0
- package/data/problems/exam-room.json +1 -0
- package/data/problems/excel-sheet-column-number.json +1 -0
- package/data/problems/excel-sheet-column-title.json +1 -0
- package/data/problems/exclusive-time-of-functions.json +1 -0
- package/data/problems/expression-add-operators.json +1 -0
- package/data/problems/expressive-words.json +1 -0
- package/data/problems/extra-characters-in-a-string.json +1 -0
- package/data/problems/factor-combinations.json +1 -0
- package/data/problems/factorial-trailing-zeroes.json +1 -0
- package/data/problems/fair-candy-swap.json +1 -0
- package/data/problems/falling-squares.json +1 -0
- package/data/problems/fibonacci-number.json +1 -0
- package/data/problems/find-all-anagrams-in-a-string.json +1 -0
- package/data/problems/find-all-duplicates-in-an-array.json +1 -0
- package/data/problems/find-all-numbers-disappeared-in-an-array.json +1 -0
- package/data/problems/find-anagram-mappings.json +1 -0
- package/data/problems/find-and-replace-in-string.json +1 -0
- package/data/problems/find-and-replace-pattern.json +1 -0
- package/data/problems/find-bottom-left-tree-value.json +1 -0
- package/data/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree.json +1 -0
- package/data/problems/find-duplicate-file-in-system.json +1 -0
- package/data/problems/find-duplicate-subtrees.json +1 -0
- package/data/problems/find-eventual-safe-states.json +1 -0
- package/data/problems/find-first-and-last-position-of-element-in-sorted-array.json +1 -0
- package/data/problems/find-in-mountain-array.json +1 -0
- package/data/problems/find-k-closest-elements.json +1 -0
- package/data/problems/find-k-pairs-with-smallest-sums.json +1 -0
- package/data/problems/find-k-th-smallest-pair-distance.json +1 -0
- package/data/problems/find-largest-value-in-each-tree-row.json +1 -0
- package/data/problems/find-leaves-of-binary-tree.json +1 -0
- package/data/problems/find-median-from-data-stream.json +1 -0
- package/data/problems/find-minimum-in-rotated-sorted-array-ii.json +1 -0
- package/data/problems/find-minimum-in-rotated-sorted-array.json +1 -0
- package/data/problems/find-mode-in-binary-search-tree.json +1 -0
- package/data/problems/find-peak-element.json +1 -0
- package/data/problems/find-permutation.json +1 -0
- package/data/problems/find-pivot-index.json +1 -0
- package/data/problems/find-right-interval.json +1 -0
- package/data/problems/find-smallest-letter-greater-than-target.json +1 -0
- package/data/problems/find-the-celebrity.json +1 -0
- package/data/problems/find-the-closest-palindrome.json +1 -0
- package/data/problems/find-the-derangement-of-an-array.json +1 -0
- package/data/problems/find-the-difference.json +1 -0
- package/data/problems/find-the-duplicate-number.json +1 -0
- package/data/problems/find-the-index-of-the-first-occurrence-in-a-string.json +1 -0
- package/data/problems/find-the-shortest-superstring.json +1 -0
- package/data/problems/find-the-town-judge.json +1 -0
- package/data/problems/first-bad-version.json +1 -0
- package/data/problems/first-missing-positive.json +1 -0
- package/data/problems/first-unique-character-in-a-string.json +1 -0
- package/data/problems/fizz-buzz.json +1 -0
- package/data/problems/flatten-2d-vector.json +1 -0
- package/data/problems/flatten-a-multilevel-doubly-linked-list.json +1 -0
- package/data/problems/flatten-binary-tree-to-linked-list.json +1 -0
- package/data/problems/flatten-nested-list-iterator.json +1 -0
- package/data/problems/flip-binary-tree-to-match-preorder-traversal.json +1 -0
- package/data/problems/flip-equivalent-binary-trees.json +1 -0
- package/data/problems/flip-game-ii.json +1 -0
- package/data/problems/flip-game.json +1 -0
- package/data/problems/flip-string-to-monotone-increasing.json +1 -0
- package/data/problems/flipping-an-image.json +1 -0
- package/data/problems/flood-fill.json +1 -0
- package/data/problems/fraction-addition-and-subtraction.json +1 -0
- package/data/problems/fraction-to-recurring-decimal.json +1 -0
- package/data/problems/freedom-trail.json +1 -0
- package/data/problems/friends-of-appropriate-ages.json +1 -0
- package/data/problems/frog-jump.json +1 -0
- package/data/problems/fruit-into-baskets.json +1 -0
- package/data/problems/game-of-life.json +1 -0
- package/data/problems/gas-station.json +1 -0
- package/data/problems/generalized-abbreviation.json +1 -0
- package/data/problems/generate-parentheses.json +1 -0
- package/data/problems/generate-random-point-in-a-circle.json +1 -0
- package/data/problems/global-and-local-inversions.json +1 -0
- package/data/problems/goat-latin.json +1 -0
- package/data/problems/graph-valid-tree.json +1 -0
- package/data/problems/gray-code.json +1 -0
- package/data/problems/greatest-common-divisor-of-strings.json +1 -0
- package/data/problems/greatest-common-divisor-traversal.json +1 -0
- package/data/problems/group-anagrams.json +1 -0
- package/data/problems/group-shifted-strings.json +1 -0
- package/data/problems/groups-of-special-equivalent-strings.json +1 -0
- package/data/problems/guess-number-higher-or-lower-ii.json +1 -0
- package/data/problems/guess-number-higher-or-lower.json +1 -0
- package/data/problems/guess-the-word.json +1 -0
- package/data/problems/h-index-ii.json +1 -0
- package/data/problems/h-index.json +1 -0
- package/data/problems/hamming-distance.json +1 -0
- package/data/problems/hand-of-straights.json +1 -0
- package/data/problems/happy-number.json +1 -0
- package/data/problems/heaters.json +1 -0
- package/data/problems/house-robber-ii.json +1 -0
- package/data/problems/house-robber-iii.json +1 -0
- package/data/problems/house-robber.json +1 -0
- package/data/problems/image-overlap.json +1 -0
- package/data/problems/image-smoother.json +1 -0
- package/data/problems/implement-magic-dictionary.json +1 -0
- package/data/problems/implement-queue-using-stacks.json +1 -0
- package/data/problems/implement-rand10-using-rand7.json +1 -0
- package/data/problems/implement-stack-using-queues.json +1 -0
- package/data/problems/implement-trie-prefix-tree.json +1 -0
- package/data/problems/increasing-order-search-tree.json +1 -0
- package/data/problems/increasing-triplet-subsequence.json +1 -0
- package/data/problems/inorder-successor-in-bst-ii.json +1 -0
- package/data/problems/inorder-successor-in-bst.json +1 -0
- package/data/problems/insert-delete-getrandom-o1-duplicates-allowed.json +1 -0
- package/data/problems/insert-delete-getrandom-o1.json +1 -0
- package/data/problems/insert-greatest-common-divisors-in-linked-list.json +1 -0
- package/data/problems/insert-interval.json +1 -0
- package/data/problems/insert-into-a-binary-search-tree.json +1 -0
- package/data/problems/insert-into-a-sorted-circular-linked-list.json +1 -0
- package/data/problems/insertion-sort-list.json +1 -0
- package/data/problems/integer-break.json +1 -0
- package/data/problems/integer-replacement.json +1 -0
- package/data/problems/integer-to-english-words.json +1 -0
- package/data/problems/integer-to-roman.json +1 -0
- package/data/problems/interleaving-string.json +1 -0
- package/data/problems/intersection-of-two-arrays-ii.json +1 -0
- package/data/problems/intersection-of-two-arrays.json +1 -0
- package/data/problems/intersection-of-two-linked-lists.json +1 -0
- package/data/problems/interval-list-intersections.json +1 -0
- package/data/problems/invert-binary-tree.json +1 -0
- package/data/problems/ip-to-cidr.json +1 -0
- package/data/problems/ipo.json +1 -0
- package/data/problems/is-graph-bipartite.json +1 -0
- package/data/problems/is-subsequence.json +1 -0
- package/data/problems/island-perimeter.json +1 -0
- package/data/problems/isomorphic-strings.json +1 -0
- package/data/problems/jewels-and-stones.json +1 -0
- package/data/problems/jump-game-ii.json +1 -0
- package/data/problems/jump-game-vii.json +1 -0
- package/data/problems/jump-game.json +1 -0
- package/data/problems/k-closest-points-to-origin.json +1 -0
- package/data/problems/k-diff-pairs-in-an-array.json +1 -0
- package/data/problems/k-empty-slots.json +1 -0
- package/data/problems/k-inverse-pairs-array.json +1 -0
- package/data/problems/k-similar-strings.json +1 -0
- package/data/problems/k-th-smallest-in-lexicographical-order.json +1 -0
- package/data/problems/k-th-smallest-prime-fraction.json +1 -0
- package/data/problems/k-th-symbol-in-grammar.json +1 -0
- package/data/problems/keyboard-row.json +1 -0
- package/data/problems/keys-and-rooms.json +1 -0
- package/data/problems/kill-process.json +1 -0
- package/data/problems/knight-dialer.json +1 -0
- package/data/problems/knight-probability-in-chessboard.json +1 -0
- package/data/problems/koko-eating-bananas.json +1 -0
- package/data/problems/kth-largest-element-in-a-stream.json +1 -0
- package/data/problems/kth-largest-element-in-an-array.json +1 -0
- package/data/problems/kth-smallest-element-in-a-bst.json +1 -0
- package/data/problems/kth-smallest-element-in-a-sorted-matrix.json +1 -0
- package/data/problems/kth-smallest-number-in-multiplication-table.json +1 -0
- package/data/problems/largest-bst-subtree.json +1 -0
- package/data/problems/largest-component-size-by-common-factor.json +1 -0
- package/data/problems/largest-divisible-subset.json +1 -0
- package/data/problems/largest-number-at-least-twice-of-others.json +1 -0
- package/data/problems/largest-number.json +1 -0
- package/data/problems/largest-palindrome-product.json +1 -0
- package/data/problems/largest-perimeter-triangle.json +1 -0
- package/data/problems/largest-plus-sign.json +1 -0
- package/data/problems/largest-rectangle-in-histogram.json +1 -0
- package/data/problems/largest-sum-of-averages.json +1 -0
- package/data/problems/largest-time-for-given-digits.json +1 -0
- package/data/problems/largest-triangle-area.json +1 -0
- package/data/problems/last-stone-weight-ii.json +1 -0
- package/data/problems/last-stone-weight.json +1 -0
- package/data/problems/leaf-similar-trees.json +1 -0
- package/data/problems/least-operators-to-express-number.json +1 -0
- package/data/problems/lemonade-change.json +1 -0
- package/data/problems/length-of-last-word.json +1 -0
- package/data/problems/length-of-longest-fibonacci-subsequence.json +1 -0
- package/data/problems/letter-case-permutation.json +1 -0
- package/data/problems/letter-combinations-of-a-phone-number.json +1 -0
- package/data/problems/lexicographical-numbers.json +1 -0
- package/data/problems/lfu-cache.json +1 -0
- package/data/problems/license-key-formatting.json +1 -0
- package/data/problems/line-reflection.json +1 -0
- package/data/problems/linked-list-components.json +1 -0
- package/data/problems/linked-list-cycle-ii.json +1 -0
- package/data/problems/linked-list-cycle.json +1 -0
- package/data/problems/linked-list-random-node.json +1 -0
- package/data/problems/logger-rate-limiter.json +1 -0
- package/data/problems/logical-or-of-two-binary-grids-represented-as-quad-trees.json +1 -0
- package/data/problems/lonely-pixel-i.json +1 -0
- package/data/problems/lonely-pixel-ii.json +1 -0
- package/data/problems/long-pressed-name.json +1 -0
- package/data/problems/longest-absolute-file-path.json +1 -0
- package/data/problems/longest-common-prefix.json +1 -0
- package/data/problems/longest-common-subsequence.json +1 -0
- package/data/problems/longest-consecutive-sequence.json +1 -0
- package/data/problems/longest-continuous-increasing-subsequence.json +1 -0
- package/data/problems/longest-happy-string.json +1 -0
- package/data/problems/longest-harmonious-subsequence.json +1 -0
- package/data/problems/longest-increasing-path-in-a-matrix.json +1 -0
- package/data/problems/longest-increasing-subsequence.json +1 -0
- package/data/problems/longest-line-of-consecutive-one-in-matrix.json +1 -0
- package/data/problems/longest-mountain-in-array.json +1 -0
- package/data/problems/longest-palindrome.json +1 -0
- package/data/problems/longest-palindromic-subsequence.json +1 -0
- package/data/problems/longest-palindromic-substring.json +1 -0
- package/data/problems/longest-repeating-character-replacement.json +1 -0
- package/data/problems/longest-substring-with-at-least-k-repeating-characters.json +1 -0
- package/data/problems/longest-substring-with-at-most-k-distinct-characters.json +1 -0
- package/data/problems/longest-substring-with-at-most-two-distinct-characters.json +1 -0
- package/data/problems/longest-substring-without-repeating-characters.json +1 -0
- package/data/problems/longest-turbulent-subarray.json +1 -0
- package/data/problems/longest-uncommon-subsequence-i.json +1 -0
- package/data/problems/longest-uncommon-subsequence-ii.json +1 -0
- package/data/problems/longest-univalue-path.json +1 -0
- package/data/problems/longest-valid-parentheses.json +1 -0
- package/data/problems/longest-word-in-dictionary-through-deleting.json +1 -0
- package/data/problems/longest-word-in-dictionary.json +1 -0
- package/data/problems/loud-and-rich.json +1 -0
- package/data/problems/lowest-common-ancestor-of-a-binary-search-tree.json +1 -0
- package/data/problems/lowest-common-ancestor-of-a-binary-tree.json +1 -0
- package/data/problems/lru-cache.json +1 -0
- package/data/problems/magic-squares-in-grid.json +1 -0
- package/data/problems/magical-string.json +1 -0
- package/data/problems/majority-element-ii.json +1 -0
- package/data/problems/majority-element.json +1 -0
- package/data/problems/making-a-large-island.json +1 -0
- package/data/problems/map-sum-pairs.json +1 -0
- package/data/problems/masking-personal-information.json +1 -0
- package/data/problems/matchsticks-to-square.json +1 -0
- package/data/problems/max-area-of-island.json +1 -0
- package/data/problems/max-chunks-to-make-sorted-ii.json +1 -0
- package/data/problems/max-chunks-to-make-sorted.json +1 -0
- package/data/problems/max-consecutive-ones-ii.json +1 -0
- package/data/problems/max-consecutive-ones.json +1 -0
- package/data/problems/max-increase-to-keep-city-skyline.json +1 -0
- package/data/problems/max-points-on-a-line.json +1 -0
- package/data/problems/max-stack.json +1 -0
- package/data/problems/max-sum-of-rectangle-no-larger-than-k.json +1 -0
- package/data/problems/maximal-rectangle.json +1 -0
- package/data/problems/maximal-square.json +1 -0
- package/data/problems/maximize-distance-to-closest-person.json +1 -0
- package/data/problems/maximum-average-subarray-i.json +1 -0
- package/data/problems/maximum-average-subarray-ii.json +1 -0
- package/data/problems/maximum-binary-tree-ii.json +1 -0
- package/data/problems/maximum-binary-tree.json +1 -0
- package/data/problems/maximum-depth-of-binary-tree.json +1 -0
- package/data/problems/maximum-depth-of-n-ary-tree.json +1 -0
- package/data/problems/maximum-distance-in-arrays.json +1 -0
- package/data/problems/maximum-frequency-stack.json +1 -0
- package/data/problems/maximum-gap.json +1 -0
- package/data/problems/maximum-length-of-pair-chain.json +1 -0
- package/data/problems/maximum-length-of-repeated-subarray.json +1 -0
- package/data/problems/maximum-product-of-three-numbers.json +1 -0
- package/data/problems/maximum-product-of-word-lengths.json +1 -0
- package/data/problems/maximum-product-subarray.json +1 -0
- package/data/problems/maximum-size-subarray-sum-equals-k.json +1 -0
- package/data/problems/maximum-subarray.json +1 -0
- package/data/problems/maximum-sum-circular-subarray.json +1 -0
- package/data/problems/maximum-sum-of-3-non-overlapping-subarrays.json +1 -0
- package/data/problems/maximum-swap.json +1 -0
- package/data/problems/maximum-vacation-days.json +1 -0
- package/data/problems/maximum-width-of-binary-tree.json +1 -0
- package/data/problems/maximum-width-ramp.json +1 -0
- package/data/problems/maximum-xor-of-two-numbers-in-an-array.json +1 -0
- package/data/problems/median-of-two-sorted-arrays.json +1 -0
- package/data/problems/meeting-rooms-ii.json +1 -0
- package/data/problems/meeting-rooms-iii.json +1 -0
- package/data/problems/meeting-rooms.json +1 -0
- package/data/problems/merge-intervals.json +1 -0
- package/data/problems/merge-k-sorted-lists.json +1 -0
- package/data/problems/merge-sorted-array.json +1 -0
- package/data/problems/merge-strings-alternately.json +1 -0
- package/data/problems/merge-triplets-to-form-target-triplet.json +1 -0
- package/data/problems/merge-two-binary-trees.json +1 -0
- package/data/problems/merge-two-sorted-lists.json +1 -0
- package/data/problems/middle-of-the-linked-list.json +1 -0
- package/data/problems/min-cost-climbing-stairs.json +1 -0
- package/data/problems/min-cost-to-connect-all-points.json +1 -0
- package/data/problems/min-stack.json +1 -0
- package/data/problems/minesweeper.json +1 -0
- package/data/problems/mini-parser.json +1 -0
- package/data/problems/minimize-malware-spread-ii.json +1 -0
- package/data/problems/minimize-malware-spread.json +1 -0
- package/data/problems/minimize-max-distance-to-gas-station.json +1 -0
- package/data/problems/minimum-absolute-difference-in-bst.json +1 -0
- package/data/problems/minimum-add-to-make-parentheses-valid.json +1 -0
- package/data/problems/minimum-area-rectangle-ii.json +1 -0
- package/data/problems/minimum-area-rectangle.json +1 -0
- package/data/problems/minimum-array-end.json +1 -0
- package/data/problems/minimum-ascii-delete-sum-for-two-strings.json +1 -0
- package/data/problems/minimum-cost-for-tickets.json +1 -0
- package/data/problems/minimum-cost-to-hire-k-workers.json +1 -0
- package/data/problems/minimum-cost-to-merge-stones.json +1 -0
- package/data/problems/minimum-depth-of-binary-tree.json +1 -0
- package/data/problems/minimum-distance-between-bst-nodes.json +1 -0
- package/data/problems/minimum-factorization.json +1 -0
- package/data/problems/minimum-falling-path-sum.json +1 -0
- package/data/problems/minimum-genetic-mutation.json +1 -0
- package/data/problems/minimum-height-trees.json +1 -0
- package/data/problems/minimum-increment-to-make-array-unique.json +1 -0
- package/data/problems/minimum-index-sum-of-two-lists.json +1 -0
- package/data/problems/minimum-interval-to-include-each-query.json +1 -0
- package/data/problems/minimum-moves-to-equal-array-elements-ii.json +1 -0
- package/data/problems/minimum-moves-to-equal-array-elements.json +1 -0
- package/data/problems/minimum-number-of-arrows-to-burst-balloons.json +1 -0
- package/data/problems/minimum-number-of-k-consecutive-bit-flips.json +1 -0
- package/data/problems/minimum-number-of-refueling-stops.json +1 -0
- package/data/problems/minimum-path-sum.json +1 -0
- package/data/problems/minimum-size-subarray-sum.json +1 -0
- package/data/problems/minimum-swaps-to-make-sequences-increasing.json +1 -0
- package/data/problems/minimum-time-difference.json +1 -0
- package/data/problems/minimum-unique-word-abbreviation.json +1 -0
- package/data/problems/minimum-window-subsequence.json +1 -0
- package/data/problems/minimum-window-substring.json +1 -0
- package/data/problems/mirror-reflection.json +1 -0
- package/data/problems/missing-number.json +1 -0
- package/data/problems/missing-ranges.json +1 -0
- package/data/problems/monotone-increasing-digits.json +1 -0
- package/data/problems/monotonic-array.json +1 -0
- package/data/problems/most-common-word.json +1 -0
- package/data/problems/most-frequent-subtree-sum.json +1 -0
- package/data/problems/most-profit-assigning-work.json +1 -0
- package/data/problems/most-stones-removed-with-same-row-or-column.json +1 -0
- package/data/problems/move-zeroes.json +1 -0
- package/data/problems/moving-average-from-data-stream.json +1 -0
- package/data/problems/multiply-strings.json +1 -0
- package/data/problems/my-calendar-i.json +1 -0
- package/data/problems/my-calendar-ii.json +1 -0
- package/data/problems/my-calendar-iii.json +1 -0
- package/data/problems/n-ary-tree-level-order-traversal.json +1 -0
- package/data/problems/n-ary-tree-postorder-traversal.json +1 -0
- package/data/problems/n-ary-tree-preorder-traversal.json +1 -0
- package/data/problems/n-queens-ii.json +1 -0
- package/data/problems/n-queens.json +1 -0
- package/data/problems/n-repeated-element-in-size-2n-array.json +1 -0
- package/data/problems/n-th-tribonacci-number.json +1 -0
- package/data/problems/nested-list-weight-sum-ii.json +1 -0
- package/data/problems/nested-list-weight-sum.json +1 -0
- package/data/problems/network-delay-time.json +1 -0
- package/data/problems/new-21-game.json +1 -0
- package/data/problems/next-closest-time.json +1 -0
- package/data/problems/next-greater-element-i.json +1 -0
- package/data/problems/next-greater-element-ii.json +1 -0
- package/data/problems/next-greater-element-iii.json +1 -0
- package/data/problems/next-permutation.json +1 -0
- package/data/problems/nim-game.json +1 -0
- package/data/problems/non-decreasing-array.json +1 -0
- package/data/problems/non-decreasing-subsequences.json +1 -0
- package/data/problems/non-negative-integers-without-consecutive-ones.json +1 -0
- package/data/problems/non-overlapping-intervals.json +1 -0
- package/data/problems/nth-digit.json +1 -0
- package/data/problems/nth-magical-number.json +1 -0
- package/data/problems/number-complement.json +1 -0
- package/data/problems/number-of-1-bits.json +1 -0
- package/data/problems/number-of-atoms.json +1 -0
- package/data/problems/number-of-boomerangs.json +1 -0
- package/data/problems/number-of-connected-components-in-an-undirected-graph.json +1 -0
- package/data/problems/number-of-corner-rectangles.json +1 -0
- package/data/problems/number-of-digit-one.json +1 -0
- package/data/problems/number-of-distinct-islands-ii.json +1 -0
- package/data/problems/number-of-distinct-islands.json +1 -0
- package/data/problems/number-of-islands-ii.json +1 -0
- package/data/problems/number-of-islands.json +1 -0
- package/data/problems/number-of-lines-to-write-string.json +1 -0
- package/data/problems/number-of-longest-increasing-subsequence.json +1 -0
- package/data/problems/number-of-matching-subsequences.json +1 -0
- package/data/problems/number-of-music-playlists.json +1 -0
- package/data/problems/number-of-provinces.json +1 -0
- package/data/problems/number-of-recent-calls.json +1 -0
- package/data/problems/number-of-segments-in-a-string.json +1 -0
- package/data/problems/number-of-squareful-arrays.json +1 -0
- package/data/problems/number-of-subarrays-with-bounded-maximum.json +1 -0
- package/data/problems/numbers-at-most-n-given-digit-set.json +1 -0
- package/data/problems/numbers-with-same-consecutive-differences.json +1 -0
- package/data/problems/odd-even-jump.json +1 -0
- package/data/problems/odd-even-linked-list.json +1 -0
- package/data/problems/one-edit-distance.json +1 -0
- package/data/problems/ones-and-zeroes.json +1 -0
- package/data/problems/online-election.json +1 -0
- package/data/problems/online-stock-span.json +1 -0
- package/data/problems/open-the-lock.json +1 -0
- package/data/problems/optimal-account-balancing.json +1 -0
- package/data/problems/optimal-division.json +1 -0
- package/data/problems/orderly-queue.json +1 -0
- package/data/problems/out-of-boundary-paths.json +1 -0
- package/data/problems/output-contest-matches.json +1 -0
- package/data/problems/pacific-atlantic-water-flow.json +1 -0
- package/data/problems/paint-fence.json +1 -0
- package/data/problems/paint-house-ii.json +1 -0
- package/data/problems/paint-house.json +1 -0
- package/data/problems/palindrome-linked-list.json +1 -0
- package/data/problems/palindrome-number.json +1 -0
- package/data/problems/palindrome-pairs.json +1 -0
- package/data/problems/palindrome-partitioning-ii.json +1 -0
- package/data/problems/palindrome-partitioning.json +1 -0
- package/data/problems/palindrome-permutation-ii.json +1 -0
- package/data/problems/palindrome-permutation.json +1 -0
- package/data/problems/palindromic-substrings.json +1 -0
- package/data/problems/pancake-sorting.json +1 -0
- package/data/problems/parse-lisp-expression.json +1 -0
- package/data/problems/partition-array-into-disjoint-intervals.json +1 -0
- package/data/problems/partition-equal-subset-sum.json +1 -0
- package/data/problems/partition-labels.json +1 -0
- package/data/problems/partition-list.json +1 -0
- package/data/problems/partition-to-k-equal-sum-subsets.json +1 -0
- package/data/problems/pascals-triangle-ii.json +1 -0
- package/data/problems/pascals-triangle.json +1 -0
- package/data/problems/patching-array.json +1 -0
- package/data/problems/path-sum-ii.json +1 -0
- package/data/problems/path-sum-iii.json +1 -0
- package/data/problems/path-sum-iv.json +1 -0
- package/data/problems/path-sum.json +1 -0
- package/data/problems/path-with-minimum-effort.json +1 -0
- package/data/problems/peak-index-in-a-mountain-array.json +1 -0
- package/data/problems/peeking-iterator.json +1 -0
- package/data/problems/perfect-number.json +1 -0
- package/data/problems/perfect-rectangle.json +1 -0
- package/data/problems/perfect-squares.json +1 -0
- package/data/problems/permutation-in-string.json +1 -0
- package/data/problems/permutation-sequence.json +1 -0
- package/data/problems/permutations-ii.json +1 -0
- package/data/problems/permutations.json +1 -0
- package/data/problems/plus-one-linked-list.json +1 -0
- package/data/problems/plus-one.json +1 -0
- package/data/problems/poor-pigs.json +1 -0
- package/data/problems/populating-next-right-pointers-in-each-node-ii.json +1 -0
- package/data/problems/populating-next-right-pointers-in-each-node.json +1 -0
- package/data/problems/positions-of-large-groups.json +1 -0
- package/data/problems/possible-bipartition.json +1 -0
- package/data/problems/pour-water.json +1 -0
- package/data/problems/power-of-four.json +1 -0
- package/data/problems/power-of-three.json +1 -0
- package/data/problems/power-of-two.json +1 -0
- package/data/problems/powerful-integers.json +1 -0
- package/data/problems/powx-n.json +1 -0
- package/data/problems/predict-the-winner.json +1 -0
- package/data/problems/prefix-and-suffix-search.json +1 -0
- package/data/problems/preimage-size-of-factorial-zeroes-function.json +1 -0
- package/data/problems/prime-number-of-set-bits-in-binary-representation.json +1 -0
- package/data/problems/prime-palindrome.json +1 -0
- package/data/problems/print-binary-tree.json +1 -0
- package/data/problems/prison-cells-after-n-days.json +1 -0
- package/data/problems/product-of-array-except-self.json +1 -0
- package/data/problems/profitable-schemes.json +1 -0
- package/data/problems/projection-area-of-3d-shapes.json +1 -0
- package/data/problems/push-dominoes.json +1 -0
- package/data/problems/pyramid-transition-matrix.json +1 -0
- package/data/problems/queue-reconstruction-by-height.json +1 -0
- package/data/problems/rabbits-in-forest.json +1 -0
- package/data/problems/race-car.json +1 -0
- package/data/problems/random-flip-matrix.json +1 -0
- package/data/problems/random-pick-index.json +1 -0
- package/data/problems/random-pick-with-blacklist.json +1 -0
- package/data/problems/random-pick-with-weight.json +1 -0
- package/data/problems/random-point-in-non-overlapping-rectangles.json +1 -0
- package/data/problems/range-addition-ii.json +1 -0
- package/data/problems/range-addition.json +1 -0
- package/data/problems/range-module.json +1 -0
- package/data/problems/range-sum-of-bst.json +1 -0
- package/data/problems/range-sum-query-2d-immutable.json +1 -0
- package/data/problems/range-sum-query-2d-mutable.json +1 -0
- package/data/problems/range-sum-query-immutable.json +1 -0
- package/data/problems/range-sum-query-mutable.json +1 -0
- package/data/problems/ransom-note.json +1 -0
- package/data/problems/reach-a-number.json +1 -0
- package/data/problems/reachable-nodes-in-subdivided-graph.json +1 -0
- package/data/problems/reaching-points.json +1 -0
- package/data/problems/read-n-characters-given-read4-ii-call-multiple-times.json +1 -0
- package/data/problems/read-n-characters-given-read4.json +1 -0
- package/data/problems/rearrange-string-k-distance-apart.json +1 -0
- package/data/problems/reconstruct-itinerary.json +1 -0
- package/data/problems/reconstruct-original-digits-from-english.json +1 -0
- package/data/problems/recover-binary-search-tree.json +1 -0
- package/data/problems/rectangle-area-ii.json +1 -0
- package/data/problems/rectangle-area.json +1 -0
- package/data/problems/rectangle-overlap.json +1 -0
- package/data/problems/redundant-connection-ii.json +1 -0
- package/data/problems/redundant-connection.json +1 -0
- package/data/problems/regions-cut-by-slashes.json +1 -0
- package/data/problems/regular-expression-matching.json +1 -0
- package/data/problems/relative-ranks.json +1 -0
- package/data/problems/remove-9.json +1 -0
- package/data/problems/remove-boxes.json +1 -0
- package/data/problems/remove-comments.json +1 -0
- package/data/problems/remove-duplicate-letters.json +1 -0
- package/data/problems/remove-duplicates-from-sorted-array-ii.json +1 -0
- package/data/problems/remove-duplicates-from-sorted-array.json +1 -0
- package/data/problems/remove-duplicates-from-sorted-list-ii.json +1 -0
- package/data/problems/remove-duplicates-from-sorted-list.json +1 -0
- package/data/problems/remove-element.json +1 -0
- package/data/problems/remove-invalid-parentheses.json +1 -0
- package/data/problems/remove-k-digits.json +1 -0
- package/data/problems/remove-linked-list-elements.json +1 -0
- package/data/problems/remove-nth-node-from-end-of-list.json +1 -0
- package/data/problems/reorder-data-in-log-files.json +1 -0
- package/data/problems/reorder-list.json +1 -0
- package/data/problems/reordered-power-of-2.json +1 -0
- package/data/problems/reorganize-string.json +1 -0
- package/data/problems/repeated-dna-sequences.json +1 -0
- package/data/problems/repeated-string-match.json +1 -0
- package/data/problems/repeated-substring-pattern.json +1 -0
- package/data/problems/replace-words.json +1 -0
- package/data/problems/reshape-the-matrix.json +1 -0
- package/data/problems/restore-ip-addresses.json +1 -0
- package/data/problems/reveal-cards-in-increasing-order.json +1 -0
- package/data/problems/reverse-bits.json +1 -0
- package/data/problems/reverse-integer.json +1 -0
- package/data/problems/reverse-linked-list-ii.json +1 -0
- package/data/problems/reverse-linked-list.json +1 -0
- package/data/problems/reverse-nodes-in-k-group.json +1 -0
- package/data/problems/reverse-only-letters.json +1 -0
- package/data/problems/reverse-pairs.json +1 -0
- package/data/problems/reverse-string-ii.json +1 -0
- package/data/problems/reverse-string.json +1 -0
- package/data/problems/reverse-vowels-of-a-string.json +1 -0
- package/data/problems/reverse-words-in-a-string-ii.json +1 -0
- package/data/problems/reverse-words-in-a-string-iii.json +1 -0
- package/data/problems/reverse-words-in-a-string.json +1 -0
- package/data/problems/rle-iterator.json +1 -0
- package/data/problems/robot-return-to-origin.json +1 -0
- package/data/problems/robot-room-cleaner.json +1 -0
- package/data/problems/roman-to-integer.json +1 -0
- package/data/problems/rotate-array.json +1 -0
- package/data/problems/rotate-function.json +1 -0
- package/data/problems/rotate-image.json +1 -0
- package/data/problems/rotate-list.json +1 -0
- package/data/problems/rotate-string.json +1 -0
- package/data/problems/rotated-digits.json +1 -0
- package/data/problems/rotting-oranges.json +1 -0
- package/data/problems/russian-doll-envelopes.json +1 -0
- package/data/problems/same-tree.json +1 -0
- package/data/problems/satisfiability-of-equality-equations.json +1 -0
- package/data/problems/score-after-flipping-matrix.json +1 -0
- package/data/problems/score-of-parentheses.json +1 -0
- package/data/problems/scramble-string.json +1 -0
- package/data/problems/search-a-2d-matrix-ii.json +1 -0
- package/data/problems/search-a-2d-matrix.json +1 -0
- package/data/problems/search-in-a-binary-search-tree.json +1 -0
- package/data/problems/search-in-a-sorted-array-of-unknown-size.json +1 -0
- package/data/problems/search-in-rotated-sorted-array-ii.json +1 -0
- package/data/problems/search-in-rotated-sorted-array.json +1 -0
- package/data/problems/search-insert-position.json +1 -0
- package/data/problems/second-minimum-node-in-a-binary-tree.json +1 -0
- package/data/problems/self-crossing.json +1 -0
- package/data/problems/self-dividing-numbers.json +1 -0
- package/data/problems/sentence-screen-fitting.json +1 -0
- package/data/problems/sentence-similarity-ii.json +1 -0
- package/data/problems/sentence-similarity.json +1 -0
- package/data/problems/sequence-reconstruction.json +1 -0
- package/data/problems/serialize-and-deserialize-binary-tree.json +1 -0
- package/data/problems/serialize-and-deserialize-bst.json +1 -0
- package/data/problems/serialize-and-deserialize-n-ary-tree.json +1 -0
- package/data/problems/set-intersection-size-at-least-two.json +1 -0
- package/data/problems/set-matrix-zeroes.json +1 -0
- package/data/problems/set-mismatch.json +1 -0
- package/data/problems/shifting-letters.json +1 -0
- package/data/problems/shopping-offers.json +1 -0
- package/data/problems/short-encoding-of-words.json +1 -0
- package/data/problems/shortest-bridge.json +1 -0
- package/data/problems/shortest-completing-word.json +1 -0
- package/data/problems/shortest-distance-from-all-buildings.json +1 -0
- package/data/problems/shortest-distance-to-a-character.json +1 -0
- package/data/problems/shortest-palindrome.json +1 -0
- package/data/problems/shortest-path-to-get-all-keys.json +1 -0
- package/data/problems/shortest-path-visiting-all-nodes.json +1 -0
- package/data/problems/shortest-subarray-with-sum-at-least-k.json +1 -0
- package/data/problems/shortest-unsorted-continuous-subarray.json +1 -0
- package/data/problems/shortest-word-distance-ii.json +1 -0
- package/data/problems/shortest-word-distance-iii.json +1 -0
- package/data/problems/shortest-word-distance.json +1 -0
- package/data/problems/shuffle-an-array.json +1 -0
- package/data/problems/similar-rgb-color.json +1 -0
- package/data/problems/similar-string-groups.json +1 -0
- package/data/problems/simplify-path.json +1 -0
- package/data/problems/single-element-in-a-sorted-array.json +1 -0
- package/data/problems/single-number-ii.json +1 -0
- package/data/problems/single-number-iii.json +1 -0
- package/data/problems/single-number.json +1 -0
- package/data/problems/single-threaded-cpu.json +1 -0
- package/data/problems/sliding-puzzle.json +1 -0
- package/data/problems/sliding-window-maximum.json +1 -0
- package/data/problems/sliding-window-median.json +1 -0
- package/data/problems/smallest-good-base.json +1 -0
- package/data/problems/smallest-range-covering-elements-from-k-lists.json +1 -0
- package/data/problems/smallest-range-i.json +1 -0
- package/data/problems/smallest-range-ii.json +1 -0
- package/data/problems/smallest-rectangle-enclosing-black-pixels.json +1 -0
- package/data/problems/smallest-rotation-with-highest-score.json +1 -0
- package/data/problems/smallest-string-starting-from-leaf.json +1 -0
- package/data/problems/smallest-subtree-with-all-the-deepest-nodes.json +1 -0
- package/data/problems/snakes-and-ladders.json +1 -0
- package/data/problems/solve-the-equation.json +1 -0
- package/data/problems/sort-an-array.json +1 -0
- package/data/problems/sort-array-by-parity-ii.json +1 -0
- package/data/problems/sort-array-by-parity.json +1 -0
- package/data/problems/sort-characters-by-frequency.json +1 -0
- package/data/problems/sort-colors.json +1 -0
- package/data/problems/sort-list.json +1 -0
- package/data/problems/sort-transformed-array.json +1 -0
- package/data/problems/soup-servings.json +1 -0
- package/data/problems/sparse-matrix-multiplication.json +1 -0
- package/data/problems/special-binary-string.json +1 -0
- package/data/problems/spiral-matrix-ii.json +1 -0
- package/data/problems/spiral-matrix-iii.json +1 -0
- package/data/problems/spiral-matrix.json +1 -0
- package/data/problems/split-array-into-consecutive-subsequences.json +1 -0
- package/data/problems/split-array-into-fibonacci-sequence.json +1 -0
- package/data/problems/split-array-largest-sum.json +1 -0
- package/data/problems/split-array-with-equal-sum.json +1 -0
- package/data/problems/split-array-with-same-average.json +1 -0
- package/data/problems/split-bst.json +1 -0
- package/data/problems/split-concatenated-strings.json +1 -0
- package/data/problems/split-linked-list-in-parts.json +1 -0
- package/data/problems/sqrtx.json +1 -0
- package/data/problems/squares-of-a-sorted-array.json +1 -0
- package/data/problems/squirrel-simulation.json +1 -0
- package/data/problems/stamping-the-sequence.json +1 -0
- package/data/problems/stickers-to-spell-word.json +1 -0
- package/data/problems/stone-game-ii.json +1 -0
- package/data/problems/stone-game-iii.json +1 -0
- package/data/problems/stone-game.json +1 -0
- package/data/problems/strange-printer.json +1 -0
- package/data/problems/string-compression.json +1 -0
- package/data/problems/string-to-integer-atoi.json +1 -0
- package/data/problems/string-without-aaa-or-bbb.json +1 -0
- package/data/problems/strobogrammatic-number-ii.json +1 -0
- package/data/problems/strobogrammatic-number-iii.json +1 -0
- package/data/problems/strobogrammatic-number.json +1 -0
- package/data/problems/strong-password-checker.json +1 -0
- package/data/problems/student-attendance-record-i.json +1 -0
- package/data/problems/student-attendance-record-ii.json +1 -0
- package/data/problems/subarray-product-less-than-k.json +1 -0
- package/data/problems/subarray-sum-equals-k.json +1 -0
- package/data/problems/subarray-sums-divisible-by-k.json +1 -0
- package/data/problems/subarrays-with-k-different-integers.json +1 -0
- package/data/problems/subdomain-visit-count.json +1 -0
- package/data/problems/subsets-ii.json +1 -0
- package/data/problems/subsets.json +1 -0
- package/data/problems/substring-with-concatenation-of-all-words.json +1 -0
- package/data/problems/subtree-of-another-tree.json +1 -0
- package/data/problems/sudoku-solver.json +1 -0
- package/data/problems/sum-of-all-subset-xor-totals.json +1 -0
- package/data/problems/sum-of-distances-in-tree.json +1 -0
- package/data/problems/sum-of-even-numbers-after-queries.json +1 -0
- package/data/problems/sum-of-left-leaves.json +1 -0
- package/data/problems/sum-of-square-numbers.json +1 -0
- package/data/problems/sum-of-subarray-minimums.json +1 -0
- package/data/problems/sum-of-subsequence-widths.json +1 -0
- package/data/problems/sum-of-two-integers.json +1 -0
- package/data/problems/sum-root-to-leaf-numbers.json +1 -0
- package/data/problems/summary-ranges.json +1 -0
- package/data/problems/super-egg-drop.json +1 -0
- package/data/problems/super-palindromes.json +1 -0
- package/data/problems/super-pow.json +1 -0
- package/data/problems/super-ugly-number.json +1 -0
- package/data/problems/super-washing-machines.json +1 -0
- package/data/problems/surface-area-of-3d-shapes.json +1 -0
- package/data/problems/surrounded-regions.json +1 -0
- package/data/problems/swap-adjacent-in-lr-string.json +1 -0
- package/data/problems/swap-nodes-in-pairs.json +1 -0
- package/data/problems/swim-in-rising-water.json +1 -0
- package/data/problems/symmetric-tree.json +1 -0
- package/data/problems/tag-validator.json +1 -0
- package/data/problems/tallest-billboard.json +1 -0
- package/data/problems/target-sum.json +1 -0
- package/data/problems/task-scheduler.json +1 -0
- package/data/problems/teemo-attacking.json +1 -0
- package/data/problems/ternary-expression-parser.json +1 -0
- package/data/problems/text-justification.json +1 -0
- package/data/problems/the-maze-ii.json +1 -0
- package/data/problems/the-maze-iii.json +1 -0
- package/data/problems/the-maze.json +1 -0
- package/data/problems/the-skyline-problem.json +1 -0
- package/data/problems/third-maximum-number.json +1 -0
- package/data/problems/three-equal-parts.json +1 -0
- package/data/problems/time-based-key-value-store.json +1 -0
- package/data/problems/to-lower-case.json +1 -0
- package/data/problems/toeplitz-matrix.json +1 -0
- package/data/problems/top-k-frequent-elements.json +1 -0
- package/data/problems/top-k-frequent-words.json +1 -0
- package/data/problems/total-hamming-distance.json +1 -0
- package/data/problems/transform-to-chessboard.json +1 -0
- package/data/problems/transpose-matrix.json +1 -0
- package/data/problems/trapping-rain-water-ii.json +1 -0
- package/data/problems/trapping-rain-water.json +1 -0
- package/data/problems/triangle.json +1 -0
- package/data/problems/trim-a-binary-search-tree.json +1 -0
- package/data/problems/triples-with-bitwise-and-equal-to-zero.json +1 -0
- package/data/problems/two-sum-ii-input-array-is-sorted.json +1 -0
- package/data/problems/two-sum-iii-data-structure-design.json +1 -0
- package/data/problems/two-sum-iv-input-is-a-bst.json +1 -0
- package/data/problems/two-sum.json +1 -0
- package/data/problems/ugly-number-ii.json +1 -0
- package/data/problems/ugly-number.json +1 -0
- package/data/problems/uncommon-words-from-two-sentences.json +1 -0
- package/data/problems/unique-binary-search-trees-ii.json +1 -0
- package/data/problems/unique-binary-search-trees.json +1 -0
- package/data/problems/unique-email-addresses.json +1 -0
- package/data/problems/unique-morse-code-words.json +1 -0
- package/data/problems/unique-paths-ii.json +1 -0
- package/data/problems/unique-paths-iii.json +1 -0
- package/data/problems/unique-paths.json +1 -0
- package/data/problems/unique-substrings-in-wraparound-string.json +1 -0
- package/data/problems/unique-word-abbreviation.json +1 -0
- package/data/problems/univalued-binary-tree.json +1 -0
- package/data/problems/utf-8-validation.json +1 -0
- package/data/problems/valid-anagram.json +1 -0
- package/data/problems/valid-mountain-array.json +1 -0
- package/data/problems/valid-number.json +1 -0
- package/data/problems/valid-palindrome-ii.json +1 -0
- package/data/problems/valid-palindrome.json +1 -0
- package/data/problems/valid-parentheses.json +1 -0
- package/data/problems/valid-parenthesis-string.json +1 -0
- package/data/problems/valid-perfect-square.json +1 -0
- package/data/problems/valid-permutations-for-di-sequence.json +1 -0
- package/data/problems/valid-square.json +1 -0
- package/data/problems/valid-sudoku.json +1 -0
- package/data/problems/valid-tic-tac-toe-state.json +1 -0
- package/data/problems/valid-triangle-number.json +1 -0
- package/data/problems/valid-word-abbreviation.json +1 -0
- package/data/problems/valid-word-square.json +1 -0
- package/data/problems/validate-binary-search-tree.json +1 -0
- package/data/problems/validate-ip-address.json +1 -0
- package/data/problems/validate-stack-sequences.json +1 -0
- package/data/problems/verify-preorder-sequence-in-binary-search-tree.json +1 -0
- package/data/problems/verify-preorder-serialization-of-a-binary-tree.json +1 -0
- package/data/problems/verifying-an-alien-dictionary.json +1 -0
- package/data/problems/vertical-order-traversal-of-a-binary-tree.json +1 -0
- package/data/problems/vowel-spellchecker.json +1 -0
- package/data/problems/walking-robot-simulation.json +1 -0
- package/data/problems/walls-and-gates.json +1 -0
- package/data/problems/water-and-jug-problem.json +1 -0
- package/data/problems/wiggle-sort-ii.json +1 -0
- package/data/problems/wiggle-sort.json +1 -0
- package/data/problems/wiggle-subsequence.json +1 -0
- package/data/problems/wildcard-matching.json +1 -0
- package/data/problems/word-abbreviation.json +1 -0
- package/data/problems/word-break-ii.json +1 -0
- package/data/problems/word-break.json +1 -0
- package/data/problems/word-ladder-ii.json +1 -0
- package/data/problems/word-ladder.json +1 -0
- package/data/problems/word-pattern-ii.json +1 -0
- package/data/problems/word-pattern.json +1 -0
- package/data/problems/word-search-ii.json +1 -0
- package/data/problems/word-search.json +1 -0
- package/data/problems/word-squares.json +1 -0
- package/data/problems/word-subsets.json +1 -0
- package/data/problems/x-of-a-kind-in-a-deck-of-cards.json +1 -0
- package/data/problems/zigzag-conversion.json +1 -0
- package/data/problems/zigzag-iterator.json +1 -0
- package/data/problems/zuma-game.json +1 -0
- package/dist/cli.js +793 -0
- package/dist/web/assets/index-DCYvZg7a.js +150 -0
- package/dist/web/assets/index-gSBueMfH.css +1 -0
- package/dist/web/index.html +13 -0
- package/package.json +44 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "871", "slug": "profitable-schemes", "id": 871, "title": "Profitable Schemes", "difficulty": "Hard", "category": "dp", "link": "https://leetcode.com/problems/profitable-schemes/", "examples": [{"input": "n = 5, minProfit = 3, group = [2,2], profit = [2,3]", "output": "2", "explanation": "Running only the second scheme earns 3, and running both earns 5; both plans fit in 5 members."}, {"input": "n = 10, minProfit = 5, group = [2,3,5], profit = [6,7,8]", "output": "7", "explanation": "Every non-empty collection earns at least 5 and uses at most 10 members, giving 2^3 - 1 = 7 plans."}, {"input": "n = 1, minProfit = 1, group = [1], profit = [1]", "output": "1", "explanation": "The single scheme fits and earns exactly 1."}], "hints": ["Treat this as a knapsack over people and profit: dp[j][p] counts ways using j members to reach profit p.", "Cap every profit at minProfit so the table stays small, iterate members and profit downward per scheme, and take all counts modulo 10^9 + 7."], "statement": "A gang wants to run criminal schemes. There are `group.length` schemes; scheme `i` needs `group[i]` members and yields `profit[i]` coins. You have at most `n` members in total, and each scheme can be used at most once.\n\nA plan is any collection of schemes whose member requirement fits within `n` people and whose total profit reaches at least `minProfit`. Count all such plans, including the choice of running nothing when it qualifies. Return the count modulo `10^9 + 7`.\n\n**Constraints:**\n- `1 <= n <= 100`\n- `0 <= minProfit <= 100`\n- `1 <= group.length <= 100`\n- `1 <= group[i] <= 100`\n- `0 <= profit[i] <= 100`\n", "solution": "## Approach\n\nThis is a two-dimensional knapsack: `dp[j][p]` counts the plans that use exactly `j` members and bank profit `p`, where every profit above the target is folded down into the target column so the table stays compact. Each scheme is considered once, updating the table backwards over members and profit so no scheme is reused within its own step. The answer sums the target-profit column over all feasible member counts, modulo `10^9 + 7`.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m * n * minProfit), where m is the number of schemes.\n- **Space Complexity:** O(n * minProfit) for the counting table.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def profitableSchemes(self, n: int, minProfit: int, group: List[int], profit: List[int]) -> int:\n MOD = 1000000007\n dp = [[0] * (minProfit + 1) for _ in range(n + 1)]\n dp[0][0] = 1\n for g, p in zip(group, profit):\n for j in range(n, g - 1, -1):\n for k in range(minProfit, -1, -1):\n nk = min(minProfit, k + p)\n dp[j][nk] = (dp[j][nk] + dp[j - g][k]) % MOD\n return sum(dp[j][minProfit] for j in range(n + 1)) % MOD\n```\n", "starter": {"go": "package main\n\nfunc ProfitableSchemes(n int, minProfit int, group []int, profit []int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def profitableSchemes(self, n: int, minProfit: int, group: List[int], profit: List[int]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int profitableSchemes(int n, int minProfit, vector<int>& group, vector<int>& profit) {\n return 0;\n }\n};"}, "fn": "profitableSchemes", "params": [{"name": "n", "type": "int"}, {"name": "minProfit", "type": "int"}, {"name": "group", "type": "int_array"}, {"name": "profit", "type": "int_array"}], "outputType": "int", "tests": [["5", "3", "[2,2]", "[2,3]"], ["10", "5", "[2,3,5]", "[6,7,8]"], ["1", "1", "[1]", "[1]"], ["1", "2", "[1]", "[1]"], ["2", "2", "[1,1,1]", "[1,1,1]"], ["3", "0", "[1,2]", "[0,0]"], ["100", "100", "[100]", "[100]"], ["4", "4", "[2,2,2]", "[3,3,3]"], ["6", "4", "[2,2,2]", "[3,3,3]"], ["3", "3", "[1,1,1,1]", "[1,2,1,2]"], ["5", "5", "[1,1,1]", "[2,2,2]"], ["10", "1", "[5,5]", "[0,1]"], ["2", "5", "[2,2]", "[5,5]"], ["7", "6", "[3,2,2]", "[4,3,3]"], ["5", "10", "[2,3]", "[5,6]"], ["1", "0", "[1,1]", "[0,0]"], ["10", "10", "[1,2,3,4]", "[1,2,3,4]"], ["20", "8", "[4,4,4,4]", "[3,3,3,3]"], ["3", "2", "[3]", "[5]"], ["2", "2", "[3]", "[5]"], ["50", "25", "[10,10,10,10,10]", "[10,10,10,10,10]"], ["6", "3", "[1,1,1,1,1,1]", "[1,1,1,1,1,1]"], ["8", "7", "[2,3,4]", "[2,5,5]"], ["15", "12", "[5,5,5]", "[6,6,6]"], ["4", "1", "[4,4]", "[1,1]"], ["30", "20", "[5,5,5,5,5,5,5,5]", "[4,4,4,4,4,4,4,4]"], ["100", "50", "[10,10,10,10,10,10,10,10,10,10]", "[10,10,10,10,10,10,10,10,10,10]"], ["2", "0", "[1]", "[0]"]], "expected": [2, 7, 1, 0, 3, 4, 1, 3, 4, 9, 1, 2, 2, 4, 1, 3, 1, 5, 1, 0, 16, 42, 3, 4, 2, 84, 638, 2], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "874", "slug": "projection-area-of-3d-shapes", "id": 874, "title": "Projection Area of 3D Shapes", "difficulty": "Easy", "category": "matrix", "link": "https://leetcode.com/problems/projection-area-of-3d-shapes/", "examples": [{"input": "grid = [[1,2],[3,4]]", "output": "17", "explanation": "4 squares from above, 2 + 4 = 6 from the front, and 3 + 4 = 7 from the side."}, {"input": "grid = [[2]]", "output": "5", "explanation": "1 from above, 2 from the front, and 2 from the side."}, {"input": "grid = [[1,0],[0,2]]", "output": "8", "explanation": "2 from above, 1 + 2 = 3 from the front, and 1 + 2 = 3 from the side."}], "hints": ["The top view is simply the count of cells holding at least one cube.", "The front view sums each row's maximum and the side view sums each column's maximum."], "statement": "A square `n x n` grid describes stacks of unit cubes: `grid[i][j]` cubes are piled on cell `(i, j)`. Picture the solid from three sides and count the visible unit squares:\n\n- From above, every non-empty cell shows exactly one square.\n- From the front, each row shows as many squares as its tallest stack.\n- From the side, each column shows as many squares as its tallest stack.\n\nReturn the sum of the three views.\n\n**Constraints:**\n- `n == grid.length == grid[i].length`\n- `1 <= n <= 50`\n- `0 <= grid[i][j] <= 100`\n", "solution": "## Approach\n\nThe three views separate cleanly. Scan every cell once: each positive cell adds one to the top view, and each row's running maximum feeds the front view. A second pass over the columns collects each column's maximum for the side view. Adding the three totals gives the answer.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^2) for the full scan of the n x n grid.\n- **Space Complexity:** O(1) besides the input.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def projectionArea(self, grid: List[List[int]]) -> int:\n n = len(grid)\n top = sum(1 for i in range(n) for j in range(n) if grid[i][j] > 0)\n front = sum(max(row) for row in grid)\n side = sum(max(grid[i][j] for i in range(n)) for j in range(n))\n return top + front + side\n```\n", "starter": {"go": "package main\n\nfunc ProjectionArea(grid [][]int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def projectionArea(self, grid: List[List[int]]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int projectionArea(vector<vector<int>>& grid) {\n return 0;\n }\n};"}, "fn": "projectionArea", "params": [{"name": "grid", "type": "int_array_2d"}], "outputType": "int", "tests": [["[[1,2],[3,4]]"], ["[[2]]"], ["[[1,0],[0,2]]"], ["[[1,1,1],[1,0,1],[1,1,1]]"], ["[[2,2,2],[2,1,2],[2,2,2]]"], ["[[0]]"], ["[[5]]"], ["[[0,0],[0,0]]"], ["[[3,0,0],[0,0,0],[0,0,0]]"], ["[[1,2,3],[4,5,6],[7,8,9]]"], ["[[9,8,7],[6,5,4],[3,2,1]]"], ["[[0,1],[1,0]]"], ["[[4,4],[4,4]]"], ["[[1,3],[5,4]]"], ["[[0,0,5],[0,0,0],[0,0,0]]"], ["[[2,0,0],[0,3,0],[0,0,4]]"], ["[[7,7,7,7],[7,7,7,7],[7,7,7,7],[7,7,7,7]]"], ["[[1,0,0,0],[0,2,0,0],[0,0,3,0],[0,0,0,4]]"], ["[[100]]"], ["[[0,5],[5,0]]"], ["[[6,1,6],[1,6,1],[6,1,6]]"], ["[[2,5,1],[1,4,3],[6,2,7]]"], ["[[10,0],[0,10]]"], ["[[3,3,3],[0,0,0],[2,2,2]]"], ["[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]"], ["[[0,0,0,9],[0,0,0,0],[0,0,0,0],[0,0,0,0]]"], ["[[5,1],[2,3]]"], ["[[8,3,5],[2,9,1],[4,6,7]]"]], "expected": [17, 5, 8, 14, 21, 0, 11, 0, 7, 51, 51, 6, 20, 21, 11, 21, 72, 24, 201, 22, 45, 43, 42, 20, 114, 19, 20, 57], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "836", "slug": "push-dominoes", "id": 836, "title": "Push Dominoes", "difficulty": "Medium", "category": "string", "link": "https://leetcode.com/problems/push-dominoes/", "examples": [{"input": "dominoes = \"RR.L\"", "output": "\"RR.L\"", "explanation": "The middle dot is pulled both ways and stays upright."}, {"input": "dominoes = \".L.R...LR..L..\"", "output": "\"LL.RR.LLRRLL..\""}], "hints": ["Compute a left-to-right force wave (R pushes decay with distance, L resets it) and a mirrored right-to-left wave, then combine them.", "A positive combined force means R wins, a negative one means L wins, and zero means the piece stays upright.", "Segments between an R and a later L split in the middle; equal halves leave the centre standing when the gap is odd."], "statement": "A row of dominoes is written as a string where `L` means the piece already falls left, `R` means it falls right, and `.` means it stands upright. All standing dominoes then topple simultaneously in rounds: in each round, a standing piece falls left if its left neighbour already falls (or is falling) left, and falls right if its right neighbour falls right. A piece with one neighbour pulling left and the other pulling right stays upright (the forces balance). Fallen pieces never move again. Return the final configuration once nothing can change.\n\n**Constraints:**\n- `1 <= dominoes.length <= 10^5`\n- `dominoes[i]` is `L`, `R`, or `.`\n", "solution": "## Approach\n\nSweep left to right carrying a decaying rightward force that an R refreshes to full strength and an L clears; add it per cell. Sweep right to left the same way for leftward force and subtract it. Each cell's sign then decides its fate: positive falls right, negative falls left, zero stays upright \u2014 which naturally splits R...L gaps down the middle.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) where n is the number of dominoes; two linear sweeps.\n- **Space Complexity:** O(n) for the force array.\n\n## Implementation\n\n```python\nclass Solution:\n def pushDominoes(self, dominoes: str) -> str:\n n = len(dominoes)\n force = [0] * n\n f = 0\n for i, c in enumerate(dominoes):\n if c == \"R\":\n f = n\n elif c == \"L\":\n f = 0\n else:\n f = max(f - 1, 0)\n force[i] += f\n f = 0\n for i in range(n - 1, -1, -1):\n c = dominoes[i]\n if c == \"L\":\n f = n\n elif c == \"R\":\n f = 0\n else:\n f = max(f - 1, 0)\n force[i] -= f\n return \"\".join(\"R\" if x > 0 else (\"L\" if x < 0 else \".\") for x in force)\n```\n", "starter": {"go": "package main\n\nfunc PushDominoes(dominoes string) string {\n return \"\"\n}", "python": "class Solution:\n def pushDominoes(self, dominoes: str) -> str:\n return \"\"\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n string pushDominoes(string dominoes) {\n return \"\";\n }\n};"}, "fn": "pushDominoes", "params": [{"name": "dominoes", "type": "string"}], "outputType": "string", "tests": [["RR.L"], [".L.R...LR..L.."], ["R.R.L"], ["."], ["L"], ["R"], ["..."], ["LLL"], ["RRR"], ["R....L"], ["R...L"], ["R..L"], ["R.L"], ["R..........L"], ["L..........R"], [".L.R."], ["R......"], ["......L"], ["RRRR....LLLL"], ["R.L.R.L.R.L"], ["..R..LL..R.."], ["L.R.L.R.L.R."], [".R..L..R..L."], ["R"], ["RL"], ["LR"], [".R."], [".L.L.R.R."]], "expected": ["RR.L", "LL.RR.LLRRLL..", "RRR.L", ".", "L", "R", "...", "LLL", "RRR", "RRRLLL", "RR.LL", "RRLL", "R.L", "RRRRRRLLLLLL", "L..........R", "LL.RR", "RRRRRRR", "LLLLLLL", "RRRRRRLLLLLL", "R.L.R.L.R.L", "..RRLLL..RRR", "L.R.L.R.L.RR", ".RRLL..RRLL.", "R", "RL", "LR", ".RR", "LLLL.RRRR"], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "758", "slug": "pyramid-transition-matrix", "id": 758, "title": "Pyramid Transition Matrix", "difficulty": "Medium", "category": "backtracking", "link": "https://leetcode.com/problems/pyramid-transition-matrix/", "examples": [{"input": "bottom = \"BCD\", allowed = [\"BCC\",\"CDE\",\"CEA\",\"FFF\"]", "output": "true", "explanation": "Build CE then A."}, {"input": "bottom = \"AAAA\", allowed = [\"AAB\",\"AAC\",\"BCD\",\"BBE\",\"DEF\"]", "output": "false", "explanation": "No second row leads to a full pyramid."}], "hints": ["Group allowed triples by their two-letter base so each pair quickly yields its possible tops.", "Build the next row one position at a time with backtracking; abandon a row as soon as a pair has no options.", "Memoize failed rows to avoid re-exploring dead ends from different paths."], "statement": "You stack colored blocks into a centered pyramid. The bottom row is the string `bottom`, and every row above holds one fewer block than the row below it.\n\nA block resting on two neighbors is allowed only when the triple (left base, right base, top) appears in the list `allowed`. Each entry of `allowed` is a three-letter string where the first two letters are the base pair and the third is the block they support. Order matters: `ABC` differs from `BAC`.\n\nDecide whether the bottom row can grow all the way to a single top block using only allowed triples.\n\nAdaptation for this judge: the original input gives `allowed` as a list of strings; here it arrives as a string array with the same contents.\n\n**Constraints:**\n- `2 <= bottom.length <= 6`\n- `0 <= allowed.length <= 216`\n- Each entry of `allowed` has length 3.\n- All letters come from `A` through `F`.\n- All entries of `allowed` are distinct.\n", "solution": "## Approach\n\nIndex every allowed triple by its two-letter base to list possible tops instantly. Then search depth-first: expand the current row into all candidate rows above it by combining per-pair options, and recurse on each candidate. Cache rows proven impossible so repeated states are skipped. Reaching a single block means success.\n\n## Complexity Analysis\n\n- **Time Complexity:** Exponential in the worst case, but tiny here since the base holds at most 6 blocks over 6 letters.\n- **Space Complexity:** O(R * B) for the map plus recursion state, where R is the number of distinct pairs and B bounds the candidate rows.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import defaultdict\nclass Solution:\n def pyramidTransition(self, bottom: str, allowed: List[str]) -> bool:\n table = defaultdict(list)\n for s in allowed:\n table[s[:2]].append(s[2])\n failed = set()\n def dfs(row):\n if len(row) == 1:\n return True\n if row in failed:\n return False\n cands = ['']\n for i in range(len(row) - 1):\n tops = table.get(row[i:i+2])\n if not tops:\n failed.add(row)\n return False\n cands = [r + c for r in cands for c in tops]\n for nx in cands:\n if dfs(nx):\n return True\n failed.add(row)\n return False\n return dfs(bottom)\n```\n", "starter": {"go": "package main\n\nfunc PyramidTransition(bottom string, allowed []string) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def pyramidTransition(self, bottom: str, allowed: List[str]) -> bool:\n pass", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool pyramidTransition(string bottom, vector<string>& allowed) {\n return false;\n }\n};"}, "fn": "pyramidTransition", "params": [{"name": "bottom", "type": "string"}, {"name": "allowed", "type": "string_array"}], "outputType": "boolean", "tests": [["BCD", "['BCC', 'CDE', 'CEA', 'FFF']"], ["AAAA", "['AAB', 'AAC', 'BCD', 'BBE', 'DEF']"], ["AB", "['ABC']"], ["AB", "[]"], ["AB", "['BAC']"], ["BCD", "['BCC', 'CDE', 'CEA']"], ["BCD", "['BCC', 'CDE']"], ["BCD", "['CDE', 'CEA']"], ["AAA", "['AAA']"], ["AAA", "['AAB']"], ["AAAAAA", "['AAA']"], ["ABCDEF", "[]"], ["AA", "['AAB', 'AAC']"], ["AB", "['ABC', 'ABD']"], ["ABC", "['ABC', 'BCD', 'CDE', 'DEF', 'EFA', 'FAB']"], ["AB", "['ABA', 'ABB', 'ABC', 'ABD', 'ABE', 'ABF']"], ["FF", "['FFF']"], ["FF", "['FFE']"], ["ABC", "['ABD', 'BCE', 'DEF']"], ["ABC", "['ABD', 'BCE']"], ["AABB", "['AAB', 'ABB', 'BBB', 'BBC']"], ["ABCD", "['ABC', 'BCD', 'CDE', 'DEF', 'EFG']"], ["EF", "['EFA', 'EFB']"], ["CD", "['CDA', 'CDB', 'CDC']"], ["BC", "['BCB', 'BCC']"], ["AAAB", "['AAA', 'AAB']"], ["ABCDEF", "['ABC', 'BCD', 'CDE', 'DEF', 'EFA', 'FAB']"], ["ABCDE", "['ABC', 'BCD', 'CDE', 'DEF', 'EFA', 'BCA', 'CAB']"]], "expected": null, "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "480", "slug": "queue-reconstruction-by-height", "id": 480, "title": "Queue Reconstruction by Height", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/queue-reconstruction-by-height/", "examples": [{"input": "people = [[7,0],[4,4],[7,1],[5,0],[6,1],[5,2]]", "output": "[[5,0],[7,0],[5,2],[6,1],[4,4],[7,1]]", "explanation": "Sorting tall-first then slotting each person at their k index rebuilds the line."}, {"input": "people = [[6,0],[5,0],[4,0],[3,2],[2,2],[1,4]]", "output": "[[4,0],[5,0],[2,2],[3,2],[1,4],[6,0]]", "explanation": "Shorter people slide into the gaps left by taller ones already placed."}], "hints": ["Order people by height descending, breaking ties by k ascending.", "Insert each person at index k of the growing line; taller people already placed are exactly the ones each k counts.", "Insertion into a list gives O(n^2) time, fine for n up to 2000."], "statement": "A crowd is described by pairs `[h, k]`: person height `h` and the count `k` of people in front who are at least as tall as `h`. The given `people` array holds these pairs in no particular order, and exactly one line ordering satisfies every pair.\n\nRebuild that line: return the pairs from front to back so that each entry's `k` equals the number of earlier entries whose height is greater than or equal to its own.\n\n**Constraints:**\n- `1 <= people.length <= 2000`\n- `0 <= h <= 10^6`\n- `0 <= k < people.length`\n- A valid reconstruction always exists.\n", "solution": "## Approach\n\nSort everyone tallest first, with smaller k first among equal heights. Then walk that order and insert each person at index k of the current line. Because all previously placed people are at least as tall, index k is precisely where that person's taller-or-equal count matches, and later shorter arrivals never disturb earlier counts.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^2) due to sorting plus list insertions.\n- **Space Complexity:** O(n) for the growing line.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:\n people = sorted(people, key=lambda x: (-x[0], x[1]))\n line: List[List[int]] = []\n for p in people:\n line.insert(p[1], p)\n return line\n```\n", "starter": {"go": "package main\n\nfunc ReconstructQueue(people [][]int) [][]int {\n \n}", "python": "from typing import List\nclass Solution:\n def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<vector<int>> reconstructQueue(vector<vector<int>>& people) {\n return {};\n }\n};"}, "fn": "reconstructQueue", "params": [{"name": "people", "type": "int_array_2d"}], "outputType": "int_array_2d", "tests": [["[[7, 0], [4, 4], [7, 1], [5, 0], [6, 1], [5, 2]]"], ["[[6, 0], [5, 0], [4, 0], [3, 2], [2, 2], [1, 4]]"], ["[[1, 0]]"], ["[[2, 0], [1, 0]]"], ["[[3, 0], [1, 0]]"], ["[[1, 2], [4, 0], [6, 0]]"], ["[[2, 0], [4, 0], [1, 1], [5, 0]]"], ["[[5, 2], [5, 0], [5, 1], [3, 4], [5, 3]]"], ["[[1, 3], [6, 1], [0, 3], [5, 2], [1, 1], [6, 0]]"], ["[[4, 1], [4, 2], [2, 4], [0, 3], [6, 0], [0, 6], [2, 1]]"], ["[[6, 0], [4, 1], [3, 2], [0, 1], [0, 2], [3, 4], [5, 1], [4, 3]]"], ["[[3, 3], [4, 1], [3, 0], [4, 4], [5, 3], [6, 1], [5, 0], [6, 0], [1, 4]]"], ["[[5, 0], [1, 1]]"], ["[[2, 1], [1, 2], [3, 0]]"], ["[[6, 0], [3, 0], [6, 1], [4, 1]]"], ["[[3, 1], [1, 0], [2, 1], [1, 3], [6, 0]]"], ["[[2, 5], [4, 3], [6, 0], [4, 2], [3, 1], [5, 1]]"], ["[[5, 2], [5, 0], [6, 0], [0, 1], [0, 2], [2, 0], [6, 1]]"], ["[[0, 3], [4, 3], [4, 1], [1, 3], [5, 0], [1, 6], [2, 2], [5, 1]]"], ["[[6, 1], [2, 3], [6, 0], [0, 6], [4, 2], [0, 0], [2, 0], [1, 1], [6, 2]]"], ["[[5, 1], [6, 0]]"], ["[[1, 2], [1, 1], [1, 0]]"], ["[[5, 1], [5, 0], [2, 0], [1, 2]]"], ["[[2, 1], [4, 2], [1, 0], [5, 0], [6, 0]]"], ["[[4, 1], [1, 0], [4, 3], [5, 1], [1, 2], [5, 0]]"], ["[[1, 3], [0, 1], [5, 1], [6, 0], [4, 2], [1, 4], [3, 3]]"], ["[[4, 2], [4, 0], [2, 4], [1, 3], [2, 3], [5, 0], [0, 5], [6, 0]]"], ["[[0, 7], [2, 3], [2, 0], [3, 3], [6, 0], [0, 8], [0, 4], [6, 2], [6, 1]]"], ["[[2, 1], [4, 0]]"], ["[[1, 1], [1, 0], [6, 0]]"]], "expected": [[[5, 0], [7, 0], [5, 2], [6, 1], [4, 4], [7, 1]], [[4, 0], [5, 0], [2, 2], [3, 2], [1, 4], [6, 0]], [[1, 0]], [[1, 0], [2, 0]], [[1, 0], [3, 0]], [[4, 0], [6, 0], [1, 2]], [[2, 0], [1, 1], [4, 0], [5, 0]], [[5, 0], [5, 1], [5, 2], [5, 3], [3, 4]], [[6, 0], [1, 1], [6, 1], [0, 3], [1, 3], [5, 2]], [[6, 0], [2, 1], [4, 1], [0, 3], [4, 2], [2, 4], [0, 6]], [[6, 0], [0, 1], [0, 2], [4, 1], [3, 2], [5, 1], [3, 4], [4, 3]], [[3, 0], [5, 0], [4, 1], [3, 3], [1, 4], [6, 0], [6, 1], [4, 4], [5, 3]], [[5, 0], [1, 1]], [[3, 0], [2, 1], [1, 2]], [[3, 0], [6, 0], [4, 1], [6, 1]], [[1, 0], [6, 0], [2, 1], [1, 3], [3, 1]], [[6, 0], [3, 1], [5, 1], [4, 2], [4, 3], [2, 5]], [[2, 0], [0, 1], [0, 2], [5, 0], [6, 0], [5, 2], [6, 1]], [[5, 0], [4, 1], [2, 2], [0, 3], [1, 3], [5, 1], [4, 3], [1, 6]], [[0, 0], [2, 0], [1, 1], [6, 0], [6, 1], [2, 3], [0, 6], [4, 2], [6, 2]], [[6, 0], [5, 1]], [[1, 0], [1, 1], [1, 2]], [[2, 0], [5, 0], [1, 2], [5, 1]], [[1, 0], [5, 0], [2, 1], [6, 0], [4, 2]], [[1, 0], [5, 0], [1, 2], [4, 1], [5, 1], [4, 3]], [[6, 0], [0, 1], [5, 1], [4, 2], [1, 3], [1, 4], [3, 3]], [[4, 0], [5, 0], [4, 2], [1, 3], [2, 3], [0, 5], [2, 4], [6, 0]], [[2, 0], [6, 0], [6, 1], [2, 3], [0, 4], [6, 2], [3, 3], [0, 7], [0, 8]], [[4, 0], [2, 1]], [[1, 0], [1, 1], [6, 0]]], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "780", "slug": "rabbits-in-forest", "id": 780, "title": "Rabbits in Forest", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/rabbits-in-forest/", "examples": [{"input": "answers = [1,1,2]", "output": "5", "explanation": "A pair plus a trio gives five rabbits."}, {"input": "answers = [10,10,10]", "output": "11", "explanation": "Three speakers fit inside one group of eleven."}, {"input": "answers = [0,0,1,1,1]", "output": "6", "explanation": "Two lone rabbits plus two pairs (one with a silent partner) total six."}], "hints": ["Rabbits giving the same answer a can share groups of size a+1; count how many speakers gave each answer.", "For each distinct answer, the number of groups needed is the ceiling of count/(a+1).", "Multiply groups by group size and sum across all distinct answers."], "statement": "Several rabbits each claim a number: when asked how many other rabbits share\ntheir fur color, rabbit `i` answers with `answers[i]`. Different rabbits\nthat name the same number might belong to one shared color group or to\nseveral separate groups, and rabbits that name different numbers surely\nhave different colors.\n\nGiven all the answers, estimate the smallest total population that could\nhave produced them. Every rabbit that spoke must fit into some color group\nwhose size matches its answer plus one (itself plus the others it counted).\n\n**Constraints:**\n- `1 <= answers.length <= 1000`\n- `0 <= answers[i] < 1000`\n", "solution": "## Approach\n\nGroup speakers by their answer. An answer of `a` means its color group holds\nexactly `a+1` rabbits, so `c` speakers with that answer need\n`ceil(c / (a+1))` full groups. Summing `groups * (a+1)` over every distinct\nanswer yields the smallest feasible population, with silent rabbits filling\nany partially empty groups.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the number of answers.\n- **Space Complexity:** O(n) for the frequency table.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import Counter\nimport math\n\n\nclass Solution:\n def numRabbits(self, answers: List[int]) -> int:\n total = 0\n for a, c in Counter(answers).items():\n size = a + 1\n groups = (c + size - 1) // size\n total += groups * size\n return total\n```\n", "starter": {"go": "package main\n\nfunc NumRabbits(answers []int) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def numRabbits(self, answers: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int numRabbits(vector<int>& answers) {\n return 0;\n }\n};"}, "fn": "numRabbits", "params": [{"name": "answers", "type": "int_array"}], "outputType": "int", "tests": [["[1,1,2]"], ["[10,10,10]"], ["[0,0,1,1,1]"], ["[0]"], ["[1]"], ["[2]"], ["[0,0,0]"], ["[1,1,1]"], ["[1,1,1,1]"], ["[2,2,2,2,2]"], ["[0,1,2,3,4]"], ["[5,5,5,5,5,5]"], ["[5,5,5,5,5,5,5]"], ["[3,3,3,3,3,3,3]"], ["[4,4,4,4,4]"], ["[4,4,4,4,4,4]"], ["[0,0,0,0,0]"], ["[2,2,2]"], ["[2,2,2,2]"], ["[1,0,1,0,1]"], ["[999]"], ["[0,0,0,0,0,0,0,0,0,0]"], ["[1,1,2,2,2,3,3,3,3]"], ["[7,7,7,7,7,7,7,7]"], ["[7,7,7,7,7,7,7,7,7]"], ["[0,1,0,1,0,1]"], ["[2,3,2,3,2,3]"], ["[10,10,10,10,10,10,10,10,10,10,10,10]"]], "expected": [5, 11, 6, 1, 2, 3, 3, 4, 4, 6, 15, 6, 12, 8, 5, 10, 5, 3, 6, 6, 1000, 10, 9, 8, 16, 7, 7, 22], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "816", "slug": "race-car", "id": 816, "title": "Race Car", "difficulty": "Hard", "category": "dp", "link": "https://leetcode.com/problems/race-car/", "examples": [{"input": "target = 3", "output": "2", "explanation": "Drive forward twice: positions 1 then 3, using two A commands."}, {"input": "target = 6", "output": "5", "explanation": "One shortest plan is A,A,R,A,A: overshoot to 7, reverse, then advance to 6."}, {"input": "target = 1", "output": "1", "explanation": "A single forward move reaches the flag."}], "hints": ["Let n be the smallest run of A commands passing the flag (position 2^n - 1): either stop exactly or overshoot and come back.", "Memoize results: overshooting costs n+1 plus the mirrored remainder; alternatively stop one step early and add a short forward burst."], "statement": "A car starts at position 0 with speed 1. Two commands are available: `A` (accelerate) moves the car forward by its current speed and then doubles the speed, while `R` (reverse) turns the car around and resets the speed to 1 in the new direction (positions stay put on `R`).\n\nGiven a flag at integer `target > 0`, find the smallest number of commands that lands the car exactly on the flag. The car may pass the flag and come back.\n\nAdaptation note: this task uses plain integers for input and output.\n\n**Constraints:**\n- `1 <= target <= 10000`\n", "solution": "## Approach\n\nThink in terms of full forward bursts: n accelerations from rest reach 2^n - 1. If that equals the flag, n moves are optimal. Otherwise either overshoot with n moves, reverse, and solve the mirrored remainder, or drive n-1 moves, reverse, creep forward m moves, reverse again, and solve what is left. Trying every m and memoizing the remainders yields the optimum because any shortest plan has one of these two shapes.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(T log T) for target T with memoization.\n- **Space Complexity:** O(T) for the memo table plus recursion depth.\n\n## Implementation\n\n```python\nclass Solution:\n def racecar(self, target: int) -> int:\n from functools import lru_cache\n @lru_cache(maxsize=None)\n def dfs(t: int) -> int:\n if t == 0:\n return 0\n n = 1\n while (1 << n) - 1 < t:\n n += 1\n if (1 << n) - 1 == t:\n return n\n ans = n + 1 + dfs((1 << n) - 1 - t)\n for m in range(n - 1):\n cand = n + m + 1 + dfs(t - (1 << (n - 1)) + (1 << m))\n if cand < ans:\n ans = cand\n return ans\n return dfs(target)\n```\n", "starter": {"go": "package main\n\nfunc Racecar(target int) int {\n return 0\n}", "python": "class Solution:\n def racecar(self, target: int) -> int:\n return 0\n", "cpp": "class Solution {\npublic:\n int racecar(int target) {\n return 0;\n }\n};"}, "fn": "racecar", "params": [{"name": "target", "type": "int"}], "outputType": "int", "tests": [["3"], ["6"], ["1"], ["2"], ["4"], ["5"], ["7"], ["8"], ["9"], ["10"], ["15"], ["20"], ["25"], ["30"], ["50"], ["100"], ["200"], ["500"], ["1000"], ["12"], ["16"], ["21"], ["33"], ["64"], ["127"], ["256"], ["10000"], ["9999"]], "expected": [2, 5, 1, 4, 5, 7, 3, 6, 8, 7, 4, 12, 11, 7, 16, 19, 22, 20, 23, 7, 7, 10, 10, 9, 7, 11, 45, 43], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "519", "slug": "random-flip-matrix", "id": 519, "title": "Random Flip Matrix", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/random-flip-matrix/", "examples": [{"explanation": "One valid trace: [1,0] and [2,0] are flipped, then the last free cell [0,0]; after reset any cell (here [2,0]) may come first.", "input": "operations = [\"FlipMatrix\",\"flip\",\"flip\",\"flip\",\"reset\",\"flip\"], values = [[3,1],[],[],[],[],[]]", "output": "[null,[1,0],[2,0],[0,0],null,[2,0]]"}, {"explanation": "Draining a 2x2 board must return each of the four cells exactly once, in any order.", "input": "operations = [\"FlipMatrix\",\"flip\",\"flip\",\"flip\",\"flip\"], values = [[2,2],[],[],[],[]]", "output": "[null,[0,0],[0,1],[1,0],[1,1]]"}, {"explanation": "Reset clears the flipped set, so the single cell may be flipped again.", "input": "operations = [\"FlipMatrix\",\"flip\",\"reset\",\"flip\"], values = [[1,1],[],[],[]]", "output": "[null,[0,0],null,[0,0]]"}], "hints": ["Treat the board as virtual indices 0..m*n-1 and draw without replacement Fisher-Yates style: keep a remap table from drawn slots to still-unused ones so each flip costs O(1) random calls.", "Convert a drawn index k to coordinates via [k / n, k % n].", "Reset just clears the remap table and restores the pool size to m * n."], "statement": "There is an `m x n` binary grid matrix with all the values set `0` initially. Design an algorithm to randomly pick an index `(i, j)` where `matrix[i][j] == 0` and flips it to `1`. All the indices `(i, j)` where `matrix[i][j] == 0` should be equally likely to be returned.\n\nImplement the `FlipMatrix` class:\n\n- `FlipMatrix(int m, int n)` Initializes the object with the size of the binary matrix `m` and `n`.\n- `int[] flip()` Returns a random index `[i, j]` of the matrix where `matrix[i][j] == 0` and flips it to `1`.\n- `void reset()` Resets all the values of the matrix to be `0`.\n\nThe class is named `FlipMatrix` here instead of LeetCode's `Solution` because the judge harness reserves `Solution` for its driver; the constructor and methods match the original.\n\nGrading: each `flip` must return an in-bounds cell that has not been flipped since construction or the last `reset`. Any valid trace is accepted \u2014 uniformity is not statistically tested (LeetCode likewise allows at most 1000 calls, too few for a distribution test).\n\n**Constraints:**\n- `1 <= m, n <= 10^4`\n- There will be at least one free cell for each call to `flip`.\n- At most `1000` calls will be made to `flip` and `reset`.\n", "solution": "## Approach\n\nSample without replacement over the `m * n` virtual cell indices using the Fisher-Yates idea with a remap table. Keep `total` as the count of still-unflipped cells: each `flip` draws a uniform index `x` from `[0, total)`, resolves it through the table (`idx = remap.get(x, x)`), then moves the pool's last element into slot `x` (`remap[x] = remap.get(total - 1, total - 1)`) and shrinks `total`. Converting via `row = idx // n`, `col = idx % n` yields distinct valid coordinates with one random call per flip. `reset` clears the table and restores `total` to `m * n`.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1) per `flip` and O(k) per `reset` (clearing k table entries).\n- **Space Complexity:** O(k) for the remap table, where k is the number of flips since the last reset.\n\n## Implementation\n\n```python\nimport random\nfrom typing import List, Dict\n\nclass FlipMatrix:\n def __init__(self, m: int, n: int):\n self.m = m\n self.n = n\n self.total = m * n\n self.remap: Dict[int, int] = {}\n\n def flip(self) -> List[int]:\n self.total -= 1\n x = random.randint(0, self.total)\n idx = self.remap.get(x, x)\n self.remap[x] = self.remap.get(self.total, self.total)\n return [idx // self.n, idx % self.n]\n\n def reset(self) -> None:\n self.total = self.m * self.n\n self.remap.clear()\n```\n", "starter": {"go": "package main\n\ntype FlipMatrix struct {\n\n}\n\nfunc Constructor(m int, n int) FlipMatrix {\n return FlipMatrix{}\n}\n\nfunc (this *FlipMatrix) Flip() []int {\n return []int{}\n}\n\nfunc (this *FlipMatrix) Reset() {\n\n}", "python": "from typing import List\n\nclass FlipMatrix:\n def __init__(self, m: int, n: int):\n\n def flip(self) -> List[int]:\n return []\n\n def reset(self) -> None:\n\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass FlipMatrix {\npublic:\n FlipMatrix(int m, int n) {\n \n }\n\n vector<int> flip() {\n return {};\n }\n\n void reset() {\n \n }\n};"}, "fn": "solve", "params": [{"name": "operations", "type": "string_array"}, {"name": "values", "type": "int_array_2d"}], "outputType": "string_list", "tests": [["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"reset\", \"flip\"]", "[[3, 1], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[2, 2], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"reset\", \"flip\"]", "[[1, 1], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"reset\", \"flip\"]", "[[1, 2], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\"]", "[[2, 3], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[2, 3], [], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[3, 3], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[3, 3], [], [], [], [], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[4, 4], [], [], [], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[5, 5], [], [], [], [], [], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[10, 10], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"reset\", \"flip\", \"flip\", \"reset\", \"flip\"]", "[[2, 2], [], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[1, 5], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[5, 1], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[3, 4], [], [], [], [], [], [], [], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"reset\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[4, 5], [], [], [], [], [], [], [], [], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[6, 6], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[20, 20], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[50, 50], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"reset\", \"flip\", \"flip\"]", "[[1, 3], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[3, 2], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"reset\", \"flip\", \"flip\", \"reset\", \"flip\"]", "[[2, 2], [], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[4, 3], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"reset\", \"flip\", \"reset\", \"flip\"]", "[[1, 1], [], [], [], [], []]"], ["[\"FlipMatrix\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\", \"flip\"]", "[[5, 2], [], [], [], [], [], []]"]], "expected": null, "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "398", "slug": "random-pick-index", "id": 398, "title": "Random Pick Index", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/random-pick-index/", "examples": [{"input": "operations = [\"RandomPickIndex\",\"pick\",\"pick\",\"pick\",\"pick\",\"pick\",\"pick\"], values = [[1,2,3,3,3],[3],[3],[3],[3],[3],[3]]", "output": "[null,2,3,4,2,4,3]", "explanation": "Valid indexes are 2, 3 and 4. The exact sequence varies; every returned index must hold target 3."}, {"input": "operations = [\"RandomPickIndex\",\"pick\",\"pick\",\"pick\"], values = [[1,2,3,3,3],[1],[1],[1]]", "output": "[null,0,0,0]", "explanation": "Only index 0 holds the value 1, so every pick must return 0."}, {"input": "operations = [\"RandomPickIndex\",\"pick\",\"pick\",\"pick\",\"pick\",\"pick\",\"pick\"], values = [[5,5,5,5],[5],[5],[5],[5],[5],[5]]", "output": "[null,0,2,3,1,0,2]", "explanation": "All four indexes are valid; over a long trace each one must be able to appear."}], "hints": ["Store the indexes for each value, or use reservoir sampling while scanning nums for a target.", "Every index whose value equals target must have the same chance of being returned.", "The judge runs long traces and requires every valid index to appear; always returning the first match fails."], "statement": "Given an integer array `nums` that may contain duplicate values, implement the `RandomPickIndex` class:\n\n- `RandomPickIndex(int[] nums)` initializes the object with the array `nums`.\n- `int pick(int target)` returns a random index `i` such that `nums[i] == target`.\n\nEvery index whose value equals `target` must have the same probability of being returned. The given `target` is guaranteed to occur at least once in `nums`.\n\n**Constraints:**\n- `1 <= nums.length <= 2 * 10^4`\n- `-2^31 <= nums[i] <= 2^31 - 1`\n- `target` occurs at least once in `nums`\n- At most `10^4` calls will be made to `pick`\n\n**Judge note:** the checker validates each returned index and runs long traces against the same object. A long trace must produce every valid index at least once, and the checker rejects fixed or short repeating sequences. Always returning the first match therefore fails even though it is a valid index.\n", "solution": "## Approach\n\nUse **reservoir sampling with a reservoir of size one**. Scan `nums` and count how many matching positions have been seen so far. For the `k`-th match, replace the current answer with that index with probability `1/k`.\n\nAfter scanning the whole array, every one of the `m` matching indexes has probability `1/m` of being the final answer:\n\n- The first match is chosen with probability `1`.\n- The second match replaces it with probability `1/2`, and the first survives with probability `1/2`.\n- By induction, after `k` matches every candidate seen so far has probability `1/k`; processing the next match preserves that property.\n\nThe random decision must be made on every `pick` call. Returning a cached index would pass a single validity check but would fail the judge's repeated-call randomness check.\n\nAn alternative is to build a map from each value to all of its indexes in the constructor. That gives `O(1)` expected time per pick at the cost of `O(n)` extra space.\n\n## Complexity Analysis\n\n- **Time Complexity:** `O(n)` per `pick`, where `n = nums.length`.\n- **Space Complexity:** `O(1)` extra space beyond the input array.\n\n## Implementation\n\n```python\nimport random\nfrom typing import List\n\n\nclass RandomPickIndex:\n def __init__(self, nums: List[int]):\n self.nums = nums\n\n def pick(self, target: int) -> int:\n chosen = -1\n seen = 0\n\n for i, value in enumerate(self.nums):\n if value != target:\n continue\n seen += 1\n if random.randrange(seen) == 0:\n chosen = i\n\n return chosen\n```\n", "starter": {"go": "package main\n\ntype RandomPickIndex struct {\n\n}\n\nfunc Constructor(nums []int) RandomPickIndex {\n return RandomPickIndex{}\n}\n\nfunc (this *RandomPickIndex) Pick(target int) int {\n return 0\n}", "python": "from typing import List\n\nclass RandomPickIndex:\n def __init__(self, nums: List[int]):\n pass\n\n def pick(self, target: int) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\n\nclass RandomPickIndex {\npublic:\n RandomPickIndex(vector<int>& nums) {\n \n }\n\n int pick(int target) {\n return 0;\n }\n};"}, "fn": "solve", "params": [{"name": "operations", "type": "string_array"}, {"name": "values", "type": "int_array_2d"}], "outputType": "string_list", "tests": [["@javascript:JSON.stringify(['RandomPickIndex', ...Array(160).fill('pick')])", "@javascript:JSON.stringify([[1,2,3,3,3], ...Array(160).fill([3])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(160).fill('pick')])", "@javascript:JSON.stringify([[5,5,5,5], ...Array(160).fill([5])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(100).fill('pick'), ...Array(100).fill('pick')])", "@javascript:JSON.stringify([[1,2,1,2,1,2], ...Array(100).fill([1]), ...Array(100).fill([2])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(160).fill('pick')])", "@javascript:JSON.stringify([[7,8,7,8,7], ...Array(160).fill([8])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(160).fill('pick')])", "@javascript:JSON.stringify([[7,8,7,8,7], ...Array(160).fill([7])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(160).fill('pick')])", "@javascript:JSON.stringify([[-2147483648,0,2147483647,2147483647], ...Array(160).fill([2147483647])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(30).fill('pick')])", "@javascript:JSON.stringify([[42], ...Array(30).fill([42])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(240).fill('pick')])", "@javascript:JSON.stringify([[3,3,3,3,3,3], ...Array(240).fill([3])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(120).fill('pick'), ...Array(120).fill('pick')])", "@javascript:JSON.stringify([[100,200,100,200,100,200], ...Array(120).fill([100]), ...Array(120).fill([200])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(120).fill('pick'), 'RandomPickIndex', ...Array(120).fill('pick')])", "@javascript:JSON.stringify([[5,5,5], ...Array(120).fill([5]), [1,2,3,3,3], ...Array(120).fill([3])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(30).fill('pick')])", "@javascript:JSON.stringify([[1,1,1,1,2], ...Array(30).fill([2])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(180).fill('pick')])", "@javascript:JSON.stringify([[0,0,0,1,0,0,0], ...Array(180).fill([0])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(180).fill('pick')])", "@javascript:JSON.stringify([Array.from({length: 20000}, (_, i) => (i === 0 || i === 9999 || i === 19999) ? 7 : 1), ...Array(180).fill([7])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(160).fill('pick')])", "@javascript:JSON.stringify([[3,3], ...Array(160).fill([3])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(160).fill('pick')])", "@javascript:JSON.stringify([[3,0,0,0,3], ...Array(160).fill([3])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(240).fill('pick')])", "@javascript:JSON.stringify([[9,1,9,2,9,3,9], ...Array(240).fill([9])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(240).fill('pick')])", "@javascript:JSON.stringify([[4,4,4,4,4], ...Array(240).fill([4])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(300).fill('pick')])", "@javascript:JSON.stringify([[6,1,6,2,6,3,6,4,6,5,6], ...Array(300).fill([6])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(160).fill('pick')])", "@javascript:JSON.stringify([[-5,-5,-5], ...Array(160).fill([-5])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(160).fill('pick')])", "@javascript:JSON.stringify([[0,1,2,0,3,0], ...Array(160).fill([0])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(160).fill('pick')])", "@javascript:JSON.stringify([[-2147483648,2147483647,-2147483648,0,2147483647], ...Array(160).fill([2147483647])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(120).fill('pick'), ...Array(120).fill('pick'), ...Array(120).fill('pick')])", "@javascript:JSON.stringify([[1,2,3,1,2,3], ...Array(120).fill([1]), ...Array(120).fill([2]), ...Array(120).fill([3])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(120).fill('pick'), 'RandomPickIndex', ...Array(120).fill('pick')])", "@javascript:JSON.stringify([[5,5], ...Array(120).fill([5]), [8,9,8,9,8], ...Array(120).fill([8])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(300).fill('pick')])", "@javascript:JSON.stringify([Array.from({length: 50000}, (_, i) => (i === 0 || i === 25000 || i === 49999) ? 42 : 1), ...Array(300).fill([42])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(150).fill('pick')])", "@javascript:JSON.stringify([[7], ...Array(150).fill([7])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(240).fill('pick')])", "@javascript:JSON.stringify([[1,1,1,1,2,2,2,2], ...Array(240).fill([2])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(240).fill('pick')])", "@javascript:JSON.stringify([[0,1,0,1,0,1,0,1], ...Array(240).fill([0])])"], ["@javascript:JSON.stringify(['RandomPickIndex', ...Array(160).fill('pick')])", "@javascript:JSON.stringify([[9,8,7,6,5,9,8,7,6,5], ...Array(160).fill([5])])"]], "expected": null, "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "718", "slug": "random-pick-with-blacklist", "id": 718, "title": "Random Pick with Blacklist", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/random-pick-with-blacklist/", "examples": [{"input": "n = 7, blacklist = [2,3,5], calls = [0,1,2,3]", "output": "[0,1,6,4]", "explanation": "Valid numbers are 0, 1, 4 and 6. Each draw value is wrapped into that set; with tail remapping the four draws land on 0, 1, 6 and 4."}, {"input": "n = 4, blacklist = [2], calls = [0,1,2]", "output": "[0,1,3]", "explanation": "Valid numbers are 0, 1 and 3. The third draw maps past the blocked value 2 onto 3."}, {"input": "n = 1, blacklist = [], calls = [5,-3]", "output": "[0,0]", "explanation": "Only 0 is available, so every draw returns 0."}], "hints": ["Let sz = n - blacklist.length. Remap every blocked value below sz to a free value from the tail; wrapping each draw with a non-negative modulo gives an index in [0, sz).", "Build a hash set of blocked values, then assign tail replacements from n-1 downward skipping blocked entries.", "Adaptation: calls stands in for random draws so the task is deterministic. The checker only verifies that each answer lies in range and avoids the blacklist; any valid pick is accepted. Rust note: vectors arrive as usual integer lists."], "statement": "You are given a range `0` to `n - 1` with some values blocked in `blacklist`. Each call should return a uniformly chosen unblocked number.\n\nBecause random output cannot be compared directly, this task uses a deterministic stand-in: `calls` holds one integer per draw. For each entry, wrap it into the set of valid numbers and return the corresponding valid value (blocked entries below `sz` are remapped to free tail values, where `sz = n - blacklist.length`). The reference method builds that remapping once and answers every draw with a binary-free O(1) lookup.\n\nReturn one answer per entry of `calls`. The judge accepts any output whose entries are all inside `[0, n)` and avoid every blocked value, so any fair generator would pass; the wrapped-draw rule simply makes testing repeatable.\n\n*Adaptation note:* the function is named `runBlacklist` and takes `(n, blacklist, calls)` so every supported type stays within the allowed set. Correctness is validity-only.\n\n**Constraints:**\n- `1 <= n <= 10^9`\n- `0 <= blacklist.length < n`\n- All blocked values are distinct and inside `[0, n)`.\n- `1 <= calls.length <= 1000`\n", "solution": "## Approach\n\nPreprocess the blacklist once. Values below `sz = n - m` that are blocked are remapped to free tail values found by scanning down from `n - 1`. Each draw is wrapped into `[0, sz)` with a non-negative modulo and then translated through the map, giving a valid pick in O(1).\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m + q), where m is the blacklist size and q the number of draws.\n- **Space Complexity:** O(m) for the set and remap.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def runBlacklist(self, n: int, blacklist: List[int], calls: List[int]) -> List[int]:\n sz = n - len(blacklist)\n black = set(blacklist)\n mp = {}\n w = n - 1\n for b in blacklist:\n if b < sz:\n while w in black:\n w -= 1\n mp[b] = w\n w -= 1\n ans = []\n for c in calls:\n t = c % sz\n ans.append(mp.get(t, t))\n return ans\n```\n", "starter": {"go": "package main\n\nfunc RunBlacklist(n int, blacklist []int, calls []int) []int {\n return []int{}\n}", "python": "from typing import List\nclass Solution:\n def runBlacklist(self, n: int, blacklist: List[int], calls: List[int]) -> List[int]:\n return []", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<int> runBlacklist(int n, vector<int>& blacklist, vector<int>& calls) {\n return {};\n }\n};"}, "fn": "runBlacklist", "params": [{"name": "n", "type": "int"}, {"name": "blacklist", "type": "int_array"}, {"name": "calls", "type": "int_array"}], "outputType": "int_array", "tests": [["7", "[2,3,5]", "[0,1,2,3]"], ["4", "[2]", "[0,1,2]"], ["1", "[]", "[5,-3]"], ["5", "[]", "[0,1,2,3,4]"], ["5", "[0,1,2,3]", "[0,7,-2]"], ["10", "[3,5,7]", "[0,3,5,9,14]"], ["6", "[0,5]", "[0,1,2,3]"], ["8", "[1,2,3]", "[4,5,6,7,8]"], ["3", "[1]", "[0,1,2,3,4]"], ["100", "[10,20,30]", "[0,50,99,100,101]"], ["2", "[0]", "[0,1,2]"], ["2", "[1]", "[0,1,2]"], ["9", "[4,5,6,7,8]", "[0,1,2,3]"], ["9", "[0,1,2,3,4]", "[0,1,2,3]"], ["12", "[0,11]", "[0,10,11,12,22]"], ["20", "[5,6,7,8,9]", "[5,6,14,15,19]"], ["1000", "[0,1,2]", "[0,997,998,999,1000]"], ["15", "[3,8,12]", "[-5,-1,0,14,30]"], ["4", "[]", "[100,-100,0]"], ["6", "[2,4]", "[2,4,6,8]"], ["7", "[6]", "[6,7,13]"], ["11", "[5]", "[5,10,15,20]"], ["30", "[10,11,12,13,14]", "[10,11,25,29,30]"], ["50", "[0,25,49]", "[0,25,49,50,99]"], ["8", "[0,1,6,7]", "[0,1,2,3,4,5]"], ["16", "[4,8,12]", "[4,8,12,16,20]"], ["5", "[4]", "[4,5,9]"], ["1000000", "[0,999999]", "[0,1,999998,999999]"]], "expected": [[0, 1, 6, 4], [0, 1, 3], [0, 0], [0, 1, 2, 3, 4], [4, 4, 4], [0, 9, 8, 2, 0], [4, 1, 2, 3], [4, 0, 7, 6, 5], [0, 2, 0, 2, 0], [0, 50, 2, 3, 4], [1, 1, 1], [0, 0, 0], [0, 1, 2, 3], [8, 7, 6, 5], [10, 10, 1, 2, 2], [19, 18, 14, 0, 4], [999, 999, 998, 997, 3], [7, 11, 0, 2, 6], [0, 0, 0], [5, 0, 5, 0], [0, 1, 1], [10, 0, 10, 0], [29, 28, 0, 4, 5], [48, 47, 2, 3, 5], [5, 4, 2, 3, 5, 4], [15, 14, 13, 3, 7], [0, 1, 1], [999998, 1, 999998, 1]], "loose": true}
|