offcode 0.0.0-stage → 0.1.0
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-7tyR3Zsa.js +147 -0
- package/dist/web/assets/index-oer4U46K.css +1 -0
- package/dist/web/index.html +13 -0
- package/package.json +42 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "295", "slug": "pascals-triangle", "id": 295, "title": "Pascal's Triangle", "difficulty": "Easy", "category": "dp", "link": "https://leetcode.com/problems/pascals-triangle/", "examples": [{"input": "numRows = 5", "output": "[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]", "explanation": "Each interior entry is the sum of the two entries above it."}, {"input": "numRows = 1", "output": "[[1]]", "explanation": "The apex alone forms row 1."}], "hints": ["Start with [[1]] and grow one row at a time.", "Each interior entry equals the sum of the two entries diagonally above it; row edges are always 1.", "Adaptation: the nested list maps to int_list_2d in this judge."], "statement": "Produce the first `numRows` rows of Pascal's triangle.\n\nBegin with a single `1` at the top. Every later row starts and ends with `1`, and each interior position holds the sum of the two numbers directly above it from the previous row. Collect all rows from top to bottom and return them.\n\n**Constraints:**\n- `1 <= numRows <= 30`\n\n**Adaptation note:** The nested value list is represented as `int_list_2d` in this judge.\n", "solution": "## Approach\n\nBuild rows iteratively. The first row is [1]; each following row has one more entry, with 1s on both ends and interior sums taken from adjacent pairs of the previous row. Repeating this `numRows` times yields the triangle top-down with no extra bookkeeping.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(numRows^2), proportional to the total entries produced.\n- **Space Complexity:** O(numRows^2) for the stored triangle.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def generate(self, numRows: int) -> List[List[int]]:\n ans = []\n for r in range(numRows):\n row = [1] * (r + 1)\n for c in range(1, r):\n row[c] = ans[r - 1][c - 1] + ans[r - 1][c]\n ans.append(row)\n return ans\n```\n", "starter": {"go": "package main\n\nfunc Generate(numRows int) [][]int {\n \n}", "python": "from typing import List\nclass Solution:\n def generate(self, numRows: int) -> List[List[int]]:\n pass\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<vector<int>> generate(int numRows) {\n \n }\n};"}, "fn": "generate", "params": [{"name": "numRows", "type": "int"}], "outputType": "int_list_2d", "tests": [["1"], ["2"], ["3"], ["4"], ["5"], ["6"], ["7"], ["8"], ["9"], ["10"], ["11"], ["12"], ["13"], ["14"], ["15"], ["16"], ["17"], ["18"], ["19"], ["20"], ["21"], ["22"], ["23"], ["24"], ["25"], ["26"], ["27"], ["28"], ["29"], ["30"]], "expected": [[[1]], [[1], [1, 1]], [[1], [1, 1], [1, 2, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1], [1, 18, 153, 816, 3060, 8568, 18564, 31824, 43758, 48620, 43758, 31824, 18564, 8568, 3060, 816, 153, 18, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1], [1, 18, 153, 816, 3060, 8568, 18564, 31824, 43758, 48620, 43758, 31824, 18564, 8568, 3060, 816, 153, 18, 1], [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1], [1, 18, 153, 816, 3060, 8568, 18564, 31824, 43758, 48620, 43758, 31824, 18564, 8568, 3060, 816, 153, 18, 1], [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1], [1, 20, 190, 1140, 4845, 15504, 38760, 77520, 125970, 167960, 184756, 167960, 125970, 77520, 38760, 15504, 4845, 1140, 190, 20, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1], [1, 18, 153, 816, 3060, 8568, 18564, 31824, 43758, 48620, 43758, 31824, 18564, 8568, 3060, 816, 153, 18, 1], [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1], [1, 20, 190, 1140, 4845, 15504, 38760, 77520, 125970, 167960, 184756, 167960, 125970, 77520, 38760, 15504, 4845, 1140, 190, 20, 1], [1, 21, 210, 1330, 5985, 20349, 54264, 116280, 203490, 293930, 352716, 352716, 293930, 203490, 116280, 54264, 20349, 5985, 1330, 210, 21, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1], [1, 18, 153, 816, 3060, 8568, 18564, 31824, 43758, 48620, 43758, 31824, 18564, 8568, 3060, 816, 153, 18, 1], [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1], [1, 20, 190, 1140, 4845, 15504, 38760, 77520, 125970, 167960, 184756, 167960, 125970, 77520, 38760, 15504, 4845, 1140, 190, 20, 1], [1, 21, 210, 1330, 5985, 20349, 54264, 116280, 203490, 293930, 352716, 352716, 293930, 203490, 116280, 54264, 20349, 5985, 1330, 210, 21, 1], [1, 22, 231, 1540, 7315, 26334, 74613, 170544, 319770, 497420, 646646, 705432, 646646, 497420, 319770, 170544, 74613, 26334, 7315, 1540, 231, 22, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1], [1, 18, 153, 816, 3060, 8568, 18564, 31824, 43758, 48620, 43758, 31824, 18564, 8568, 3060, 816, 153, 18, 1], [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1], [1, 20, 190, 1140, 4845, 15504, 38760, 77520, 125970, 167960, 184756, 167960, 125970, 77520, 38760, 15504, 4845, 1140, 190, 20, 1], [1, 21, 210, 1330, 5985, 20349, 54264, 116280, 203490, 293930, 352716, 352716, 293930, 203490, 116280, 54264, 20349, 5985, 1330, 210, 21, 1], [1, 22, 231, 1540, 7315, 26334, 74613, 170544, 319770, 497420, 646646, 705432, 646646, 497420, 319770, 170544, 74613, 26334, 7315, 1540, 231, 22, 1], [1, 23, 253, 1771, 8855, 33649, 100947, 245157, 490314, 817190, 1144066, 1352078, 1352078, 1144066, 817190, 490314, 245157, 100947, 33649, 8855, 1771, 253, 23, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1], [1, 18, 153, 816, 3060, 8568, 18564, 31824, 43758, 48620, 43758, 31824, 18564, 8568, 3060, 816, 153, 18, 1], [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1], [1, 20, 190, 1140, 4845, 15504, 38760, 77520, 125970, 167960, 184756, 167960, 125970, 77520, 38760, 15504, 4845, 1140, 190, 20, 1], [1, 21, 210, 1330, 5985, 20349, 54264, 116280, 203490, 293930, 352716, 352716, 293930, 203490, 116280, 54264, 20349, 5985, 1330, 210, 21, 1], [1, 22, 231, 1540, 7315, 26334, 74613, 170544, 319770, 497420, 646646, 705432, 646646, 497420, 319770, 170544, 74613, 26334, 7315, 1540, 231, 22, 1], [1, 23, 253, 1771, 8855, 33649, 100947, 245157, 490314, 817190, 1144066, 1352078, 1352078, 1144066, 817190, 490314, 245157, 100947, 33649, 8855, 1771, 253, 23, 1], [1, 24, 276, 2024, 10626, 42504, 134596, 346104, 735471, 1307504, 1961256, 2496144, 2704156, 2496144, 1961256, 1307504, 735471, 346104, 134596, 42504, 10626, 2024, 276, 24, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1], [1, 18, 153, 816, 3060, 8568, 18564, 31824, 43758, 48620, 43758, 31824, 18564, 8568, 3060, 816, 153, 18, 1], [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1], [1, 20, 190, 1140, 4845, 15504, 38760, 77520, 125970, 167960, 184756, 167960, 125970, 77520, 38760, 15504, 4845, 1140, 190, 20, 1], [1, 21, 210, 1330, 5985, 20349, 54264, 116280, 203490, 293930, 352716, 352716, 293930, 203490, 116280, 54264, 20349, 5985, 1330, 210, 21, 1], [1, 22, 231, 1540, 7315, 26334, 74613, 170544, 319770, 497420, 646646, 705432, 646646, 497420, 319770, 170544, 74613, 26334, 7315, 1540, 231, 22, 1], [1, 23, 253, 1771, 8855, 33649, 100947, 245157, 490314, 817190, 1144066, 1352078, 1352078, 1144066, 817190, 490314, 245157, 100947, 33649, 8855, 1771, 253, 23, 1], [1, 24, 276, 2024, 10626, 42504, 134596, 346104, 735471, 1307504, 1961256, 2496144, 2704156, 2496144, 1961256, 1307504, 735471, 346104, 134596, 42504, 10626, 2024, 276, 24, 1], [1, 25, 300, 2300, 12650, 53130, 177100, 480700, 1081575, 2042975, 3268760, 4457400, 5200300, 5200300, 4457400, 3268760, 2042975, 1081575, 480700, 177100, 53130, 12650, 2300, 300, 25, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1], [1, 18, 153, 816, 3060, 8568, 18564, 31824, 43758, 48620, 43758, 31824, 18564, 8568, 3060, 816, 153, 18, 1], [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1], [1, 20, 190, 1140, 4845, 15504, 38760, 77520, 125970, 167960, 184756, 167960, 125970, 77520, 38760, 15504, 4845, 1140, 190, 20, 1], [1, 21, 210, 1330, 5985, 20349, 54264, 116280, 203490, 293930, 352716, 352716, 293930, 203490, 116280, 54264, 20349, 5985, 1330, 210, 21, 1], [1, 22, 231, 1540, 7315, 26334, 74613, 170544, 319770, 497420, 646646, 705432, 646646, 497420, 319770, 170544, 74613, 26334, 7315, 1540, 231, 22, 1], [1, 23, 253, 1771, 8855, 33649, 100947, 245157, 490314, 817190, 1144066, 1352078, 1352078, 1144066, 817190, 490314, 245157, 100947, 33649, 8855, 1771, 253, 23, 1], [1, 24, 276, 2024, 10626, 42504, 134596, 346104, 735471, 1307504, 1961256, 2496144, 2704156, 2496144, 1961256, 1307504, 735471, 346104, 134596, 42504, 10626, 2024, 276, 24, 1], [1, 25, 300, 2300, 12650, 53130, 177100, 480700, 1081575, 2042975, 3268760, 4457400, 5200300, 5200300, 4457400, 3268760, 2042975, 1081575, 480700, 177100, 53130, 12650, 2300, 300, 25, 1], [1, 26, 325, 2600, 14950, 65780, 230230, 657800, 1562275, 3124550, 5311735, 7726160, 9657700, 10400600, 9657700, 7726160, 5311735, 3124550, 1562275, 657800, 230230, 65780, 14950, 2600, 325, 26, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1], [1, 18, 153, 816, 3060, 8568, 18564, 31824, 43758, 48620, 43758, 31824, 18564, 8568, 3060, 816, 153, 18, 1], [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1], [1, 20, 190, 1140, 4845, 15504, 38760, 77520, 125970, 167960, 184756, 167960, 125970, 77520, 38760, 15504, 4845, 1140, 190, 20, 1], [1, 21, 210, 1330, 5985, 20349, 54264, 116280, 203490, 293930, 352716, 352716, 293930, 203490, 116280, 54264, 20349, 5985, 1330, 210, 21, 1], [1, 22, 231, 1540, 7315, 26334, 74613, 170544, 319770, 497420, 646646, 705432, 646646, 497420, 319770, 170544, 74613, 26334, 7315, 1540, 231, 22, 1], [1, 23, 253, 1771, 8855, 33649, 100947, 245157, 490314, 817190, 1144066, 1352078, 1352078, 1144066, 817190, 490314, 245157, 100947, 33649, 8855, 1771, 253, 23, 1], [1, 24, 276, 2024, 10626, 42504, 134596, 346104, 735471, 1307504, 1961256, 2496144, 2704156, 2496144, 1961256, 1307504, 735471, 346104, 134596, 42504, 10626, 2024, 276, 24, 1], [1, 25, 300, 2300, 12650, 53130, 177100, 480700, 1081575, 2042975, 3268760, 4457400, 5200300, 5200300, 4457400, 3268760, 2042975, 1081575, 480700, 177100, 53130, 12650, 2300, 300, 25, 1], [1, 26, 325, 2600, 14950, 65780, 230230, 657800, 1562275, 3124550, 5311735, 7726160, 9657700, 10400600, 9657700, 7726160, 5311735, 3124550, 1562275, 657800, 230230, 65780, 14950, 2600, 325, 26, 1], [1, 27, 351, 2925, 17550, 80730, 296010, 888030, 2220075, 4686825, 8436285, 13037895, 17383860, 20058300, 20058300, 17383860, 13037895, 8436285, 4686825, 2220075, 888030, 296010, 80730, 17550, 2925, 351, 27, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1], [1, 18, 153, 816, 3060, 8568, 18564, 31824, 43758, 48620, 43758, 31824, 18564, 8568, 3060, 816, 153, 18, 1], [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1], [1, 20, 190, 1140, 4845, 15504, 38760, 77520, 125970, 167960, 184756, 167960, 125970, 77520, 38760, 15504, 4845, 1140, 190, 20, 1], [1, 21, 210, 1330, 5985, 20349, 54264, 116280, 203490, 293930, 352716, 352716, 293930, 203490, 116280, 54264, 20349, 5985, 1330, 210, 21, 1], [1, 22, 231, 1540, 7315, 26334, 74613, 170544, 319770, 497420, 646646, 705432, 646646, 497420, 319770, 170544, 74613, 26334, 7315, 1540, 231, 22, 1], [1, 23, 253, 1771, 8855, 33649, 100947, 245157, 490314, 817190, 1144066, 1352078, 1352078, 1144066, 817190, 490314, 245157, 100947, 33649, 8855, 1771, 253, 23, 1], [1, 24, 276, 2024, 10626, 42504, 134596, 346104, 735471, 1307504, 1961256, 2496144, 2704156, 2496144, 1961256, 1307504, 735471, 346104, 134596, 42504, 10626, 2024, 276, 24, 1], [1, 25, 300, 2300, 12650, 53130, 177100, 480700, 1081575, 2042975, 3268760, 4457400, 5200300, 5200300, 4457400, 3268760, 2042975, 1081575, 480700, 177100, 53130, 12650, 2300, 300, 25, 1], [1, 26, 325, 2600, 14950, 65780, 230230, 657800, 1562275, 3124550, 5311735, 7726160, 9657700, 10400600, 9657700, 7726160, 5311735, 3124550, 1562275, 657800, 230230, 65780, 14950, 2600, 325, 26, 1], [1, 27, 351, 2925, 17550, 80730, 296010, 888030, 2220075, 4686825, 8436285, 13037895, 17383860, 20058300, 20058300, 17383860, 13037895, 8436285, 4686825, 2220075, 888030, 296010, 80730, 17550, 2925, 351, 27, 1], [1, 28, 378, 3276, 20475, 98280, 376740, 1184040, 3108105, 6906900, 13123110, 21474180, 30421755, 37442160, 40116600, 37442160, 30421755, 21474180, 13123110, 6906900, 3108105, 1184040, 376740, 98280, 20475, 3276, 378, 28, 1]], [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1], [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1], [1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1], [1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1], [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1], [1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1], [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1], [1, 16, 120, 560, 1820, 4368, 8008, 11440, 12870, 11440, 8008, 4368, 1820, 560, 120, 16, 1], [1, 17, 136, 680, 2380, 6188, 12376, 19448, 24310, 24310, 19448, 12376, 6188, 2380, 680, 136, 17, 1], [1, 18, 153, 816, 3060, 8568, 18564, 31824, 43758, 48620, 43758, 31824, 18564, 8568, 3060, 816, 153, 18, 1], [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1], [1, 20, 190, 1140, 4845, 15504, 38760, 77520, 125970, 167960, 184756, 167960, 125970, 77520, 38760, 15504, 4845, 1140, 190, 20, 1], [1, 21, 210, 1330, 5985, 20349, 54264, 116280, 203490, 293930, 352716, 352716, 293930, 203490, 116280, 54264, 20349, 5985, 1330, 210, 21, 1], [1, 22, 231, 1540, 7315, 26334, 74613, 170544, 319770, 497420, 646646, 705432, 646646, 497420, 319770, 170544, 74613, 26334, 7315, 1540, 231, 22, 1], [1, 23, 253, 1771, 8855, 33649, 100947, 245157, 490314, 817190, 1144066, 1352078, 1352078, 1144066, 817190, 490314, 245157, 100947, 33649, 8855, 1771, 253, 23, 1], [1, 24, 276, 2024, 10626, 42504, 134596, 346104, 735471, 1307504, 1961256, 2496144, 2704156, 2496144, 1961256, 1307504, 735471, 346104, 134596, 42504, 10626, 2024, 276, 24, 1], [1, 25, 300, 2300, 12650, 53130, 177100, 480700, 1081575, 2042975, 3268760, 4457400, 5200300, 5200300, 4457400, 3268760, 2042975, 1081575, 480700, 177100, 53130, 12650, 2300, 300, 25, 1], [1, 26, 325, 2600, 14950, 65780, 230230, 657800, 1562275, 3124550, 5311735, 7726160, 9657700, 10400600, 9657700, 7726160, 5311735, 3124550, 1562275, 657800, 230230, 65780, 14950, 2600, 325, 26, 1], [1, 27, 351, 2925, 17550, 80730, 296010, 888030, 2220075, 4686825, 8436285, 13037895, 17383860, 20058300, 20058300, 17383860, 13037895, 8436285, 4686825, 2220075, 888030, 296010, 80730, 17550, 2925, 351, 27, 1], [1, 28, 378, 3276, 20475, 98280, 376740, 1184040, 3108105, 6906900, 13123110, 21474180, 30421755, 37442160, 40116600, 37442160, 30421755, 21474180, 13123110, 6906900, 3108105, 1184040, 376740, 98280, 20475, 3276, 378, 28, 1], [1, 29, 406, 3654, 23751, 118755, 475020, 1560780, 4292145, 10015005, 20030010, 34597290, 51895935, 67863915, 77558760, 77558760, 67863915, 51895935, 34597290, 20030010, 10015005, 4292145, 1560780, 475020, 118755, 23751, 3654, 406, 29, 1]]], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "416", "slug": "patching-array", "id": 416, "title": "Patching Array", "difficulty": "Hard", "category": "array", "link": "https://leetcode.com/problems/patching-array/", "examples": [{"explanation": "Subset sums of [1,3] cover 1, 3 and 4. Patching in 2 extends coverage to every value 1..6.", "input": "nums = [1,3], n = 6", "output": "1"}, {"explanation": "Patching 2 and then 4 (one workable choice) fills the gaps so that 1..20 all become reachable.", "input": "nums = [1,5,10], n = 20", "output": "2"}, {"explanation": "Sums of [1,2,2] already produce 1, 2, 3, 4 and 5.", "input": "nums = [1,2,2], n = 5", "output": "0"}], "hints": ["Track `miss`, the smallest value not yet known to be formable; initially everything below `miss` is covered.", "If the next array element is at most `miss`, absorb it (coverage grows to miss + nums[i]); otherwise patch `miss` itself, doubling coverage.", "Count patches until `miss` exceeds n; use 64-bit integers since coverage can pass 2^31."], "statement": "You start with a sorted array `nums` of positive integers and a target reach `n`. Using any subset of the array's elements (each at most once), you can assemble various totals. If every integer from `1` through `n` can already be formed this way, nothing needs to change. Otherwise you may insert extra numbers (\"patches\") anywhere in the array. Return the smallest number of patches that makes all values in `[1, n]` representable as subset sums.\n\n**Constraints:**\n- `1 <= nums.length <= 1000`\n- `1 <= nums[i] <= 10^4`\n- `nums` is sorted in non-decreasing order.\n- `1 <= n <= 2^31 - 1`\n", "solution": "## Approach\n\nMaintain `miss`, the smallest total not yet achievable; every value below it is already covered. If the next array entry is at most `miss`, include it and stretch coverage by its value; otherwise insert `miss` itself as a patch, which doubles the covered range. Repeat until coverage passes `n`, counting the patches used.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m + log n), where m is the length of `nums`.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def minPatches(self, nums: List[int], n: int) -> int:\n miss = 1\n patches = 0\n i = 0\n while miss <= n:\n if i < len(nums) and nums[i] <= miss:\n miss += nums[i]\n i += 1\n else:\n miss += miss\n patches += 1\n return patches\n```\n", "starter": {"go": "package main\n\nfunc MinPatches(nums []int, n int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def minPatches(self, nums: List[int], n: int) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int minPatches(vector<int>& nums, int n) {\n return 0;\n }\n};"}, "fn": "minPatches", "params": [{"name": "nums", "type": "int_array"}, {"name": "n", "type": "int"}], "outputType": "int", "tests": [["[1,3]", "6"], ["[1,5,10]", "20"], ["[1,2,2]", "5"], ["[1]", "1"], ["[1]", "2"], ["[2]", "1"], ["[2]", "3"], ["[1,2,4,8]", "15"], ["[1,2,4,8]", "16"], ["[1,2,4]", "8"], ["[1,3,5]", "10"], ["[1,4,9]", "20"], ["[1,2,3]", "6"], ["[1,2,3]", "7"], ["[5]", "5"], ["[1,2,7]", "14"], ["[1,2,7]", "15"], ["[1,10,100]", "1000"], ["[1,2,4,13,43]", "100"], ["[3]", "6"], ["[1,2,2,6,9]", "20"], ["[1,5,10,100]", "1000"], ["[2,4,8,16]", "31"], ["[1,2,4,8,16]", "100"], ["[7]", "7"], ["[1,10000]", "1000000"], ["[1,2,32]", "2147483647"], ["[1,3,6,10,15]", "30"], ["[4,9]", "20"], ["[1,1,1,1]", "4"]], "expected": [1, 2, 0, 0, 1, 1, 1, 0, 1, 1, 1, 2, 0, 1, 3, 1, 2, 8, 2, 2, 0, 7, 1, 2, 3, 19, 28, 1, 3, 0], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "291", "slug": "path-sum-ii", "id": 291, "title": "Path Sum II", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/path-sum-ii/", "examples": [{"input": "root = [5,4,8,11,null,13,4,7,2,null,null,5,1], targetSum = 22", "output": "[[5,4,11,2],[5,8,4,5]]", "explanation": "Two leaf-ending chains sum to 22: 5-4-11-2 and 5-8-4-5."}, {"input": "root = [1,2,3], targetSum = 5", "output": "[]", "explanation": "No leaf chain reaches 5."}, {"input": "root = [1,2], targetSum = 0", "output": "[]", "explanation": "No leaf chain reaches 0."}], "hints": ["Depth-first search with backtracking maintains the current root-to-node chain.", "Copy the chain into the answer only at leaves whose values sum to the target.", "Adaptation: the nested list maps to int_list_2d; order of paths is normalized by the checker."], "statement": "Collect every root-to-leaf chain whose values add up to a target total.\n\nExplore the tree depth-first while keeping the current path. At each node, extend the path and reduce the remaining sum. When a leaf is reached, keep a snapshot of the path if its sum matches the target; otherwise discard it. Then backtrack and try the next branch.\n\nReturn all matching paths as value lists ordered from root to leaf. The checker treats path order as insignificant but each individual path must run root-first.\n\n**Constraints:**\n- `0 <= number of nodes <= 5000`\n- `-1000 <= Node.val <= 1000`\n- `-1000 <= targetSum <= 1000`\n\n**Adaptation note:** The nested value list is represented as `int_list_2d` in this judge.\n", "solution": "## Approach\n\nBacktracking depth-first search keeps one mutable path from the root to the current node. Each step appends the node value; at a leaf the accumulated path is copied to the answer when its sum equals the target. Removing the value on the way back up restores the path for sibling branches. Copying only at leaves keeps memory proportional to depth plus output size.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n * h) in the worst case \u2014 each root-to-leaf path of length h may be copied.\n- **Space Complexity:** O(h) recursion depth excluding the answer.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def pathSum(self, root, targetSum: int) -> List[List[int]]:\n ans = []\n path = []\n def dfs(n, rest):\n if not n:\n return\n path.append(n.val)\n if not n.left and not n.right:\n if n.val == rest:\n ans.append(list(path))\n else:\n dfs(n.left, rest - n.val)\n dfs(n.right, rest - n.val)\n path.pop()\n dfs(root, targetSum)\n return ans\n```\n", "starter": {"go": "// Definition for a binary tree node.\n// type TreeNode struct {\n// Val int\n// Left *TreeNode\n// Right *TreeNode\n// }\npackage main\n\nfunc PathSum(root *TreeNode, TargetSum int) [][]int {\n \n}", "python": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, val=0, left=None, right=None):\n# self.val = val\n# self.left = left\n# self.right = right\n\nfrom typing import List\nclass Solution:\n def pathSum(self, root, targetSum: int) -> List[List[int]]:\n pass\n", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\n#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<vector<int>> pathSum(TreeNode* root, int targetSum) {\n \n }\n};"}, "fn": "pathSum", "params": [{"name": "root", "type": "tree_node", "visualizeType": "tree_node"}, {"name": "targetSum", "type": "int"}], "outputType": "int_list_2d", "tests": [["[5,4,8,11,null,13,4,7,2,null,null,5,1]", "22"], ["[1,2,3]", "5"], ["[1,2]", "0"], ["[]", "0"], ["[1,2,3,4,5]", "7"], ["[5,4,8,11,null,13,4,7,2,null,null,null,1]", "22"], ["[1]", "1"], ["[1]", "2"], ["[1,-2,-3,1,3,-2,null,-1]", "-1"], ["[1,2,3,4,null,null,5]", "7"], ["[-2,null,-3]", "-5"], ["[0]", "0"], ["[1,2,null,3,null,4]", "10"], ["[3,9,20,null,null,15,7]", "12"], ["[1,2,3,4,5,6,7]", "10"], ["[10,5,-3,3,2,null,11,3,-2,null,1]", "18"], ["[5,4,8,11,null,13,4,7,2,null,null,5,1]", "26"], ["[2,1,3]", "3"], ["[4,2,6,1,3,5,7]", "7"], ["[1,null,2,null,3]", "6"], ["[7,3,10,2,5,null,12]", "22"], ["[1,2,3,null,4,5,6]", "8"], ["[5,3,6,2,4,null,7]", "10"], ["[-1,-2,-3]", "-3"], ["[0,1,1]", "1"], ["[1,2,3,4,5,6,7,8]", "15"]], "expected": [[[5, 4, 11, 2], [5, 8, 4, 5]], [], [], [], [[1, 2, 4]], [[5, 4, 11, 2]], [[1]], [], [[1, -2, 1, -1]], [[1, 2, 4]], [[-2, -3]], [[0]], [[1, 2, 3, 4]], [[3, 9]], [[1, 3, 6]], [[10, 5, 2, 1], [10, -3, 11]], [[5, 8, 13]], [[2, 1]], [[4, 2, 1]], [[1, 2, 3]], [], [], [[5, 3, 2]], [[-1, -2]], [[0, 1], [0, 1]], [[1, 2, 4, 8]]], "loose": true}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "505", "slug": "path-sum-iii", "id": 505, "title": "Path Sum III", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/path-sum-iii/", "examples": [{"input": "root = [10,5,-3,3,2,null,11,3,-2,null,1], targetSum = 8", "output": "3", "explanation": "Three downward routes total 8."}, {"input": "root = [5,4,8,11,null,13,4,7,2,null,null,5,1], targetSum = 22", "output": "3", "explanation": "Three routes hit 22."}, {"input": "root = [], targetSum = 0", "output": "0", "explanation": "No nodes means no paths."}], "hints": ["Carry prefix sums from the root: paths ending at the current node match earlier prefixes offset by targetSum.", "A hash map of prefix frequencies updated on entry and removed on exit keeps the walk linear.", "Use 64-bit sums to avoid overflow on deep paths."], "statement": "You are given a binary tree `root` and a number `targetSum`. Count the downward paths whose node values add up to `targetSum`. A path may begin at any node and finish at any descendant of that start (the start and end may coincide); it must follow parent-to-child links only.\n\n**Constraints:**\n- Node count lies in `[0, 1000]`.\n- Node values and `targetSum` fit the stated ranges; sums may exceed 32-bit during accumulation, so use 64-bit counters internally.\n", "solution": "## Approach\n\nDo a depth-first walk carrying the running sum from the root. A hash map counts how often each prefix sum has appeared on the current path; any earlier prefix equal to `current - targetSum` closes a qualifying downward path ending here. Add that count, recurse into both children, then decrement the current prefix before backtracking.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the node count. Each node is visited once with O(1) map work.\n- **Space Complexity:** O(h) for recursion depth plus the prefix table, where h is the tree height.\n\n## Implementation\n\n```python\nfrom collections import defaultdict\nclass Solution:\n def pathSum(self, root, targetSum: int) -> int:\n freq = defaultdict(int)\n freq[0] = 1\n def dfs(n, cur):\n if not n:\n return 0\n cur += n.val\n res = freq[cur - targetSum]\n freq[cur] += 1\n res += dfs(n.left, cur)\n res += dfs(n.right, cur)\n freq[cur] -= 1\n return res\n return dfs(root, 0)\n```\n", "starter": {"go": "// Definition for a binary tree node.\n// type TreeNode struct {\n// Val int\n// Left *TreeNode\n// Right *TreeNode\n// }\npackage main\n\nfunc PathSum(root *TreeNode, targetSum int) int {\n \n}", "python": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, val=0, left=None, right=None):\n# self.val = val\n# self.left = left\n# self.right = right\n\nclass Solution:\n def pathSum(self, root, targetSum: int) -> int:\n pass\n", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\nclass Solution {\npublic:\n int pathSum(TreeNode* root, int targetSum) {\n \n }\n};"}, "fn": "pathSum", "params": [{"name": "root", "type": "tree_node", "visualizeType": "tree_node"}, {"name": "targetSum", "type": "int"}], "outputType": "int", "tests": [["[10,5,-3,3,2,null,11,3,-2,null,1]", "8"], ["[5,4,8,11,null,13,4,7,2,null,null,5,1]", "22"], ["[]", "0"], ["[1]", "1"], ["[1]", "2"], ["[1,2,3]", "3"], ["[0,0,0]", "0"], ["[1,null,2,null,3]", "3"], ["[-1,-2,-3]", "-3"], ["[5]", "5"], ["[3,3,3]", "3"], ["[1,-2,-3,1,3,-2,null,-1]", "-1"], ["[1,2,3,4,5]", "5"], ["[0]", "0"], ["[1,2,null,3]", "3"], ["[5,4,8,11,null,13,4,7,2,null,null,5,1]", "5"], ["[10,5,-3,3,2,null,11,3,-2,null,1]", "3"], ["[1,null,2,null,3,null,4]", "6"], ["[2,2,2]", "2"], ["[0,1,1]", "1"], ["[-2,null,-3]", "-5"], ["[1,-1,1]", "0"], ["[3,5,1,6,2,0,8,null,null,7,4]", "8"], ["[1,2,3,4,null,null,5]", "8"], ["[1000000,1000000,1000000]", "1000000"], ["[1,1,1,1,1]", "2"], ["[0,0,null,0]", "0"], ["[5,3,6,2,4,null,null,1]", "8"]], "expected": [3, 3, 0, 1, 0, 2, 5, 2, 2, 1, 3, 4, 1, 1, 2, 3, 3, 1, 3, 4, 1, 1, 2, 1, 3, 4, 6, 1], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "685", "slug": "path-sum-iv", "id": 685, "title": "Path Sum IV", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/path-sum-iv/", "examples": [{"input": "nums = [113,215,221]", "output": "12", "explanation": "Paths 3->5 (=8) and 3->1 (=4) total 12."}, {"input": "nums = [113,221]", "output": "4", "explanation": "Single path 3 -> 1 totals 4."}, {"input": "nums = [111,222,333]", "output": "6", "explanation": "Chain 1->2->3 sums to 6."}], "hints": ["Decode each entry: hundreds are depth, tens are position, ones are the node value.", "Store the values in a map keyed by (depth, position); children of (d, p) sit at (d+1, 2p-1) and (d+1, 2p).", "Depth-first walk from (1, 1), adding the running total whenever a node has no children in the map."], "statement": "You are given an array `nums` encoding a binary tree. Each entry is a three-digit number:\n\n- hundreds digit: depth `d` (root is depth 1),\n- tens digit: position `p` within that depth (counting from 1),\n- ones digit: node value `v` (0..9).\n\nThe tree is consistent: every code except the root has its parent present, and positions follow heap rules where children of `(d, p)` are `(d+1, 2p-1)` and `(d+1, 2p)`.\n\nAdd up the sums of all root-to-leaf paths and return the total.\n\n**Adaptation:** the encoded entries map to an int array in this judge.\n\n**Constraints:**\n- `1 <= nums.length <= 50`\n- Each code is between 111 and 459 with value digit 0..9 and forms a valid tree.\n", "solution": "## Approach\n\nDecode each triple into a `(depth, position) -> value` table. From the root `(1, 1)`, recurse to children `(d+1, 2p-1)` and `(d+1, 2p)` carrying the running sum. When neither child exists in the table, the accumulated sum is one complete path; add it to the answer.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) for n codes.\n- **Space Complexity:** O(n) for the table plus recursion depth.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def pathSum(self, nums: List[int]) -> int:\n val = {}\n for x in nums:\n d, p, v = x // 100, (x // 10) % 10, x % 10\n val[(d, p)] = v\n def dfs(d, p, cur):\n if (d, p) not in val:\n return 0\n cur += val[(d, p)]\n has_l = (d + 1, 2 * p - 1) in val\n has_r = (d + 1, 2 * p) in val\n if not has_l and not has_r:\n return cur\n return dfs(d + 1, 2 * p - 1, cur) + dfs(d + 1, 2 * p, cur)\n return dfs(1, 1, 0)\n```\n", "starter": {"go": "package main\n\nfunc PathSum(nums []int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def pathSum(self, nums: List[int]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int pathSum(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "pathSum", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[113,215,221]"], ["[113,221]"], ["[111,222,333]"], ["[113]"], ["[113,215,221,342,324]"], ["[111]"], ["[115,215,225,335,345]"], ["[119,219,229,339,349]"], ["[110,210,220]"], ["[113,214,221,334]"], ["[121,222,223]"], ["[111,212,223,414,425]"], ["[115]"], ["[112,213,214,314,325]"], ["[119,229,339,449]"], ["[111,222,333,444]"], ["[113,215,216,315,326]"], ["[114,214,224,314,324,334,344]"], ["[110,210]"], ["[117,217,227,317,327,337,347]"], ["[111,211,221,311,322]"], ["[119,219,229]"], ["[113,215,221,345]"], ["[116,216,226]"], ["[111,212,213,314]"], ["[118,218,228,318,328]"], ["[115,225,335,445]"], ["[112,212,222,312,323]"]], "expected": [12, 4, 6, 3, 18, 1, 40, 72, 0, 15, 0, 7, 5, 21, 27, 6, 29, 48, 0, 84, 9, 36, 17, 24, 8, 64, 15, 17], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "290", "slug": "path-sum", "id": 290, "title": "Path Sum", "difficulty": "Easy", "category": "tree", "link": "https://leetcode.com/problems/path-sum/", "examples": [{"input": "root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22", "output": "true", "explanation": "Route 5 -> 4 -> 11 -> 2 adds to 22 and ends at a leaf."}, {"input": "root = [1,2,3], targetSum = 5", "output": "false", "explanation": "Routes 1 -> 2 (=3) and 1 -> 3 (=4) both miss 5."}, {"input": "root = [], targetSum = 0", "output": "false", "explanation": "With no nodes there is no root-to-leaf route."}], "hints": ["Subtract the current node value from the remaining sum as you descend.", "Only return true at a leaf whose remaining sum is exactly zero.", "An empty tree never satisfies the condition, even when the target is zero."], "statement": "Determine whether any root-to-leaf chain in a binary tree adds up to a given total.\n\nStart at the root with the full target. At each step, subtract the current node's value and continue to its children. When a leaf (a node with no children) is reached, success means the leftover amount is zero. Interior nodes never count, even if the partial sum matches early.\n\nReturn `true` if at least one qualifying leaf route exists, otherwise `false`.\n\n**Constraints:**\n- `0 <= number of nodes <= 5000`\n- `-1000 <= Node.val <= 1000`\n- `-1000 <= targetSum <= 1000`\n", "solution": "## Approach\n\nDepth-first search carries the remaining sum downward. Each call subtracts the current value; at a leaf the call succeeds exactly when nothing remains. Non-leaf nodes combine their children's answers with logical OR, and a null tree immediately fails. Negative values are handled naturally since no early pruning is used.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), each node visited once.\n- **Space Complexity:** O(h) recursion depth.\n\n## Implementation\n\n```python\nclass Solution:\n def hasPathSum(self, root, targetSum: int) -> bool:\n if not root:\n return False\n if not root.left and not root.right:\n return root.val == targetSum\n rest = targetSum - root.val\n return self.hasPathSum(root.left, rest) or self.hasPathSum(root.right, rest)\n```\n", "starter": {"go": "// Definition for a binary tree node.\n// type TreeNode struct {\n// Val int\n// Left *TreeNode\n// Right *TreeNode\n// }\npackage main\n\nfunc HasPathSum(root *TreeNode, TargetSum int) bool {\n \n}", "python": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, val=0, left=None, right=None):\n# self.val = val\n# self.left = left\n# self.right = right\n\nclass Solution:\n def hasPathSum(self, root, targetSum: int) -> bool:\n pass\n", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\nclass Solution {\npublic:\n bool hasPathSum(TreeNode* root, int targetSum) {\n \n }\n};"}, "fn": "hasPathSum", "params": [{"name": "root", "type": "tree_node", "visualizeType": "tree_node"}, {"name": "targetSum", "type": "int"}], "outputType": "boolean", "tests": [["[5,4,8,11,null,13,4,7,2,null,null,null,1]", "22"], ["[1,2,3]", "5"], ["[]", "0"], ["[1,2]", "1"], ["[1,-2,-3,1,3,-2,null,-1]", "-1"], ["[1,2,3,4,5]", "7"], ["[1]", "1"], ["[1]", "2"], ["[]", "5"], ["[5,4,8,11,null,13,4,7,2,null,null,5,1]", "22"], ["[1,2,3,4,null,null,5]", "7"], ["[-2,null,-3]", "-5"], ["[1,-2,3]", "-1"], ["[3,9,20,null,null,15,7]", "12"], ["[3,9,20,null,null,15,7]", "30"], ["[5,4,8,11,null,13,4,7,2,null,null,null,1]", "26"], ["[1,2,null,3,null,4]", "10"], ["[0]", "0"], ["[0]", "1"], ["[1,2,3,4,5,6,7]", "10"], ["[10,5,15,2,7,12,20]", "17"], ["[-5,-10,0]", "-15"], ["[2,1,3]", "3"], ["[4,2,6,1,3,5,7]", "7"], ["[1,null,2,null,3]", "6"], ["[7,3,10,2,5,null,12]", "12"]], "expected": [true, false, false, false, true, true, true, false, false, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "223", "slug": "path-with-minimum-effort", "id": 223, "title": "Path With Minimum Effort", "difficulty": "Medium", "category": "graph", "link": "https://leetcode.com/problems/path-with-minimum-effort/", "examples": [{"input": "heights = [[1,2,2],[3,8,2],[5,3,5]]", "output": "2", "explanation": "The route of [1,3,5,3,5] has a maximum absolute difference of 2 in consecutive cells. This is better than the route of [1,2,2,2,5], where the maximum absolute difference is 3."}, {"input": "heights = [[1,2,3],[3,8,4],[5,3,5]]", "output": "1", "explanation": "The route of [1,2,3,4,5] has a maximum absolute difference of 1 in consecutive cells, which is better than route [1,3,5,3,5]."}, {"input": "heights = [[1,2,1,1,1],[1,2,1,2,1],[1,2,1,2,1],[1,2,1,2,1],[1,1,1,2,1]]", "output": "0", "explanation": "This route does not require any effort."}], "hints": ["Consider the grid as a graph, where adjacent cells have an edge with cost of the difference between the cells.", "If you are given threshold k, check if it is possible to go from (0, 0) to (n-1, m-1) using only edges of cost at most k.", "Binary search the k value."], "statement": "You are planning a walk over a terrain map `heights` with `rows` rows and `columns` columns, where `heights[row][col]` is the altitude of that square. The walk begins at the upper-left corner `(0, 0)` and must finish at the lower-right corner `(rows-1, columns-1)`, moving only to the four directly neighboring squares.\n\nFor any chosen walk, look at the absolute altitude change between each pair of successive squares and take the largest of those changes; that maximum is the walk's effort. Among all possible walks, return the smallest achievable effort.\n\n**Constraints:**\n- `rows == heights.length`\n- `columns == heights[i].length`\n- `1 <= rows, columns <= 100`\n- `1 <= heights[i][j] <= 10^6`\n", "solution": "## Approach\n\nTreat each cell as a graph node with edges to its four neighbors weighted by the absolute height difference. The effort of a path is the maximum edge weight along it, so run Dijkstra where the path cost is the max edge seen so far instead of a sum. A min-heap ordered by effort expands the cheapest frontier first, and the first time the target is popped its effort is optimal.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(mn log(mn)), where m and n are the grid dimensions. Each cell is processed with heap operations.\n- **Space Complexity:** O(mn) for the distance array and the heap.\n\n## Implementation\n\n```python\nimport heapq\nclass Solution:\n def minimumEffortPath(self, heights: list[list[int]]) -> int:\n rows, cols = len(heights), len(heights[0])\n dist = [[10**18] * cols for _ in range(rows)]\n dist[0][0] = 0\n pq = [(0, 0, 0)]\n while pq:\n effort, r, c = heapq.heappop(pq)\n if r == rows - 1 and c == cols - 1:\n return effort\n if effort > dist[r][c]:\n continue\n for dr, dc in ((1, 0), (-1, 0), (0, 1), (0, -1)):\n nr, nc = r + dr, c + dc\n if 0 <= nr < rows and 0 <= nc < cols:\n nxt = max(effort, abs(heights[r][c] - heights[nr][nc]))\n if nxt < dist[nr][nc]:\n dist[nr][nc] = nxt\n heapq.heappush(pq, (nxt, nr, nc))\n return dist[rows - 1][cols - 1]\n```\n", "starter": {"go": "package main\n\nfunc MinimumEffortPath(heights [][]int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def minimumEffortPath(self, heights: List[List[int]]) -> int:\n ", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int minimumEffortPath(vector<vector<int>>& heights) {\n return 0;\n }\n};"}, "fn": "minimumEffortPath", "params": [{"name": "heights", "type": "int_array_2d"}], "outputType": "int", "tests": [["[[1,2,2],[3,8,2],[5,3,5]]"], ["[[1,2,3],[3,8,4],[5,3,5]]"], ["[[1,2,1,1,1],[1,2,1,2,1],[1,2,1,2,1],[1,2,1,2,1],[1,1,1,2,1]]"], ["[[1]]"], ["[[1,10],[10,1]]"], ["[[1,2],[3,4]]"], ["[[3]]"], ["[[1,2,3],[4,5,6],[7,8,9]]"], ["[[1,1000000],[1,1]]"], ["[[4,3,4,10,5,5,9,2],[10,8,2,10,9,7,5,6],[5,8,10,10,10,7,4,2],[5,1,3,1,1,3,1,9],[6,4,10,6,10,9,4,6]]"], ["[[5]]"], ["[[1,2]]"], ["[[1],[2]]"], ["[[2,2],[2,2]]"], ["[[5,1],[1,5]]"], ["[[1,2,3,4]]"], ["[[1],[2],[3],[4]]"], ["[[1,3],[2,5],[4,6]]"], ["[[1,2,3],[1,2,3],[1,2,3]]"], ["[[10,10,10],[10,1,10],[10,10,10]]"], ["[[1,100],[100,100]]"], ["[[2,1],[1,2]]"], ["[[1,5,1],[5,1,5],[1,5,1]]"], ["[[7,7,7,7],[7,7,7,7]]"], ["[[3,2,1],[6,5,4]]"], ["[[100,1,100],[1,100,1],[100,1,100]]"], ["[[1,4],[2,3],[5,6],[7,8]]"], ["[[9,9],[9,9],[9,1]]"], ["[[6,5,4,3],[1,2,7,8]]"], ["[[2,3,1],[4,6,5]]"]], "expected": [2, 1, 0, 0, 9, 2, 0, 3, 0, 5, 0, 1, 1, 0, 4, 1, 1, 2, 1, 0, 99, 1, 4, 0, 3, 99, 3, 8, 3, 2], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "849", "slug": "peak-index-in-a-mountain-array", "id": 849, "title": "Peak Index in a Mountain Array", "difficulty": "Medium", "category": "binary-search", "link": "https://leetcode.com/problems/peak-index-in-a-mountain-array/", "examples": [{"input": "arr = [0,1,0]", "output": "1", "explanation": "Peak at index 1."}, {"input": "arr = [0,2,1,0]", "output": "1", "explanation": "Maximum at index 1."}, {"input": "arr = [0,10,5,2]", "output": "1", "explanation": "Summit at index 1."}], "hints": ["The slope tells the side: when arr[mid] < arr[mid+1] the peak lies to the right, otherwise to the left.", "Binary-search that slope test for O(log n); a linear max scan also works but is slower.", "Keep the loop invariant lo < hi and return lo when they meet."], "statement": "Locate the summit of a mountain array.\n\nAn array `arr` is a mountain when its length is at least three and there is a single peak index `p` such that values rise strictly from the start to `p` and then fall strictly after `p`. Given such an array, return the peak index.\n\n**Constraints:**\n- `3 <= arr.length <= 10^4`\n- `0 <= arr[i] <= 10^6`\n- `arr` is guaranteed to be a mountain array.\n", "solution": "## Approach\n\nCompare each middle index with its right neighbour: an upward slope means the summit is further right, a downward slope means it is at or left of centre. Halving the interval on this test homes in on the unique peak.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log n), where n is the array length.\n- **Space Complexity:** O(1) extra.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def peakIndexInMountainArray(self, arr: List[int]) -> int:\n lo, hi = 0, len(arr) - 1\n while lo < hi:\n mid = (lo + hi) // 2\n if arr[mid] < arr[mid + 1]:\n lo = mid + 1\n else:\n hi = mid\n return lo\n```\n", "starter": {"go": "package main\n\nfunc PeakIndexInMountainArray(arr []int) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def peakIndexInMountainArray(self, arr: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int peakIndexInMountainArray(vector<int>& arr) {\n return 0;\n }\n};"}, "fn": "peakIndexInMountainArray", "params": [{"name": "arr", "type": "int_array"}], "outputType": "int", "tests": [["[0,1,0]"], ["[0,2,1,0]"], ["[0,10,5,2]"], ["[3,4,5,1]"], ["[1,3,5,4,2]"], ["[0,1,2,3,2,1,0]"], ["[1,2,3,4,5,4,3,2,1]"], ["[10,20,30,20,10]"], ["[0,5,4,3,2,1]"], ["[1,5,4]"], ["[2,5,3]"], ["[0,2,4,3,1]"], ["[1,2,10,9,8,7]"], ["[3,5,3,2,0]"], ["[24,69,100,99,79,78,67,36,26,19]"], ["[1,2,3,5,4]"], ["[5,10,3]"], ["[0,3,2]"], ["[1,4,3,2,1,0]"], ["[0,1,3,5,4,2]"], ["[2,3,4,5,1]"], ["[1,2,3,4,3]"], ["[40,50,60,30,20,10]"], ["[0,10,20,15,10,5]"], ["[1,3,2]"], ["[0,1,2,1]"], ["[18,29,38,59,98,100,99,90,80,70]"], ["[3,9,8,6,4]"]], "expected": [1, 1, 1, 2, 2, 3, 4, 2, 1, 1, 1, 2, 2, 1, 2, 3, 1, 1, 1, 3, 3, 3, 2, 2, 1, 2, 5, 1], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "382", "slug": "peeking-iterator", "id": 382, "title": "Peeking Iterator", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/peeking-iterator/", "examples": [{"input": "nums = [1,2,3], operations = [\"next\",\"peek\",\"next\",\"next\",\"hasNext\"]", "output": "[1,2,2,3,0]", "explanation": "next gives 1, peek previews 2, next gives 2, next gives 3, then nothing remains (0)."}, {"input": "nums = [1], operations = [\"hasNext\",\"next\",\"hasNext\"]", "output": "[1,1,0]", "explanation": "One value present (1), next returns it, then empty (0)."}, {"input": "nums = [1,2], operations = [\"peek\",\"peek\",\"next\",\"hasNext\"]", "output": "[1,1,1,1]", "explanation": "Repeated peeks return 1 without advancing; next returns 1; one value remains."}], "hints": ["Adaptation: instead of a PeekingIterator class, implement runPeek(nums, operations) simulating the calls.", "Keep an index: next returns nums[i++], peek returns nums[i], hasNext returns 1/0.", "Cache nothing extra; peek never advances."], "statement": "Simulate an iterator with lookahead over an integer array.\n\n**Adaptation:** the original design asks for a `PeekingIterator` class with\n`next`, `peek`, and `hasNext`; here implement `runPeek(nums, operations)`\nwhere `operations` lists the calls to run in order. Return one integer per\noperation: the value for `next`/`peek`, and `1`/`0` for `hasNext`\ntrue/false. Calls are guaranteed valid (peek/next only when data remains).\n\n**Constraints:**\n- `1 <= nums.length <= 1000`\n- At most `1000` operations.\n", "solution": "## Approach\n\nKeep an index into nums. For each requested operation emit nums[idx] for peek, nums[idx++] for next, or 1/0 for hasNext depending on whether the index is still inside the array.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(q) for q operations.\n- **Space Complexity:** O(q) for the output.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def runPeek(self, nums: List[int], operations: List[str]) -> List[int]:\n out, idx = [], 0\n for op in operations:\n if op == \"next\":\n out.append(nums[idx]); idx += 1\n elif op == \"peek\":\n out.append(nums[idx])\n elif op == \"hasNext\":\n out.append(1 if idx < len(nums) else 0)\n return out\n```\n", "starter": {"go": "package main\n\nfunc RunPeek(nums []int, operations []string) []int {\n return []int{}\n}", "python": "from typing import List\nclass Solution:\n def runPeek(self, nums: List[int], operations: List[str]) -> List[int]:\n return []", "cpp": "#include <string>\n#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<int> runPeek(vector<int>& nums, vector<string>& operations) {\n return {};\n }\n};"}, "fn": "runPeek", "params": [{"name": "nums", "type": "int_array"}, {"name": "operations", "type": "string_array"}], "outputType": "int_array", "tests": [["[1,2,3]", "[\"next\",\"peek\",\"next\",\"next\",\"hasNext\"]"], ["[1]", "[\"hasNext\",\"next\",\"hasNext\"]"], ["[1,2]", "[\"peek\",\"peek\",\"next\",\"hasNext\"]"], ["[5,6,7,8]", "[\"next\",\"hasNext\",\"peek\",\"next\",\"hasNext\",\"next\",\"hasNext\"]"], ["[1,2]", "[\"next\",\"next\",\"hasNext\"]"], ["[1,2,3,4]", "[\"peek\",\"next\",\"peek\",\"next\",\"peek\",\"next\",\"hasNext\"]"], ["[10]", "[\"peek\",\"hasNext\",\"next\",\"hasNext\"]"], ["[1,2,3]", "[\"hasNext\",\"hasNext\",\"next\",\"hasNext\"]"], ["[4,5]", "[\"next\",\"hasNext\",\"hasNext\"]"], ["[1,2,3,4,5]", "[\"next\",\"next\",\"peek\",\"hasNext\",\"next\",\"hasNext\"]"], ["[7]", "[\"hasNext\"]"], ["[7]", "[\"peek\"]"], ["[7]", "[\"next\"]"], ["[1,2]", "[\"peek\",\"next\",\"peek\",\"next\",\"hasNext\"]"], ["[3,1,2]", "[\"next\",\"peek\",\"hasNext\",\"next\",\"hasNext\"]"], ["[2,4,6]", "[\"peek\",\"next\",\"hasNext\",\"next\",\"hasNext\",\"next\",\"hasNext\"]"], ["[9,8,7]", "[\"hasNext\",\"peek\",\"peek\",\"next\",\"next\",\"peek\",\"next\",\"hasNext\"]"], ["[1,2,3,4,5,6]", "[\"next\",\"next\",\"next\",\"hasNext\",\"peek\",\"next\",\"hasNext\"]"], ["[5]", "[\"hasNext\",\"peek\",\"next\",\"hasNext\",\"hasNext\"]"], ["[1,1,1]", "[\"peek\",\"next\",\"peek\",\"next\",\"peek\",\"next\",\"hasNext\"]"], ["[10,20]", "[\"next\",\"peek\",\"hasNext\",\"next\",\"hasNext\"]"], ["[3,3,3,3]", "[\"hasNext\",\"next\",\"hasNext\",\"next\",\"hasNext\",\"next\",\"peek\",\"next\",\"hasNext\"]"], ["[100,200,300]", "[\"next\",\"hasNext\",\"hasNext\",\"next\",\"next\",\"hasNext\"]"], ["[1,2,3]", "[\"peek\",\"hasNext\",\"next\",\"hasNext\",\"peek\",\"next\",\"peek\",\"next\",\"hasNext\"]"], ["[8,9]", "[\"hasNext\",\"hasNext\",\"hasNext\",\"next\",\"peek\",\"next\",\"hasNext\"]"], ["[4]", "[\"peek\",\"peek\",\"peek\",\"next\",\"hasNext\"]"], ["[6,7,8,9,10]", "[\"peek\",\"next\",\"peek\",\"next\",\"peek\",\"next\",\"peek\",\"next\",\"peek\",\"next\",\"hasNext\"]"], ["[11,22]", "[\"next\",\"next\",\"hasNext\",\"hasNext\"]"], ["[0,1]", "[\"peek\",\"next\",\"hasNext\",\"next\",\"hasNext\"]"]], "expected": [[1, 2, 2, 3, 0], [1, 1, 0], [1, 1, 1, 1], [5, 1, 6, 6, 1, 7, 1], [1, 2, 0], [1, 1, 2, 2, 3, 3, 1], [10, 1, 10, 0], [1, 1, 1, 1], [4, 1, 1], [1, 2, 3, 1, 3, 1], [1], [7], [7], [1, 1, 2, 2, 0], [3, 1, 1, 1, 1], [2, 2, 1, 4, 1, 6, 0], [1, 9, 9, 9, 8, 7, 7, 0], [1, 2, 3, 1, 4, 4, 1], [1, 5, 5, 0, 0], [1, 1, 1, 1, 1, 1, 0], [10, 20, 1, 20, 0], [1, 3, 1, 3, 1, 3, 3, 3, 0], [100, 1, 1, 200, 300, 0], [1, 1, 1, 1, 2, 2, 3, 3, 0], [1, 1, 1, 8, 9, 9, 0], [4, 4, 4, 4, 0], [6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 0], [11, 22, 0, 0], [0, 0, 1, 1, 0]], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "569", "slug": "perfect-number", "id": 569, "title": "Perfect Number", "difficulty": "Easy", "category": "math", "link": "https://leetcode.com/problems/perfect-number/", "examples": [{"input": "num = 28", "output": "true", "explanation": "Its proper divisors 1, 2, 4, 7 and 14 add up to 28."}, {"input": "num = 8", "output": "false", "explanation": "The proper divisors 1, 2 and 4 sum to 7, not 8."}, {"input": "num = 1", "output": "false", "explanation": "1 has no proper divisors, so the empty sum 0 differs from 1."}], "hints": ["Only trial divisors up to the square root are needed; each divisor d pairs with num / d.", "Start the total at 1 for num > 1 and take care not to double-count a square root."], "statement": "A positive whole number is called perfect when it equals the sum of all its proper divisors, meaning every divisor except the number itself. For instance, 6 qualifies because 1 + 2 + 3 = 6, while 8 does not because 1 + 2 + 4 = 7.\n\nGiven `num`, decide whether it is perfect.\n\n**Constraints:**\n- `1 <= num <= 10^8`\n", "solution": "## Approach\n\nScan possible divisors only up to the square root of `num`. Whenever `d` divides `num`, add both `d` and its partner `num / d` to a running total (adding the square root just once). Starting from 1 covers the universal divisor for `num > 1`. The number is perfect exactly when the accumulated total equals `num`.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(sqrt(num)) trial divisions.\n- **Space Complexity:** O(1) extra memory.\n\n## Implementation\n\n```python\nclass Solution:\n def checkPerfectNumber(self, num: int) -> bool:\n if num <= 1:\n return False\n total = 1\n d = 2\n while d * d <= num:\n if num % d == 0:\n total += d\n other = num // d\n if other != d:\n total += other\n if total > num:\n return False\n d += 1\n return total == num\n```\n", "starter": {"go": "package main\n\nfunc CheckPerfectNumber(num int) bool {\n \n}", "python": "class Solution:\n def checkPerfectNumber(self, num: int) -> bool:\n pass", "cpp": "class Solution {\npublic:\n bool checkPerfectNumber(int num) {\n return false;\n }\n};"}, "fn": "checkPerfectNumber", "params": [{"name": "num", "type": "int"}], "outputType": "boolean", "tests": [["28"], ["8"], ["1"], ["6"], ["496"], ["8128"], ["33550336"], ["2"], ["3"], ["4"], ["5"], ["7"], ["12"], ["27"], ["100"], ["1000"], ["99999999"], ["100000000"], ["33550335"], ["33550337"], ["8127"], ["8129"], ["495"], ["497"], ["29"], ["16"], ["36"], ["49"]], "expected": [true, false, false, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "467", "slug": "perfect-rectangle", "id": 467, "title": "Perfect Rectangle", "difficulty": "Hard", "category": "array", "link": "https://leetcode.com/problems/perfect-rectangle/", "examples": [{"explanation": "The five small blocks tile the square from (1,1) to (4,4) without overlap.", "input": "rectangles = [[1,1,3,3],[3,1,4,2],[3,2,4,4],[1,3,2,4],[2,3,3,4]]", "output": "true"}, {"explanation": "A hole sits where [2,1,3,4] would go, so the union is not solid.", "input": "rectangles = [[1,1,2,3],[1,3,2,4],[3,1,4,2],[3,2,4,4]]", "output": "false"}, {"explanation": "The last two blocks overlap on [2,2,3,3].", "input": "rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]]", "output": "false"}], "hints": ["Add up all small areas and compare with the area of the min/max bounding box.", "Toggle each block corner in a set; interior corners appear an even number of times and cancel.", "At the end exactly the four extreme corners must remain."], "statement": "Each entry of `rectangles` describes one axis-aligned block by its lower-left corner `(xi, yi)` and its upper-right corner `(ai, bi)`, with `xi < ai` and `yi < bi`. Decide whether the blocks fit together perfectly: jointly they must fill some larger rectangle exactly, with no overlaps and no gaps.\n\nThat means two things must hold at once: the total covered area must equal the area of the bounding box, and the block corners must cancel out everywhere except at the four extreme corners.\n\n**Constraints:**\n- `1 <= rectangles.length <= 2 * 10^4`\n- `rectangles[i].length == 4`\n- `-10^5 <= xi < ai <= 10^5`\n- `-10^5 <= yi < bi <= 10^5`\n", "solution": "## Approach\n\nSum the areas of all small blocks and track the extreme coordinates of their union. Insert each block corner into a set, removing it when seen again, so shared interior corners cancel and only unmatched corners survive. A perfect tiling leaves exactly the four bounding-box corners and has total area equal to the bounding-box area; any gap, overlap, or stray corner breaks one of those checks.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m), where m is the number of rectangles.\n- **Space Complexity:** O(m) for the corner set.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def isRectangleCover(self, rectangles: List[List[int]]) -> bool:\n area = 0\n min_x = min_y = 10 ** 9\n max_x = max_y = -10 ** 9\n corners = set()\n for x1, y1, x2, y2 in rectangles:\n area += (x2 - x1) * (y2 - y1)\n min_x = min(min_x, x1); min_y = min(min_y, y1)\n max_x = max(max_x, x2); max_y = max(max_y, y2)\n for p in ((x1, y1), (x1, y2), (x2, y1), (x2, y2)):\n if p in corners:\n corners.remove(p)\n else:\n corners.add(p)\n if len(corners) != 4:\n return False\n if {(min_x, min_y), (min_x, max_y), (max_x, min_y), (max_x, max_y)} != corners:\n return False\n return area == (max_x - min_x) * (max_y - min_y)\n```\n", "starter": {"go": "package main\n\nfunc IsRectangleCover(rectangles [][]int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def isRectangleCover(self, rectangles: List[List[int]]) -> bool:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool isRectangleCover(vector<vector<int>>& rectangles) {\n return false;\n }\n};"}, "fn": "isRectangleCover", "params": [{"name": "rectangles", "type": "int_array_2d"}], "outputType": "boolean", "tests": [["[[1,1,3,3],[3,1,4,2],[3,2,4,4],[1,3,2,4],[2,3,3,4]]"], ["[[1,1,2,3],[1,3,2,4],[3,1,4,2],[3,2,4,4]]"], ["[[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]]"], ["[[0,0,1,1]]"], ["[[0,0,1,1],[1,0,2,1]]"], ["[[0,0,1,1],[0,1,1,2]]"], ["[[0,0,2,2],[1,1,3,3]]"], ["[[0,0,1,1],[1,1,2,2]]"], ["[[0,0,3,1],[0,1,3,2],[0,2,3,3]]"], ["[[-1,-1,0,0],[0,-1,1,0],[-1,0,0,1],[0,0,1,1]]"], ["[[0,0,1,1],[0,0,1,1]]"], ["[[0,0,4,4],[1,1,2,2]]"], ["[[0,0,2,1],[2,0,4,1],[0,1,4,2]]"], ["[[0,0,1,2],[1,0,2,2],[0,2,2,3]]"], ["[[0,0,5,5],[1,1,4,4],[1,1,2,2]]"], ["[[-100000,-100000,100000,100000]]"], ["[[0,0,2,2],[2,0,4,2],[0,2,2,4],[2,2,4,4]]"], ["[[0,0,2,2],[1,0,3,2],[0,2,3,4]]"], ["[[1,1,2,2],[2,1,3,2],[3,1,4,2],[1,2,4,4]]"], ["[[0,0,1,1],[2,2,3,3]]"], ["[[0,0,10,1],[0,1,1,10],[1,1,10,10]]"], ["[[0,0,1,1],[1,0,2,1],[0,1,1,2],[1,1,2,2]]"], ["[[0,0,3,3],[1,1,2,2]]"], ["[[0,0,2,2],[0,2,2,3],[2,0,3,3]]"], ["[[-2,-2,2,2],[-1,-1,1,1]]"], ["[[0,0,1,3],[1,0,2,1],[1,1,2,3]]"], ["[[0,0,2,1],[0,1,1,2],[1,1,2,2]]"], ["[[5,5,8,8],[5,8,8,10],[8,5,10,10]]"], ["[[0,0,1,1],[0,1,2,2],[1,0,2,1]]"], ["[[0,0,4,1],[0,1,4,2],[0,2,4,3],[0,3,4,4]]"]], "expected": [true, false, false, true, true, true, false, false, true, true, false, false, true, true, false, true, true, false, true, false, true, true, false, true, false, true, true, true, true, true], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "228", "slug": "perfect-squares", "id": 228, "title": "Perfect Squares", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/perfect-squares/", "examples": [{"input": "n = 12", "output": "3", "explanation": "12 = 4 + 4 + 4."}, {"input": "n = 13", "output": "2", "explanation": "13 = 4 + 9."}], "hints": ["Use dynamic programming. dp[i] = minimum number of perfect squares that sum to i.", "dp[0] = 0. For each i, try all perfect squares j*j <= i and update dp[i] = min(dp[i], dp[i - j*j] + 1)."], "statement": "You receive an integer `n`. Split it into a sum of perfect-square addends using as few addends as possible, and report that smallest achievable count.\n\nA perfect square is what you get when a whole number is multiplied by itself \u2014 the square of an integer. That makes `1`, `4`, `9`, and `16` perfect squares, whereas `3` and `11` fall outside that family.\n\n**Constraints:**\n- 1 \u2264 n \u2264 10<sup>4</sup>\n", "solution": "## Approach\n\nUse 1D dynamic programming. Let `dp[i]` be the minimum number of perfect squares that sum to `i`. Base case: `dp[0] = 0`. For each `i` from 1 to `n`, try every perfect square `j*j <= i` and update `dp[i] = min(dp[i], dp[i - j*j] + 1)`.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n * sqrt(n)), as for each of the n values we try up to sqrt(n) perfect squares.\n- **Space Complexity:** O(n) for the dp array.\n\n## Implementation\n\n```python\nclass Solution:\n def numSquares(self, n: int) -> int:\n dp = [n + 1] * (n + 1)\n dp[0] = 0\n for i in range(1, n + 1):\n j = 1\n while j * j <= i:\n dp[i] = min(dp[i], dp[i - j * j] + 1)\n j += 1\n return dp[n]\n```\n", "starter": {"go": "package main\n\nfunc NumSquares(n int) int {\n \n}", "python": "class Solution:\n def numSquares(self, n: int) -> int:\n ", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int numSquares(int n) {\n \n }\n};"}, "fn": "numSquares", "params": [{"name": "n", "type": "int"}], "outputType": "int", "tests": [["12"], ["13"], ["1"], ["2"], ["3"], ["4"], ["7"], ["9"], ["10"], ["16"], ["100"], ["1000"], ["9999"], ["10000"], ["43"], ["5"], ["6"], ["8"], ["11"], ["14"], ["15"], ["17"], ["18"], ["19"], ["20"], ["24"], ["25"], ["26"], ["27"], ["28"]], "expected": [3, 2, 1, 2, 3, 1, 4, 1, 2, 1, 1, 2, 4, 1, 3, 2, 3, 2, 3, 3, 4, 2, 2, 3, 2, 3, 1, 2, 3, 4], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "85", "slug": "permutation-in-string", "id": 85, "title": "Permutation in String", "difficulty": "Medium", "category": "sliding-window", "link": "https://leetcode.com/problems/permutation-in-string/", "examples": [{"input": "s1 = \"ab\", s2 = \"eidbaooo\"", "output": "true", "explanation": "The substring \"ba\" is a permutation of \"ab\"."}, {"input": "s1 = \"ab\", s2 = \"eidboaoo\"", "output": "false", "explanation": "No permutation of \"ab\" appears as a contiguous substring in \"eidboaoo\"."}, {"input": "s1 = \"adc\", s2 = \"dcda\"", "output": "true", "explanation": "The substring \"cda\" is a permutation of \"adc\"."}], "hints": ["A permutation is determined by character frequencies, not character order.", "Maintain a window in s2 whose length is exactly s1.length.", "Update only the counts for the character entering and leaving the window."], "statement": "Given two nonempty lowercase strings `s1` and `s2`, return `true` if `s2` contains a contiguous substring that is a permutation of `s1`. Otherwise, return `false`.\n\nA permutation uses every character of `s1` exactly once, including duplicate characters.\n\n**Constraints:**\n\n- `1 <= s1.length, s2.length <= 10^4`\n- `s1` and `s2` contain only lowercase English letters.\n\n**Portable interface:** Implement `checkInclusion(s1, s2)` directly. The judge supplies both strings and expects a boolean result; no input parsing is required.\n", "solution": "## Approach\n\nCount how many of each lowercase letter `s1` requires, then scan `s2` with a fixed-size sliding window. When a character enters or leaves the window, update its deficit and the number of required characters still missing. A window is a permutation exactly when its length is `s1.length` and no required characters remain.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m + n), where `m` is the length of `s1` and `n` is the length of `s2`.\n- **Space Complexity:** O(1), because the frequency array always has 26 entries.\n\n## Implementation\n\n```python\nclass Solution:\n def checkInclusion(self, s1: str, s2: str) -> bool:\n if len(s1) > len(s2):\n return False\n\n needed = [0] * 26\n for char in s1:\n needed[ord(char) - ord(\"a\")] += 1\n\n remaining = len(s1)\n for right, char in enumerate(s2):\n entering = ord(char) - ord(\"a\")\n if needed[entering] > 0:\n remaining -= 1\n needed[entering] -= 1\n\n if right >= len(s1):\n leaving = ord(s2[right - len(s1)]) - ord(\"a\")\n needed[leaving] += 1\n if needed[leaving] > 0:\n remaining += 1\n\n if right + 1 >= len(s1) and remaining == 0:\n return True\n return False\n```\n", "starter": {"go": "package main\n\nfunc CheckInclusion(s1 string, s2 string) bool {\n return false\n}", "python": "class Solution:\n def checkInclusion(self, s1: str, s2: str) -> bool:\n return False\n", "cpp": "#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n bool checkInclusion(string s1, string s2) {\n return false;\n }\n};"}, "fn": "checkInclusion", "params": [{"name": "s1", "type": "string"}, {"name": "s2", "type": "string"}], "outputType": "boolean", "tests": [["ab", "eidbaooo"], ["ab", "eidboaoo"], ["adc", "dcda"], ["a", "a"], ["a", "bbbb"], ["z", "zzzzz"], ["abc", "bbbca"], ["abc", "defgh"], ["abc", "ccccbbbbaaaa"], ["abc", "ccccbbbbaaaacba"], ["aa", "baa"], ["aa", "abab"], ["aab", "eidbaaoo"], ["aab", "aaab"], ["aab", "aba"], ["abcd", "dcba"], ["abcd", "abc"], ["abcd", "zzabdczz"], ["hello", "ooolleoooleh"], ["xyz", "afdgzyxksldfm"], ["xyz", "xy"], ["zz", "zz"], ["zz", "azbz"], ["aaa", "aaaaa"], ["aaa", "aa"], ["abb", "baba"], ["abb", "abca"], ["abcdxabcde", "abcdeabcdx"], ["abcdxabcde", "abcdeabcd"], ["qwerty", "ytrewq"], ["qwerty", "qwertx"], ["mnop", "aaaaponmaaa"], ["mnop", "mmnnoopp"], ["abcdefghijklmnopqrstuvwxyz", "zyxwvutsrqponmlkjihgfedcba"], ["abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxy"], ["abcabc", "cbacba"], ["abcabc", "abcabxabc"], ["abab", "baba"], ["abab", "abba"], ["abab", "aaaaabbbbb"], ["aabbcc", "ccbbaa"], ["aabbcc", "abcabc"], ["aabbcc", "aaabbbccc"], ["leetcode", "edocteel"], ["leetcode", "leetcodx"], ["silent", "listen"], ["silent", "enlistxx"], ["aaaaab", "baaaaa"], ["aaaaab", "aaaaaaaaab"], ["abcde", "edcbaedcba"], ["@javascript:'a'.repeat(10000)", "@javascript:'a'.repeat(10000)"], ["@javascript:'a'.repeat(9998) + 'b'", "@javascript:'z' + 'a'.repeat(9998) + 'b'"]], "expected": [true, false, true, true, false, true, true, false, false, true, true, false, true, true, true, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, true, true, true, true, false, true, false, true, true, true, true, true, true, true], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "268", "slug": "permutation-sequence", "id": 268, "title": "Permutation Sequence", "difficulty": "Hard", "category": "math", "link": "https://leetcode.com/problems/permutation-sequence/", "examples": [{"input": "n = 3, k = 3", "output": "\"213\"", "explanation": "The orderings are 123, 132, 213, 231, 312, 321; the 3rd is 213."}, {"input": "n = 4, k = 9", "output": "\"2314\"", "explanation": "Among the 24 orderings of 1..4, the 9th in sorted order is 2314."}, {"input": "n = 3, k = 1", "output": "\"123\"", "explanation": "The first ordering is the digits in increasing order."}], "hints": ["There are (n-1)! orderings starting with each choice for the first digit, so divide (k-1) by (n-1)! to pick it.", "Convert k to 0-based, then repeatedly select index k / fact and update k = k % fact with shrinking factorials.", "Keep the remaining digits in a list and remove the chosen digit at each step."], "statement": "Consider the digits `1` through `n` arranged in increasing order. All `n!` orderings of these digits can be listed from smallest to largest in dictionary order. Given `n` and a 1-based position `k`, return the ordering that appears at that position.\n\nFor example, with `n = 3` the ordered list is `123`, `132`, `213`, `231`, `312`, `321`, so asking for `k = 3` yields `213`.\n\nDo not generate every ordering; instead decide the result one place at a time by counting how many orderings start with each remaining digit.\n\n**Constraints:**\n- `1 <= n <= 9`\n- `1 <= k <= n!`\n", "solution": "## Approach\n\nThere are (n-1)! orderings for each choice of leading digit, so the first digit is determined by dividing the 0-based rank by (n-1)!. Remove that digit, then repeat with the remainder and the next smaller factorial until all positions are fixed.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^2) due to list removals, with n at most 9.\n- **Space Complexity:** O(n) for the remaining digits and factorials.\n\n## Implementation\n\n```python\nclass Solution:\n def getPermutation(self, n: int, k: int) -> str:\n digits = list(range(1, n + 1))\n fact = [1] * (n + 1)\n for i in range(1, n + 1):\n fact[i] = fact[i - 1] * i\n k -= 1\n res = []\n for i in range(n, 0, -1):\n idx = k // fact[i - 1]\n k %= fact[i - 1]\n res.append(str(digits.pop(idx)))\n return \"\".join(res)\n```\n", "starter": {"go": "package main\n\nfunc GetPermutation(n int, k int) string {\n return \"\"\n}", "python": "class Solution:\n def getPermutation(self, n: int, k: int) -> str:\n return \"\"\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n string getPermutation(int n, int k) {\n return \"\";\n }\n};"}, "fn": "getPermutation", "params": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "outputType": "string", "tests": [["3", "3"], ["4", "9"], ["3", "1"], ["1", "1"], ["2", "1"], ["2", "2"], ["3", "2"], ["3", "4"], ["3", "5"], ["3", "6"], ["4", "1"], ["4", "24"], ["4", "12"], ["4", "13"], ["5", "1"], ["5", "120"], ["5", "60"], ["5", "61"], ["5", "38"], ["6", "1"], ["6", "720"], ["6", "360"], ["7", "1"], ["7", "5040"], ["7", "2500"], ["8", "1"], ["8", "40320"], ["8", "20000"], ["9", "1"], ["9", "362880"], ["9", "100000"], ["9", "362879"]], "expected": ["213", "2314", "123", "1", "12", "21", "132", "231", "312", "321", "1234", "4321", "2431", "3124", "12345", "54321", "32541", "34125", "24153", "123456", "654321", "365421", "1234567", "7654321", "4371562", "12345678", "87654321", "48652173", "123456789", "987654321", "358926471", "987654312"], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "209", "slug": "permutations-ii", "id": 209, "title": "Permutations II", "difficulty": "Medium", "category": "backtracking", "link": "https://leetcode.com/problems/permutations-ii/", "examples": [{"input": "nums = [1,1,2]", "output": "[[1,1,2],[1,2,1],[2,1,1]]", "explanation": "The three output arrays do not include duplicate permutations: [1,1,2] appears only once."}, {"input": "nums = [1,2,3]", "output": "[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]", "explanation": "There are six ways to order three distinct values."}], "hints": ["Sort `nums` so equal values are adjacent.", "Build the permutation one position at a time, and skip placing `nums[i]` when it equals a value already placed at that same depth in a previous branch."], "statement": "You are handed an array `nums` whose entries may repeat. List every distinct ordering of its elements, each ordering exactly once, and return the collection in whatever sequence you prefer.\n\n**Constraints:**\n\n- `1 <= nums.length <= 8`\n- `-10 <= nums[i] <= 10`\n", "solution": "## Approach\n\nSort the array first so that equal values are adjacent. Perform standard permutation backtracking, but skip a value at a given recursion depth when it equals the previous value and that previous value has not been used yet in the current branch. This rule ensures that duplicate elements are not placed at the same position across branches, so each unique permutation is produced exactly once.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n * P) where P is the number of unique permutations of length n; each permutation is copied at a cost of O(n).\n- **Space Complexity:** O(n) for the recursion stack and helper data, excluding the O(n * P) output.\n\n## Implementation\n\n```python\nfrom typing import List\n\n\nclass Solution:\n def permuteUnique(self, nums: List[int]) -> List[List[int]]:\n nums.sort()\n n = len(nums)\n result: List[List[int]] = []\n used = [False] * n\n current: List[int] = []\n\n def backtrack() -> None:\n if len(current) == n:\n result.append(current.copy())\n return\n for i in range(n):\n if used[i]:\n continue\n if i > 0 and nums[i] == nums[i - 1] and not used[i - 1]:\n continue\n used[i] = True\n current.append(nums[i])\n backtrack()\n current.pop()\n used[i] = False\n\n backtrack()\n return result\n```", "starter": {"go": "package main\n\nfunc PermuteUnique(nums []int) [][]int {\n \n}", "python": "from typing import List\nclass Solution:\n def permuteUnique(self, nums: List[int]) -> List[List[int]]:\n ", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<vector<int>> permuteUnique(vector<int>& nums) {\n \n }\n};"}, "fn": "permuteUnique", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int_list_2d", "tests": [["[1]"], ["[1,1,2]"], ["[1,2,3]"], ["[2,2,2]"], ["[1,2]"], ["[-1,-1]"], ["[1,1,1,1]"], ["[1,1,2,2]"], ["[-10,-5,0,5]"], ["[3,3,0,3]"], ["[1,2,2,3]"], ["[10,9,8,7]"], ["[0]"], ["[1,1]"], ["[1,2,2]"], ["[2,1,1]"], ["[1,1,1]"], ["[0,0,1]"], ["[1,1,2,3]"], ["[0,0,0]"], ["[5,5]"], ["[-10,10]"], ["[0,1,1]"], ["[2,2,3,3]"], ["[1,1,1,2]"], ["[0,0,0,1]"], ["[-1,0,1]"], ["[3,2,1,1]"], ["[10,10,10]"], ["[-5,-5,5]"]], "expected": [[[1]], [[1, 1, 2], [1, 2, 1], [2, 1, 1]], [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]], [[2, 2, 2]], [[1, 2], [2, 1]], [[-1, -1]], [[1, 1, 1, 1]], [[1, 1, 2, 2], [1, 2, 1, 2], [1, 2, 2, 1], [2, 1, 1, 2], [2, 1, 2, 1], [2, 2, 1, 1]], [[-10, -5, 0, 5], [-10, -5, 5, 0], [-10, 0, -5, 5], [-10, 0, 5, -5], [-10, 5, -5, 0], [-10, 5, 0, -5], [-5, -10, 0, 5], [-5, -10, 5, 0], [-5, 0, -10, 5], [-5, 0, 5, -10], [-5, 5, -10, 0], [-5, 5, 0, -10], [0, -10, -5, 5], [0, -10, 5, -5], [0, -5, -10, 5], [0, -5, 5, -10], [0, 5, -10, -5], [0, 5, -5, -10], [5, -10, -5, 0], [5, -10, 0, -5], [5, -5, -10, 0], [5, -5, 0, -10], [5, 0, -10, -5], [5, 0, -5, -10]], [[0, 3, 3, 3], [3, 0, 3, 3], [3, 3, 0, 3], [3, 3, 3, 0]], [[1, 2, 2, 3], [1, 2, 3, 2], [1, 3, 2, 2], [2, 1, 2, 3], [2, 1, 3, 2], [2, 2, 1, 3], [2, 2, 3, 1], [2, 3, 1, 2], [2, 3, 2, 1], [3, 1, 2, 2], [3, 2, 1, 2], [3, 2, 2, 1]], [[7, 8, 9, 10], [7, 8, 10, 9], [7, 9, 8, 10], [7, 9, 10, 8], [7, 10, 8, 9], [7, 10, 9, 8], [8, 7, 9, 10], [8, 7, 10, 9], [8, 9, 7, 10], [8, 9, 10, 7], [8, 10, 7, 9], [8, 10, 9, 7], [9, 7, 8, 10], [9, 7, 10, 8], [9, 8, 7, 10], [9, 8, 10, 7], [9, 10, 7, 8], [9, 10, 8, 7], [10, 7, 8, 9], [10, 7, 9, 8], [10, 8, 7, 9], [10, 8, 9, 7], [10, 9, 7, 8], [10, 9, 8, 7]], [[0]], [[1, 1]], [[1, 2, 2], [2, 1, 2], [2, 2, 1]], [[1, 1, 2], [1, 2, 1], [2, 1, 1]], [[1, 1, 1]], [[0, 0, 1], [0, 1, 0], [1, 0, 0]], [[1, 1, 2, 3], [1, 1, 3, 2], [1, 2, 1, 3], [1, 2, 3, 1], [1, 3, 1, 2], [1, 3, 2, 1], [2, 1, 1, 3], [2, 1, 3, 1], [2, 3, 1, 1], [3, 1, 1, 2], [3, 1, 2, 1], [3, 2, 1, 1]], [[0, 0, 0]], [[5, 5]], [[-10, 10], [10, -10]], [[0, 1, 1], [1, 0, 1], [1, 1, 0]], [[2, 2, 3, 3], [2, 3, 2, 3], [2, 3, 3, 2], [3, 2, 2, 3], [3, 2, 3, 2], [3, 3, 2, 2]], [[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]], [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]], [[-1, 0, 1], [-1, 1, 0], [0, -1, 1], [0, 1, -1], [1, -1, 0], [1, 0, -1]], [[1, 1, 2, 3], [1, 1, 3, 2], [1, 2, 1, 3], [1, 2, 3, 1], [1, 3, 1, 2], [1, 3, 2, 1], [2, 1, 1, 3], [2, 1, 3, 1], [2, 3, 1, 1], [3, 1, 1, 2], [3, 1, 2, 1], [3, 2, 1, 1]], [[10, 10, 10]], [[-5, -5, 5], [-5, 5, -5], [5, -5, -5]]], "loose": true}
|