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": "602", "slug": "boundary-of-binary-tree", "id": 602, "title": "Boundary of Binary Tree", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/boundary-of-binary-tree/", "examples": [{"input": "root = [1,null,2,3,4]", "output": "[1,3,4,2]", "explanation": "Root, leaves, then reversed right edge."}, {"input": "root = [1,2,3,4,5,6,null,null,null,7,8,9,10]", "output": "[1,2,4,7,8,9,10,6,3]", "explanation": "Left edge plus leaves plus right edge."}, {"input": "root = [1]", "output": "[1]", "explanation": "Single node listed once."}], "hints": ["Handle the empty tree and the single-leaf root as special cases first.", "Walk the left edge preferring left children and skipping leaves; mirror this on the right but reverse the collected order.", "Collect leaves with a left-to-right depth-first walk so each leaf appears exactly once."], "statement": "You are given the root of a binary tree. List the values on its outer edge in counter-clockwise order, starting at the root.\n\nThe required order is: the root first (unless the tree is empty), then the left edge from top to bottom excluding any leaves, then all leaves from left to right, then the right edge from bottom to top excluding any leaves. No node appears twice; when the root itself is a leaf it is listed once.\n\nThe left edge follows left children when possible, otherwise right children, down to but not including the leftmost leaf. The right edge mirrors this on the right side.\n\nReturn the collected values as a list.\n\n**Constraints:**\n- `0 <= number of nodes <= 10^4`\n- `-1000 <= Node.val <= 1000`\n", "solution": "## Approach\n\nEmit the root unless the tree is empty or a lone leaf. Then walk the left edge preferring left moves while skipping leaves, gather every leaf left to right with DFS, and walk the right edge preferring right moves, appending that edge in reverse so the whole order runs counter-clockwise without duplicates.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), three linear walks.\n- **Space Complexity:** O(h) recursion depth plus O(n) output.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def boundaryOfBinaryTree(self, root) -> List[int]:\n if not root:\n return []\n if not root.left and not root.right:\n return [root.val]\n res = [root.val]\n cur = root.left\n while cur:\n if cur.left or cur.right:\n res.append(cur.val)\n cur = cur.left if cur.left else cur.right\n def leaves(node):\n if not node:\n return\n if not node.left and not node.right:\n res.append(node.val)\n return\n leaves(node.left)\n leaves(node.right)\n leaves(root)\n tmp = []\n cur = root.right\n while cur:\n if cur.left or cur.right:\n tmp.append(cur.val)\n cur = cur.right if cur.right else cur.left\n res.extend(reversed(tmp))\n return res\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 BoundaryOfBinaryTree(root *TreeNode) []int {\n return nil\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\nfrom typing import List\nclass Solution:\n def boundaryOfBinaryTree(self, root) -> List[int]:\n return []\n", "cpp": "/*\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<int> boundaryOfBinaryTree(TreeNode* root) {\n return {};\n }\n};"}, "fn": "boundaryOfBinaryTree", "params": [{"name": "root", "type": "tree_node"}], "outputType": "int_list", "tests": [["[1,null,2,3,4]"], ["[1,2,3,4,5,6,null,null,null,7,8,9,10]"], ["[1]"], ["[]"], ["[1,2]"], ["[1,null,2]"], ["[1,2,3]"], ["[1,2,null,3,4]"], ["[1,null,2,null,3]"], ["[1,2,3,4,null,null,5]"], ["[2,1,3]"], ["[1,2,3,4,5]"], ["[1,2,3,null,4,5,null]"], ["[5,4,null,3,null,2]"], ["[1,2,null,3,null,4]"], ["[1,null,2,3]"], ["[1,2,3,4,5,6,7]"], ["[3,1,null,1]"], ["[1,2,3,null,null,4,5]"], ["[10,5,15,3,7,null,18]"], ["[1,2,null,3,4]"], ["[1,null,3,2]"], ["[4,2,6,1,3,5,7]"], ["[1,2,3,null,4,null,5]"], ["[0]"], ["[1,2,3,4,null,5,null,6]"], ["[7,6,5,4,3,2,1]"], ["[1,null,2,null,3,null,4]"]], "expected": [[1, 3, 4, 2], [1, 2, 4, 7, 8, 9, 10, 6, 3], [1], [], [1, 2], [1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 3, 2], [1, 2, 4, 5, 3], [2, 1, 3], [1, 2, 4, 5, 3], [1, 2, 4, 5, 3], [5, 4, 3, 2], [1, 2, 3, 4], [1, 3, 2], [1, 2, 4, 5, 6, 7, 3], [3, 1, 1], [1, 2, 4, 5, 3], [10, 5, 3, 7, 18, 15], [1, 2, 3, 4], [1, 2, 3], [4, 2, 1, 3, 5, 7, 6], [1, 2, 4, 5, 3], [0], [1, 2, 4, 6, 5, 3], [7, 6, 4, 3, 2, 1, 5], [1, 4, 3, 2]], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "610", "slug": "brick-wall", "id": 610, "title": "Brick Wall", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/brick-wall/", "examples": [{"input": "wall = [[1,2,2,1],[3,1,2],[1,3,2],[2,4],[3,1,2],[1,3,1,1]]", "output": "2", "explanation": "Best cut follows four boundaries."}, {"input": "wall = [[1],[1],[1]]", "output": "3", "explanation": "No inner edges exist."}, {"input": "wall = [[1,1],[2]]", "output": "1"}], "hints": ["Convert each row into running prefix sums, ignoring the final outer edge.", "The best cut sits at the most frequent prefix offset; crossed bricks equal rows minus that frequency.", "A hash map from offset to row count finds the optimum in linear time."], "statement": "A brick wall has several rows. Row `i` is described by a list of brick widths whose total is the same for every row. You must draw one straight vertical cut from the top of the wall to the bottom, choosing a position that is not on either outer edge.\n\nWhenever the cut passes through the interior of a brick it counts as crossed; passing exactly along a brick boundary avoids crossing that row's brick. Return the smallest possible number of crossed bricks.\n\n**Constraints:**\n- `n == wall.length`\n- `1 <= n <= 10^4`\n- `1 <= wall[i].length <= 10^4`\n- `1 <= sum(wall[i].length) <= 2 * 10^4`\n- Every row sums to the same total width\n- `1 <= wall[i][j] <= 2^31 - 1`\n\nAdaptation note: the original signature uses nested lists; here it is modelled as `int[][] wall` (`int_array_2d`) with identical values.\n", "solution": "## Approach\n\nFor each row accumulate inner edge positions and count how many rows share each offset. Cutting at the most popular offset skips the most bricks, so the answer is rows minus that maximum frequency (zero frequency when no inner edge exists).\n\n## Complexity Analysis\n\n- **Time Complexity:** O(total bricks)\n- **Space Complexity:** O(total edges) for the frequency map.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import Counter\nclass Solution:\n def leastBricks(self, wall: List[List[int]]) -> int:\n freq = Counter()\n for row in wall:\n s = 0\n for w in row[:-1]:\n s += w\n freq[s] += 1\n return len(wall) - max(freq.values(), default=0)\n```\n", "starter": {"go": "package main\n\nfunc LeastBricks(wall [][]int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def leastBricks(self, wall: List[List[int]]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int leastBricks(vector<vector<int>>& wall) {\n return 0;\n }\n};"}, "fn": "leastBricks", "params": [{"name": "wall", "type": "int_array_2d"}], "outputType": "int", "tests": [["[[1,2,2,1],[3,1,2],[1,3,2],[2,4],[3,1,2],[1,3,1,1]]"], ["[[1],[1],[1]]"], ["[[1,1],[2]]"], ["[[2],[2],[2]]"], ["[[1,1,1],[1,1,1]]"], ["[[3,1,2],[1,3,2],[1,1,4]]"], ["[[1,2],[2,1],[1,2]]"], ["[[4],[1,3],[2,2]]"], ["[[1,3,1,1],[3,1,2],[1,3,2]]"], ["[[1,2,3],[3,3],[6]]"], ["[[2,2],[2,2],[2,2]]"], ["[[1,1,1,1],[2,2],[4]]"], ["[[5],[2,3],[1,4]]"], ["[[1,4],[2,3],[3,2]]"], ["[[2,1,1],[1,3],[3,1]]"], ["[[1],[2],[1,1]]"], ["[[3,3],[3,3],[1,5]]"], ["[[1,2,2,1],[1,2,2,1]]"], ["[[2,4],[3,1,2],[1,3,2]]"], ["[[1,1],[1,1],[1,1]]"], ["[[6],[3,3],[2,2,2]]"], ["[[1,5],[5,1],[3,3]]"], ["[[4,2],[2,4],[3,3]]"], ["[[1,2,3,4],[10],[5,5]]"], ["[[2,2,2],[6],[3,3]]"], ["[[1,3],[2,2],[4]]"], ["[[7],[3,4],[1,6]]"], ["[[2,3],[5],[1,1,3]]"]], "expected": [2, 3, 1, 3, 0, 1, 1, 2, 0, 1, 0, 1, 2, 2, 1, 2, 1, 0, 1, 0, 2, 2, 2, 2, 2, 2, 2, 1], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "801", "slug": "bricks-falling-when-hit", "id": 801, "title": "Bricks Falling When Hit", "difficulty": "Hard", "category": "graph", "link": "https://leetcode.com/problems/bricks-falling-when-hit/", "examples": [{"input": "grid = [[1,0,0,0],[1,1,1,0]], hits = [[1,0]]", "output": "[2]", "explanation": "Two bricks lose their top connection."}, {"input": "grid = [[1,0,0,0],[1,1,0,0]], hits = [[1,1],[1,0]]", "output": "[0,0]", "explanation": "No extra bricks fall."}, {"input": "grid = [[1,1,1],[0,1,0],[0,0,0]], hits = [[0,2],[2,0]]", "output": "[0,0]", "explanation": "Empty-cell hit gives zero."}], "hints": ["A brick survives exactly when a four-directional path of bricks reaches the top row.", "Recompute the top-connected count after each removal with a flood fill from the first row.", "Fallen bricks equal the drop in connected count minus one for the erased brick, floored at zero."], "statement": "You are given a wall `grid` of `1`s (bricks) and `0`s (empty). A brick is stable when it sits in the top row or connects to a stable brick through shared sides (up, down, left, right). Each entry of `hits` names a cell whose brick, if present, is removed. After each removal, every brick that is no longer stable drops away.\n\nFor every hit in order, report how many bricks fell as a consequence, not counting the directly removed brick itself. A hit on an empty cell causes zero falls.\n\n**Constraints:**\n- `1 <= grid.length, grid[0].length <= 50` for these tests (original allows up to 200)\n- `1 <= hits.length <= 100`\n- `hits[i]` is a valid cell coordinate\n", "solution": "## Approach\n\nA brick is stable exactly when a four-directional brick path reaches the top row. After copying the wall, each hit is applied and a flood fill from the top row recounts stable bricks; the fall count is the shrinkage of that set minus the erased brick itself, floored at zero.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(h * m * n), one flood fill per hit over an m by n wall.\n- **Space Complexity:** O(m * n) for the copy and the visited marks.\n\n## Implementation\n\n```python\nfrom collections import deque\nfrom typing import List\nclass Solution:\n def hitBricks(self, grid: List[List[int]], hits: List[List[int]]) -> List[int]:\n m, n = len(grid), len(grid[0])\n cur = [row[:] for row in grid]\n def stable() -> int:\n vis = [[False] * n for _ in range(m)]\n q = deque()\n for c in range(n):\n if cur[0][c] == 1 and not vis[0][c]:\n vis[0][c] = True\n q.append((0, c))\n cnt = 0\n while q:\n r, c = q.popleft()\n cnt += 1\n for dr, dc in ((1,0),(-1,0),(0,1),(0,-1)):\n nr, nc = r + dr, c + dc\n if 0 <= nr < m and 0 <= nc < n and cur[nr][nc] == 1 and not vis[nr][nc]:\n vis[nr][nc] = True\n q.append((nr, nc))\n return cnt\n before = stable()\n ans = []\n for x, y in hits:\n if not (0 <= x < m and 0 <= y < n) or cur[x][y] == 0:\n ans.append(0)\n continue\n cur[x][y] = 0\n after = stable()\n ans.append(max(0, before - after - 1))\n before = after\n return ans\n```\n", "starter": {"go": "package main\n\nfunc HitBricks(grid [][]int, hits [][]int) []int {\n return nil\n}", "python": "from typing import List\nclass Solution:\n def hitBricks(self, grid: List[List[int]], hits: List[List[int]]) -> List[int]:\n return []", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<int> hitBricks(vector<vector<int>>& grid, vector<vector<int>>& hits) {\n return {};\n }\n};"}, "fn": "hitBricks", "params": [{"name": "grid", "type": "int_array_2d"}, {"name": "hits", "type": "int_array_2d"}], "outputType": "int_array", "tests": [["[[1, 0, 0, 0], [1, 1, 1, 0]]", "[[1, 0]]"], ["[[1, 0, 0, 0], [1, 1, 0, 0]]", "[[1, 1], [1, 0]]"], ["[[1, 1, 1], [0, 1, 0], [0, 0, 0]]", "[[0, 2], [2, 0]]"], ["[[1]]", "[[0, 0]]"], ["[[0]]", "[[0, 0]]"], ["[[1, 1], [1, 1]]", "[[0, 0]]"], ["[[1, 1], [1, 1]]", "[[0, 0], [1, 1]]"], ["[[1, 0], [0, 1]]", "[[0, 0]]"], ["[[1, 1, 1], [1, 1, 1], [1, 1, 1]]", "[[1, 1]]"], ["[[1, 1, 1], [1, 1, 1], [1, 1, 1]]", "[[0, 0], [0, 1], [0, 2]]"], ["[[1, 0, 1], [1, 1, 1], [0, 0, 1]]", "[[1, 0], [0, 2]]"], ["[[1, 1, 0], [1, 0, 0], [0, 0, 0]]", "[[0, 0], [0, 1]]"], ["[[1, 0, 0], [0, 1, 0], [0, 0, 1]]", "[[0, 0], [1, 1], [2, 2]]"], ["[[1, 1, 1, 1], [1, 1, 1, 1]]", "[[1, 0], [1, 1]]"], ["[[1], [1], [1]]", "[[1, 0]]"], ["[[1], [1], [1]]", "[[2, 0]]"], ["[[0, 1, 1], [1, 1, 1], [1, 1, 1]]", "[[0, 1]]"], ["[[1, 0, 1, 0], [1, 1, 1, 1], [0, 0, 1, 0]]", "[[1, 1], [0, 2]]"], ["[[1, 1], [0, 1], [0, 1]]", "[[1, 1]]"], ["[[1, 1, 1]]", "[[0, 1]]"], ["[[1, 1, 1]]", "[[0, 0], [0, 1], [0, 2]]"], ["[[1, 0], [1, 1], [1, 1]]", "[[2, 0], [1, 0]]"], ["[[0, 0], [0, 0]]", "[[0, 0], [1, 1]]"], ["[[1, 1], [1, 0]]", "[[0, 0], [0, 0]]"], ["[[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1]]", "[[0, 0], [2, 2]]"], ["[[1, 0, 0, 0], [1, 1, 1, 1], [1, 0, 0, 0]]", "[[1, 3], [1, 0]]"], ["[[1, 1], [1, 1], [1, 1]]", "[[2, 1], [1, 1], [0, 1]]"], ["[[0, 1], [1, 1]]", "[[0, 0], [0, 1]]"]], "expected": [[2], [0, 0], [0, 0], [0], [0], [0], [0, 1], [0], [0], [0, 0, 6], [0, 3], [1, 0], [0, 0, 0], [0, 0], [1], [0], [0], [0, 3], [1], [0], [0, 0, 0], [0, 2], [0, 0], [1, 0], [0, 0], [0, 3], [0, 0, 0], [0, 2]], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "974", "slug": "broken-calculator", "id": 974, "title": "Broken Calculator", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/broken-calculator/", "examples": [{"input": "startValue = 2, target = 3", "output": "2", "explanation": "Double to 4, then subtract once."}, {"input": "startValue = 5, target = 8", "output": "2", "explanation": "Subtract to 4, then double to 8."}, {"input": "startValue = 3, target = 10", "output": "3", "explanation": "Double to 6, subtract to 5, double to 10."}], "hints": ["Going forward, doubling overshoots while subtracting crawls; think backwards from target instead.", "Reversed, the moves are halve (when even) and add one: an odd target must first be bumped up to become even.", "Once target drops to startValue or below, the rest is plain subtraction."], "statement": "A calculator starts by showing `startValue`. It has only two buttons: doubling\nthe displayed number, and subtracting one from it. Each button press counts as\none operation.\n\nGiven `startValue` and `target`, return the smallest number of operations that\nreaches exactly `target` from `startValue`.\n\n**Constraints:**\n- `1 <= startValue, target <= 10^9`\n", "solution": "## Approach\n\nReason backwards from `target` toward `startValue`. In reverse, doubling\nbecomes halving and subtracting becomes adding one. While `target` stays above\n`startValue`, an even target is halved for free progress, while an odd target\nmust first be incremented (one operation) to become even. Each reverse step\nmaps to exactly one forward operation. Once `target` sinks to `startValue` or\nbelow, only plain subtractions remain, contributing `startValue - target`\noperations.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log target), since target at least halves every two steps.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def brokenCalc(self, startValue: int, target: int) -> int:\n ops = 0\n while target > startValue:\n ops += 1\n if target % 2 == 1:\n target += 1\n else:\n target //= 2\n return ops + (startValue - target)\n```\n", "starter": {"go": "package main\n\nfunc BrokenCalc(startValue int, target int) int {\n return 0\n}", "python": "class Solution:\n def brokenCalc(self, startValue: int, target: int) -> int:\n return 0", "cpp": "class Solution {\npublic:\n int brokenCalc(int startValue, int target) {\n return 0;\n }\n};"}, "fn": "brokenCalc", "params": [{"name": "startValue", "type": "int"}, {"name": "target", "type": "int"}], "outputType": "int", "tests": [["2", "3"], ["5", "8"], ["3", "10"], ["1", "1"], ["1", "1000000000"], ["10", "1"], ["3", "3"], ["2", "2"], ["5", "5"], ["1", "2"], ["2", "1"], ["4", "4"], ["7", "11"], ["9", "15"], ["100", "1"], ["1", "100"], ["5", "9"], ["6", "6"], ["8", "24"], ["3", "4"], ["10", "10"], ["1", "3"], ["2", "9"], ["15", "20"], ["25", "50"], ["1024", "1"], ["1", "1000000"], ["999999999", "1000000000"]], "expected": [2, 2, 3, 0, 39, 9, 0, 0, 0, 1, 1, 0, 3, 3, 99, 10, 2, 0, 4, 2, 0, 3, 6, 6, 1, 1023, 28, 500000000], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "855", "slug": "buddy-strings", "id": 855, "title": "Buddy Strings", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/buddy-strings/", "examples": [{"input": "s = \"ab\", goal = \"ba\"", "output": "true", "explanation": "Exchanging the two characters turns \"ab\" into \"ba\"."}, {"input": "s = \"ab\", goal = \"ab\"", "output": "false", "explanation": "No swap of distinct positions keeps them equal."}, {"input": "s = \"aa\", goal = \"aa\"", "output": "true", "explanation": "Swapping the two equal letters leaves \"aa\"."}], "hints": ["If the lengths differ, success is impossible without even checking letters.", "When the strings are already identical, look for any repeated character that allows a harmless swap.", "Otherwise there must be exactly two mismatching spots, and the letters must cross-match."], "statement": "You are given two strings `s` and `goal` of the same alphabet. You may pick exactly two positions `i` and `j` with `i != j` and exchange the characters at those spots in `s`. After that single exchange, the result must equal `goal`.\n\nDecide whether such an exchange exists. Note that the two positions must be different even when the strings already look alike; in that case a swap of two equal letters is the only way to succeed.\n\n**Constraints:**\n- `1 <= s.length <= 2 * 10^4`\n- `s` and `goal` contain only lowercase English letters.\n", "solution": "## Approach\n\nCompare the two strings position by position. Different lengths can never work. When the strings are already equal, a swap is still required, so success needs a duplicated letter to exchange harmlessly. Otherwise collect mismatching indices: there must be exactly two, and the characters must cross-match so one swap fixes both.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the string length. Each position is examined once.\n- **Space Complexity:** O(1) extra besides a small set for duplicate detection.\n\n## Implementation\n\n```python\nclass Solution:\n def buddyStrings(self, s: str, goal: str) -> bool:\n if len(s) != len(goal):\n return False\n if s == goal:\n return len(set(s)) < len(s)\n diffs = [i for i in range(len(s)) if s[i] != goal[i]]\n return len(diffs) == 2 and s[diffs[0]] == goal[diffs[1]] and s[diffs[1]] == goal[diffs[0]]\n```\n", "starter": {"go": "package main\n\nfunc BuddyStrings(s string, goal string) bool {\n return false\n}", "python": "class Solution:\n def buddyStrings(self, s: str, goal: str) -> bool:\n pass", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool buddyStrings(string s, string goal) {\n return false;\n }\n};"}, "fn": "buddyStrings", "params": [{"name": "s", "type": "string"}, {"name": "goal", "type": "string"}], "outputType": "boolean", "tests": [["ab", "ba"], ["ab", "ab"], ["aa", "aa"], ["aaaaaaabc", "aaaaaaacb"], ["abcd", "badc"], ["abcd", "abdc"], ["abcaa", "abcba"], ["abc", "acb"], ["a", "a"], ["a", "b"], ["ab", "ca"], ["abcde", "abced"], ["abcd", "abcd"], ["aabb", "bbaa"], ["abac", "abad"], ["xyzw", "xzyw"], ["hello", "holle"], ["abcabc", "abcabc"], ["ab", "bb"], ["aaab", "aaab"], ["abc", "def"], ["abcd", "dcba"], ["abca", "abca"], ["zzxy", "zzyx"], ["abcdef", "abcfed"], ["aab", "aba"], ["abcde", "edcba"], ["qwerty", "qwerty"]], "expected": [true, false, true, true, false, true, false, true, false, false, false, true, false, false, false, true, true, true, false, true, false, false, true, true, true, true, false, false], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "225", "slug": "build-a-matrix-with-conditions", "id": 225, "title": "Build a Matrix With Conditions", "difficulty": "Hard", "category": "graph", "link": "https://leetcode.com/problems/build-a-matrix-with-conditions/", "examples": [{"input": "k = 3, rowConditions = [[1,2],[3,2]], colConditions = [[2,1],[3,2]]", "output": "[[3,0,0],[0,0,1],[0,2,0]]"}, {"input": "k = 3, rowConditions = [[1,2],[2,3],[3,1],[2,3]], colConditions = [[2,1]]", "output": "[]"}], "hints": ["Topological sort for rows and columns separately. Place number i at (rowPos[i], colPos[i])."], "statement": "Take a positive integer `k` alongside two collections of precedence pairs:\n- a 2D integer array `rowConditions` holding `n` pairs shaped `rowConditions[i] = [abovei, belowi]`, plus\n- a 2D integer array `colConditions` holding `m` pairs shaped `colConditions[i] = [lefti, righti]`.\n\nEvery entry appearing in either collection lies between `1` and `k` inclusive.\n\nAssemble a `k x k` grid holding each integer `1` through `k` a single time, filling every unused position with `0`.\n\nThe placement must additionally respect both families of precedence rules:\n- For each `i` from `0` to `n - 1`, the cell holding `abovei` sits in a strictly earlier row than the cell holding `belowi`.\n- For each `i` from `0` to `m - 1`, the cell holding `lefti` sits in a strictly earlier column than the cell holding `righti`.\n\nProduce any grid meeting all of the above; when the requirements conflict, produce a vacuous grid.\n\n**Constraints:**\n- `2 <= k <= 400`\n- `1 <= rowConditions.length, colConditions.length <= 10^4`\n- `rowConditions[i].length == colConditions[i].length == 2`\n- `1 <= abovei, belowi, lefti, righti <= k`\n- `abovei != belowi`\n- `lefti != righti`\n", "solution": "## Approach\n\nTopologically order numbers for rows and for columns. If either has a cycle, return empty. Place number `i` at `(rowIndex[i], colIndex[i])`.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(k + E)\n- **Space Complexity:** O(k + E)\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import deque\nclass Solution:\n def buildMatrix(self, k: int, rowConditions: List[List[int]], colConditions: List[List[int]]) -> List[List[int]]:\n def topo(cond):\n g = [[] for _ in range(k + 1)]\n indeg = [0] * (k + 1)\n for a, b in cond:\n g[a].append(b)\n indeg[b] += 1\n q = deque([i for i in range(1, k + 1) if indeg[i] == 0])\n order = []\n while q:\n u = q.popleft()\n order.append(u)\n for v in g[u]:\n indeg[v] -= 1\n if indeg[v] == 0:\n q.append(v)\n return order if len(order) == k else None\n ro, co = topo(rowConditions), topo(colConditions)\n if ro is None or co is None:\n return []\n rpos = {v: i for i, v in enumerate(ro)}\n cpos = {v: i for i, v in enumerate(co)}\n mat = [[0] * k for _ in range(k)]\n for num in range(1, k + 1):\n mat[rpos[num]][cpos[num]] = num\n return mat\n```\n", "starter": {"go": "package main\n\nfunc BuildMatrix(k int, rowConditions [][]int, colConditions [][]int) [][]int {\n return nil\n}", "python": "from typing import List\nclass Solution:\n def buildMatrix(self, k: int, rowConditions: List[List[int]], colConditions: List[List[int]]) -> List[List[int]]:\n ", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<vector<int>> buildMatrix(int k, vector<vector<int>>& rowConditions, vector<vector<int>>& colConditions) {\n return {};\n }\n};"}, "fn": "buildMatrix", "params": [{"name": "k", "type": "int"}, {"name": "rowConditions", "type": "int_array_2d"}, {"name": "colConditions", "type": "int_array_2d"}], "outputType": "int_array_2d", "tests": [["3", "[[1,2],[3,2]]", "[[2,1],[3,2]]"], ["3", "[[1,2],[2,3],[3,1],[2,3]]", "[[2,1]]"], ["2", "[[1,2]]", "[[2,1]]"], ["2", "[[1,2],[2,1]]", "[[1,2]]"], ["4", "[[1,2],[2,3],[3,4]]", "[[4,3],[3,2],[2,1]]"], ["3", "[[1,2]]", "[[1,2]]"], ["2", "[[1,2]]", "[[1,2]]"], ["2", "[[2,1]]", "[[2,1]]"], ["2", "[[2,1]]", "[[1,2]]"], ["2", "[[1,2],[2,1]]", "[[2,1]]"], ["3", "[[1,3]]", "[[3,2]]"], ["3", "[[1,2],[2,3]]", "[[3,1]]"], ["3", "[[3,1]]", "[[1,2],[2,3]]"], ["4", "[[4,1]]", "[[2,3]]"], ["4", "[[1,2],[1,3],[1,4]]", "[[4,2]]"], ["4", "[[4,2]]", "[[1,2],[1,3],[1,4]]"], ["4", "[[1,2],[3,4]]", "[[1,3],[2,4]]"], ["5", "[[5,1]]", "[[4,2]]"], ["5", "[[1,2],[2,3],[3,4],[4,5]]", "[[1,2],[2,3],[3,4],[4,5]]"], ["5", "[[1,2],[2,3],[3,4],[4,5]]", "[[5,4],[4,3],[3,2],[2,1]]"], ["5", "[[1,2],[1,3],[2,4],[3,4],[4,5]]", "[[1,5]]"], ["5", "[[1,2],[1,2],[2,3]]", "[[2,3],[2,3]]"], ["3", "[[1,2],[2,1]]", "[[1,3]]"], ["3", "[[1,2]]", "[[1,2],[2,1]]"], ["4", "[[1,2],[2,3],[3,1]]", "[[1,2]]"], ["6", "[[1,2],[2,3],[3,4],[4,5],[5,6]]", "[[6,1]]"], ["6", "[[6,1]]", "[[1,2],[2,3],[3,4],[4,5],[5,6]]"], ["6", "[[1,2],[3,4],[5,6]]", "[[2,3],[4,5]]"], ["7", "[[1,2],[2,3],[4,5],[5,6],[6,7]]", "[[1,4],[2,5],[3,6]]"], ["8", "[[1,5],[2,5],[3,6],[4,6],[5,7],[6,8]]", "[[1,2],[3,4],[7,8]]"], ["5", "[[2,1],[3,2],[4,3]]", "[[1,3],[3,5]]"], ["4", "[[1,3],[2,3],[3,4]]", "[[1,2],[2,4],[1,4]]"]], "expected": [[[0, 0, 1], [3, 0, 0], [0, 2, 0]], [], [[0, 1], [2, 0]], [], [[0, 0, 0, 1], [0, 0, 2, 0], [0, 3, 0, 0], [4, 0, 0, 0]], [[1, 0, 0], [0, 3, 0], [0, 0, 2]], [[1, 0], [0, 2]], [[2, 0], [0, 1]], [[0, 2], [1, 0]], [], [[1, 0, 0], [0, 0, 2], [0, 3, 0]], [[0, 0, 1], [2, 0, 0], [0, 3, 0]], [[0, 2, 0], [0, 0, 3], [1, 0, 0]], [[0, 2, 0, 0], [0, 0, 0, 3], [0, 0, 4, 0], [1, 0, 0, 0]], [[1, 0, 0, 0], [0, 0, 0, 2], [0, 3, 0, 0], [0, 0, 4, 0]], [[1, 0, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4], [0, 2, 0, 0]], [[1, 0, 0, 0], [0, 0, 3, 0], [0, 2, 0, 0], [0, 0, 0, 4]], [[0, 0, 0, 0, 2], [0, 3, 0, 0, 0], [0, 0, 4, 0, 0], [0, 0, 0, 5, 0], [1, 0, 0, 0, 0]], [[1, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 0, 0, 0, 5]], [[0, 0, 0, 0, 1], [0, 0, 0, 2, 0], [0, 0, 3, 0, 0], [0, 4, 0, 0, 0], [5, 0, 0, 0, 0]], [[1, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 0, 0, 0, 5]], [[1, 0, 0, 0, 0], [0, 0, 4, 0, 0], [0, 0, 0, 5, 0], [0, 2, 0, 0, 0], [0, 0, 0, 0, 3]], [], [], [], [[0, 0, 0, 0, 0, 1], [2, 0, 0, 0, 0, 0], [0, 3, 0, 0, 0, 0], [0, 0, 4, 0, 0, 0], [0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 6, 0]], [[0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 6], [1, 0, 0, 0, 0, 0]], [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 3, 0], [0, 0, 0, 0, 0, 5], [0, 2, 0, 0, 0, 0], [0, 0, 4, 0, 0, 0], [0, 0, 0, 6, 0, 0]], [[1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6], [0, 0, 0, 7, 0, 0, 0]], [[1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0], [0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 0], [0, 0, 5, 0, 0, 0, 0, 0], [0, 0, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 7, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 8]], [[0, 0, 4, 0, 0], [0, 0, 0, 0, 5], [0, 0, 0, 3, 0], [0, 2, 0, 0, 0], [1, 0, 0, 0, 0]], [[1, 0, 0, 0], [0, 0, 2, 0], [0, 3, 0, 0], [0, 0, 0, 4]]], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "691", "slug": "bulb-switcher-ii", "id": 691, "title": "Bulb Switcher II", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/bulb-switcher-ii/", "examples": [{"input": "n = 1, presses = 1", "output": "2", "explanation": "One lamp can end on or off after one press."}, {"input": "n = 2, presses = 1", "output": "3", "explanation": "With two lamps, one press yields three reachable patterns."}, {"input": "n = 3, presses = 1", "output": "4", "explanation": "With at least three lamps, one press yields four patterns."}], "hints": ["Only the first three lamps matter; further lamps repeat the same behavior pattern.", "Enumerate the four button effects and notice presses beyond a small bound stop creating new states.", "Handle n = 1 and n = 2 separately, then use the capped table 1, 4, 7, 8 for n >= 3."], "statement": "There are `n` lamps in a row, all starting switched on. Four buttons are available:\n\n- flip every lamp,\n- flip lamps at even positions,\n- flip lamps at odd positions,\n- flip lamps whose position leaves remainder 1 when divided by 3 (positions 1, 4, 7, ...).\n\nPress any button exactly `presses` times in total (the same button may be pressed repeatedly). Return how many distinct on/off patterns can result.\n\n**Constraints:**\n- `1 <= n <= 1000`\n- `0 <= presses <= 1000`\n", "solution": "## Approach\n\nThe four operations interact so only a few states exist. With zero presses there is one pattern. A single lamp toggles between two states. Two lamps admit 3 states after one press and 4 afterwards. With three or more lamps the reachable counts are 4, 7, then 8 once at least three presses are available; extra presses only revisit states.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def flipLights(self, n: int, presses: int) -> int:\n if presses == 0:\n return 1\n if n == 1:\n return 2\n if n == 2:\n return 3 if presses == 1 else 4\n if presses == 1:\n return 4\n if presses == 2:\n return 7\n return 8\n```\n", "starter": {"go": "package main\n\nfunc FlipLights(n int, presses int) int {\n return 0\n}", "python": "class Solution:\n def flipLights(self, n: int, presses: int) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int flipLights(int n, int presses) {\n return 0;\n }\n};"}, "fn": "flipLights", "params": [{"name": "n", "type": "int"}, {"name": "presses", "type": "int"}], "outputType": "int", "tests": [["1", "1"], ["2", "1"], ["3", "1"], ["1", "0"], ["1", "2"], ["1", "1000"], ["2", "0"], ["2", "2"], ["2", "3"], ["3", "0"], ["3", "2"], ["3", "3"], ["3", "100"], ["4", "2"], ["4", "3"], ["5", "4"], ["10", "0"], ["10", "1"], ["10", "2"], ["10", "3"], ["10", "10"], ["1000", "0"], ["1000", "1"], ["1000", "2"], ["1000", "3"], ["1000", "1000"], ["2", "1000"], ["6", "5"]], "expected": [2, 3, 4, 1, 2, 2, 1, 4, 4, 1, 7, 8, 8, 7, 8, 8, 1, 4, 7, 8, 8, 1, 4, 7, 8, 8, 4, 8], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "408", "slug": "bulb-switcher", "id": 408, "title": "Bulb Switcher", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/bulb-switcher/", "examples": [{"explanation": "After round 1 the lit lamps are [on,on,on]; after round 2 [on,off,on]; after round 3 [on,off,off], so 1 lamp stays on.", "input": "n = 3", "output": "1"}, {"explanation": "With no lamps, none can be on.", "input": "n = 0", "output": "0"}, {"explanation": "The single lamp is flipped once and stays on.", "input": "n = 1", "output": "1"}], "hints": ["A lamp is flipped once per divisor of its position, so only positions with an odd divisor count end lit.", "Odd divisor counts happen exactly for perfect squares.", "The answer is the number of squares up to n, i.e. floor(sqrt(n))."], "statement": "There are `n` lamps, all switched off at the start. In round 1 every lamp is flipped on. In round 2 every second lamp is flipped, in round 3 every third lamp is flipped, and so on: during round `i`, each lamp whose 1-based position is a multiple of `i` changes state. After completing all `n` rounds, report how many lamps remain lit.\n\n**Constraints:**\n- `0 <= n <= 10^9`\n", "solution": "## Approach\n\nLamp `p` is toggled once for every divisor of `p`. Divisors pair up, except when `p` is a perfect square, which has an odd count. Hence exactly the square-numbered lamps finish on, and the answer is the count of squares not exceeding `n`.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nimport math\nclass Solution:\n def bulbSwitch(self, n: int) -> int:\n return int(math.isqrt(n))\n```\n", "starter": {"go": "package main\n\nfunc BulbSwitch(n int) int {\n \n}", "python": "class Solution:\n def bulbSwitch(self, n: int) -> int:\n pass", "cpp": "class Solution {\npublic:\n int bulbSwitch(int n) {\n return 0;\n }\n};"}, "fn": "bulbSwitch", "params": [{"name": "n", "type": "int"}], "outputType": "int", "tests": [["3"], ["0"], ["1"], ["2"], ["4"], ["5"], ["8"], ["9"], ["10"], ["15"], ["16"], ["24"], ["25"], ["26"], ["48"], ["49"], ["99"], ["100"], ["101"], ["999"], ["1000"], ["10000"], ["99999"], ["100000"], ["999999999"], ["1000000000"], ["2147395600"], ["7"], ["35"], ["36"]], "expected": [1, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 7, 9, 10, 10, 31, 31, 100, 316, 316, 31622, 31622, 46340, 2, 5, 6], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "393", "slug": "bulls-and-cows", "id": 393, "title": "Bulls and Cows", "difficulty": "Medium", "category": "string", "link": "https://leetcode.com/problems/bulls-and-cows/", "examples": [{"input": "secret = \"1807\", guess = \"7810\"", "output": "\"1A3B\"", "explanation": "One digit lines up; three others are displaced matches."}, {"input": "secret = \"1123\", guess = \"0111\"", "output": "\"1A1B\"", "explanation": "One bull plus one reusable '1' elsewhere."}, {"input": "secret = \"11\", guess = \"10\"", "output": "\"1A0B\"", "explanation": "Only the first position matches."}], "hints": ["First sweep the positions once to count bulls and set those spots aside.", "For the remaining spots, count how many of each digit each string still holds.", "Each digit contributes the smaller of its two leftover counts to the cow total."], "statement": "You play Bulls and Cows against a friend: `secret` is the hidden code and `guess` is your\nattempt; both are digit strings of equal length. A bull is a position where both strings\nhold the same digit. A cow is a digit that appears in both strings but in different\npositions, with each character used at most once (bulls take priority). Return the score as\n`\"xAyB\"`, where `x` counts bulls and `y` counts cows.\n\n**Constraints:**\n- `1 <= secret.length <= 1000`\n- `secret.length == guess.length`\n- Both strings contain only digits.\n", "solution": "## Approach\n\nCount bulls in one pass while tallying leftover digit frequencies for both strings; cows are the per-digit minima of those leftovers.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n)\n- **Space Complexity:** O(1)\n\n## Implementation\n\n```python\nclass Solution:\n def getHint(self, secret: str, guess: str) -> str:\n bulls = sum(a == b for a, b in zip(secret, guess))\n s = [0] * 10\n g = [0] * 10\n for a, b in zip(secret, guess):\n if a != b:\n s[ord(a) - 48] += 1\n g[ord(b) - 48] += 1\n cows = sum(min(x, y) for x, y in zip(s, g))\n return f\"{bulls}A{cows}B\"\n```\n", "starter": {"go": "package main\n\nfunc GetHint(secret string, guess string) string {\n return \"\"\n}", "python": "class Solution:\n def getHint(self, secret: str, guess: str) -> str:\n ", "cpp": "#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n string getHint(string secret, string guess) {\n return \"\";\n }\n};"}, "fn": "getHint", "params": [{"name": "secret", "type": "string"}, {"name": "guess", "type": "string"}], "outputType": "string", "tests": [["1807", "7810"], ["1123", "0111"], ["11", "10"], ["1", "0"], ["1", "1"], ["1234", "1234"], ["1234", "4321"], ["0000", "0000"], ["0000", "1111"], ["1122", "2211"], ["5678", "5678"], ["930789", "459908"], ["75", "56"], ["8536631", "5102932"], ["47", "61"], ["4960", "3242"], ["800909", "056088"], ["7", "4"], ["095", "432"], ["939", "409"], ["7547", "9543"], ["53487", "56880"], ["017", "007"], ["55974187", "41516434"], ["402", "397"], ["922606", "035047"], ["5674688", "2552344"], ["90290", "10374"], ["1", "8"], ["7920397", "5947617"]], "expected": ["1A3B", "1A1B", "1A0B", "0A0B", "1A0B", "4A0B", "0A4B", "4A0B", "0A0B", "0A4B", "4A0B", "0A4B", "0A1B", "1A2B", "0A0B", "0A1B", "0A3B", "0A0B", "0A0B", "1A0B", "2A0B", "2A0B", "2A0B", "0A3B", "0A0B", "0A1B", "0A2B", "1A0B", "0A0B", "2A1B"], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "136", "slug": "burst-balloons", "id": 136, "title": "Burst Balloons", "difficulty": "Hard", "category": "dp-2d", "link": "https://leetcode.com/problems/burst-balloons/", "examples": [{"input": "nums = [3,1,5,8]", "output": "167", "explanation": "One optimal order is 1, 5, 3, 8, which yields 167 coins."}, {"input": "nums = [1,5]", "output": "10", "explanation": "Max coins from [1, 5] is 10."}, {"input": "nums = [7]", "output": "7", "explanation": "Max coins from [7] is 7."}], "hints": ["Choosing the first balloon is awkward because its future neighbors are unknown; instead, choose the last balloon burst in an interval.", "Pad the array with a value of 1 at each end and let dp[left][right] be the best result for that closed interval.", "Try every index as the last balloon in each interval, building answers from shorter intervals to longer ones."], "statement": "You are given an array `nums` of non-negative integers representing balloons. If you burst balloon `i`, you gain `nums[i - 1] * nums[i] * nums[i + 1]` coins. After the balloon is burst, its two neighbors become adjacent.\n\nTreat positions outside the current array as balloons with value `1`. Return the maximum number of coins you can collect by bursting every balloon.\n\n**Constraints:**\n\n- `1 <= nums.length <= 300`\n- `0 <= nums[i] <= 100`\n- The maximum coin total fits in a signed 32-bit integer.\n", "solution": "## Approach\n\nPad the balloon values with `1` at both ends. Let `dp[left][right]` be the maximum coins obtainable by bursting every balloon in that closed interval. Instead of choosing the first balloon, try each position as the last balloon burst; its neighbors are then the fixed values immediately outside the interval. Build the table from shorter intervals to longer ones.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^3), because every interval tries every possible final balloon.\n- **Space Complexity:** O(n^2) for the dynamic programming table.\n\n## Implementation\n\n```python\nfrom typing import List\n\n\nclass Solution:\n def maxCoins(self, nums: List[int]) -> int:\n n = len(nums)\n values = [1, *nums, 1]\n dp = [[0] * (n + 2) for _ in range(n + 2)]\n\n for length in range(1, n + 1):\n for left in range(1, n - length + 2):\n right = left + length - 1\n boundary_product = values[left - 1] * values[right + 1]\n best = 0\n for last in range(left, right + 1):\n coins = (\n dp[left][last - 1]\n + dp[last + 1][right]\n + boundary_product * values[last]\n )\n if coins > best:\n best = coins\n dp[left][right] = best\n return dp[1][n]\n```\n", "starter": {"go": "package main\n\nfunc MaxCoins(nums []int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def maxCoins(self, nums: List[int]) -> int:\n pass\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int maxCoins(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "maxCoins", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[3,1,5,8]"], ["[1,5]"], ["[7]"], ["[1]"], ["[0]"], ["[2]"], ["[1,1]"], ["[2,2]"], ["[1,2,3]"], ["[3,2,1]"], ["[1,1,1]"], ["[2,1,2]"], ["[5,1,5]"], ["[1,3,1,5]"], ["[9,1,2]"], ["[2,9,1]"], ["[4,2,3,1]"], ["[1,2,3,4]"], ["[4,3,2,1]"], ["[2,2,2,2]"], ["[1,5,1,5,1]"], ["[8,2,6,3]"], ["[3,7,2,5]"], ["[10,1,10]"], ["[1,10,1]"], ["[6,4,2,8,3]"], ["[2,4,6,8]"], ["[8,6,4,2]"], ["[1,2,1,2,1,2]"], ["[9,9]"], ["[3,3,3]"], ["[4,1,7,1,4]"], ["[2,3,5,7]"], ["[7,5,3,2]"], ["[5,2,8,1,6]"], ["[1,4,9,4,1]"], ["[10,10,10]"], ["[2,10,2,10]"], ["[6,1,1,6]"], ["[3,1,4,1,5,9]"], ["[9,2,6,5,3,5]"], ["[1,1,2,3,5,8]"], ["[8,5,3,2,1,1]"], ["[2,7,1,8,2,8]"], ["[5,5,1,5,5]"], ["[1,6,2,7,3,8]"], ["[8,3,7,2,6,1]"], ["[4,4,4,4,4]"], ["[1,2,3,4,5,6,7]"], ["[7,6,5,4,3,2,1]"], ["[2,1,3,1,4,1,5]"], ["[10,2,1,3,10]"], ["[6,9,2,4,7]"], ["[3,8,1,6,2,9,4]"], ["[1,9,1,9,1,9,1]"], ["[2,5,3,7,1,4,6,8]"], ["[100]"], ["[100,100]"], ["[100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100]"]], "expected": [167, 10, 7, 1, 0, 2, 2, 6, 12, 12, 3, 10, 55, 40, 45, 36, 44, 40, 40, 22, 65, 272, 195, 210, 30, 424, 280, 280, 24, 90, 39, 188, 168, 168, 404, 172, 1110, 430, 84, 356, 732, 208, 208, 768, 305, 652, 652, 212, 504, 504, 143, 476, 751, 988, 999, 1021, 100, 10100, 148010100], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "813", "slug": "bus-routes", "id": 813, "title": "Bus Routes", "difficulty": "Hard", "category": "graph", "link": "https://leetcode.com/problems/bus-routes/", "examples": [{"input": "routes = [[1,2,7],[3,6,7]], source = 1, target = 6", "output": "2", "explanation": "Ride the first bus to stop 7, then change to the second bus to reach 6."}, {"input": "routes = [[7,12],[4,5,15],[6],[15,19],[9,12,13]], source = 15, target = 12", "output": "-1", "explanation": "No chain of shared stops connects 15 to 12."}, {"input": "routes = [[1,2,3]], source = 1, target = 1", "output": "0", "explanation": "Start and destination coincide, so no bus is needed."}], "hints": ["Index every stop to the list of buses serving it, turning transfers into graph edges.", "Breadth-first search over buses (not stops) starting from all buses at the source; the first time a bus reaches the target its depth is the answer."], "statement": "Each bus route is a list of stops it serves in order; you may board or alight at any stop on a route, and changing buses is allowed only at a shared stop. Given all `routes`, a starting stop `source` and a destination `target`, find the smallest number of buses you must ride to reach the destination.\n\nIf the start equals the destination, the answer is 0 without boarding. If the destination cannot be reached at all, return -1. Otherwise count each bus boarded, including the first and the last.\n\n**Constraints:**\n- `1 <= routes.length <= 500`\n- `1 <= routes[i].length <= 10^5`\n- Total stops across routes is at most `10^5`.\n- `0 <= routes[i][j] < 10^6`\n- `0 <= source, target < 10^6`\n", "solution": "## Approach\n\nMap each stop to the buses that visit it. Then breadth-first search outward from the source stop, expanding stop by stop but marking whole buses as visited the first time any of their stops is reached. The search proceeds in layers where each layer corresponds to boarding one more bus; reaching the target stop inside a newly boarded bus yields its depth. If the queue empties, the target is unreachable.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(total stops across all routes).\n- **Space Complexity:** O(total stops) for the index, queue, and visited sets.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import defaultdict, deque\nclass Solution:\n def numBusesToDestination(self, routes: List[List[int]], source: int, target: int) -> int:\n if source == target:\n return 0\n stop_to_buses = defaultdict(list)\n for b, stops in enumerate(routes):\n for s in stops:\n stop_to_buses[s].append(b)\n if source not in stop_to_buses or target not in stop_to_buses:\n return -1\n q = deque([source])\n seen_stop = {source}\n seen_bus = [False] * len(routes)\n buses = 0\n while q:\n buses += 1\n for _ in range(len(q)):\n stop = q.popleft()\n for b in stop_to_buses.get(stop, []):\n if seen_bus[b]:\n continue\n seen_bus[b] = True\n for ns in routes[b]:\n if ns == target:\n return buses\n if ns not in seen_stop:\n seen_stop.add(ns)\n q.append(ns)\n return -1\n```\n", "starter": {"go": "package main\n\nfunc NumBusesToDestination(routes [][]int, source int, target int) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def numBusesToDestination(self, routes: List[List[int]], source: int, target: int) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int numBusesToDestination(vector<vector<int>>& routes, int source, int target) {\n return 0;\n }\n};"}, "fn": "numBusesToDestination", "params": [{"name": "routes", "type": "int_array_2d"}, {"name": "source", "type": "int"}, {"name": "target", "type": "int"}], "outputType": "int", "tests": [["[[1,2,7],[3,6,7]]", "1", "6"], ["[[7,12],[4,5,15],[6],[15,19],[9,12,13]]", "15", "12"], ["[[1,2,3]]", "1", "1"], ["[[1,2,3]]", "1", "3"], ["[[1,2],[2,3],[3,4]]", "1", "4"], ["[[1,2],[3,4]]", "1", "4"], ["[[1,2,3,4,5]]", "1", "5"], ["[[1,7],[7,2],[2,9]]", "1", "9"], ["[[1,2],[2,3],[4,5]]", "1", "5"], ["[[0,1,2],[3,4,5],[2,3]]", "0", "5"], ["[[1,2],[2,3],[3,1]]", "1", "3"], ["[[5]]", "5", "5"], ["[[5]]", "5", "6"], ["[[1,10],[10,20],[20,30],[30,40]]", "1", "40"], ["[[1,2,3],[3,4,5],[5,6,1]]", "2", "6"], ["[[100,200],[200,300],[400,500]]", "100", "500"], ["[[1,2],[3,4],[2,3]]", "1", "4"], ["[[1,5,9],[2,6,10],[5,6]]", "1", "10"], ["[[0,5,10],[5,15],[10,20],[15,20]]", "0", "20"], ["[[1,2],[2,3],[3,4],[4,5],[5,1]]", "1", "4"], ["[[7,8,9]]", "7", "9"], ["[[7,8,9]]", "9", "7"], ["[[1,2,7],[3,6,7],[6,8]]", "1", "8"], ["[[1,2],[4,5,6],[2,4]]", "1", "6"], ["[[10,20,30],[40,50],[20,40]]", "10", "50"], ["[[1,2,3,4],[4,5,6],[6,7,1]]", "2", "7"], ["[[0,1],[1,2],[2,3],[3,4],[4,5]]", "0", "5"], ["[[2,4,6],[8,10],[4,8]]", "2", "10"]], "expected": [2, -1, 0, 1, 3, -1, 1, 3, -1, 3, 1, 0, -1, 4, 2, -1, 3, 3, 2, 2, 1, 1, 3, 3, 3, 2, 5, 3], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "529", "slug": "can-i-win", "id": 529, "title": "Can I Win", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/can-i-win/", "examples": [{"input": "maxChoosableInteger = 10, desiredTotal = 11", "output": "false", "explanation": "Whatever the first player picks, the second player can always answer with a number that reaches 11 first."}, {"input": "maxChoosableInteger = 10, desiredTotal = 0", "output": "true", "explanation": "The target is already met, so the first player has won without moving."}, {"input": "maxChoosableInteger = 10, desiredTotal = 1", "output": "true", "explanation": "The first player picks 1 and reaches the target immediately."}], "hints": ["Encode the set of used numbers as a bitmask and memoize game states so each reachable position is solved once.", "If the sum 1 + 2 + ... + max falls short of the target, the first player can never win."], "statement": "Two players take turns choosing from the pool of integers `1` through `maxChoosableInteger`. Each number may be used at most once per game. The chosen numbers accumulate into a running total, and the player whose pick makes the total reach or exceed `desiredTotal` wins immediately.\n\nBoth players play perfectly. Return `true` if the first player can force a win, and `false` otherwise. A non-positive target counts as already met, so the first player wins without moving.\n\n**Constraints:**\n- `1 <= maxChoosableInteger <= 20`\n- `0 <= desiredTotal <= 300`\n", "solution": "## Approach\n\nTreat the set of already picked numbers as a bitmask and explore the game tree with depth-first search: a position is winning if some unused pick reaches the target at once or leaves the opponent in a losing position. Memoize results by mask so every reachable subset is evaluated a single time. Two shortcuts finish early: a non-positive target is an instant win, and a target above the sum of the whole pool is an instant loss.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m * 2^m), where m is `maxChoosableInteger` (at most 20), for the memoized states times the moves tried per state.\n- **Space Complexity:** O(2^m) for the memo table.\n\n## Implementation\n\n```python\nfrom functools import lru_cache\n\nclass Solution:\n def canIWin(self, maxChoosableInteger: int, desiredTotal: int) -> bool:\n if desiredTotal <= 0:\n return True\n if maxChoosableInteger * (maxChoosableInteger + 1) // 2 < desiredTotal:\n return False\n\n @lru_cache(maxsize=None)\n def win(used: int, total: int) -> bool:\n for i in range(1, maxChoosableInteger + 1):\n bit = 1 << (i - 1)\n if used & bit:\n continue\n if total + i >= desiredTotal or not win(used | bit, total + i):\n return True\n return False\n\n return win(0, 0)\n```\n", "starter": {"go": "package main\n\nfunc CanIWin(maxChoosableInteger int, desiredTotal int) bool {\n \n}", "python": "class Solution:\n def canIWin(self, maxChoosableInteger: int, desiredTotal: int) -> bool:\n pass", "cpp": "class Solution {\npublic:\n bool canIWin(int maxChoosableInteger, int desiredTotal) {\n return false;\n }\n};"}, "fn": "canIWin", "params": [{"name": "maxChoosableInteger", "type": "int"}, {"name": "desiredTotal", "type": "int"}], "outputType": "boolean", "tests": [["10", "11"], ["10", "0"], ["10", "1"], ["5", "50"], ["3", "6"], ["4", "6"], ["8", "5"], ["1", "1"], ["1", "2"], ["2", "3"], ["3", "5"], ["7", "16"], ["12", "36"], ["20", "40"], ["3", "2"], ["4", "10"], ["5", "10"], ["6", "15"], ["7", "10"], ["8", "12"], ["10", "40"], ["10", "55"], ["20", "1"], ["20", "300"], ["5", "15"], ["6", "21"], ["10", "5"], ["4", "4"]], "expected": [false, true, true, false, true, true, true, true, false, false, true, true, true, true, true, false, true, true, true, true, false, false, true, false, true, false, true, true], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "641", "slug": "can-place-flowers", "id": 641, "title": "Can Place Flowers", "difficulty": "Easy", "category": "array", "link": "https://leetcode.com/problems/can-place-flowers/", "examples": [{"input": "flowerbed = [1,0,0,0,1], n = 1", "output": "true", "explanation": "The middle gap fits one flower."}, {"input": "flowerbed = [1,0,0,0,1], n = 2", "output": "false", "explanation": "Only one gap exists."}, {"input": "flowerbed = [0,0,0], n = 2", "output": "true", "explanation": "Both ends can be used."}], "hints": ["A spot works when it and both neighbors are empty (edges need one neighbor).", "Walk once, planting greedily; planting early never hurts.", "Stop early once n flowers are placed."], "statement": "A flowerbed row uses `1` for a planted plot and `0` for empty. New flowers cannot touch: no two planted plots may sit side by side. Given `flowerbed` and `n`, decide whether `n` new flowers can be added without breaking the rule.\n\n**Constraints:**\n- `1 <= flowerbed.length <= 20000`, entries are 0 or 1.\n- `0 <= n <= flowerbed.length`; no adjacent ones in the input.\n", "solution": "## Approach\n\nScan left to right planting wherever the current and neighboring plots are empty. Greedy works because using the earliest slot leaves maximal room to the right.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m).\n- **Space Complexity:** O(1) besides a copy.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool:\n a = list(flowerbed)\n placed = 0\n for i in range(len(a)):\n if a[i]==0 and (i==0 or a[i-1]==0) and (i==len(a)-1 or a[i+1]==0):\n a[i]=1; placed+=1\n if placed>=n:\n return True\n return placed>=n\n```\n", "starter": {"go": "package main\n\nfunc CanPlaceFlowers(flowerbed []int, n int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool canPlaceFlowers(vector<int>& flowerbed, int n) {\n return false;\n }\n};"}, "fn": "canPlaceFlowers", "params": [{"name": "flowerbed", "type": "int_array"}, {"name": "n", "type": "int"}], "outputType": "boolean", "tests": [["[1,0,0,0,1]", "1"], ["[1,0,0,0,1]", "2"], ["[0,0,0]", "2"], ["[0]", "1"], ["[1]", "0"], ["[1]", "1"], ["[0]", "0"], ["[0,0]", "1"], ["[1,0]", "1"], ["[0,1]", "1"], ["[0,0,0,0,0]", "3"], ["[1,0,0,0,0,1]", "2"], ["[0,0,1,0,0]", "2"], ["[1,0,1,0,1]", "0"], ["[1,0,1,0,1]", "1"], ["[0,0,0,0,1]", "2"], ["[1,0,0,0,0]", "2"], ["[0,1,0]", "1"], ["[0,0,1,0,1,0,0]", "2"], ["[1,0,0,1,0,0,1]", "1"], ["[0,0,0,1,0,0,0]", "3"], ["[0,0,0,0,0,0]", "3"], ["[1,0,0,0,1,0,0]", "2"], ["[0,1,0,1,0,1,0]", "1"], ["[0,0]", "0"], ["[1,0,0]", "1"], ["[0,0,1]", "1"], ["[0,0,0,0]", "2"]], "expected": [true, false, true, true, true, false, true, true, false, false, true, false, true, true, false, true, true, false, true, false, false, true, true, false, true, true, true, true], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "730", "slug": "candy-crush", "id": 730, "title": "Candy Crush", "difficulty": "Medium", "category": "matrix", "link": "https://leetcode.com/problems/candy-crush/", "examples": [{"input": "board = [[\"1\",\"1\",\"1\",\"2\"],[\"1\",\"3\",\"2\",\"2\"],[\"1\",\"2\",\"3\",\"1\"]]", "output": "[\"0002\",\"0322\",\"0231\"]", "explanation": "The top row triple and left column triple crush to 0, then survivors fall down leaving rows 0002, 0322 and 0231."}, {"input": "board = [[\"1\",\"2\",\"3\"],[\"4\",\"5\",\"6\"]]", "output": "[\"123\",\"456\"]", "explanation": "No row or column holds three equal non-zero values, so the board is already stable."}, {"input": "board = [[\"2\",\"2\",\"2\"]]", "output": "[\"000\"]", "explanation": "One horizontal triple crushes and nothing falls."}], "hints": ["Repeat two phases until stable: mark every horizontal or vertical run of 3+ equal non-zero cells, then apply gravity per column.", "Mark before crushing so overlapping crosses disappear together; '0' means empty and never forms a run.", "Drop each column by compacting non-zero values to the bottom and filling the top with zeros, then re-encode each row as one string. Adaptation: input is char_array_2d with digits '0'-'5' and output is string_list of row strings; Rust receives the board as its encoded string."], "statement": "You are given a candy board where each cell holds a digit character from `1` to `5` (`0` means empty after crushing). Repeatedly settle the board:\n\n1. Crush: every horizontal or vertical run of at least three equal non-zero values disappears at once (all such cells become `0`). Overlapping runs crush together.\n2. Drop: for each column, the surviving non-zero values fall to the bottom and zeros rise to the top.\n\nStop when a full scan finds nothing to crush. Return the stable board as one string per row (each row's characters joined left to right).\n\n*Adaptation note:* the board arrives as `char_array_2d` and the answer is a `string_list` of row strings, mirroring the minesweeper layout so every language can express it. Digits stay single characters (`0` to `5`); Rust sees the board as its encoded string and parses it first.\n\n**Constraints:**\n- `1 <= board.length, board[i].length <= 50`\n- Each input cell is `1` to `5`; settled cells may be `0` to `5`.\n- The board is rectangular.\n", "solution": "## Approach\n\nLoop crush-then-drop until no run qualifies. Each crush pass scans rows and columns for 3+ equal non-zero runs and marks them first so crosses vanish together, then zeroes them. Gravity compacts every column bottom-up. When a pass marks nothing, encode each row of digits as one string.\n\n## Complexity Analysis\n\n- **Time Complexity:** O((m*n)^2) worst case, but each crush removes at least three cells so passes are few; each pass is O(m*n).\n- **Space Complexity:** O(m*n) for the integer copy and mark grid.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def candyCrush(self, board: List[List[str]]) -> List[str]:\n m, n = len(board), len(board[0])\n g = [[ord(board[r][c]) - 48 for c in range(n)] for r in range(m)]\n while True:\n crush = [[False]*n for _ in range(m)]\n any_crush = False\n for r in range(m):\n c = 0\n while c < n:\n if g[r][c] == 0:\n c += 1\n continue\n nc = c\n while nc < n and g[r][nc] == g[r][c]:\n nc += 1\n if nc - c >= 3:\n for k in range(c, nc):\n crush[r][k] = True\n any_crush = True\n c = nc\n for c in range(n):\n r = 0\n while r < m:\n if g[r][c] == 0:\n r += 1\n continue\n nr = r\n while nr < m and g[nr][c] == g[r][c]:\n nr += 1\n if nr - r >= 3:\n for k in range(r, nr):\n crush[k][c] = True\n any_crush = True\n r = nr\n if not any_crush:\n break\n for r in range(m):\n for c in range(n):\n if crush[r][c]:\n g[r][c] = 0\n for c in range(n):\n w = m - 1\n for r in range(m - 1, -1, -1):\n if g[r][c] != 0:\n g[w][c] = g[r][c]\n w -= 1\n for r in range(w, -1, -1):\n g[r][c] = 0\n return [''.join(str(g[r][c]) for c in range(n)) for r in range(m)]\n```\n", "starter": {"go": "package main\n\nfunc CandyCrush(board [][]byte) []string {\n return []string{}\n}", "python": "from typing import List\nclass Solution:\n def candyCrush(self, board: List[List[str]]) -> List[str]:\n return []", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n vector<string> candyCrush(vector<vector<char>>& board) {\n return {};\n }\n};"}, "fn": "candyCrush", "params": [{"name": "board", "type": "char_array_2d"}], "outputType": "string_list", "tests": [["[[\"1\",\"1\",\"1\",\"2\"],[\"1\",\"3\",\"2\",\"2\"],[\"1\",\"2\",\"3\",\"1\"]]"], ["[[\"1\",\"2\",\"3\"],[\"4\",\"5\",\"6\"]]"], ["[[\"2\",\"2\",\"2\"]]"], ["[[\"1\"]]"], ["[[\"1\",\"1\"]]"], ["[[\"1\"],[\"1\"],[\"1\"]]"], ["[[\"1\",\"1\",\"2\",\"2\",\"2\"]]"], ["[[\"1\",\"2\",\"1\",\"2\",\"1\"]]"], ["[[\"1\",\"1\",\"1\"],[\"1\",\"1\",\"1\"],[\"1\",\"1\",\"1\"]]"], ["[[\"1\",\"2\",\"3\"],[\"1\",\"2\",\"3\"],[\"1\",\"2\",\"3\"]]"], ["[[\"1\",\"2\",\"3\",\"4\"],[\"5\",\"5\",\"5\",\"4\"],[\"1\",\"2\",\"3\",\"4\"]]"], ["[[\"3\",\"3\",\"1\",\"2\"],[\"3\",\"1\",\"1\",\"2\"],[\"3\",\"2\",\"1\",\"1\"]]"], ["[[\"1\",\"2\"],[\"3\",\"4\"]]"], ["[[\"5\",\"5\",\"5\",\"5\"]]"], ["[[\"5\"],[\"5\"],[\"5\"],[\"5\"]]"], ["[[\"1\",\"2\",\"2\",\"2\",\"1\"]]"], ["[[\"1\",\"1\",\"2\",\"1\",\"1\"]]"], ["[[\"2\",\"1\",\"1\",\"1\",\"2\"]]"], ["[[\"1\",\"2\",\"3\",\"3\",\"3\"]]"], ["[[\"1\",\"1\",\"1\",\"1\",\"2\",\"2\",\"2\"]]"], ["[[\"1\",\"2\",\"1\"],[\"2\",\"1\",\"2\"],[\"1\",\"2\",\"1\"]]"], ["[[\"4\",\"4\",\"4\",\"1\"],[\"2\",\"3\",\"2\",\"1\"],[\"2\",\"2\",\"2\",\"1\"]]"], ["[[\"1\",\"1\",\"1\",\"2\",\"2\"],[\"3\",\"3\",\"3\",\"2\",\"2\"]]"], ["[[\"2\",\"2\",\"3\",\"3\"],[\"2\",\"2\",\"3\",\"3\"]]"], ["[[\"1\",\"2\",\"3\",\"4\",\"5\"]]"], ["[[\"1\"],[\"2\"],[\"3\"],[\"3\"],[\"3\"]]"], ["[[\"5\",\"1\",\"5\",\"1\",\"5\"]]"], ["[[\"2\",\"2\",\"2\",\"2\",\"2\"]]"]], "expected": [["0002", "0322", "0231"], ["123", "456"], ["000"], ["1"], ["11"], ["0", "0", "0"], ["11000"], ["12121"], ["000", "000", "000"], ["000", "000", "000"], ["0000", "1230", "1230"], ["0302", "0102", "0201"], ["12", "34"], ["0000"], ["0", "0", "0", "0"], ["10001"], ["11211"], ["20002"], ["12000"], ["0000000"], ["121", "212", "121"], ["0000", "0000", "2320"], ["00022", "00022"], ["2233", "2233"], ["12345"], ["0", "0", "0", "1", "2"], ["51515"], ["00000"]], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "241", "slug": "candy", "id": 241, "title": "Candy", "difficulty": "Hard", "category": "greedy", "link": "https://leetcode.com/problems/candy/", "examples": [{"input": "ratings = [1,0,2]", "output": "5", "explanation": "You can allocate to the first, second and third child with 2, 1, 2 candies respectively."}, {"input": "ratings = [1,2,2]", "output": "4", "explanation": "You can allocate to the first, second and third child with 1, 2, 1 candies respectively."}], "hints": ["Start by giving every child one candy.", "A left-to-right pass fixes the left neighbor requirement: if ratings[i] > ratings[i-1], give child i more than child i-1.", "A right-to-left pass fixes the right neighbor requirement; take the max of the two passes for each child."], "statement": "`n` youngsters form a single queue.\n\nAn integer array `ratings` assigns each youngster a score.\n\nSweets are handed out under both of these stipulations:\n\n- Every youngster collects at least one sweet.\n- Whenever one youngster's score exceeds an immediate neighbour's score, the higher-scored youngster collects strictly more sweets than that neighbour.\n\nReport the least total quantity of sweets sufficient to satisfy the whole queue.\n\n**Constraints:**\n\n- `1 <= n == ratings.length <= 5 * 10^4`\n- `0 <= ratings[i] <= 5 * 10^4`\n", "solution": "## Approach\n\nGive every child one candy, then run two passes. A left-to-right pass guarantees that a child with a higher rating than the child on their left receives more candies. A right-to-left pass guarantees the same toward the right. The candy count for each child is the maximum produced by the two passes, and summing those counts gives the minimum total.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where `n` is `ratings.length`.\n- **Space Complexity:** O(n) for the candies array.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def candy(self, ratings: List[int]) -> int:\n n = len(ratings)\n candies = [1] * n\n for i in range(1, n):\n if ratings[i] > ratings[i - 1]:\n candies[i] = candies[i - 1] + 1\n for i in range(n - 2, -1, -1):\n if ratings[i] > ratings[i + 1]:\n candies[i] = max(candies[i], candies[i + 1] + 1)\n return sum(candies)\n```", "starter": {"go": "package main\n\nfunc Candy(ratings []int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def candy(self, ratings: List[int]) -> int:\n ", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int candy(vector<int>& ratings) {\n \n }\n};"}, "fn": "candy", "params": [{"name": "ratings", "type": "int_array"}], "outputType": "int", "tests": [["[1,0,2]"], ["[1,2,2]"], ["[1,2,3]"], ["[3,2,1,0]"], ["[1]"], ["[0]"], ["[5,5,5,5,5]"], ["[1,0,2,3,4,1,1,2,3,4]"], ["[2,1,2]"], ["[4,3,2,1]"], ["[1,2,3,4,5]"], ["[1,3,2,2,1]"], ["[1,2,3,2,1]"], ["[1,2,3,4,3,2,1]"], ["[10,20,30,20,10,0,5]"], ["[50000,0,49999,1,49998,2]"], ["[1,2,3,4,4,3,2,1]"], ["[3,1,3,1,3]"], ["[1,1]"], ["[2,2,1]"], ["[1,2,2,1]"], ["[1,3,4,5,2]"], ["[5,4,3,2,1,2,3]"], ["[1,2,3,3,3,2,1]"], ["[2,4,2,6,1,7,8,9,2,1]"], ["[1,0,0,1]"], ["[0,1,2,5,3,2,0]"], ["[100,90,80,70,60,50]"], ["[1,2,3,4,5,4,3,2,1,0]"], ["[3,2,2,3]"], ["[1,5,2,5,1]"], ["[2,1]"]], "expected": [5, 4, 6, 10, 1, 1, 5, 23, 5, 10, 15, 7, 9, 16, 15, 9, 20, 8, 2, 4, 6, 11, 20, 13, 19, 6, 16, 21, 31, 6, 7, 3], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "187", "slug": "capacity-to-ship-packages-within-d-days", "id": 187, "title": "Capacity To Ship Packages Within D Days", "difficulty": "Medium", "category": "binary-search", "link": "https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/", "examples": [{"input": "weights = [1,2,3,4,5,6,7,8,9,10], days = 5", "output": "15", "explanation": "Capacity 15 ships as [1,2,3,4,5],[6,7],[8],[9],[10] in 5 days; 14 needs 6 days."}, {"input": "weights = [3,2,2,4,1,4], days = 3", "output": "6", "explanation": "Capacity 6 ships as [3,2],[2,4],[1,4] in 3 days; 5 needs 4 days."}, {"input": "weights = [1,2,3,1,1], days = 4", "output": "3", "explanation": "Capacity 3 ships as [1,2],[3],[1],[1] in 4 days."}], "hints": ["For a fixed capacity, greedily fill each day and count how many days are needed.", "Feasibility is monotone: if capacity C works, every larger capacity works.", "Binary-search between max(weights) and sum(weights)."], "statement": "A conveyor belt has packages with weights `weights[i]`. Each day, packages\nare loaded onto the ship in the given order, without exceeding the ship's\ncapacity. Given `weights` and `days`, return the least ship capacity that\nallows all packages to be shipped within `days` days.\n\n**Constraints:**\n\n- `1 <= days <= weights.length <= 5 * 10^4`\n- `1 <= weights[i] <= 500`\n", "solution": "## Approach\n\nBinary-search the answer between `max(weights)` and `sum(weights)`.\nFor a candidate capacity, greedily pack packages in order and count the\ndays needed; this test is monotone, so the smallest feasible capacity is\nthe lower bound of the feasible suffix.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log(sum - max))\n- **Space Complexity:** O(1)\n\n## Implementation\n\n```python\nfrom typing import List\n\n\nclass Solution:\n def shipWithinDays(self, weights: List[int], days: int) -> int:\n def can_ship(capacity: int) -> bool:\n used, load = 1, 0\n for w in weights:\n if load + w > capacity:\n used += 1\n load = w\n else:\n load += w\n return used <= days\n\n low, high = max(weights), sum(weights)\n while low < high:\n mid = low + (high - low) // 2\n if can_ship(mid):\n high = mid\n else:\n low = mid + 1\n return low\n```\n", "starter": {"go": "package main\n\nfunc ShipWithinDays(weights []int, days int) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def shipWithinDays(self, weights: List[int], days: int) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int shipWithinDays(vector<int>& weights, int days) {\n return 0;\n }\n};"}, "fn": "shipWithinDays", "params": [{"name": "weights", "type": "int_array"}, {"name": "days", "type": "int"}], "outputType": "int", "tests": [["[1,2,3,4,5,6,7,8,9,10]", "5"], ["[3,2,2,4,1,4]", "3"], ["[1,2,3,1,1]", "4"], ["[1]", "1"], ["[1,2,3,4,5]", "1"], ["[1,2,3,4,5]", "5"], ["[10,50,100,100,50,100,100,100]", "4"], ["[500,500,500,500,500]", "2"], ["[1,2,3,4,5,6,7,8,9,10]", "10"], ["[1,2,3,4,5,6,7,8,9,10]", "1"], ["[5,5,5,5,5]", "3"], ["[2,3,1,2,4,3]", "3"], ["[7,2,5,10,8]", "2"], ["@javascript:JSON.stringify(Array(1000).fill(500))", "50"], ["@javascript:JSON.stringify(Array.from({length:5000},(_,i)=>(i%500)+1))", "100"], ["[5]", "1"], ["[2,2,2,2]", "2"], ["[1,1,1,1,1]", "5"], ["[1,1,1,1,1]", "1"], ["[10,20,30]", "2"], ["[3,3,3,3,3,3]", "4"], ["[100,200,300,400]", "2"], ["[1,10,100,10,1]", "3"], ["[5,4,3,2,1]", "2"], ["[500]", "1"], ["[250,250,250,250]", "4"], ["[250,250,250,250]", "1"], ["[50,50,50,50,50,50,50]", "3"], ["[1,2,3,4,5,6]", "3"], ["[10,10,10,10,10]", "2"], ["[7,7,7,7,7,7,7]", "5"], ["[100,100,100]", "3"]], "expected": [15, 6, 3, 1, 15, 5, 200, 1500, 10, 55, 10, 6, 18, 10000, 12675, 5, 4, 1, 5, 30, 6, 600, 100, 9, 500, 250, 1000, 150, 9, 30, 14, 100], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "83", "slug": "car-fleet", "id": 83, "title": "Car Fleet", "difficulty": "Medium", "category": "stack", "link": "https://leetcode.com/problems/car-fleet/", "examples": [{"input": "target = 12, position = [10,8,0,5,3], speed = [2,4,1,1,3]", "output": "3", "explanation": "There are 3 fleets."}, {"input": "target = 10, position = [3], speed = [3]", "output": "1", "explanation": "There is 1 fleet."}, {"input": "target = 100, position = [0,2,4], speed = [4,2,1]", "output": "1", "explanation": "There is 1 fleet."}], "hints": ["Process cars from the one closest to the target to the one farthest away.", "A car starts a new fleet only when its arrival time is greater than the slowest fleet time ahead of it."], "statement": "`n` automobiles head toward a finish line posted at mile marker `target`.\nAutomobile `i` begins at `position[i]` and maintains the fixed pace `speed[i]`.\n\nA quicker automobile is allowed to close the gap to a slower one ahead yet is forbidden from overtaking.\nAll automobiles that rendezvous collapse into a single convoy that proceeds onward at the pace of its slowest member.\nAn automobile merging into a convoy precisely upon crossing the finish line counts as part of that convoy.\n\nCount how many separate convoys cross the finish line.\n\n**Constraints:**\n\n- `1 <= position.length == speed.length <= 100000`\n- `1 <= target <= 1000000`\n- `0 <= position[i] < target`\n- All positions are unique.\n- `1 <= speed[i] <= 1000000`\n", "solution": "## Approach\n\nProcess cars from the position closest to the target to the farthest. Track the\narrival time of the slowest fleet ahead; a car creates a new fleet only when\nits arrival time is greater. Compare arrival-time fractions by cross\nmultiplication to avoid floating-point precision issues.\n\n## Complexity Analysis\n\n- **Time Complexity:** `O(n log n)` for sorting the cars by position.\n- **Space Complexity:** `O(n)` for the sorted indices.\n\n## Implementation\n\n```python\nfrom typing import List\n\n\nclass Solution:\n def carFleet(self, target: int, position: List[int], speed: List[int]) -> int:\n order = sorted(range(len(position)), key=position.__getitem__, reverse=True)\n fleets = 0\n fleet_distance = 0\n fleet_speed = 1\n for index in order:\n distance = target - position[index]\n if fleets == 0 or distance * fleet_speed > fleet_distance * speed[index]:\n fleets += 1\n fleet_distance = distance\n fleet_speed = speed[index]\n return fleets\n```\n", "starter": {"go": "package main\n\nfunc CarFleet(target int, position []int, speed []int) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def carFleet(self, target: int, position: List[int], speed: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int carFleet(int target, vector<int>& position, vector<int>& speed) {\n return 0;\n }\n};"}, "fn": "carFleet", "params": [{"name": "target", "type": "int"}, {"name": "position", "type": "int_array"}, {"name": "speed", "type": "int_array"}], "outputType": "int", "tests": [["12", "[10,8,0,5,3]", "[2,4,1,1,3]"], ["10", "[3]", "[3]"], ["100", "[0,2,4]", "[4,2,1]"], ["10", "[6,8]", "[3,2]"], ["12", "[10,8,6]", "[1,2,3]"], ["10", "[0,2,4,6,8]", "[1,1,1,1,1]"], ["20", "[19,0,10,5,15]", "[1,20,2,4,1]"], ["1000", "[0,9,18,27,36,45,54,63,72,81,90,99,108,117,126,135,144,153,162,171,180,189,198,207,216,225,234,243,252,261,270,279,288,297,306,315,324,333,342,351,360,369,378,387,396,405,414,423,432,441,450,459,468,477,486,495,504,513,522,531,540,549,558,567,576,585,594,603,612,621,630,639,648,657,666,675,684,693,702,711,720,729,738,747,756,765,774,783,792,801,810,819,828,837,846,855,864,873,882,891]", "[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]"], ["408", "[58,271,314,350,326,52,360,384,244,43,370,145,14,367,68,305,139,231,35,341,8,285]", "[45,32,13,2,15,22,41,32,41,24,5,22,27,26,33,48,19,40,45,34,25,38]"], ["415", "[31,308,97,401,85,240,310,349,44,241,196,144,28,139,300,83,122,206,47,5,45,225,161,102,11,153,222,132]", "[6,11,44,19,48,17,2,33,14,15,48,27,8,43,22,47,16,23,30,49,50,19,44,27,50,11,14,33]"], ["347", "[15,327,230,344,235,288,220,203,11,156,244,222,149,185,300,104,188,45,31,243,249,129,193]", "[30,39,8,1,30,17,30,27,24,33,6,45,30,25,20,41,2,5,2,11,4,1,50]"], ["761", "[384,587,56,28,75,754,641,331,652,530,739,328,302,453,451,546,490,556,435,228,610,454,195,47,295,423]", "[47,32,33,44,19,22,29,30,29,44,35,16,37,44,15,28,23,26,27,20,13,36,29,30,21,46]"], ["887", "[608,557,266,291,738,507,769,702,274,559,736,488,690,121,357,746,155,872,514,230,783,244,287,19,555,705,431,449]", "[47,32,47,46,29,12,15,14,7,12,13,46,27,42,41,28,3,20,1,50,43,42,15,46,31,50,31,28]"], ["648", "[194,17,311,112,483,526,533,572]", "[14,27,36,41,38,39,2,37]"], ["770", "[397,48,663,338,665,192,257,118,725,334,477,156,567,304,229,459,657,340,157,152,133,562,113,250,573,52,49,384,310]", "[25,12,29,18,1,24,45,40,21,44,19,20,15,36,45,12,27,10,11,6,13,30,29,12,49,34,29,20,15]"], ["349", "[10,11,62,83,321,281,126,155,284,44,70,116,217,311,16,325,323,318,209,292,82,3,23,282,59,211,225]", "[35,26,3,2,13,48,21,18,37,20,41,44,31,2,37,48,3,50,21,42,49,44,37,48,27,4,17]"], ["940", "[455,880,47,501,166,876,545]", "[49,46,37,4,7,18,19]"], ["756", "[363,589,267,2,432,274,189]", "[1,12,9,8,13,12,45]"], ["409", "[304,166,325,187,184,33,397]", "[47,6,21,38,9,24,35]"], ["593", "[101,390,451,421,238,153,49,89,232,407,124,355,233,550,335,476,133,324,500,66,299,21,54]", "[49,18,33,28,3,38,49,46,11,42,7,4,29,50,19,18,43,14,7,50,45,10,11]"], ["80", "[29,36,73,22,51]", "[45,10,41,48,41]"], ["129", "[128,9,99]", "[11,14,39]"], ["514", "[191,379,0,497,137,66,178,375,481,450,187,108,27,412,391,262,411,254,316]", "[29,20,23,10,27,24,23,22,41,48,21,20,15,42,31,26,45,20,35]"], ["375", "[7,206,120,12,36,183,257,373,279]", "[7,32,7,16,31,6,29,8,13]"], ["587", "[67,2,510,276,144,37,549,464,60,370,115,329,334]", "[13,20,17,8,33,40,39,44,31,26,45,48,33]"], ["145", "[47,135,11,35,31,109,122,43,106,143,117,6,42,91,32,129,120,93,114,57,65]", "[32,7,32,7,8,25,14,11,32,9,10,27,40,23,44,9,32,37,6,25,40]"], ["506", "[174,334,169,32,271,449,488,316,42,336,349,286,415,473,152,448,289,11,269,136]", "[39,40,11,38,9,14,49,44,3,48,1,40,25,18,9,26,27,4,1,26]"], ["590", "[113,514,309,508]", "[14,9,6,1]"], ["513", "[57,161,257,223,30,199,460,321,202,463,64,158,430,392,59,63,506,320,358,18,413,435,189]", "[35,28,17,38,29,16,15,42,21,38,13,34,3,30,49,28,5,10,31,6,41,36,29]"], ["451", "[100,95,48,215,307,69,247,336,149]", "[4,47,50,49,38,9,8,23,18]"], ["873", "[317,141,538,848,103,260,206,863,211,770,472,368,129,75,291,731,67,680,20,717,357,667,90,374,12,156]", "[40,9,18,45,50,33,10,47,48,27,14,41,42,49,38,39,46,17,28,1,48,27,50,35,26,25]"], ["880", "[331]", "[35]"], ["423", "[17,143,212,254,82,53,208,236,15,79,359,71,393,324,99,98,55]", "[36,11,28,47,20,39,20,39,2,31,42,1,40,33,22,25,44]"], ["703", "[129,123,548,223,395,132,116,246,84,590,331,202,582,700,680,133]", "[16,15,20,37,38,5,24,35,12,21,28,15,34,25,50,33]"], ["417", "[326,408,199,292,72,13,21,375,262]", "[37,32,43,46,7,34,27,16,1]"], ["495", "[211,383,343,130,206,193,396,402,393,73,302,195,238,167,306,80,480,275,257]", "[21,22,1,32,49,12,25,4,13,2,19,30,47,38,25,6,11,36,11]"], ["681", "[475,239,38,340,334,679,617,481,631,71,634,616,13,423,331,61,188,149,76,7,168,238,413,255,416,300,92]", "[37,26,43,4,49,16,31,6,19,48,31,16,49,48,27,48,35,28,9,8,39,46,43,6,39,20,45]"], ["916", "[823,291,537,762,553,296,336,577,817,759,48,790,430,85,580,103,735,136,910]", "[9,24,11,40,25,28,31,16,43,28,15,36,21,14,1,44,31,42,13]"], ["465", "[43,361,235,272,28,97,0,150,103,258,138,252,368,349,162,399,182,242,35,230,355,359,90,407,37,133,389,163,445]", "[39,20,31,44,25,22,39,12,37,6,17,24,21,6,35,6,15,8,39,10,17,34,19,28,33,46,17,30,15]"], ["154", "[71,44,45,105,147,145,102,54,47,72,110,111,126,26,138,53,82,51,115,68,19,17,80,123,89,134,124]", "[34,15,24,35,24,21,50,15,44,11,28,25,30,13,36,7,48,7,36,11,32,25,40,25,10,5,8]"], ["616", "[602,523,517,511,439,501,233,600,35,102,86,121,429,427,114,420,567,194,569,592,220,240,414,532]", "[26,5,14,45,34,29,24,7,44,3,48,33,44,41,22,1,18,9,34,25,20,13,46,39]"], ["407", "[371,161,78,393,280,64,390,112,322,136,354,41,237,398,114,294,331,55,303,321,63,263,201,14,170]", "[34,7,26,1,32,17,26,13,46,45,2,3,48,39,24,15,46,7,12,21,14,9,34,7,18]"], ["863", "[539,854,418,569,298,713,58,772,503,145,614,402,16,775,408,94,118,179,27,485,132,263,620,108,116,855]", "[40,33,40,35,28,39,26,33,4,19,36,15,8,27,42,27,44,39,24,39,2,41,16,13,38,29]"], ["808", "[651,281,360,807,6,643,141,556,425,751,541,230,410,696,604,538,747]", "[21,30,31,10,7,30,25,34,5,28,29,14,11,44,33,2,15]"], ["743", "[463]", "[7]"], ["838", "[375,257,751,792,346]", "[47,6,23,4,41]"], ["298", "[44,15,250,146,20,187,12,28,10,181,256,183,188,275,254,80,204,241,213,45,6,139,273,297,13,88,61,99,236]", "[8,3,18,29,36,13,10,43,16,9,16,35,22,31,14,43,50,25,10,39,30,5,18,29,30,1,14,35,12]"], ["195", "[85,48,154,71,99,141,32,113,67,17,139,46,182,58,60,41,119,38,126,109]", "[6,5,20,11,14,9,48,25,30,35,8,31,42,11,26,1,12,47,6,17]"], ["594", "[441,151,527,200,73,560,105,482,75,254,162,290,323,420,219,56,565]", "[3,24,25,30,5,34,33,22,25,14,17,34,45,30,35,22,35]"], ["506", "[191,444,53,493,321,56,28]", "[27,38,39,42,5,48,21]"], ["880", "[595,685,184,22,679]", "[3,42,9,12,39]"], ["382", "[311,96,183,42,350,106,197,73,245,2,200,135,163,150,191]", "[43,10,5,44,23,2,25,4,21,32,45,18,45,30,7]"], ["836", "[191,665,292,339,517,49,273,523,739,394,352,782,504,376,114,291,314]", "[21,40,21,44,15,26,21,8,11,28,37,6,43,36,9,50,17]"], ["103", "[57,90,37,31,53,86,48,62,5,97,88,18,25,15,70,4,83,30,74,52,44,28,102,64,7,98,59]", "[33,36,29,34,21,48,3,40,35,50,41,24,1,14,43,38,35,16,23,50,5,30,33,40,17,20,45]"], ["403", "[34,184,249,212,217,320,13,95,201,61,87,49,375,294,354,14,353,293,179,268,48]", "[44,37,22,7,10,37,48,39,44,3,10,41,42,27,18,31,6,7,2,27,8]"], ["525", "[401,482,217,323,396,520,55,210,415,227,120,144,518,257]", "[4,9,34,33,6,27,46,33,6,19,2,7,24,17]"], ["816", "[785,593,141,143,182,549,464,601,635,215,644,408,195,210,588,554,490,526,263]", "[13,50,23,8,33,22,37,20,27,48,17,42,41,10,15,50,33,38,45]"], ["506", "[409]", "[47]"], ["224", "[215,91,159,12,67,203,88,9,49,114,157,166,0,8,101,42,13,7,58,30,65,180,124]", "[35,8,21,30,7,4,5,18,37,50,3,6,1,20,33,26,23,28,27,6,13,12,37]"], ["47", "[8,42,6,3,37,7,40,36,32,35,26,44,22,11,30,12,34,15,14,4,27]", "[18,19,46,45,42,1,34,3,28,27,26,15,22,29,50,49,44,5,10,3,16]"], ["1", "[0]", "[1]"], ["1000000", "@javascript:JSON.stringify(Array.from({length:25000},(_,i)=>i*40))", "@javascript:JSON.stringify(Array.from({length:25000},(_,i)=>i===0?1000000:1+i%1000))"]], "expected": [3, 1, 1, 2, 1, 5, 2, 20, 3, 4, 5, 9, 7, 2, 2, 5, 5, 3, 5, 4, 3, 3, 9, 5, 5, 7, 5, 2, 5, 3, 4, 1, 9, 8, 4, 4, 6, 3, 5, 9, 5, 6, 6, 6, 1, 3, 11, 8, 6, 3, 3, 7, 3, 10, 8, 7, 6, 1, 7, 5, 1, 1023], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "205", "slug": "car-pooling", "id": 205, "title": "Car Pooling", "difficulty": "Medium", "category": "heap", "link": "https://leetcode.com/problems/car-pooling/", "examples": [{"input": "trips = [[2,1,5],[3,3,7]], capacity = 4", "output": "false", "explanation": "At kilometer 1, 2 passengers are picked up, so the car holds 2."}, {"input": "trips = [[2,1,5],[3,3,7]], capacity = 5", "output": "true", "explanation": "At kilometer 1, the car holds 2 passengers."}], "hints": ["Sort the pickup and dropoff events by location, then process them in order.", "Use a difference array: add passengers at `from`, subtract them at `to`, then sweep over all locations.", "Passengers always drop off at `to` before others pick up at the same location, so subtract before adding at equal positions."], "statement": "A vehicle with `capacity` vacant seats travels exclusively eastward (reversing toward the west is impossible).\n\nA manifest `trips` describes the itinerary, where `trips[i] = [numPassengers[i], from[i], to[i]]` means booking `i` boards `numPassengers[i]` riders at kilometre `from[i]` east of the start and alights them at kilometre `to[i]` east of the start.\n\nWhenever boarding and alighting coincide at one kilometre, alighting completes first.\nAlong the entire journey the headcount aboard must never surpass `capacity`.\n\nDecide whether every booking can be honoured: return `true` when feasible, `false` otherwise.\n\n**Constraints:**\n\n- `1 <= trips.length <= 1000`\n- `trips[i].length == 3`\n- `1 <= numPassengers[i] <= 100`\n- `0 <= from[i] < to[i] <= 1000`\n- `1 <= capacity <= 10^5`\n", "solution": "## Approach\n\nUse a difference array over the 1001 possible kilometer positions (the maximum `to` position is 1000). For every trip add its passengers at `from` and subtract them at `to`. Then sweep mile by mile, accumulating the running passenger count; if it ever exceeds `capacity`, return `false`. Because drops and pickups at the same location resolve to drop-off first, subtracting at `to` before later pickups at the same index is automatically correct in the sweep.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n + L), where `n` is `trips.length` and `L = 1001` is the fixed number of locations.\n- **Space Complexity:** O(1), since the difference array has a fixed size of 1001.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def carPooling(self, trips: List[List[int]], capacity: int) -> bool:\n delta = [0] * 1001\n for passengers, start, end in trips:\n delta[start] += passengers\n delta[end] -= passengers\n onboard = 0\n for change in delta:\n onboard += change\n if onboard > capacity:\n return False\n return True\n```", "starter": {"go": "package main\n\nfunc CarPooling(trips [][]int, capacity int) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def carPooling(self, trips: List[List[int]], capacity: int) -> bool:\n ", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n bool carPooling(vector<vector<int>>& trips, int capacity) {\n \n }\n};"}, "fn": "carPooling", "params": [{"name": "trips", "type": "int_array_2d"}, {"name": "capacity", "type": "int"}], "outputType": "boolean", "tests": [["[[2,1,5],[3,3,7]]", "4"], ["[[2,1,5],[3,3,7]]", "5"], ["[[2,1,5],[3,5,7]]", "3"], ["[[3,2,7],[3,7,9],[8,3,9]]", "11"], ["[[1,0,5]]", "1"], ["[[2,0,5]]", "1"], ["[[9,0,1],[3,3,7]]", "4"], ["[[10,0,1000]]", "10"], ["[[10,0,1000]]", "9"], ["[[5,0,1],[5,1,2],[5,2,3]]", "5"], ["[[5,0,1],[5,1,2],[5,2,3]]", "4"], ["[[4,5,6],[6,4,7],[7,3,8],[8,2,9]]", "30"], ["[[4,5,6],[6,4,7],[7,3,8],[8,2,9]]", "18"], ["[[1,1,2],[2,1,3],[3,1,4]]", "6"], ["[[1,1,2],[2,1,3],[3,1,4]]", "5"], ["[[100,0,2],[100,1,3],[100,2,4]]", "200"], ["[[100,0,2],[100,1,3],[100,2,4]]", "100"], ["[[2,1,5],[3,3,7],[4,4,6]]", "6"], ["[[2,1,5],[3,3,7],[4,4,6]]", "5"], ["[[1,2,3],[1,5,6],[1,6,7]]", "2"], ["[[1,0,1]]", "1"], ["[[2,0,2],[2,0,2]]", "4"], ["[[2,0,2],[2,0,2]]", "3"], ["[[1,0,10],[2,0,10],[3,0,10]]", "6"], ["[[1,0,10],[2,0,10],[3,0,10]]", "5"], ["[[3,0,5],[2,5,10]]", "3"], ["[[100,500,600]]", "100"], ["[[100,500,600]]", "99"], ["[[1,999,1000]]", "1"], ["[[2,998,1000],[2,999,1000]]", "4"], ["[[2,998,1000],[2,999,1000]]", "3"], ["[[1,0,1000],[1,0,1000],[1,0,1000]]", "3"]], "expected": [false, true, true, true, true, false, false, true, false, true, false, true, false, true, false, true, false, false, false, true, true, true, false, true, false, true, true, false, true, true, false, true], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "820", "slug": "card-flipping-game", "id": 820, "title": "Card Flipping Game", "difficulty": "Medium", "category": "hash-table", "link": "https://leetcode.com/problems/card-flipping-game/", "examples": [{"input": "fronts = [1,2,4,4,7], backs = [1,3,4,1,3]", "output": "2", "explanation": "Values 1 and 4 each appear on both sides of some card and are disqualified; the smallest remaining value is 2."}, {"input": "fronts = [1], backs = [1]", "output": "0", "explanation": "The only value is double-sided on its card, so no good number exists."}, {"input": "fronts = [2,3], backs = [4,5]", "output": "2", "explanation": "No card shows the same value twice, so the minimum of all faces wins."}], "hints": ["A value appearing on both faces of any single card can never be the hidden answer.", "Collect those forbidden values, then take the minimum over all faces not in the set (0 when empty)."], "statement": "There are cards with a number on the front and a (possibly different) number on the back. In one move you may flip any card over. After any sequence of flips, look at the upward faces: a value is called good when no upward face equals that value on a downward face of the same card \u2014 equivalently, the value never sits on a card whose two sides are both that value after hiding? The working rule is simpler: any value that occupies both sides of at least one card is permanently disqualified, because that card always shows it on one side.\n\nFind the smallest good value among all numbers appearing on either side. Return 0 when every value is disqualified.\n\nAdaptation note: this task uses portable `int_array` inputs and an `int` output.\n\n**Constraints:**\n- `1 <= fronts.length == backs.length <= 1000`\n- `1 <= fronts[i], backs[i] <= 2000`\n", "solution": "## Approach\n\nScan the cards once and mark every value that appears on both faces of the same card as forbidden: such a card exposes that value no matter how it is flipped. Then scan all front and back faces and keep the smallest value not in the forbidden set. When everything is forbidden, return 0.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) for n cards.\n- **Space Complexity:** O(n) for the forbidden set in the worst case.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def flipgame(self, fronts: List[int], backs: List[int]) -> int:\n bad = {f for f, b in zip(fronts, backs) if f == b}\n ans = 10 ** 9\n for v in fronts + backs:\n if v not in bad and v < ans:\n ans = v\n return 0 if ans == 10 ** 9 else ans\n```\n", "starter": {"go": "package main\n\nfunc Flipgame(fronts []int, backs []int) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def flipgame(self, fronts: List[int], backs: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int flipgame(vector<int>& fronts, vector<int>& backs) {\n return 0;\n }\n};"}, "fn": "flipgame", "params": [{"name": "fronts", "type": "int_array"}, {"name": "backs", "type": "int_array"}], "outputType": "int", "tests": [["[1,2,4,4,7]", "[1,3,4,1,3]"], ["[1]", "[1]"], ["[2,3]", "[4,5]"], ["[1]", "[2]"], ["[5,5,5]", "[5,5,5]"], ["[1,2,3]", "[1,2,3]"], ["[1,2,3]", "[4,5,6]"], ["[7,7,1]", "[7,2,2]"], ["[2,2,2]", "[3,3,3]"], ["[10,20]", "[20,10]"], ["[3,1,2]", "[3,3,3]"], ["[1,2]", "[2,1]"], ["[4,4,4]", "[1,2,3]"], ["[2000,1]", "[1,2000]"], ["[6,6]", "[6,7]"], ["[8,9,10]", "[11,12,13]"], ["[1,3,5]", "[2,4,6]"], ["[5,4,3,2,1]", "[1,2,3,4,5]"], ["[9,9,9,1]", "[9,8,7,2]"], ["[100,100]", "[1,2]"], ["[2,4,6,8]", "[2,4,6,8]"], ["[3,3,4,4]", "[5,6,5,6]"], ["[1,5,1]", "[5,1,5]"], ["[7,3,9]", "[1,3,2]"], ["[12,34]", "[56,78]"], ["[1,1,2]", "[2,2,1]"], ["[4,5]", "[4,6]"], ["[11,22,33]", "[44,55,66]"]], "expected": [2, 0, 2, 1, 0, 0, 1, 1, 2, 10, 1, 1, 1, 1, 7, 8, 1, 1, 1, 1, 0, 3, 1, 1, 12, 1, 5, 11], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "901", "slug": "cat-and-mouse", "id": 901, "title": "Cat and Mouse", "difficulty": "Hard", "category": "graph", "link": "https://leetcode.com/problems/cat-and-mouse/", "examples": [{"input": "graph = [[2,5],[3],[3,4,5],[1,2],[2],[0,2]]", "output": "0", "explanation": "With perfect play neither side can force a win, so the game is a draw."}, {"input": "graph = [[1,3],[0],[3],[0,2]]", "output": "1", "explanation": "The mouse starts next to the hole and steps into it on the first move."}, {"input": "graph = [[1],[0,2],[1,3],[2]]", "output": "2", "explanation": "The cat cuts off the only path, so the mouse is caught."}], "hints": ["Model each situation as (mouse node, cat node, whose turn) and work backwards from positions whose outcome is known.", "The mouse reaching node 0 is a mouse win; both players landing together is a cat win.", "A player picks a winning move when one exists, otherwise they delay; positions that never resolve are draws."], "statement": "An undirected graph is given as adjacency lists `graph`, where `graph[i]` holds the neighbors of node `i`. The mouse starts on node `1`, the cat on node `2`, and node `0` is the hole. Play alternates with the mouse moving first:\n\n- The mouse wins instantly by stepping onto node `0`.\n- The cat wins instantly by stepping onto the mouse's node.\n- The cat is never allowed to enter node `0`; it must pick another neighbor (every test graph gives the cat a legal move).\n- If both sides play on forever with no forced win, the result is a draw.\n\nReturn `1` when the mouse can force a win, `2` when the cat can force a win, and `0` for a draw under optimal play.\n\n**Constraints:**\n- `4 <= graph.length <= 50`\n- Every neighbor list is non-empty and every neighbor index is valid\n- Node `0` is reachable and the cat always has a move outside node `0`\n\nNote: the graph is passed as plain nested integer arrays (adjacency lists), which is the supported input encoding for this game.\n", "solution": "## Approach\n\nTreat every combination of mouse position, cat position, and player to move as a game state. Terminal states are known at once: mouse on the hole wins for the mouse, shared nodes win for the cat. Then propagate backwards: a player whose turn it is claims a state when any move leads to their win, while a state becomes a loss only after every legal move (cat moves into the hole are excluded) leads to the opponent's win. States never decided correspond to infinite evasion, i.e. draws.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^3) for n nodes, since there are O(n^2) position pairs times 2 turns, each processed over its graph edges.\n- **Space Complexity:** O(n^2) for the outcome and remaining-move tables.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import deque\nclass Solution:\n def catAndMouse(self, graph: List[List[int]]) -> int:\n n = len(graph)\n color = [[[0] * 2 for _ in range(n)] for __ in range(n)]\n degree = [[[0] * 2 for _ in range(n)] for __ in range(n)]\n for m in range(n):\n for c in range(n):\n degree[m][c][0] = len(graph[m])\n degree[m][c][1] = sum(1 for x in graph[c] if x != 0)\n q = deque()\n for c in range(n):\n for t in range(2):\n color[0][c][t] = 1\n q.append((0, c, t))\n if c > 0:\n color[c][c][t] = 2\n q.append((c, c, t))\n while q:\n m, c, t = q.popleft()\n res = color[m][c][t]\n if t == 0:\n for m2 in range(n):\n if m not in graph[m2] or color[m2][c][1] != 0:\n continue\n if res == 1:\n color[m2][c][1] = 1\n q.append((m2, c, 1))\n else:\n degree[m2][c][1] -= 1\n if degree[m2][c][1] == 0:\n color[m2][c][1] = 2\n q.append((m2, c, 1))\n else:\n for c2 in range(1, n):\n if c not in graph[c2] or color[m][c2][0] != 0:\n continue\n if res == 2:\n color[m][c2][0] = 2\n q.append((m, c2, 0))\n else:\n degree[m][c2][0] -= 1\n if degree[m][c2][0] == 0:\n color[m][c2][0] = 1\n q.append((m, c2, 0))\n return color[1][2][0]\n```\n", "starter": {"go": "package main\n\nfunc CatAndMouse(graph [][]int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def catAndMouse(self, graph: List[List[int]]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int catAndMouse(vector<vector<int>>& graph) {\n return 0;\n }\n};"}, "fn": "catAndMouse", "params": [{"name": "graph", "type": "int_array_2d"}], "outputType": "int", "tests": [["[[2,5],[3],[3,4,5],[1,2],[2],[0,2]]"], ["[[1,3],[0],[3],[0,2]]"], ["[[1],[0,2],[1,3],[2]]"], ["[[1, 3], [0, 2], [1, 3], [0, 2]]"], ["[[3, 4], [2, 4], [1, 3], [0, 2], [0, 1]]"], ["[[2, 6], [2, 3, 6], [0, 1, 6], [1, 4], [3, 5], [4, 6], [0, 1, 2, 5]]"], ["[[1, 2, 8], [0, 5, 7], [0, 3, 5], [2, 8], [5, 6], [1, 2, 4], [4, 7], [1, 6, 8], [0, 3, 7]]"], ["[[1, 2, 7], [0, 2, 3], [0, 1, 3], [1, 2, 4], [3, 6, 7], [6, 7], [4, 5], [0, 4, 5]]"], ["[[6, 7], [2, 3, 5, 7], [1, 3, 4, 6], [1, 2, 6], [2, 5, 7], [1, 4], [0, 2, 3, 7], [0, 1, 4, 6]]"], ["[[3, 4, 5], [4, 6], [3, 7], [0, 2, 5], [0, 1, 6, 8], [0, 3, 6, 7, 8], [1, 4, 5], [2, 5, 8], [4, 5, 7]]"], ["[[1, 7], [0, 2, 7], [1, 5, 8], [4, 6, 7], [3, 8], [2, 6], [3, 5, 7], [0, 1, 3, 6, 8], [2, 4, 7]]"], ["[[1, 2, 3], [0, 2], [0, 1, 3], [0, 2]]"], ["[[5, 6], [3, 4], [3, 4, 5], [1, 2, 6], [1, 2, 6], [0, 2], [0, 3, 4]]"], ["[[1, 2], [0, 3], [0, 3], [1, 2]]"], ["[[1, 2, 3, 4], [0, 4], [0, 3, 4], [0, 2, 4], [0, 1, 2, 3]]"], ["[[1, 4], [0, 3], [4, 5], [1, 4, 5], [0, 2, 3], [2, 3]]"], ["[[2, 3], [2, 3], [0, 1], [0, 1]]"], ["[[1, 2], [0, 4], [0, 3], [2, 6], [1, 5], [4, 6], [3, 5]]"], ["[[2, 3], [2, 3], [0, 1], [0, 1]]"], ["[[1, 2], [0, 3], [0, 3], [1, 2]]"], ["[[4, 5], [2, 3, 4], [1, 5], [1, 4], [0, 1, 3], [0, 2]]"], ["[[1, 6], [0, 2, 4], [1, 5], [5, 7], [1, 6, 7], [2, 3], [0, 4], [3, 4]]"], ["[[1, 5], [0, 3], [3, 4], [1, 2], [2, 5], [0, 4]]"], ["[[1, 4], [0, 2], [1, 3], [2, 4], [0, 3]]"], ["[[1, 3], [0, 2], [1, 3], [0, 2]]"], ["[[1, 5], [0, 4, 6], [3, 4, 6], [2, 4], [1, 2, 3], [0, 7], [1, 2, 7], [5, 6]]"], ["[[2, 3], [4, 5], [0, 4, 5], [0, 4], [1, 2, 3], [1, 2]]"], ["[[1, 2, 4, 5], [0, 3, 6], [0, 5], [1, 5], [0, 6], [0, 2, 3], [1, 4]]"]], "expected": [0, 1, 2, 2, 2, 2, 1, 2, 2, 0, 2, 2, 0, 1, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 0, 0], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "808", "slug": "chalkboard-xor-game", "id": 808, "title": "Chalkboard XOR Game", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/chalkboard-xor-game/", "examples": [{"input": "nums = [1,1,2]", "output": "false", "explanation": "The xor of all numbers is 2 (nonzero) and the count is odd, so the first player cannot force erasing everything."}, {"input": "nums = [0,1]", "output": "true", "explanation": "With an even count the first player has a mirroring strategy even though the xor is nonzero."}, {"input": "nums = [1,2,3]", "output": "true", "explanation": "The xor of the whole board is already 0, so the first player wins immediately."}], "hints": ["XOR every entry once: a zero total means the board is already balanced.", "When the total is nonzero, the parity of the length decides the winner: even favors the first player, odd favors the second."], "statement": "Numbers are written on a board. Two players alternate erasing one number at a time. The player who makes the xor of the remaining numbers equal 0 wins immediately; if every number is erased without that happening, the last player to move is declared the winner.\n\nBoth players play perfectly and the first player moves first. Given the starting list `nums`, decide whether the first player can force a win.\n\nIn other words, work out the xor of the whole list and look at its length: a zero xor is an instant win, otherwise an even length still lets the first player force a win while an odd length does not.\n\n**Constraints:**\n- `1 <= nums.length <= 1000`\n- `0 <= nums[i] < 2^16`\n", "solution": "## Approach\n\nCompute the xor of the whole board. A zero value is an immediate win for the player to move. Otherwise the key insight is parity: with an even number of entries the first player can always answer the opponent's move and force the win, while with an odd number the second player mirrors instead. So the answer is true when the xor is zero or the length is even.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) to xor the array once.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def xorGame(self, nums: List[int]) -> bool:\n x = 0\n for v in nums:\n x ^= v\n return x == 0 or len(nums) % 2 == 0\n```\n", "starter": {"go": "package main\n\nfunc XorGame(nums []int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def xorGame(self, nums: List[int]) -> bool:\n return False\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool xorGame(vector<int>& nums) {\n return false;\n }\n};"}, "fn": "xorGame", "params": [{"name": "nums", "type": "int_array"}], "outputType": "boolean", "tests": [["[1,1,2]"], ["[0,1]"], ["[1,2,3]"], ["[0]"], ["[1]"], ["[0,0]"], ["[1,1]"], ["[2,2,2]"], ["[1,2]"], ["[3,3]"], ["[4,1,7]"], ["[0,0,0]"], ["[5,5,5,5]"], ["[1,2,4,8]"], ["[0,0,1]"], ["[7,7,7,7,7]"], ["[10,20,30]"], ["[1,1,1,1,1,1]"], ["[0,1,2,3,4]"], ["[100,200]"], ["[8,8,9]"], ["[15,15,15]"], ["[0,0,0,0]"], ["[1,2,3,4]"], ["[6,6,6,6,6,6,6]"], ["[65535,65535]"], ["[0,0,0,1]"], ["[3,5,7,9,11]"]], "expected": [false, true, true, true, false, true, true, false, true, true, false, true, true, true, false, false, true, true, false, true, false, false, true, true, false, true, true, false], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "797", "slug": "champagne-tower", "id": 797, "title": "Champagne Tower", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/champagne-tower/", "examples": [{"input": "poured = 1, query_row = 1, query_glass = 1", "output": "\"0.0\"", "explanation": "Only the top glass fills."}, {"input": "poured = 2, query_row = 1, query_glass = 1", "output": "\"0.5\"", "explanation": "Half the overflow reaches each glass below."}, {"input": "poured = 4, query_row = 2, query_glass = 1", "output": "\"0.5\"", "explanation": "Two levels of splitting leave half a cup."}], "hints": ["This is a portable adaptation: return the amount as a finite decimal string; the checker allows 1e-9 absolute plus 1e-5 relative error.", "Simulate row by row, pushing half the excess of each full glass to its two children.", "Cap the queried glass at 1.0 before formatting the answer."], "statement": "A tower of champagne glasses is stacked so that row `r` holds `r + 1` glasses. You pour `poured` cups into the top glass. Each glass holds at most one cup; any surplus splits evenly to the two glasses directly below it (half to the lower-left, half to the lower-right). The pouring happens all at once and the liquid keeps flowing downward through full glasses.\n\nGiven `query_row` and `query_glass`, report how full that particular glass ends up, capped at one. Because this judge avoids binary floating types, return the amount as a decimal string such as `\"0.5\"` or `\"1.0\"`; answers within a tiny tolerance are accepted.\n\n**Constraints:**\n- `0 <= poured <= 10^9`\n- `0 <= query_row < 100`\n- `0 <= query_glass <= query_row`\n- This is a portable adaptation: the floating answer is exchanged as a decimal string with tolerance 1e-9 absolute plus 1e-5 relative.\n", "solution": "## Approach\n\nSimulate the pouring level by level with a small table that only needs rows up to the queried one. Each glass keeps at most one cup and forwards half its surplus to each of its two children. The queried entry capped at one is formatted as a decimal string.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(r^2), where r is `query_row` (at most 100).\n- **Space Complexity:** O(r^2) for the simulated triangle.\n\n## Implementation\n\n```python\nclass Solution:\n def champagneTower(self, poured: int, query_row: int, query_glass: int) -> str:\n dp = [[0.0] * (query_row + 2) for _ in range(query_row + 2)]\n dp[0][0] = float(poured)\n for r in range(query_row + 1):\n for c in range(r + 1):\n excess = (dp[r][c] - 1.0) / 2.0\n if excess > 0:\n dp[r + 1][c] += excess\n dp[r + 1][c + 1] += excess\n return str(min(1.0, dp[query_row][query_glass]))\n```\n", "starter": {"go": "package main\n\nfunc ChampagneTower(poured int, query_row int, query_glass int) string {\n return \"\"\n}", "python": "class Solution:\n def champagneTower(self, poured: int, query_row: int, query_glass: int) -> str:\n return \"\"", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n string champagneTower(int poured, int query_row, int query_glass) {\n return \"\";\n }\n};"}, "fn": "champagneTower", "params": [{"name": "poured", "type": "int"}, {"name": "query_row", "type": "int"}, {"name": "query_glass", "type": "int"}], "outputType": "string", "tests": [["1", "1", "1"], ["2", "1", "1"], ["4", "2", "1"], ["0", "0", "0"], ["1", "0", "0"], ["2", "0", "0"], ["3", "1", "0"], ["3", "1", "1"], ["6", "2", "0"], ["6", "2", "1"], ["6", "2", "2"], ["10", "3", "1"], ["10", "4", "2"], ["25", "6", "1"], ["100", "4", "2"], ["100", "10", "5"], ["5", "2", "0"], ["5", "2", "2"], ["8", "3", "0"], ["8", "3", "3"], ["0", "5", "2"], ["1", "99", "50"], ["50", "5", "2"], ["7", "3", "1"], ["7", "3", "2"], ["20", "4", "0"], ["20", "4", "4"], ["1000", "8", "4"]], "expected": ["0.0", "0.5", "0.5", "0.0", "1.0", "1.0", "1.0", "1.0", "0.75", "1.0", "0.75", "1.0", "0.625", "0.1875", "1.0", "1.0", "0.5", "0.5", "0.125", "0.125", "0.0", "0.0", "1.0", "0.5", "0.5", "0.3125", "0.3125", "1.0"], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "126", "slug": "cheapest-flights-within-k-stops", "id": 126, "title": "Cheapest Flights Within K Stops", "difficulty": "Medium", "category": "graph", "link": "https://leetcode.com/problems/cheapest-flights-within-k-stops/", "examples": [{"input": "n = 4, flights = [[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]], src = 0, dst = 3, k = 1", "output": "700", "explanation": "The cheapest price within K stops is 700."}, {"input": "n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 1", "output": "200", "explanation": "The cheapest price within K stops is 200."}, {"input": "n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 0", "output": "500", "explanation": "The cheapest price within K stops is 500."}], "hints": ["At most k stops means at most k + 1 flight edges.", "Run k + 1 rounds of Bellman-Ford relaxation, reading each round from the previous round's distances.", "Do not relax in place: doing so could use more than the permitted number of flights within one round."], "statement": "There are `n` cities labeled from `0` to `n - 1`. Each directed flight\n`flights[i] = [from, to, price]` has the given ticket price.\n\nReturn the cheapest price for a route from `src` to `dst` that uses at most\n`k` intermediate stops. Return `-1` if no such route exists.\n\n**Constraints:**\n\n- `2 <= n <= 100`\n- `0 <= flights.length <= n * (n - 1) / 2`\n- `flights[i].length == 3`\n- `0 <= from, to, src, dst < n`\n- `from != to` and `src != dst`\n- `1 <= price <= 10^4`\n- `0 <= k < n`\n- There are no duplicate directed flights.\n", "solution": "## Approach\n\nAt most `k` intermediate stops means at most `k + 1` flight edges. Perform `k + 1` Bellman-Ford rounds, cloning the previous costs before each round so every update uses one additional edge at most. The destination remains unreachable if its cost is still infinity after the final round.\n\n## Complexity Analysis\n\n- **Time Complexity:** O((k + 1) * E), where E is the number of flights.\n- **Space Complexity:** O(V) for the current and next cost arrays.\n\n## Implementation\n\n```python\nfrom typing import List\n\n\nclass Solution:\n def findCheapestPrice(\n self, n: int, flights: List[List[int]], src: int, dst: int, k: int\n ) -> int:\n infinity = float(\"inf\")\n cost = [infinity] * n\n cost[src] = 0\n\n for _ in range(k + 1):\n next_cost = cost.copy()\n for source, target, price in flights:\n if cost[source] != infinity:\n next_cost[target] = min(next_cost[target], cost[source] + price)\n cost = next_cost\n\n return -1 if cost[dst] == infinity else cost[dst]\n```\n", "starter": {"go": "package main\n\nfunc FindCheapestPrice(n int, flights [][]int, src int, dst int, k int) int {\n return 0\n}\n", "python": "from typing import List\n\nclass Solution:\n def findCheapestPrice(self, n: int, flights: List[List[int]], src: int, dst: int, k: int) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int findCheapestPrice(int n, vector<vector<int>>& flights, int src, int dst, int k) {\n return 0;\n }\n};"}, "fn": "findCheapestPrice", "params": [{"name": "n", "type": "int"}, {"name": "flights", "type": "int_array_2d", "visualizeType": "directed_weighted_edges", "numNodesRef": "n"}, {"name": "src", "type": "int"}, {"name": "dst", "type": "int"}, {"name": "k", "type": "int"}], "outputType": "int", "tests": [["2", "[[0,1,5]]", "0", "1", "0"], ["2", "[[0,1,5]]", "1", "0", "0"], ["2", "[[1,0,7]]", "1", "0", "1"], ["2", "[[0,1,10000]]", "0", "1", "1"], ["3", "[[0,1,100],[1,2,100],[0,2,500]]", "0", "2", "0"], ["3", "[[0,1,100],[1,2,100],[0,2,500]]", "0", "2", "1"], ["3", "[[0,1,100],[1,2,100],[0,2,500]]", "2", "0", "2"], ["3", "[[0,1,5],[1,2,5]]", "0", "2", "0"], ["3", "[[0,1,5],[1,2,5]]", "0", "2", "1"], ["3", "[[0,1,10],[1,2,10],[2,0,10]]", "1", "0", "1"], ["3", "[[1,0,1],[0,2,20],[1,2,100]]", "1", "2", "1"], ["3", "[[0,2,50],[0,1,20],[1,2,20]]", "0", "2", "1"], ["4", "[[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]]", "0", "3", "1"], ["4", "[[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]]", "0", "3", "2"], ["4", "[[0,1,1],[1,2,1],[2,3,1],[0,3,10]]", "0", "3", "0"], ["4", "[[0,1,1],[1,2,1],[2,3,1],[0,3,10]]", "0", "3", "1"], ["4", "[[0,1,1],[1,2,1],[2,3,1],[0,3,10]]", "0", "3", "2"], ["4", "[[0,1,5],[0,2,2],[2,1,1],[1,3,2],[2,3,10]]", "0", "3", "1"], ["4", "[[0,1,5],[0,2,2],[2,1,1],[1,3,2],[2,3,10]]", "0", "3", "2"], ["4", "[[0,1,3],[1,0,3],[2,3,3],[3,2,3]]", "0", "3", "3"], ["4", "[[3,2,8],[2,1,7],[1,0,6],[3,0,30]]", "3", "0", "2"], ["4", "[[0,1,10],[0,2,10],[1,3,10],[2,3,5],[1,2,1]]", "0", "3", "1"], ["5", "[[0,1,2],[1,2,2],[2,3,2],[3,4,2],[0,4,20]]", "0", "4", "0"], ["5", "[[0,1,2],[1,2,2],[2,3,2],[3,4,2],[0,4,20]]", "0", "4", "2"], ["5", "[[0,1,2],[1,2,2],[2,3,2],[3,4,2],[0,4,20]]", "0", "4", "3"], ["5", "[[0,1,10],[0,2,3],[2,1,3],[1,3,2],[2,3,8],[3,4,1],[1,4,20]]", "0", "4", "1"], ["5", "[[0,1,10],[0,2,3],[2,1,3],[1,3,2],[2,3,8],[3,4,1],[1,4,20]]", "0", "4", "2"], ["5", "[[0,1,10],[0,2,3],[2,1,3],[1,3,2],[2,3,8],[3,4,1],[1,4,20]]", "0", "4", "3"], ["5", "[[0,1,1],[1,0,1],[2,3,1],[3,4,1],[4,2,1]]", "0", "4", "4"], ["5", "[[4,3,4],[3,2,4],[2,1,4],[1,0,4],[4,0,30]]", "4", "0", "3"], ["5", "[[0,1,5],[0,2,6],[0,3,7],[0,4,8]]", "0", "4", "4"], ["6", "[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[0,5,50]]", "0", "5", "3"], ["6", "[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[0,5,50]]", "0", "5", "4"], ["6", "[[0,1,10],[0,2,4],[2,3,4],[3,1,1],[1,4,2],[3,4,8],[4,5,3],[2,5,30]]", "0", "5", "2"], ["6", "[[0,1,10],[0,2,4],[2,3,4],[3,1,1],[1,4,2],[3,4,8],[4,5,3],[2,5,30]]", "0", "5", "4"], ["6", "[[0,1,2],[0,2,2],[1,3,2],[2,3,1],[3,4,2],[4,5,2],[1,5,20]]", "0", "5", "2"], ["6", "[[5,4,5],[4,3,5],[3,2,5],[2,1,5],[1,0,5],[5,0,40]]", "5", "0", "4"], ["6", "[[0,1,1],[1,0,1],[2,3,1],[3,2,1],[4,5,1],[5,4,1]]", "0", "5", "5"], ["7", "[[0,1,3],[1,2,3],[2,3,3],[3,4,3],[4,5,3],[5,6,3],[0,6,30]]", "0", "6", "4"], ["7", "[[0,1,3],[1,2,3],[2,3,3],[3,4,3],[4,5,3],[5,6,3],[0,6,30]]", "0", "6", "5"], ["7", "[[0,1,8],[0,2,2],[2,3,2],[3,1,2],[1,4,2],[4,5,2],[5,6,2],[3,6,20]]", "0", "6", "3"], ["7", "[[0,1,8],[0,2,2],[2,3,2],[3,1,2],[1,4,2],[4,5,2],[5,6,2],[3,6,20]]", "0", "6", "5"], ["7", "[[0,1,5],[0,2,5],[1,3,5],[2,4,1],[3,5,1],[4,5,5],[5,6,1],[2,6,20]]", "0", "6", "2"], ["7", "[[6,5,1],[5,4,2],[4,3,3],[3,2,4],[2,1,5],[1,0,6],[6,0,50]]", "6", "0", "5"], ["8", "[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,6,1],[6,7,1],[0,7,100]]", "0", "7", "5"], ["8", "[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,6,1],[6,7,1],[0,7,100]]", "0", "7", "6"], ["8", "[[0,1,9],[0,2,3],[2,3,3],[3,1,1],[1,4,2],[3,5,5],[4,6,2],[5,6,1],[6,7,2],[2,7,40]]", "0", "7", "3"], ["8", "[[0,1,9],[0,2,3],[2,3,3],[3,1,1],[1,4,2],[3,5,5],[4,6,2],[5,6,1],[6,7,2],[2,7,40]]", "0", "7", "6"], ["10", "[[0,1,2],[1,2,2],[2,3,2],[3,4,2],[4,5,2],[5,6,2],[6,7,2],[7,8,2],[8,9,2],[0,9,50]]", "0", "9", "7"], ["10", "[[0,1,2],[1,2,2],[2,3,2],[3,4,2],[4,5,2],[5,6,2],[6,7,2],[7,8,2],[8,9,2],[0,9,50]]", "0", "9", "8"], ["10", "[[0,1,10],[0,2,4],[2,3,4],[3,1,1],[1,4,3],[3,5,6],[4,6,3],[5,6,1],[6,7,2],[7,8,2],[8,9,2],[2,9,60]]", "0", "9", "5"], ["12", "[[0,1,1],[1,2,2],[2,3,3],[3,4,4],[4,5,5],[5,6,6],[6,7,7],[7,8,8],[8,9,9],[9,10,10],[10,11,11],[0,11,100]]", "0", "11", "10"], ["100", "[[0,1,1],[0,2,10000],[0,3,10000],[0,4,10000],[0,5,10000],[0,6,10000],[0,7,10000],[0,8,10000],[0,9,10000],[0,10,10000],[0,11,10000],[0,12,10000],[0,13,10000],[0,14,10000],[0,15,10000],[0,16,10000],[0,17,10000],[0,18,10000],[0,19,10000],[0,20,10000],[0,21,10000],[0,22,10000],[0,23,10000],[0,24,10000],[0,25,10000],[0,26,10000],[0,27,10000],[0,28,10000],[0,29,10000],[0,30,10000],[0,31,10000],[0,32,10000],[0,33,10000],[0,34,10000],[0,35,10000],[0,36,10000],[0,37,10000],[0,38,10000],[0,39,10000],[0,40,10000],[0,41,10000],[0,42,10000],[0,43,10000],[0,44,10000],[0,45,10000],[0,46,10000],[0,47,10000],[0,48,10000],[0,49,10000],[0,50,10000],[0,51,10000],[0,52,10000],[0,53,10000],[0,54,10000],[0,55,10000],[0,56,10000],[0,57,10000],[0,58,10000],[0,59,10000],[0,60,10000],[0,61,10000],[0,62,10000],[0,63,10000],[0,64,10000],[0,65,10000],[0,66,10000],[0,67,10000],[0,68,10000],[0,69,10000],[0,70,10000],[0,71,10000],[0,72,10000],[0,73,10000],[0,74,10000],[0,75,10000],[0,76,10000],[0,77,10000],[0,78,10000],[0,79,10000],[0,80,10000],[0,81,10000],[0,82,10000],[0,83,10000],[0,84,10000],[0,85,10000],[0,86,10000],[0,87,10000],[0,88,10000],[0,89,10000],[0,90,10000],[0,91,10000],[0,92,10000],[0,93,10000],[0,94,10000],[0,95,10000],[0,96,10000],[0,97,10000],[0,98,10000],[0,99,10000],[1,2,1],[1,3,10000],[1,4,10000],[1,5,10000],[1,6,10000],[1,7,10000],[1,8,10000],[1,9,10000],[1,10,10000],[1,11,10000],[1,12,10000],[1,13,10000],[1,14,10000],[1,15,10000],[1,16,10000],[1,17,10000],[1,18,10000],[1,19,10000],[1,20,10000],[1,21,10000],[1,22,10000],[1,23,10000],[1,24,10000],[1,25,10000],[1,26,10000],[1,27,10000],[1,28,10000],[1,29,10000],[1,30,10000],[1,31,10000],[1,32,10000],[1,33,10000],[1,34,10000],[1,35,10000],[1,36,10000],[1,37,10000],[1,38,10000],[1,39,10000],[1,40,10000],[1,41,10000],[1,42,10000],[1,43,10000],[1,44,10000],[1,45,10000],[1,46,10000],[1,47,10000],[1,48,10000],[1,49,10000],[1,50,10000],[1,51,10000],[1,52,10000],[1,53,10000],[1,54,10000],[1,55,10000],[1,56,10000],[1,57,10000],[1,58,10000],[1,59,10000],[1,60,10000],[1,61,10000],[1,62,10000],[1,63,10000],[1,64,10000],[1,65,10000],[1,66,10000],[1,67,10000],[1,68,10000],[1,69,10000],[1,70,10000],[1,71,10000],[1,72,10000],[1,73,10000],[1,74,10000],[1,75,10000],[1,76,10000],[1,77,10000],[1,78,10000],[1,79,10000],[1,80,10000],[1,81,10000],[1,82,10000],[1,83,10000],[1,84,10000],[1,85,10000],[1,86,10000],[1,87,10000],[1,88,10000],[1,89,10000],[1,90,10000],[1,91,10000],[1,92,10000],[1,93,10000],[1,94,10000],[1,95,10000],[1,96,10000],[1,97,10000],[1,98,10000],[1,99,10000],[2,3,1],[2,4,10000],[2,5,10000],[2,6,10000],[2,7,10000],[2,8,10000],[2,9,10000],[2,10,10000],[2,11,10000],[2,12,10000],[2,13,10000],[2,14,10000],[2,15,10000],[2,16,10000],[2,17,10000],[2,18,10000],[2,19,10000],[2,20,10000],[2,21,10000],[2,22,10000],[2,23,10000],[2,24,10000],[2,25,10000],[2,26,10000],[2,27,10000],[2,28,10000],[2,29,10000],[2,30,10000],[2,31,10000],[2,32,10000],[2,33,10000],[2,34,10000],[2,35,10000],[2,36,10000],[2,37,10000],[2,38,10000],[2,39,10000],[2,40,10000],[2,41,10000],[2,42,10000],[2,43,10000],[2,44,10000],[2,45,10000],[2,46,10000],[2,47,10000],[2,48,10000],[2,49,10000],[2,50,10000],[2,51,10000],[2,52,10000],[2,53,10000],[2,54,10000],[2,55,10000],[2,56,10000],[2,57,10000],[2,58,10000],[2,59,10000],[2,60,10000],[2,61,10000],[2,62,10000],[2,63,10000],[2,64,10000],[2,65,10000],[2,66,10000],[2,67,10000],[2,68,10000],[2,69,10000],[2,70,10000],[2,71,10000],[2,72,10000],[2,73,10000],[2,74,10000],[2,75,10000],[2,76,10000],[2,77,10000],[2,78,10000],[2,79,10000],[2,80,10000],[2,81,10000],[2,82,10000],[2,83,10000],[2,84,10000],[2,85,10000],[2,86,10000],[2,87,10000],[2,88,10000],[2,89,10000],[2,90,10000],[2,91,10000],[2,92,10000],[2,93,10000],[2,94,10000],[2,95,10000],[2,96,10000],[2,97,10000],[2,98,10000],[2,99,10000],[3,4,1],[3,5,10000],[3,6,10000],[3,7,10000],[3,8,10000],[3,9,10000],[3,10,10000],[3,11,10000],[3,12,10000],[3,13,10000],[3,14,10000],[3,15,10000],[3,16,10000],[3,17,10000],[3,18,10000],[3,19,10000],[3,20,10000],[3,21,10000],[3,22,10000],[3,23,10000],[3,24,10000],[3,25,10000],[3,26,10000],[3,27,10000],[3,28,10000],[3,29,10000],[3,30,10000],[3,31,10000],[3,32,10000],[3,33,10000],[3,34,10000],[3,35,10000],[3,36,10000],[3,37,10000],[3,38,10000],[3,39,10000],[3,40,10000],[3,41,10000],[3,42,10000],[3,43,10000],[3,44,10000],[3,45,10000],[3,46,10000],[3,47,10000],[3,48,10000],[3,49,10000],[3,50,10000],[3,51,10000],[3,52,10000],[3,53,10000],[3,54,10000],[3,55,10000],[3,56,10000],[3,57,10000],[3,58,10000],[3,59,10000],[3,60,10000],[3,61,10000],[3,62,10000],[3,63,10000],[3,64,10000],[3,65,10000],[3,66,10000],[3,67,10000],[3,68,10000],[3,69,10000],[3,70,10000],[3,71,10000],[3,72,10000],[3,73,10000],[3,74,10000],[3,75,10000],[3,76,10000],[3,77,10000],[3,78,10000],[3,79,10000],[3,80,10000],[3,81,10000],[3,82,10000],[3,83,10000],[3,84,10000],[3,85,10000],[3,86,10000],[3,87,10000],[3,88,10000],[3,89,10000],[3,90,10000],[3,91,10000],[3,92,10000],[3,93,10000],[3,94,10000],[3,95,10000],[3,96,10000],[3,97,10000],[3,98,10000],[3,99,10000],[4,5,1],[4,6,10000],[4,7,10000],[4,8,10000],[4,9,10000],[4,10,10000],[4,11,10000],[4,12,10000],[4,13,10000],[4,14,10000],[4,15,10000],[4,16,10000],[4,17,10000],[4,18,10000],[4,19,10000],[4,20,10000],[4,21,10000],[4,22,10000],[4,23,10000],[4,24,10000],[4,25,10000],[4,26,10000],[4,27,10000],[4,28,10000],[4,29,10000],[4,30,10000],[4,31,10000],[4,32,10000],[4,33,10000],[4,34,10000],[4,35,10000],[4,36,10000],[4,37,10000],[4,38,10000],[4,39,10000],[4,40,10000],[4,41,10000],[4,42,10000],[4,43,10000],[4,44,10000],[4,45,10000],[4,46,10000],[4,47,10000],[4,48,10000],[4,49,10000],[4,50,10000],[4,51,10000],[4,52,10000],[4,53,10000],[4,54,10000],[4,55,10000],[4,56,10000],[4,57,10000],[4,58,10000],[4,59,10000],[4,60,10000],[4,61,10000],[4,62,10000],[4,63,10000],[4,64,10000],[4,65,10000],[4,66,10000],[4,67,10000],[4,68,10000],[4,69,10000],[4,70,10000],[4,71,10000],[4,72,10000],[4,73,10000],[4,74,10000],[4,75,10000],[4,76,10000],[4,77,10000],[4,78,10000],[4,79,10000],[4,80,10000],[4,81,10000],[4,82,10000],[4,83,10000],[4,84,10000],[4,85,10000],[4,86,10000],[4,87,10000],[4,88,10000],[4,89,10000],[4,90,10000],[4,91,10000],[4,92,10000],[4,93,10000],[4,94,10000],[4,95,10000],[4,96,10000],[4,97,10000],[4,98,10000],[4,99,10000],[5,6,1],[5,7,10000],[5,8,10000],[5,9,10000],[5,10,10000],[5,11,10000],[5,12,10000],[5,13,10000],[5,14,10000],[5,15,10000],[5,16,10000],[5,17,10000],[5,18,10000],[5,19,10000],[5,20,10000],[5,21,10000],[5,22,10000],[5,23,10000],[5,24,10000],[5,25,10000],[5,26,10000],[5,27,10000],[5,28,10000],[5,29,10000],[5,30,10000],[5,31,10000],[5,32,10000],[5,33,10000],[5,34,10000],[5,35,10000],[5,36,10000],[5,37,10000],[5,38,10000],[5,39,10000],[5,40,10000],[5,41,10000],[5,42,10000],[5,43,10000],[5,44,10000],[5,45,10000],[5,46,10000],[5,47,10000],[5,48,10000],[5,49,10000],[5,50,10000],[5,51,10000],[5,52,10000],[5,53,10000],[5,54,10000],[5,55,10000],[5,56,10000],[5,57,10000],[5,58,10000],[5,59,10000],[5,60,10000],[5,61,10000],[5,62,10000],[5,63,10000],[5,64,10000],[5,65,10000],[5,66,10000],[5,67,10000],[5,68,10000],[5,69,10000],[5,70,10000],[5,71,10000],[5,72,10000],[5,73,10000],[5,74,10000],[5,75,10000],[5,76,10000],[5,77,10000],[5,78,10000],[5,79,10000],[5,80,10000],[5,81,10000],[5,82,10000],[5,83,10000],[5,84,10000],[5,85,10000],[5,86,10000],[5,87,10000],[5,88,10000],[5,89,10000],[5,90,10000],[5,91,10000],[5,92,10000],[5,93,10000],[5,94,10000],[5,95,10000],[5,96,10000],[5,97,10000],[5,98,10000],[5,99,10000],[6,7,1],[6,8,10000],[6,9,10000],[6,10,10000],[6,11,10000],[6,12,10000],[6,13,10000],[6,14,10000],[6,15,10000],[6,16,10000],[6,17,10000],[6,18,10000],[6,19,10000],[6,20,10000],[6,21,10000],[6,22,10000],[6,23,10000],[6,24,10000],[6,25,10000],[6,26,10000],[6,27,10000],[6,28,10000],[6,29,10000],[6,30,10000],[6,31,10000],[6,32,10000],[6,33,10000],[6,34,10000],[6,35,10000],[6,36,10000],[6,37,10000],[6,38,10000],[6,39,10000],[6,40,10000],[6,41,10000],[6,42,10000],[6,43,10000],[6,44,10000],[6,45,10000],[6,46,10000],[6,47,10000],[6,48,10000],[6,49,10000],[6,50,10000],[6,51,10000],[6,52,10000],[6,53,10000],[6,54,10000],[6,55,10000],[6,56,10000],[6,57,10000],[6,58,10000],[6,59,10000],[6,60,10000],[6,61,10000],[6,62,10000],[6,63,10000],[6,64,10000],[6,65,10000],[6,66,10000],[6,67,10000],[6,68,10000],[6,69,10000],[6,70,10000],[6,71,10000],[6,72,10000],[6,73,10000],[6,74,10000],[6,75,10000],[6,76,10000],[6,77,10000],[6,78,10000],[6,79,10000],[6,80,10000],[6,81,10000],[6,82,10000],[6,83,10000],[6,84,10000],[6,85,10000],[6,86,10000],[6,87,10000],[6,88,10000],[6,89,10000],[6,90,10000],[6,91,10000],[6,92,10000],[6,93,10000],[6,94,10000],[6,95,10000],[6,96,10000],[6,97,10000],[6,98,10000],[6,99,10000],[7,8,1],[7,9,10000],[7,10,10000],[7,11,10000],[7,12,10000],[7,13,10000],[7,14,10000],[7,15,10000],[7,16,10000],[7,17,10000],[7,18,10000],[7,19,10000],[7,20,10000],[7,21,10000],[7,22,10000],[7,23,10000],[7,24,10000],[7,25,10000],[7,26,10000],[7,27,10000],[7,28,10000],[7,29,10000],[7,30,10000],[7,31,10000],[7,32,10000],[7,33,10000],[7,34,10000],[7,35,10000],[7,36,10000],[7,37,10000],[7,38,10000],[7,39,10000],[7,40,10000],[7,41,10000],[7,42,10000],[7,43,10000],[7,44,10000],[7,45,10000],[7,46,10000],[7,47,10000],[7,48,10000],[7,49,10000],[7,50,10000],[7,51,10000],[7,52,10000],[7,53,10000],[7,54,10000],[7,55,10000],[7,56,10000],[7,57,10000],[7,58,10000],[7,59,10000],[7,60,10000],[7,61,10000],[7,62,10000],[7,63,10000],[7,64,10000],[7,65,10000],[7,66,10000],[7,67,10000],[7,68,10000],[7,69,10000],[7,70,10000],[7,71,10000],[7,72,10000],[7,73,10000],[7,74,10000],[7,75,10000],[7,76,10000],[7,77,10000],[7,78,10000],[7,79,10000],[7,80,10000],[7,81,10000],[7,82,10000],[7,83,10000],[7,84,10000],[7,85,10000],[7,86,10000],[7,87,10000],[7,88,10000],[7,89,10000],[7,90,10000],[7,91,10000],[7,92,10000],[7,93,10000],[7,94,10000],[7,95,10000],[7,96,10000],[7,97,10000],[7,98,10000],[7,99,10000],[8,9,1],[8,10,10000],[8,11,10000],[8,12,10000],[8,13,10000],[8,14,10000],[8,15,10000],[8,16,10000],[8,17,10000],[8,18,10000],[8,19,10000],[8,20,10000],[8,21,10000],[8,22,10000],[8,23,10000],[8,24,10000],[8,25,10000],[8,26,10000],[8,27,10000],[8,28,10000],[8,29,10000],[8,30,10000],[8,31,10000],[8,32,10000],[8,33,10000],[8,34,10000],[8,35,10000],[8,36,10000],[8,37,10000],[8,38,10000],[8,39,10000],[8,40,10000],[8,41,10000],[8,42,10000],[8,43,10000],[8,44,10000],[8,45,10000],[8,46,10000],[8,47,10000],[8,48,10000],[8,49,10000],[8,50,10000],[8,51,10000],[8,52,10000],[8,53,10000],[8,54,10000],[8,55,10000],[8,56,10000],[8,57,10000],[8,58,10000],[8,59,10000],[8,60,10000],[8,61,10000],[8,62,10000],[8,63,10000],[8,64,10000],[8,65,10000],[8,66,10000],[8,67,10000],[8,68,10000],[8,69,10000],[8,70,10000],[8,71,10000],[8,72,10000],[8,73,10000],[8,74,10000],[8,75,10000],[8,76,10000],[8,77,10000],[8,78,10000],[8,79,10000],[8,80,10000],[8,81,10000],[8,82,10000],[8,83,10000],[8,84,10000],[8,85,10000],[8,86,10000],[8,87,10000],[8,88,10000],[8,89,10000],[8,90,10000],[8,91,10000],[8,92,10000],[8,93,10000],[8,94,10000],[8,95,10000],[8,96,10000],[8,97,10000],[8,98,10000],[8,99,10000],[9,10,1],[9,11,10000],[9,12,10000],[9,13,10000],[9,14,10000],[9,15,10000],[9,16,10000],[9,17,10000],[9,18,10000],[9,19,10000],[9,20,10000],[9,21,10000],[9,22,10000],[9,23,10000],[9,24,10000],[9,25,10000],[9,26,10000],[9,27,10000],[9,28,10000],[9,29,10000],[9,30,10000],[9,31,10000],[9,32,10000],[9,33,10000],[9,34,10000],[9,35,10000],[9,36,10000],[9,37,10000],[9,38,10000],[9,39,10000],[9,40,10000],[9,41,10000],[9,42,10000],[9,43,10000],[9,44,10000],[9,45,10000],[9,46,10000],[9,47,10000],[9,48,10000],[9,49,10000],[9,50,10000],[9,51,10000],[9,52,10000],[9,53,10000],[9,54,10000],[9,55,10000],[9,56,10000],[9,57,10000],[9,58,10000],[9,59,10000],[9,60,10000],[9,61,10000],[9,62,10000],[9,63,10000],[9,64,10000],[9,65,10000],[9,66,10000],[9,67,10000],[9,68,10000],[9,69,10000],[9,70,10000],[9,71,10000],[9,72,10000],[9,73,10000],[9,74,10000],[9,75,10000],[9,76,10000],[9,77,10000],[9,78,10000],[9,79,10000],[9,80,10000],[9,81,10000],[9,82,10000],[9,83,10000],[9,84,10000],[9,85,10000],[9,86,10000],[9,87,10000],[9,88,10000],[9,89,10000],[9,90,10000],[9,91,10000],[9,92,10000],[9,93,10000],[9,94,10000],[9,95,10000],[9,96,10000],[9,97,10000],[9,98,10000],[9,99,10000],[10,11,1],[10,12,10000],[10,13,10000],[10,14,10000],[10,15,10000],[10,16,10000],[10,17,10000],[10,18,10000],[10,19,10000],[10,20,10000],[10,21,10000],[10,22,10000],[10,23,10000],[10,24,10000],[10,25,10000],[10,26,10000],[10,27,10000],[10,28,10000],[10,29,10000],[10,30,10000],[10,31,10000],[10,32,10000],[10,33,10000],[10,34,10000],[10,35,10000],[10,36,10000],[10,37,10000],[10,38,10000],[10,39,10000],[10,40,10000],[10,41,10000],[10,42,10000],[10,43,10000],[10,44,10000],[10,45,10000],[10,46,10000],[10,47,10000],[10,48,10000],[10,49,10000],[10,50,10000],[10,51,10000],[10,52,10000],[10,53,10000],[10,54,10000],[10,55,10000],[10,56,10000],[10,57,10000],[10,58,10000],[10,59,10000],[10,60,10000],[10,61,10000],[10,62,10000],[10,63,10000],[10,64,10000],[10,65,10000],[10,66,10000],[10,67,10000],[10,68,10000],[10,69,10000],[10,70,10000],[10,71,10000],[10,72,10000],[10,73,10000],[10,74,10000],[10,75,10000],[10,76,10000],[10,77,10000],[10,78,10000],[10,79,10000],[10,80,10000],[10,81,10000],[10,82,10000],[10,83,10000],[10,84,10000],[10,85,10000],[10,86,10000],[10,87,10000],[10,88,10000],[10,89,10000],[10,90,10000],[10,91,10000],[10,92,10000],[10,93,10000],[10,94,10000],[10,95,10000],[10,96,10000],[10,97,10000],[10,98,10000],[10,99,10000],[11,12,1],[11,13,10000],[11,14,10000],[11,15,10000],[11,16,10000],[11,17,10000],[11,18,10000],[11,19,10000],[11,20,10000],[11,21,10000],[11,22,10000],[11,23,10000],[11,24,10000],[11,25,10000],[11,26,10000],[11,27,10000],[11,28,10000],[11,29,10000],[11,30,10000],[11,31,10000],[11,32,10000],[11,33,10000],[11,34,10000],[11,35,10000],[11,36,10000],[11,37,10000],[11,38,10000],[11,39,10000],[11,40,10000],[11,41,10000],[11,42,10000],[11,43,10000],[11,44,10000],[11,45,10000],[11,46,10000],[11,47,10000],[11,48,10000],[11,49,10000],[11,50,10000],[11,51,10000],[11,52,10000],[11,53,10000],[11,54,10000],[11,55,10000],[11,56,10000],[11,57,10000],[11,58,10000],[11,59,10000],[11,60,10000],[11,61,10000],[11,62,10000],[11,63,10000],[11,64,10000],[11,65,10000],[11,66,10000],[11,67,10000],[11,68,10000],[11,69,10000],[11,70,10000],[11,71,10000],[11,72,10000],[11,73,10000],[11,74,10000],[11,75,10000],[11,76,10000],[11,77,10000],[11,78,10000],[11,79,10000],[11,80,10000],[11,81,10000],[11,82,10000],[11,83,10000],[11,84,10000],[11,85,10000],[11,86,10000],[11,87,10000],[11,88,10000],[11,89,10000],[11,90,10000],[11,91,10000],[11,92,10000],[11,93,10000],[11,94,10000],[11,95,10000],[11,96,10000],[11,97,10000],[11,98,10000],[11,99,10000],[12,13,1],[12,14,10000],[12,15,10000],[12,16,10000],[12,17,10000],[12,18,10000],[12,19,10000],[12,20,10000],[12,21,10000],[12,22,10000],[12,23,10000],[12,24,10000],[12,25,10000],[12,26,10000],[12,27,10000],[12,28,10000],[12,29,10000],[12,30,10000],[12,31,10000],[12,32,10000],[12,33,10000],[12,34,10000],[12,35,10000],[12,36,10000],[12,37,10000],[12,38,10000],[12,39,10000],[12,40,10000],[12,41,10000],[12,42,10000],[12,43,10000],[12,44,10000],[12,45,10000],[12,46,10000],[12,47,10000],[12,48,10000],[12,49,10000],[12,50,10000],[12,51,10000],[12,52,10000],[12,53,10000],[12,54,10000],[12,55,10000],[12,56,10000],[12,57,10000],[12,58,10000],[12,59,10000],[12,60,10000],[12,61,10000],[12,62,10000],[12,63,10000],[12,64,10000],[12,65,10000],[12,66,10000],[12,67,10000],[12,68,10000],[12,69,10000],[12,70,10000],[12,71,10000],[12,72,10000],[12,73,10000],[12,74,10000],[12,75,10000],[12,76,10000],[12,77,10000],[12,78,10000],[12,79,10000],[12,80,10000],[12,81,10000],[12,82,10000],[12,83,10000],[12,84,10000],[12,85,10000],[12,86,10000],[12,87,10000],[12,88,10000],[12,89,10000],[12,90,10000],[12,91,10000],[12,92,10000],[12,93,10000],[12,94,10000],[12,95,10000],[12,96,10000],[12,97,10000],[12,98,10000],[12,99,10000],[13,14,1],[13,15,10000],[13,16,10000],[13,17,10000],[13,18,10000],[13,19,10000],[13,20,10000],[13,21,10000],[13,22,10000],[13,23,10000],[13,24,10000],[13,25,10000],[13,26,10000],[13,27,10000],[13,28,10000],[13,29,10000],[13,30,10000],[13,31,10000],[13,32,10000],[13,33,10000],[13,34,10000],[13,35,10000],[13,36,10000],[13,37,10000],[13,38,10000],[13,39,10000],[13,40,10000],[13,41,10000],[13,42,10000],[13,43,10000],[13,44,10000],[13,45,10000],[13,46,10000],[13,47,10000],[13,48,10000],[13,49,10000],[13,50,10000],[13,51,10000],[13,52,10000],[13,53,10000],[13,54,10000],[13,55,10000],[13,56,10000],[13,57,10000],[13,58,10000],[13,59,10000],[13,60,10000],[13,61,10000],[13,62,10000],[13,63,10000],[13,64,10000],[13,65,10000],[13,66,10000],[13,67,10000],[13,68,10000],[13,69,10000],[13,70,10000],[13,71,10000],[13,72,10000],[13,73,10000],[13,74,10000],[13,75,10000],[13,76,10000],[13,77,10000],[13,78,10000],[13,79,10000],[13,80,10000],[13,81,10000],[13,82,10000],[13,83,10000],[13,84,10000],[13,85,10000],[13,86,10000],[13,87,10000],[13,88,10000],[13,89,10000],[13,90,10000],[13,91,10000],[13,92,10000],[13,93,10000],[13,94,10000],[13,95,10000],[13,96,10000],[13,97,10000],[13,98,10000],[13,99,10000],[14,15,1],[14,16,10000],[14,17,10000],[14,18,10000],[14,19,10000],[14,20,10000],[14,21,10000],[14,22,10000],[14,23,10000],[14,24,10000],[14,25,10000],[14,26,10000],[14,27,10000],[14,28,10000],[14,29,10000],[14,30,10000],[14,31,10000],[14,32,10000],[14,33,10000],[14,34,10000],[14,35,10000],[14,36,10000],[14,37,10000],[14,38,10000],[14,39,10000],[14,40,10000],[14,41,10000],[14,42,10000],[14,43,10000],[14,44,10000],[14,45,10000],[14,46,10000],[14,47,10000],[14,48,10000],[14,49,10000],[14,50,10000],[14,51,10000],[14,52,10000],[14,53,10000],[14,54,10000],[14,55,10000],[14,56,10000],[14,57,10000],[14,58,10000],[14,59,10000],[14,60,10000],[14,61,10000],[14,62,10000],[14,63,10000],[14,64,10000],[14,65,10000],[14,66,10000],[14,67,10000],[14,68,10000],[14,69,10000],[14,70,10000],[14,71,10000],[14,72,10000],[14,73,10000],[14,74,10000],[14,75,10000],[14,76,10000],[14,77,10000],[14,78,10000],[14,79,10000],[14,80,10000],[14,81,10000],[14,82,10000],[14,83,10000],[14,84,10000],[14,85,10000],[14,86,10000],[14,87,10000],[14,88,10000],[14,89,10000],[14,90,10000],[14,91,10000],[14,92,10000],[14,93,10000],[14,94,10000],[14,95,10000],[14,96,10000],[14,97,10000],[14,98,10000],[14,99,10000],[15,16,1],[15,17,10000],[15,18,10000],[15,19,10000],[15,20,10000],[15,21,10000],[15,22,10000],[15,23,10000],[15,24,10000],[15,25,10000],[15,26,10000],[15,27,10000],[15,28,10000],[15,29,10000],[15,30,10000],[15,31,10000],[15,32,10000],[15,33,10000],[15,34,10000],[15,35,10000],[15,36,10000],[15,37,10000],[15,38,10000],[15,39,10000],[15,40,10000],[15,41,10000],[15,42,10000],[15,43,10000],[15,44,10000],[15,45,10000],[15,46,10000],[15,47,10000],[15,48,10000],[15,49,10000],[15,50,10000],[15,51,10000],[15,52,10000],[15,53,10000],[15,54,10000],[15,55,10000],[15,56,10000],[15,57,10000],[15,58,10000],[15,59,10000],[15,60,10000],[15,61,10000],[15,62,10000],[15,63,10000],[15,64,10000],[15,65,10000],[15,66,10000],[15,67,10000],[15,68,10000],[15,69,10000],[15,70,10000],[15,71,10000],[15,72,10000],[15,73,10000],[15,74,10000],[15,75,10000],[15,76,10000],[15,77,10000],[15,78,10000],[15,79,10000],[15,80,10000],[15,81,10000],[15,82,10000],[15,83,10000],[15,84,10000],[15,85,10000],[15,86,10000],[15,87,10000],[15,88,10000],[15,89,10000],[15,90,10000],[15,91,10000],[15,92,10000],[15,93,10000],[15,94,10000],[15,95,10000],[15,96,10000],[15,97,10000],[15,98,10000],[15,99,10000],[16,17,1],[16,18,10000],[16,19,10000],[16,20,10000],[16,21,10000],[16,22,10000],[16,23,10000],[16,24,10000],[16,25,10000],[16,26,10000],[16,27,10000],[16,28,10000],[16,29,10000],[16,30,10000],[16,31,10000],[16,32,10000],[16,33,10000],[16,34,10000],[16,35,10000],[16,36,10000],[16,37,10000],[16,38,10000],[16,39,10000],[16,40,10000],[16,41,10000],[16,42,10000],[16,43,10000],[16,44,10000],[16,45,10000],[16,46,10000],[16,47,10000],[16,48,10000],[16,49,10000],[16,50,10000],[16,51,10000],[16,52,10000],[16,53,10000],[16,54,10000],[16,55,10000],[16,56,10000],[16,57,10000],[16,58,10000],[16,59,10000],[16,60,10000],[16,61,10000],[16,62,10000],[16,63,10000],[16,64,10000],[16,65,10000],[16,66,10000],[16,67,10000],[16,68,10000],[16,69,10000],[16,70,10000],[16,71,10000],[16,72,10000],[16,73,10000],[16,74,10000],[16,75,10000],[16,76,10000],[16,77,10000],[16,78,10000],[16,79,10000],[16,80,10000],[16,81,10000],[16,82,10000],[16,83,10000],[16,84,10000],[16,85,10000],[16,86,10000],[16,87,10000],[16,88,10000],[16,89,10000],[16,90,10000],[16,91,10000],[16,92,10000],[16,93,10000],[16,94,10000],[16,95,10000],[16,96,10000],[16,97,10000],[16,98,10000],[16,99,10000],[17,18,1],[17,19,10000],[17,20,10000],[17,21,10000],[17,22,10000],[17,23,10000],[17,24,10000],[17,25,10000],[17,26,10000],[17,27,10000],[17,28,10000],[17,29,10000],[17,30,10000],[17,31,10000],[17,32,10000],[17,33,10000],[17,34,10000],[17,35,10000],[17,36,10000],[17,37,10000],[17,38,10000],[17,39,10000],[17,40,10000],[17,41,10000],[17,42,10000],[17,43,10000],[17,44,10000],[17,45,10000],[17,46,10000],[17,47,10000],[17,48,10000],[17,49,10000],[17,50,10000],[17,51,10000],[17,52,10000],[17,53,10000],[17,54,10000],[17,55,10000],[17,56,10000],[17,57,10000],[17,58,10000],[17,59,10000],[17,60,10000],[17,61,10000],[17,62,10000],[17,63,10000],[17,64,10000],[17,65,10000],[17,66,10000],[17,67,10000],[17,68,10000],[17,69,10000],[17,70,10000],[17,71,10000],[17,72,10000],[17,73,10000],[17,74,10000],[17,75,10000],[17,76,10000],[17,77,10000],[17,78,10000],[17,79,10000],[17,80,10000],[17,81,10000],[17,82,10000],[17,83,10000],[17,84,10000],[17,85,10000],[17,86,10000],[17,87,10000],[17,88,10000],[17,89,10000],[17,90,10000],[17,91,10000],[17,92,10000],[17,93,10000],[17,94,10000],[17,95,10000],[17,96,10000],[17,97,10000],[17,98,10000],[17,99,10000],[18,19,1],[18,20,10000],[18,21,10000],[18,22,10000],[18,23,10000],[18,24,10000],[18,25,10000],[18,26,10000],[18,27,10000],[18,28,10000],[18,29,10000],[18,30,10000],[18,31,10000],[18,32,10000],[18,33,10000],[18,34,10000],[18,35,10000],[18,36,10000],[18,37,10000],[18,38,10000],[18,39,10000],[18,40,10000],[18,41,10000],[18,42,10000],[18,43,10000],[18,44,10000],[18,45,10000],[18,46,10000],[18,47,10000],[18,48,10000],[18,49,10000],[18,50,10000],[18,51,10000],[18,52,10000],[18,53,10000],[18,54,10000],[18,55,10000],[18,56,10000],[18,57,10000],[18,58,10000],[18,59,10000],[18,60,10000],[18,61,10000],[18,62,10000],[18,63,10000],[18,64,10000],[18,65,10000],[18,66,10000],[18,67,10000],[18,68,10000],[18,69,10000],[18,70,10000],[18,71,10000],[18,72,10000],[18,73,10000],[18,74,10000],[18,75,10000],[18,76,10000],[18,77,10000],[18,78,10000],[18,79,10000],[18,80,10000],[18,81,10000],[18,82,10000],[18,83,10000],[18,84,10000],[18,85,10000],[18,86,10000],[18,87,10000],[18,88,10000],[18,89,10000],[18,90,10000],[18,91,10000],[18,92,10000],[18,93,10000],[18,94,10000],[18,95,10000],[18,96,10000],[18,97,10000],[18,98,10000],[18,99,10000],[19,20,1],[19,21,10000],[19,22,10000],[19,23,10000],[19,24,10000],[19,25,10000],[19,26,10000],[19,27,10000],[19,28,10000],[19,29,10000],[19,30,10000],[19,31,10000],[19,32,10000],[19,33,10000],[19,34,10000],[19,35,10000],[19,36,10000],[19,37,10000],[19,38,10000],[19,39,10000],[19,40,10000],[19,41,10000],[19,42,10000],[19,43,10000],[19,44,10000],[19,45,10000],[19,46,10000],[19,47,10000],[19,48,10000],[19,49,10000],[19,50,10000],[19,51,10000],[19,52,10000],[19,53,10000],[19,54,10000],[19,55,10000],[19,56,10000],[19,57,10000],[19,58,10000],[19,59,10000],[19,60,10000],[19,61,10000],[19,62,10000],[19,63,10000],[19,64,10000],[19,65,10000],[19,66,10000],[19,67,10000],[19,68,10000],[19,69,10000],[19,70,10000],[19,71,10000],[19,72,10000],[19,73,10000],[19,74,10000],[19,75,10000],[19,76,10000],[19,77,10000],[19,78,10000],[19,79,10000],[19,80,10000],[19,81,10000],[19,82,10000],[19,83,10000],[19,84,10000],[19,85,10000],[19,86,10000],[19,87,10000],[19,88,10000],[19,89,10000],[19,90,10000],[19,91,10000],[19,92,10000],[19,93,10000],[19,94,10000],[19,95,10000],[19,96,10000],[19,97,10000],[19,98,10000],[19,99,10000],[20,21,1],[20,22,10000],[20,23,10000],[20,24,10000],[20,25,10000],[20,26,10000],[20,27,10000],[20,28,10000],[20,29,10000],[20,30,10000],[20,31,10000],[20,32,10000],[20,33,10000],[20,34,10000],[20,35,10000],[20,36,10000],[20,37,10000],[20,38,10000],[20,39,10000],[20,40,10000],[20,41,10000],[20,42,10000],[20,43,10000],[20,44,10000],[20,45,10000],[20,46,10000],[20,47,10000],[20,48,10000],[20,49,10000],[20,50,10000],[20,51,10000],[20,52,10000],[20,53,10000],[20,54,10000],[20,55,10000],[20,56,10000],[20,57,10000],[20,58,10000],[20,59,10000],[20,60,10000],[20,61,10000],[20,62,10000],[20,63,10000],[20,64,10000],[20,65,10000],[20,66,10000],[20,67,10000],[20,68,10000],[20,69,10000],[20,70,10000],[20,71,10000],[20,72,10000],[20,73,10000],[20,74,10000],[20,75,10000],[20,76,10000],[20,77,10000],[20,78,10000],[20,79,10000],[20,80,10000],[20,81,10000],[20,82,10000],[20,83,10000],[20,84,10000],[20,85,10000],[20,86,10000],[20,87,10000],[20,88,10000],[20,89,10000],[20,90,10000],[20,91,10000],[20,92,10000],[20,93,10000],[20,94,10000],[20,95,10000],[20,96,10000],[20,97,10000],[20,98,10000],[20,99,10000],[21,22,1],[21,23,10000],[21,24,10000],[21,25,10000],[21,26,10000],[21,27,10000],[21,28,10000],[21,29,10000],[21,30,10000],[21,31,10000],[21,32,10000],[21,33,10000],[21,34,10000],[21,35,10000],[21,36,10000],[21,37,10000],[21,38,10000],[21,39,10000],[21,40,10000],[21,41,10000],[21,42,10000],[21,43,10000],[21,44,10000],[21,45,10000],[21,46,10000],[21,47,10000],[21,48,10000],[21,49,10000],[21,50,10000],[21,51,10000],[21,52,10000],[21,53,10000],[21,54,10000],[21,55,10000],[21,56,10000],[21,57,10000],[21,58,10000],[21,59,10000],[21,60,10000],[21,61,10000],[21,62,10000],[21,63,10000],[21,64,10000],[21,65,10000],[21,66,10000],[21,67,10000],[21,68,10000],[21,69,10000],[21,70,10000],[21,71,10000],[21,72,10000],[21,73,10000],[21,74,10000],[21,75,10000],[21,76,10000],[21,77,10000],[21,78,10000],[21,79,10000],[21,80,10000],[21,81,10000],[21,82,10000],[21,83,10000],[21,84,10000],[21,85,10000],[21,86,10000],[21,87,10000],[21,88,10000],[21,89,10000],[21,90,10000],[21,91,10000],[21,92,10000],[21,93,10000],[21,94,10000],[21,95,10000],[21,96,10000],[21,97,10000],[21,98,10000],[21,99,10000],[22,23,1],[22,24,10000],[22,25,10000],[22,26,10000],[22,27,10000],[22,28,10000],[22,29,10000],[22,30,10000],[22,31,10000],[22,32,10000],[22,33,10000],[22,34,10000],[22,35,10000],[22,36,10000],[22,37,10000],[22,38,10000],[22,39,10000],[22,40,10000],[22,41,10000],[22,42,10000],[22,43,10000],[22,44,10000],[22,45,10000],[22,46,10000],[22,47,10000],[22,48,10000],[22,49,10000],[22,50,10000],[22,51,10000],[22,52,10000],[22,53,10000],[22,54,10000],[22,55,10000],[22,56,10000],[22,57,10000],[22,58,10000],[22,59,10000],[22,60,10000],[22,61,10000],[22,62,10000],[22,63,10000],[22,64,10000],[22,65,10000],[22,66,10000],[22,67,10000],[22,68,10000],[22,69,10000],[22,70,10000],[22,71,10000],[22,72,10000],[22,73,10000],[22,74,10000],[22,75,10000],[22,76,10000],[22,77,10000],[22,78,10000],[22,79,10000],[22,80,10000],[22,81,10000],[22,82,10000],[22,83,10000],[22,84,10000],[22,85,10000],[22,86,10000],[22,87,10000],[22,88,10000],[22,89,10000],[22,90,10000],[22,91,10000],[22,92,10000],[22,93,10000],[22,94,10000],[22,95,10000],[22,96,10000],[22,97,10000],[22,98,10000],[22,99,10000],[23,24,1],[23,25,10000],[23,26,10000],[23,27,10000],[23,28,10000],[23,29,10000],[23,30,10000],[23,31,10000],[23,32,10000],[23,33,10000],[23,34,10000],[23,35,10000],[23,36,10000],[23,37,10000],[23,38,10000],[23,39,10000],[23,40,10000],[23,41,10000],[23,42,10000],[23,43,10000],[23,44,10000],[23,45,10000],[23,46,10000],[23,47,10000],[23,48,10000],[23,49,10000],[23,50,10000],[23,51,10000],[23,52,10000],[23,53,10000],[23,54,10000],[23,55,10000],[23,56,10000],[23,57,10000],[23,58,10000],[23,59,10000],[23,60,10000],[23,61,10000],[23,62,10000],[23,63,10000],[23,64,10000],[23,65,10000],[23,66,10000],[23,67,10000],[23,68,10000],[23,69,10000],[23,70,10000],[23,71,10000],[23,72,10000],[23,73,10000],[23,74,10000],[23,75,10000],[23,76,10000],[23,77,10000],[23,78,10000],[23,79,10000],[23,80,10000],[23,81,10000],[23,82,10000],[23,83,10000],[23,84,10000],[23,85,10000],[23,86,10000],[23,87,10000],[23,88,10000],[23,89,10000],[23,90,10000],[23,91,10000],[23,92,10000],[23,93,10000],[23,94,10000],[23,95,10000],[23,96,10000],[23,97,10000],[23,98,10000],[23,99,10000],[24,25,1],[24,26,10000],[24,27,10000],[24,28,10000],[24,29,10000],[24,30,10000],[24,31,10000],[24,32,10000],[24,33,10000],[24,34,10000],[24,35,10000],[24,36,10000],[24,37,10000],[24,38,10000],[24,39,10000],[24,40,10000],[24,41,10000],[24,42,10000],[24,43,10000],[24,44,10000],[24,45,10000],[24,46,10000],[24,47,10000],[24,48,10000],[24,49,10000],[24,50,10000],[24,51,10000],[24,52,10000],[24,53,10000],[24,54,10000],[24,55,10000],[24,56,10000],[24,57,10000],[24,58,10000],[24,59,10000],[24,60,10000],[24,61,10000],[24,62,10000],[24,63,10000],[24,64,10000],[24,65,10000],[24,66,10000],[24,67,10000],[24,68,10000],[24,69,10000],[24,70,10000],[24,71,10000],[24,72,10000],[24,73,10000],[24,74,10000],[24,75,10000],[24,76,10000],[24,77,10000],[24,78,10000],[24,79,10000],[24,80,10000],[24,81,10000],[24,82,10000],[24,83,10000],[24,84,10000],[24,85,10000],[24,86,10000],[24,87,10000],[24,88,10000],[24,89,10000],[24,90,10000],[24,91,10000],[24,92,10000],[24,93,10000],[24,94,10000],[24,95,10000],[24,96,10000],[24,97,10000],[24,98,10000],[24,99,10000],[25,26,1],[25,27,10000],[25,28,10000],[25,29,10000],[25,30,10000],[25,31,10000],[25,32,10000],[25,33,10000],[25,34,10000],[25,35,10000],[25,36,10000],[25,37,10000],[25,38,10000],[25,39,10000],[25,40,10000],[25,41,10000],[25,42,10000],[25,43,10000],[25,44,10000],[25,45,10000],[25,46,10000],[25,47,10000],[25,48,10000],[25,49,10000],[25,50,10000],[25,51,10000],[25,52,10000],[25,53,10000],[25,54,10000],[25,55,10000],[25,56,10000],[25,57,10000],[25,58,10000],[25,59,10000],[25,60,10000],[25,61,10000],[25,62,10000],[25,63,10000],[25,64,10000],[25,65,10000],[25,66,10000],[25,67,10000],[25,68,10000],[25,69,10000],[25,70,10000],[25,71,10000],[25,72,10000],[25,73,10000],[25,74,10000],[25,75,10000],[25,76,10000],[25,77,10000],[25,78,10000],[25,79,10000],[25,80,10000],[25,81,10000],[25,82,10000],[25,83,10000],[25,84,10000],[25,85,10000],[25,86,10000],[25,87,10000],[25,88,10000],[25,89,10000],[25,90,10000],[25,91,10000],[25,92,10000],[25,93,10000],[25,94,10000],[25,95,10000],[25,96,10000],[25,97,10000],[25,98,10000],[25,99,10000],[26,27,1],[26,28,10000],[26,29,10000],[26,30,10000],[26,31,10000],[26,32,10000],[26,33,10000],[26,34,10000],[26,35,10000],[26,36,10000],[26,37,10000],[26,38,10000],[26,39,10000],[26,40,10000],[26,41,10000],[26,42,10000],[26,43,10000],[26,44,10000],[26,45,10000],[26,46,10000],[26,47,10000],[26,48,10000],[26,49,10000],[26,50,10000],[26,51,10000],[26,52,10000],[26,53,10000],[26,54,10000],[26,55,10000],[26,56,10000],[26,57,10000],[26,58,10000],[26,59,10000],[26,60,10000],[26,61,10000],[26,62,10000],[26,63,10000],[26,64,10000],[26,65,10000],[26,66,10000],[26,67,10000],[26,68,10000],[26,69,10000],[26,70,10000],[26,71,10000],[26,72,10000],[26,73,10000],[26,74,10000],[26,75,10000],[26,76,10000],[26,77,10000],[26,78,10000],[26,79,10000],[26,80,10000],[26,81,10000],[26,82,10000],[26,83,10000],[26,84,10000],[26,85,10000],[26,86,10000],[26,87,10000],[26,88,10000],[26,89,10000],[26,90,10000],[26,91,10000],[26,92,10000],[26,93,10000],[26,94,10000],[26,95,10000],[26,96,10000],[26,97,10000],[26,98,10000],[26,99,10000],[27,28,1],[27,29,10000],[27,30,10000],[27,31,10000],[27,32,10000],[27,33,10000],[27,34,10000],[27,35,10000],[27,36,10000],[27,37,10000],[27,38,10000],[27,39,10000],[27,40,10000],[27,41,10000],[27,42,10000],[27,43,10000],[27,44,10000],[27,45,10000],[27,46,10000],[27,47,10000],[27,48,10000],[27,49,10000],[27,50,10000],[27,51,10000],[27,52,10000],[27,53,10000],[27,54,10000],[27,55,10000],[27,56,10000],[27,57,10000],[27,58,10000],[27,59,10000],[27,60,10000],[27,61,10000],[27,62,10000],[27,63,10000],[27,64,10000],[27,65,10000],[27,66,10000],[27,67,10000],[27,68,10000],[27,69,10000],[27,70,10000],[27,71,10000],[27,72,10000],[27,73,10000],[27,74,10000],[27,75,10000],[27,76,10000],[27,77,10000],[27,78,10000],[27,79,10000],[27,80,10000],[27,81,10000],[27,82,10000],[27,83,10000],[27,84,10000],[27,85,10000],[27,86,10000],[27,87,10000],[27,88,10000],[27,89,10000],[27,90,10000],[27,91,10000],[27,92,10000],[27,93,10000],[27,94,10000],[27,95,10000],[27,96,10000],[27,97,10000],[27,98,10000],[27,99,10000],[28,29,1],[28,30,10000],[28,31,10000],[28,32,10000],[28,33,10000],[28,34,10000],[28,35,10000],[28,36,10000],[28,37,10000],[28,38,10000],[28,39,10000],[28,40,10000],[28,41,10000],[28,42,10000],[28,43,10000],[28,44,10000],[28,45,10000],[28,46,10000],[28,47,10000],[28,48,10000],[28,49,10000],[28,50,10000],[28,51,10000],[28,52,10000],[28,53,10000],[28,54,10000],[28,55,10000],[28,56,10000],[28,57,10000],[28,58,10000],[28,59,10000],[28,60,10000],[28,61,10000],[28,62,10000],[28,63,10000],[28,64,10000],[28,65,10000],[28,66,10000],[28,67,10000],[28,68,10000],[28,69,10000],[28,70,10000],[28,71,10000],[28,72,10000],[28,73,10000],[28,74,10000],[28,75,10000],[28,76,10000],[28,77,10000],[28,78,10000],[28,79,10000],[28,80,10000],[28,81,10000],[28,82,10000],[28,83,10000],[28,84,10000],[28,85,10000],[28,86,10000],[28,87,10000],[28,88,10000],[28,89,10000],[28,90,10000],[28,91,10000],[28,92,10000],[28,93,10000],[28,94,10000],[28,95,10000],[28,96,10000],[28,97,10000],[28,98,10000],[28,99,10000],[29,30,1],[29,31,10000],[29,32,10000],[29,33,10000],[29,34,10000],[29,35,10000],[29,36,10000],[29,37,10000],[29,38,10000],[29,39,10000],[29,40,10000],[29,41,10000],[29,42,10000],[29,43,10000],[29,44,10000],[29,45,10000],[29,46,10000],[29,47,10000],[29,48,10000],[29,49,10000],[29,50,10000],[29,51,10000],[29,52,10000],[29,53,10000],[29,54,10000],[29,55,10000],[29,56,10000],[29,57,10000],[29,58,10000],[29,59,10000],[29,60,10000],[29,61,10000],[29,62,10000],[29,63,10000],[29,64,10000],[29,65,10000],[29,66,10000],[29,67,10000],[29,68,10000],[29,69,10000],[29,70,10000],[29,71,10000],[29,72,10000],[29,73,10000],[29,74,10000],[29,75,10000],[29,76,10000],[29,77,10000],[29,78,10000],[29,79,10000],[29,80,10000],[29,81,10000],[29,82,10000],[29,83,10000],[29,84,10000],[29,85,10000],[29,86,10000],[29,87,10000],[29,88,10000],[29,89,10000],[29,90,10000],[29,91,10000],[29,92,10000],[29,93,10000],[29,94,10000],[29,95,10000],[29,96,10000],[29,97,10000],[29,98,10000],[29,99,10000],[30,31,1],[30,32,10000],[30,33,10000],[30,34,10000],[30,35,10000],[30,36,10000],[30,37,10000],[30,38,10000],[30,39,10000],[30,40,10000],[30,41,10000],[30,42,10000],[30,43,10000],[30,44,10000],[30,45,10000],[30,46,10000],[30,47,10000],[30,48,10000],[30,49,10000],[30,50,10000],[30,51,10000],[30,52,10000],[30,53,10000],[30,54,10000],[30,55,10000],[30,56,10000],[30,57,10000],[30,58,10000],[30,59,10000],[30,60,10000],[30,61,10000],[30,62,10000],[30,63,10000],[30,64,10000],[30,65,10000],[30,66,10000],[30,67,10000],[30,68,10000],[30,69,10000],[30,70,10000],[30,71,10000],[30,72,10000],[30,73,10000],[30,74,10000],[30,75,10000],[30,76,10000],[30,77,10000],[30,78,10000],[30,79,10000],[30,80,10000],[30,81,10000],[30,82,10000],[30,83,10000],[30,84,10000],[30,85,10000],[30,86,10000],[30,87,10000],[30,88,10000],[30,89,10000],[30,90,10000],[30,91,10000],[30,92,10000],[30,93,10000],[30,94,10000],[30,95,10000],[30,96,10000],[30,97,10000],[30,98,10000],[30,99,10000],[31,32,1],[31,33,10000],[31,34,10000],[31,35,10000],[31,36,10000],[31,37,10000],[31,38,10000],[31,39,10000],[31,40,10000],[31,41,10000],[31,42,10000],[31,43,10000],[31,44,10000],[31,45,10000],[31,46,10000],[31,47,10000],[31,48,10000],[31,49,10000],[31,50,10000],[31,51,10000],[31,52,10000],[31,53,10000],[31,54,10000],[31,55,10000],[31,56,10000],[31,57,10000],[31,58,10000],[31,59,10000],[31,60,10000],[31,61,10000],[31,62,10000],[31,63,10000],[31,64,10000],[31,65,10000],[31,66,10000],[31,67,10000],[31,68,10000],[31,69,10000],[31,70,10000],[31,71,10000],[31,72,10000],[31,73,10000],[31,74,10000],[31,75,10000],[31,76,10000],[31,77,10000],[31,78,10000],[31,79,10000],[31,80,10000],[31,81,10000],[31,82,10000],[31,83,10000],[31,84,10000],[31,85,10000],[31,86,10000],[31,87,10000],[31,88,10000],[31,89,10000],[31,90,10000],[31,91,10000],[31,92,10000],[31,93,10000],[31,94,10000],[31,95,10000],[31,96,10000],[31,97,10000],[31,98,10000],[31,99,10000],[32,33,1],[32,34,10000],[32,35,10000],[32,36,10000],[32,37,10000],[32,38,10000],[32,39,10000],[32,40,10000],[32,41,10000],[32,42,10000],[32,43,10000],[32,44,10000],[32,45,10000],[32,46,10000],[32,47,10000],[32,48,10000],[32,49,10000],[32,50,10000],[32,51,10000],[32,52,10000],[32,53,10000],[32,54,10000],[32,55,10000],[32,56,10000],[32,57,10000],[32,58,10000],[32,59,10000],[32,60,10000],[32,61,10000],[32,62,10000],[32,63,10000],[32,64,10000],[32,65,10000],[32,66,10000],[32,67,10000],[32,68,10000],[32,69,10000],[32,70,10000],[32,71,10000],[32,72,10000],[32,73,10000],[32,74,10000],[32,75,10000],[32,76,10000],[32,77,10000],[32,78,10000],[32,79,10000],[32,80,10000],[32,81,10000],[32,82,10000],[32,83,10000],[32,84,10000],[32,85,10000],[32,86,10000],[32,87,10000],[32,88,10000],[32,89,10000],[32,90,10000],[32,91,10000],[32,92,10000],[32,93,10000],[32,94,10000],[32,95,10000],[32,96,10000],[32,97,10000],[32,98,10000],[32,99,10000],[33,34,1],[33,35,10000],[33,36,10000],[33,37,10000],[33,38,10000],[33,39,10000],[33,40,10000],[33,41,10000],[33,42,10000],[33,43,10000],[33,44,10000],[33,45,10000],[33,46,10000],[33,47,10000],[33,48,10000],[33,49,10000],[33,50,10000],[33,51,10000],[33,52,10000],[33,53,10000],[33,54,10000],[33,55,10000],[33,56,10000],[33,57,10000],[33,58,10000],[33,59,10000],[33,60,10000],[33,61,10000],[33,62,10000],[33,63,10000],[33,64,10000],[33,65,10000],[33,66,10000],[33,67,10000],[33,68,10000],[33,69,10000],[33,70,10000],[33,71,10000],[33,72,10000],[33,73,10000],[33,74,10000],[33,75,10000],[33,76,10000],[33,77,10000],[33,78,10000],[33,79,10000],[33,80,10000],[33,81,10000],[33,82,10000],[33,83,10000],[33,84,10000],[33,85,10000],[33,86,10000],[33,87,10000],[33,88,10000],[33,89,10000],[33,90,10000],[33,91,10000],[33,92,10000],[33,93,10000],[33,94,10000],[33,95,10000],[33,96,10000],[33,97,10000],[33,98,10000],[33,99,10000],[34,35,1],[34,36,10000],[34,37,10000],[34,38,10000],[34,39,10000],[34,40,10000],[34,41,10000],[34,42,10000],[34,43,10000],[34,44,10000],[34,45,10000],[34,46,10000],[34,47,10000],[34,48,10000],[34,49,10000],[34,50,10000],[34,51,10000],[34,52,10000],[34,53,10000],[34,54,10000],[34,55,10000],[34,56,10000],[34,57,10000],[34,58,10000],[34,59,10000],[34,60,10000],[34,61,10000],[34,62,10000],[34,63,10000],[34,64,10000],[34,65,10000],[34,66,10000],[34,67,10000],[34,68,10000],[34,69,10000],[34,70,10000],[34,71,10000],[34,72,10000],[34,73,10000],[34,74,10000],[34,75,10000],[34,76,10000],[34,77,10000],[34,78,10000],[34,79,10000],[34,80,10000],[34,81,10000],[34,82,10000],[34,83,10000],[34,84,10000],[34,85,10000],[34,86,10000],[34,87,10000],[34,88,10000],[34,89,10000],[34,90,10000],[34,91,10000],[34,92,10000],[34,93,10000],[34,94,10000],[34,95,10000],[34,96,10000],[34,97,10000],[34,98,10000],[34,99,10000],[35,36,1],[35,37,10000],[35,38,10000],[35,39,10000],[35,40,10000],[35,41,10000],[35,42,10000],[35,43,10000],[35,44,10000],[35,45,10000],[35,46,10000],[35,47,10000],[35,48,10000],[35,49,10000],[35,50,10000],[35,51,10000],[35,52,10000],[35,53,10000],[35,54,10000],[35,55,10000],[35,56,10000],[35,57,10000],[35,58,10000],[35,59,10000],[35,60,10000],[35,61,10000],[35,62,10000],[35,63,10000],[35,64,10000],[35,65,10000],[35,66,10000],[35,67,10000],[35,68,10000],[35,69,10000],[35,70,10000],[35,71,10000],[35,72,10000],[35,73,10000],[35,74,10000],[35,75,10000],[35,76,10000],[35,77,10000],[35,78,10000],[35,79,10000],[35,80,10000],[35,81,10000],[35,82,10000],[35,83,10000],[35,84,10000],[35,85,10000],[35,86,10000],[35,87,10000],[35,88,10000],[35,89,10000],[35,90,10000],[35,91,10000],[35,92,10000],[35,93,10000],[35,94,10000],[35,95,10000],[35,96,10000],[35,97,10000],[35,98,10000],[35,99,10000],[36,37,1],[36,38,10000],[36,39,10000],[36,40,10000],[36,41,10000],[36,42,10000],[36,43,10000],[36,44,10000],[36,45,10000],[36,46,10000],[36,47,10000],[36,48,10000],[36,49,10000],[36,50,10000],[36,51,10000],[36,52,10000],[36,53,10000],[36,54,10000],[36,55,10000],[36,56,10000],[36,57,10000],[36,58,10000],[36,59,10000],[36,60,10000],[36,61,10000],[36,62,10000],[36,63,10000],[36,64,10000],[36,65,10000],[36,66,10000],[36,67,10000],[36,68,10000],[36,69,10000],[36,70,10000],[36,71,10000],[36,72,10000],[36,73,10000],[36,74,10000],[36,75,10000],[36,76,10000],[36,77,10000],[36,78,10000],[36,79,10000],[36,80,10000],[36,81,10000],[36,82,10000],[36,83,10000],[36,84,10000],[36,85,10000],[36,86,10000],[36,87,10000],[36,88,10000],[36,89,10000],[36,90,10000],[36,91,10000],[36,92,10000],[36,93,10000],[36,94,10000],[36,95,10000],[36,96,10000],[36,97,10000],[36,98,10000],[36,99,10000],[37,38,1],[37,39,10000],[37,40,10000],[37,41,10000],[37,42,10000],[37,43,10000],[37,44,10000],[37,45,10000],[37,46,10000],[37,47,10000],[37,48,10000],[37,49,10000],[37,50,10000],[37,51,10000],[37,52,10000],[37,53,10000],[37,54,10000],[37,55,10000],[37,56,10000],[37,57,10000],[37,58,10000],[37,59,10000],[37,60,10000],[37,61,10000],[37,62,10000],[37,63,10000],[37,64,10000],[37,65,10000],[37,66,10000],[37,67,10000],[37,68,10000],[37,69,10000],[37,70,10000],[37,71,10000],[37,72,10000],[37,73,10000],[37,74,10000],[37,75,10000],[37,76,10000],[37,77,10000],[37,78,10000],[37,79,10000],[37,80,10000],[37,81,10000],[37,82,10000],[37,83,10000],[37,84,10000],[37,85,10000],[37,86,10000],[37,87,10000],[37,88,10000],[37,89,10000],[37,90,10000],[37,91,10000],[37,92,10000],[37,93,10000],[37,94,10000],[37,95,10000],[37,96,10000],[37,97,10000],[37,98,10000],[37,99,10000],[38,39,1],[38,40,10000],[38,41,10000],[38,42,10000],[38,43,10000],[38,44,10000],[38,45,10000],[38,46,10000],[38,47,10000],[38,48,10000],[38,49,10000],[38,50,10000],[38,51,10000],[38,52,10000],[38,53,10000],[38,54,10000],[38,55,10000],[38,56,10000],[38,57,10000],[38,58,10000],[38,59,10000],[38,60,10000],[38,61,10000],[38,62,10000],[38,63,10000],[38,64,10000],[38,65,10000],[38,66,10000],[38,67,10000],[38,68,10000],[38,69,10000],[38,70,10000],[38,71,10000],[38,72,10000],[38,73,10000],[38,74,10000],[38,75,10000],[38,76,10000],[38,77,10000],[38,78,10000],[38,79,10000],[38,80,10000],[38,81,10000],[38,82,10000],[38,83,10000],[38,84,10000],[38,85,10000],[38,86,10000],[38,87,10000],[38,88,10000],[38,89,10000],[38,90,10000],[38,91,10000],[38,92,10000],[38,93,10000],[38,94,10000],[38,95,10000],[38,96,10000],[38,97,10000],[38,98,10000],[38,99,10000],[39,40,1],[39,41,10000],[39,42,10000],[39,43,10000],[39,44,10000],[39,45,10000],[39,46,10000],[39,47,10000],[39,48,10000],[39,49,10000],[39,50,10000],[39,51,10000],[39,52,10000],[39,53,10000],[39,54,10000],[39,55,10000],[39,56,10000],[39,57,10000],[39,58,10000],[39,59,10000],[39,60,10000],[39,61,10000],[39,62,10000],[39,63,10000],[39,64,10000],[39,65,10000],[39,66,10000],[39,67,10000],[39,68,10000],[39,69,10000],[39,70,10000],[39,71,10000],[39,72,10000],[39,73,10000],[39,74,10000],[39,75,10000],[39,76,10000],[39,77,10000],[39,78,10000],[39,79,10000],[39,80,10000],[39,81,10000],[39,82,10000],[39,83,10000],[39,84,10000],[39,85,10000],[39,86,10000],[39,87,10000],[39,88,10000],[39,89,10000],[39,90,10000],[39,91,10000],[39,92,10000],[39,93,10000],[39,94,10000],[39,95,10000],[39,96,10000],[39,97,10000],[39,98,10000],[39,99,10000],[40,41,1],[40,42,10000],[40,43,10000],[40,44,10000],[40,45,10000],[40,46,10000],[40,47,10000],[40,48,10000],[40,49,10000],[40,50,10000],[40,51,10000],[40,52,10000],[40,53,10000],[40,54,10000],[40,55,10000],[40,56,10000],[40,57,10000],[40,58,10000],[40,59,10000],[40,60,10000],[40,61,10000],[40,62,10000],[40,63,10000],[40,64,10000],[40,65,10000],[40,66,10000],[40,67,10000],[40,68,10000],[40,69,10000],[40,70,10000],[40,71,10000],[40,72,10000],[40,73,10000],[40,74,10000],[40,75,10000],[40,76,10000],[40,77,10000],[40,78,10000],[40,79,10000],[40,80,10000],[40,81,10000],[40,82,10000],[40,83,10000],[40,84,10000],[40,85,10000],[40,86,10000],[40,87,10000],[40,88,10000],[40,89,10000],[40,90,10000],[40,91,10000],[40,92,10000],[40,93,10000],[40,94,10000],[40,95,10000],[40,96,10000],[40,97,10000],[40,98,10000],[40,99,10000],[41,42,1],[41,43,10000],[41,44,10000],[41,45,10000],[41,46,10000],[41,47,10000],[41,48,10000],[41,49,10000],[41,50,10000],[41,51,10000],[41,52,10000],[41,53,10000],[41,54,10000],[41,55,10000],[41,56,10000],[41,57,10000],[41,58,10000],[41,59,10000],[41,60,10000],[41,61,10000],[41,62,10000],[41,63,10000],[41,64,10000],[41,65,10000],[41,66,10000],[41,67,10000],[41,68,10000],[41,69,10000],[41,70,10000],[41,71,10000],[41,72,10000],[41,73,10000],[41,74,10000],[41,75,10000],[41,76,10000],[41,77,10000],[41,78,10000],[41,79,10000],[41,80,10000],[41,81,10000],[41,82,10000],[41,83,10000],[41,84,10000],[41,85,10000],[41,86,10000],[41,87,10000],[41,88,10000],[41,89,10000],[41,90,10000],[41,91,10000],[41,92,10000],[41,93,10000],[41,94,10000],[41,95,10000],[41,96,10000],[41,97,10000],[41,98,10000],[41,99,10000],[42,43,1],[42,44,10000],[42,45,10000],[42,46,10000],[42,47,10000],[42,48,10000],[42,49,10000],[42,50,10000],[42,51,10000],[42,52,10000],[42,53,10000],[42,54,10000],[42,55,10000],[42,56,10000],[42,57,10000],[42,58,10000],[42,59,10000],[42,60,10000],[42,61,10000],[42,62,10000],[42,63,10000],[42,64,10000],[42,65,10000],[42,66,10000],[42,67,10000],[42,68,10000],[42,69,10000],[42,70,10000],[42,71,10000],[42,72,10000],[42,73,10000],[42,74,10000],[42,75,10000],[42,76,10000],[42,77,10000],[42,78,10000],[42,79,10000],[42,80,10000],[42,81,10000],[42,82,10000],[42,83,10000],[42,84,10000],[42,85,10000],[42,86,10000],[42,87,10000],[42,88,10000],[42,89,10000],[42,90,10000],[42,91,10000],[42,92,10000],[42,93,10000],[42,94,10000],[42,95,10000],[42,96,10000],[42,97,10000],[42,98,10000],[42,99,10000],[43,44,1],[43,45,10000],[43,46,10000],[43,47,10000],[43,48,10000],[43,49,10000],[43,50,10000],[43,51,10000],[43,52,10000],[43,53,10000],[43,54,10000],[43,55,10000],[43,56,10000],[43,57,10000],[43,58,10000],[43,59,10000],[43,60,10000],[43,61,10000],[43,62,10000],[43,63,10000],[43,64,10000],[43,65,10000],[43,66,10000],[43,67,10000],[43,68,10000],[43,69,10000],[43,70,10000],[43,71,10000],[43,72,10000],[43,73,10000],[43,74,10000],[43,75,10000],[43,76,10000],[43,77,10000],[43,78,10000],[43,79,10000],[43,80,10000],[43,81,10000],[43,82,10000],[43,83,10000],[43,84,10000],[43,85,10000],[43,86,10000],[43,87,10000],[43,88,10000],[43,89,10000],[43,90,10000],[43,91,10000],[43,92,10000],[43,93,10000],[43,94,10000],[43,95,10000],[43,96,10000],[43,97,10000],[43,98,10000],[43,99,10000],[44,45,1],[44,46,10000],[44,47,10000],[44,48,10000],[44,49,10000],[44,50,10000],[44,51,10000],[44,52,10000],[44,53,10000],[44,54,10000],[44,55,10000],[44,56,10000],[44,57,10000],[44,58,10000],[44,59,10000],[44,60,10000],[44,61,10000],[44,62,10000],[44,63,10000],[44,64,10000],[44,65,10000],[44,66,10000],[44,67,10000],[44,68,10000],[44,69,10000],[44,70,10000],[44,71,10000],[44,72,10000],[44,73,10000],[44,74,10000],[44,75,10000],[44,76,10000],[44,77,10000],[44,78,10000],[44,79,10000],[44,80,10000],[44,81,10000],[44,82,10000],[44,83,10000],[44,84,10000],[44,85,10000],[44,86,10000],[44,87,10000],[44,88,10000],[44,89,10000],[44,90,10000],[44,91,10000],[44,92,10000],[44,93,10000],[44,94,10000],[44,95,10000],[44,96,10000],[44,97,10000],[44,98,10000],[44,99,10000],[45,46,1],[45,47,10000],[45,48,10000],[45,49,10000],[45,50,10000],[45,51,10000],[45,52,10000],[45,53,10000],[45,54,10000],[45,55,10000],[45,56,10000],[45,57,10000],[45,58,10000],[45,59,10000],[45,60,10000],[45,61,10000],[45,62,10000],[45,63,10000],[45,64,10000],[45,65,10000],[45,66,10000],[45,67,10000],[45,68,10000],[45,69,10000],[45,70,10000],[45,71,10000],[45,72,10000],[45,73,10000],[45,74,10000],[45,75,10000],[45,76,10000],[45,77,10000],[45,78,10000],[45,79,10000],[45,80,10000],[45,81,10000],[45,82,10000],[45,83,10000],[45,84,10000],[45,85,10000],[45,86,10000],[45,87,10000],[45,88,10000],[45,89,10000],[45,90,10000],[45,91,10000],[45,92,10000],[45,93,10000],[45,94,10000],[45,95,10000],[45,96,10000],[45,97,10000],[45,98,10000],[45,99,10000],[46,47,1],[46,48,10000],[46,49,10000],[46,50,10000],[46,51,10000],[46,52,10000],[46,53,10000],[46,54,10000],[46,55,10000],[46,56,10000],[46,57,10000],[46,58,10000],[46,59,10000],[46,60,10000],[46,61,10000],[46,62,10000],[46,63,10000],[46,64,10000],[46,65,10000],[46,66,10000],[46,67,10000],[46,68,10000],[46,69,10000],[46,70,10000],[46,71,10000],[46,72,10000],[46,73,10000],[46,74,10000],[46,75,10000],[46,76,10000],[46,77,10000],[46,78,10000],[46,79,10000],[46,80,10000],[46,81,10000],[46,82,10000],[46,83,10000],[46,84,10000],[46,85,10000],[46,86,10000],[46,87,10000],[46,88,10000],[46,89,10000],[46,90,10000],[46,91,10000],[46,92,10000],[46,93,10000],[46,94,10000],[46,95,10000],[46,96,10000],[46,97,10000],[46,98,10000],[46,99,10000],[47,48,1],[47,49,10000],[47,50,10000],[47,51,10000],[47,52,10000],[47,53,10000],[47,54,10000],[47,55,10000],[47,56,10000],[47,57,10000],[47,58,10000],[47,59,10000],[47,60,10000],[47,61,10000],[47,62,10000],[47,63,10000],[47,64,10000],[47,65,10000],[47,66,10000],[47,67,10000],[47,68,10000],[47,69,10000],[47,70,10000],[47,71,10000],[47,72,10000],[47,73,10000],[47,74,10000],[47,75,10000],[47,76,10000],[47,77,10000],[47,78,10000],[47,79,10000],[47,80,10000],[47,81,10000],[47,82,10000],[47,83,10000],[47,84,10000],[47,85,10000],[47,86,10000],[47,87,10000],[47,88,10000],[47,89,10000],[47,90,10000],[47,91,10000],[47,92,10000],[47,93,10000],[47,94,10000],[47,95,10000],[47,96,10000],[47,97,10000],[47,98,10000],[47,99,10000],[48,49,1],[48,50,10000],[48,51,10000],[48,52,10000],[48,53,10000],[48,54,10000],[48,55,10000],[48,56,10000],[48,57,10000],[48,58,10000],[48,59,10000],[48,60,10000],[48,61,10000],[48,62,10000],[48,63,10000],[48,64,10000],[48,65,10000],[48,66,10000],[48,67,10000],[48,68,10000],[48,69,10000],[48,70,10000],[48,71,10000],[48,72,10000],[48,73,10000],[48,74,10000],[48,75,10000],[48,76,10000],[48,77,10000],[48,78,10000],[48,79,10000],[48,80,10000],[48,81,10000],[48,82,10000],[48,83,10000],[48,84,10000],[48,85,10000],[48,86,10000],[48,87,10000],[48,88,10000],[48,89,10000],[48,90,10000],[48,91,10000],[48,92,10000],[48,93,10000],[48,94,10000],[48,95,10000],[48,96,10000],[48,97,10000],[48,98,10000],[48,99,10000],[49,50,1],[49,51,10000],[49,52,10000],[49,53,10000],[49,54,10000],[49,55,10000],[49,56,10000],[49,57,10000],[49,58,10000],[49,59,10000],[49,60,10000],[49,61,10000],[49,62,10000],[49,63,10000],[49,64,10000],[49,65,10000],[49,66,10000],[49,67,10000],[49,68,10000],[49,69,10000],[49,70,10000],[49,71,10000],[49,72,10000],[49,73,10000],[49,74,10000],[49,75,10000],[49,76,10000],[49,77,10000],[49,78,10000],[49,79,10000],[49,80,10000],[49,81,10000],[49,82,10000],[49,83,10000],[49,84,10000],[49,85,10000],[49,86,10000],[49,87,10000],[49,88,10000],[49,89,10000],[49,90,10000],[49,91,10000],[49,92,10000],[49,93,10000],[49,94,10000],[49,95,10000],[49,96,10000],[49,97,10000],[49,98,10000],[49,99,10000],[50,51,1],[50,52,10000],[50,53,10000],[50,54,10000],[50,55,10000],[50,56,10000],[50,57,10000],[50,58,10000],[50,59,10000],[50,60,10000],[50,61,10000],[50,62,10000],[50,63,10000],[50,64,10000],[50,65,10000],[50,66,10000],[50,67,10000],[50,68,10000],[50,69,10000],[50,70,10000],[50,71,10000],[50,72,10000],[50,73,10000],[50,74,10000],[50,75,10000],[50,76,10000],[50,77,10000],[50,78,10000],[50,79,10000],[50,80,10000],[50,81,10000],[50,82,10000],[50,83,10000],[50,84,10000],[50,85,10000],[50,86,10000],[50,87,10000],[50,88,10000],[50,89,10000],[50,90,10000],[50,91,10000],[50,92,10000],[50,93,10000],[50,94,10000],[50,95,10000],[50,96,10000],[50,97,10000],[50,98,10000],[50,99,10000],[51,52,1],[51,53,10000],[51,54,10000],[51,55,10000],[51,56,10000],[51,57,10000],[51,58,10000],[51,59,10000],[51,60,10000],[51,61,10000],[51,62,10000],[51,63,10000],[51,64,10000],[51,65,10000],[51,66,10000],[51,67,10000],[51,68,10000],[51,69,10000],[51,70,10000],[51,71,10000],[51,72,10000],[51,73,10000],[51,74,10000],[51,75,10000],[51,76,10000],[51,77,10000],[51,78,10000],[51,79,10000],[51,80,10000],[51,81,10000],[51,82,10000],[51,83,10000],[51,84,10000],[51,85,10000],[51,86,10000],[51,87,10000],[51,88,10000],[51,89,10000],[51,90,10000],[51,91,10000],[51,92,10000],[51,93,10000],[51,94,10000],[51,95,10000],[51,96,10000],[51,97,10000],[51,98,10000],[51,99,10000],[52,53,1],[52,54,10000],[52,55,10000],[52,56,10000],[52,57,10000],[52,58,10000],[52,59,10000],[52,60,10000],[52,61,10000],[52,62,10000],[52,63,10000],[52,64,10000],[52,65,10000],[52,66,10000],[52,67,10000],[52,68,10000],[52,69,10000],[52,70,10000],[52,71,10000],[52,72,10000],[52,73,10000],[52,74,10000],[52,75,10000],[52,76,10000],[52,77,10000],[52,78,10000],[52,79,10000],[52,80,10000],[52,81,10000],[52,82,10000],[52,83,10000],[52,84,10000],[52,85,10000],[52,86,10000],[52,87,10000],[52,88,10000],[52,89,10000],[52,90,10000],[52,91,10000],[52,92,10000],[52,93,10000],[52,94,10000],[52,95,10000],[52,96,10000],[52,97,10000],[52,98,10000],[52,99,10000],[53,54,1],[53,55,10000],[53,56,10000],[53,57,10000],[53,58,10000],[53,59,10000],[53,60,10000],[53,61,10000],[53,62,10000],[53,63,10000],[53,64,10000],[53,65,10000],[53,66,10000],[53,67,10000],[53,68,10000],[53,69,10000],[53,70,10000],[53,71,10000],[53,72,10000],[53,73,10000],[53,74,10000],[53,75,10000],[53,76,10000],[53,77,10000],[53,78,10000],[53,79,10000],[53,80,10000],[53,81,10000],[53,82,10000],[53,83,10000],[53,84,10000],[53,85,10000],[53,86,10000],[53,87,10000],[53,88,10000],[53,89,10000],[53,90,10000],[53,91,10000],[53,92,10000],[53,93,10000],[53,94,10000],[53,95,10000],[53,96,10000],[53,97,10000],[53,98,10000],[53,99,10000],[54,55,1],[54,56,10000],[54,57,10000],[54,58,10000],[54,59,10000],[54,60,10000],[54,61,10000],[54,62,10000],[54,63,10000],[54,64,10000],[54,65,10000],[54,66,10000],[54,67,10000],[54,68,10000],[54,69,10000],[54,70,10000],[54,71,10000],[54,72,10000],[54,73,10000],[54,74,10000],[54,75,10000],[54,76,10000],[54,77,10000],[54,78,10000],[54,79,10000],[54,80,10000],[54,81,10000],[54,82,10000],[54,83,10000],[54,84,10000],[54,85,10000],[54,86,10000],[54,87,10000],[54,88,10000],[54,89,10000],[54,90,10000],[54,91,10000],[54,92,10000],[54,93,10000],[54,94,10000],[54,95,10000],[54,96,10000],[54,97,10000],[54,98,10000],[54,99,10000],[55,56,1],[55,57,10000],[55,58,10000],[55,59,10000],[55,60,10000],[55,61,10000],[55,62,10000],[55,63,10000],[55,64,10000],[55,65,10000],[55,66,10000],[55,67,10000],[55,68,10000],[55,69,10000],[55,70,10000],[55,71,10000],[55,72,10000],[55,73,10000],[55,74,10000],[55,75,10000],[55,76,10000],[55,77,10000],[55,78,10000],[55,79,10000],[55,80,10000],[55,81,10000],[55,82,10000],[55,83,10000],[55,84,10000],[55,85,10000],[55,86,10000],[55,87,10000],[55,88,10000],[55,89,10000],[55,90,10000],[55,91,10000],[55,92,10000],[55,93,10000],[55,94,10000],[55,95,10000],[55,96,10000],[55,97,10000],[55,98,10000],[55,99,10000],[56,57,1],[56,58,10000],[56,59,10000],[56,60,10000],[56,61,10000],[56,62,10000],[56,63,10000],[56,64,10000],[56,65,10000],[56,66,10000],[56,67,10000],[56,68,10000],[56,69,10000],[56,70,10000],[56,71,10000],[56,72,10000],[56,73,10000],[56,74,10000],[56,75,10000],[56,76,10000],[56,77,10000],[56,78,10000],[56,79,10000],[56,80,10000],[56,81,10000],[56,82,10000],[56,83,10000],[56,84,10000],[56,85,10000],[56,86,10000],[56,87,10000],[56,88,10000],[56,89,10000],[56,90,10000],[56,91,10000],[56,92,10000],[56,93,10000],[56,94,10000],[56,95,10000],[56,96,10000],[56,97,10000],[56,98,10000],[56,99,10000],[57,58,1],[57,59,10000],[57,60,10000],[57,61,10000],[57,62,10000],[57,63,10000],[57,64,10000],[57,65,10000],[57,66,10000],[57,67,10000],[57,68,10000],[57,69,10000],[57,70,10000],[57,71,10000],[57,72,10000],[57,73,10000],[57,74,10000],[57,75,10000],[57,76,10000],[57,77,10000],[57,78,10000],[57,79,10000],[57,80,10000],[57,81,10000],[57,82,10000],[57,83,10000],[57,84,10000],[57,85,10000],[57,86,10000],[57,87,10000],[57,88,10000],[57,89,10000],[57,90,10000],[57,91,10000],[57,92,10000],[57,93,10000],[57,94,10000],[57,95,10000],[57,96,10000],[57,97,10000],[57,98,10000],[57,99,10000],[58,59,1],[58,60,10000],[58,61,10000],[58,62,10000],[58,63,10000],[58,64,10000],[58,65,10000],[58,66,10000],[58,67,10000],[58,68,10000],[58,69,10000],[58,70,10000],[58,71,10000],[58,72,10000],[58,73,10000],[58,74,10000],[58,75,10000],[58,76,10000],[58,77,10000],[58,78,10000],[58,79,10000],[58,80,10000],[58,81,10000],[58,82,10000],[58,83,10000],[58,84,10000],[58,85,10000],[58,86,10000],[58,87,10000],[58,88,10000],[58,89,10000],[58,90,10000],[58,91,10000],[58,92,10000],[58,93,10000],[58,94,10000],[58,95,10000],[58,96,10000],[58,97,10000],[58,98,10000],[58,99,10000],[59,60,1],[59,61,10000],[59,62,10000],[59,63,10000],[59,64,10000],[59,65,10000],[59,66,10000],[59,67,10000],[59,68,10000],[59,69,10000],[59,70,10000],[59,71,10000],[59,72,10000],[59,73,10000],[59,74,10000],[59,75,10000],[59,76,10000],[59,77,10000],[59,78,10000],[59,79,10000],[59,80,10000],[59,81,10000],[59,82,10000],[59,83,10000],[59,84,10000],[59,85,10000],[59,86,10000],[59,87,10000],[59,88,10000],[59,89,10000],[59,90,10000],[59,91,10000],[59,92,10000],[59,93,10000],[59,94,10000],[59,95,10000],[59,96,10000],[59,97,10000],[59,98,10000],[59,99,10000],[60,61,1],[60,62,10000],[60,63,10000],[60,64,10000],[60,65,10000],[60,66,10000],[60,67,10000],[60,68,10000],[60,69,10000],[60,70,10000],[60,71,10000],[60,72,10000],[60,73,10000],[60,74,10000],[60,75,10000],[60,76,10000],[60,77,10000],[60,78,10000],[60,79,10000],[60,80,10000],[60,81,10000],[60,82,10000],[60,83,10000],[60,84,10000],[60,85,10000],[60,86,10000],[60,87,10000],[60,88,10000],[60,89,10000],[60,90,10000],[60,91,10000],[60,92,10000],[60,93,10000],[60,94,10000],[60,95,10000],[60,96,10000],[60,97,10000],[60,98,10000],[60,99,10000],[61,62,1],[61,63,10000],[61,64,10000],[61,65,10000],[61,66,10000],[61,67,10000],[61,68,10000],[61,69,10000],[61,70,10000],[61,71,10000],[61,72,10000],[61,73,10000],[61,74,10000],[61,75,10000],[61,76,10000],[61,77,10000],[61,78,10000],[61,79,10000],[61,80,10000],[61,81,10000],[61,82,10000],[61,83,10000],[61,84,10000],[61,85,10000],[61,86,10000],[61,87,10000],[61,88,10000],[61,89,10000],[61,90,10000],[61,91,10000],[61,92,10000],[61,93,10000],[61,94,10000],[61,95,10000],[61,96,10000],[61,97,10000],[61,98,10000],[61,99,10000],[62,63,1],[62,64,10000],[62,65,10000],[62,66,10000],[62,67,10000],[62,68,10000],[62,69,10000],[62,70,10000],[62,71,10000],[62,72,10000],[62,73,10000],[62,74,10000],[62,75,10000],[62,76,10000],[62,77,10000],[62,78,10000],[62,79,10000],[62,80,10000],[62,81,10000],[62,82,10000],[62,83,10000],[62,84,10000],[62,85,10000],[62,86,10000],[62,87,10000],[62,88,10000],[62,89,10000],[62,90,10000],[62,91,10000],[62,92,10000],[62,93,10000],[62,94,10000],[62,95,10000],[62,96,10000],[62,97,10000],[62,98,10000],[62,99,10000],[63,64,1],[63,65,10000],[63,66,10000],[63,67,10000],[63,68,10000],[63,69,10000],[63,70,10000],[63,71,10000],[63,72,10000],[63,73,10000],[63,74,10000],[63,75,10000],[63,76,10000],[63,77,10000],[63,78,10000],[63,79,10000],[63,80,10000],[63,81,10000],[63,82,10000],[63,83,10000],[63,84,10000],[63,85,10000],[63,86,10000],[63,87,10000],[63,88,10000],[63,89,10000],[63,90,10000],[63,91,10000],[63,92,10000],[63,93,10000],[63,94,10000],[63,95,10000],[63,96,10000],[63,97,10000],[63,98,10000],[63,99,10000],[64,65,1],[64,66,10000],[64,67,10000],[64,68,10000],[64,69,10000],[64,70,10000],[64,71,10000],[64,72,10000],[64,73,10000],[64,74,10000],[64,75,10000],[64,76,10000],[64,77,10000],[64,78,10000],[64,79,10000],[64,80,10000],[64,81,10000],[64,82,10000],[64,83,10000],[64,84,10000],[64,85,10000],[64,86,10000],[64,87,10000],[64,88,10000],[64,89,10000],[64,90,10000],[64,91,10000],[64,92,10000],[64,93,10000],[64,94,10000],[64,95,10000],[64,96,10000],[64,97,10000],[64,98,10000],[64,99,10000],[65,66,1],[65,67,10000],[65,68,10000],[65,69,10000],[65,70,10000],[65,71,10000],[65,72,10000],[65,73,10000],[65,74,10000],[65,75,10000],[65,76,10000],[65,77,10000],[65,78,10000],[65,79,10000],[65,80,10000],[65,81,10000],[65,82,10000],[65,83,10000],[65,84,10000],[65,85,10000],[65,86,10000],[65,87,10000],[65,88,10000],[65,89,10000],[65,90,10000],[65,91,10000],[65,92,10000],[65,93,10000],[65,94,10000],[65,95,10000],[65,96,10000],[65,97,10000],[65,98,10000],[65,99,10000],[66,67,1],[66,68,10000],[66,69,10000],[66,70,10000],[66,71,10000],[66,72,10000],[66,73,10000],[66,74,10000],[66,75,10000],[66,76,10000],[66,77,10000],[66,78,10000],[66,79,10000],[66,80,10000],[66,81,10000],[66,82,10000],[66,83,10000],[66,84,10000],[66,85,10000],[66,86,10000],[66,87,10000],[66,88,10000],[66,89,10000],[66,90,10000],[66,91,10000],[66,92,10000],[66,93,10000],[66,94,10000],[66,95,10000],[66,96,10000],[66,97,10000],[66,98,10000],[66,99,10000],[67,68,1],[67,69,10000],[67,70,10000],[67,71,10000],[67,72,10000],[67,73,10000],[67,74,10000],[67,75,10000],[67,76,10000],[67,77,10000],[67,78,10000],[67,79,10000],[67,80,10000],[67,81,10000],[67,82,10000],[67,83,10000],[67,84,10000],[67,85,10000],[67,86,10000],[67,87,10000],[67,88,10000],[67,89,10000],[67,90,10000],[67,91,10000],[67,92,10000],[67,93,10000],[67,94,10000],[67,95,10000],[67,96,10000],[67,97,10000],[67,98,10000],[67,99,10000],[68,69,1],[68,70,10000],[68,71,10000],[68,72,10000],[68,73,10000],[68,74,10000],[68,75,10000],[68,76,10000],[68,77,10000],[68,78,10000],[68,79,10000],[68,80,10000],[68,81,10000],[68,82,10000],[68,83,10000],[68,84,10000],[68,85,10000],[68,86,10000],[68,87,10000],[68,88,10000],[68,89,10000],[68,90,10000],[68,91,10000],[68,92,10000],[68,93,10000],[68,94,10000],[68,95,10000],[68,96,10000],[68,97,10000],[68,98,10000],[68,99,10000],[69,70,1],[69,71,10000],[69,72,10000],[69,73,10000],[69,74,10000],[69,75,10000],[69,76,10000],[69,77,10000],[69,78,10000],[69,79,10000],[69,80,10000],[69,81,10000],[69,82,10000],[69,83,10000],[69,84,10000],[69,85,10000],[69,86,10000],[69,87,10000],[69,88,10000],[69,89,10000],[69,90,10000],[69,91,10000],[69,92,10000],[69,93,10000],[69,94,10000],[69,95,10000],[69,96,10000],[69,97,10000],[69,98,10000],[69,99,10000],[70,71,1],[70,72,10000],[70,73,10000],[70,74,10000],[70,75,10000],[70,76,10000],[70,77,10000],[70,78,10000],[70,79,10000],[70,80,10000],[70,81,10000],[70,82,10000],[70,83,10000],[70,84,10000],[70,85,10000],[70,86,10000],[70,87,10000],[70,88,10000],[70,89,10000],[70,90,10000],[70,91,10000],[70,92,10000],[70,93,10000],[70,94,10000],[70,95,10000],[70,96,10000],[70,97,10000],[70,98,10000],[70,99,10000],[71,72,1],[71,73,10000],[71,74,10000],[71,75,10000],[71,76,10000],[71,77,10000],[71,78,10000],[71,79,10000],[71,80,10000],[71,81,10000],[71,82,10000],[71,83,10000],[71,84,10000],[71,85,10000],[71,86,10000],[71,87,10000],[71,88,10000],[71,89,10000],[71,90,10000],[71,91,10000],[71,92,10000],[71,93,10000],[71,94,10000],[71,95,10000],[71,96,10000],[71,97,10000],[71,98,10000],[71,99,10000],[72,73,1],[72,74,10000],[72,75,10000],[72,76,10000],[72,77,10000],[72,78,10000],[72,79,10000],[72,80,10000],[72,81,10000],[72,82,10000],[72,83,10000],[72,84,10000],[72,85,10000],[72,86,10000],[72,87,10000],[72,88,10000],[72,89,10000],[72,90,10000],[72,91,10000],[72,92,10000],[72,93,10000],[72,94,10000],[72,95,10000],[72,96,10000],[72,97,10000],[72,98,10000],[72,99,10000],[73,74,1],[73,75,10000],[73,76,10000],[73,77,10000],[73,78,10000],[73,79,10000],[73,80,10000],[73,81,10000],[73,82,10000],[73,83,10000],[73,84,10000],[73,85,10000],[73,86,10000],[73,87,10000],[73,88,10000],[73,89,10000],[73,90,10000],[73,91,10000],[73,92,10000],[73,93,10000],[73,94,10000],[73,95,10000],[73,96,10000],[73,97,10000],[73,98,10000],[73,99,10000],[74,75,1],[74,76,10000],[74,77,10000],[74,78,10000],[74,79,10000],[74,80,10000],[74,81,10000],[74,82,10000],[74,83,10000],[74,84,10000],[74,85,10000],[74,86,10000],[74,87,10000],[74,88,10000],[74,89,10000],[74,90,10000],[74,91,10000],[74,92,10000],[74,93,10000],[74,94,10000],[74,95,10000],[74,96,10000],[74,97,10000],[74,98,10000],[74,99,10000],[75,76,1],[75,77,10000],[75,78,10000],[75,79,10000],[75,80,10000],[75,81,10000],[75,82,10000],[75,83,10000],[75,84,10000],[75,85,10000],[75,86,10000],[75,87,10000],[75,88,10000],[75,89,10000],[75,90,10000],[75,91,10000],[75,92,10000],[75,93,10000],[75,94,10000],[75,95,10000],[75,96,10000],[75,97,10000],[75,98,10000],[75,99,10000],[76,77,1],[76,78,10000],[76,79,10000],[76,80,10000],[76,81,10000],[76,82,10000],[76,83,10000],[76,84,10000],[76,85,10000],[76,86,10000],[76,87,10000],[76,88,10000],[76,89,10000],[76,90,10000],[76,91,10000],[76,92,10000],[76,93,10000],[76,94,10000],[76,95,10000],[76,96,10000],[76,97,10000],[76,98,10000],[76,99,10000],[77,78,1],[77,79,10000],[77,80,10000],[77,81,10000],[77,82,10000],[77,83,10000],[77,84,10000],[77,85,10000],[77,86,10000],[77,87,10000],[77,88,10000],[77,89,10000],[77,90,10000],[77,91,10000],[77,92,10000],[77,93,10000],[77,94,10000],[77,95,10000],[77,96,10000],[77,97,10000],[77,98,10000],[77,99,10000],[78,79,1],[78,80,10000],[78,81,10000],[78,82,10000],[78,83,10000],[78,84,10000],[78,85,10000],[78,86,10000],[78,87,10000],[78,88,10000],[78,89,10000],[78,90,10000],[78,91,10000],[78,92,10000],[78,93,10000],[78,94,10000],[78,95,10000],[78,96,10000],[78,97,10000],[78,98,10000],[78,99,10000],[79,80,1],[79,81,10000],[79,82,10000],[79,83,10000],[79,84,10000],[79,85,10000],[79,86,10000],[79,87,10000],[79,88,10000],[79,89,10000],[79,90,10000],[79,91,10000],[79,92,10000],[79,93,10000],[79,94,10000],[79,95,10000],[79,96,10000],[79,97,10000],[79,98,10000],[79,99,10000],[80,81,1],[80,82,10000],[80,83,10000],[80,84,10000],[80,85,10000],[80,86,10000],[80,87,10000],[80,88,10000],[80,89,10000],[80,90,10000],[80,91,10000],[80,92,10000],[80,93,10000],[80,94,10000],[80,95,10000],[80,96,10000],[80,97,10000],[80,98,10000],[80,99,10000],[81,82,1],[81,83,10000],[81,84,10000],[81,85,10000],[81,86,10000],[81,87,10000],[81,88,10000],[81,89,10000],[81,90,10000],[81,91,10000],[81,92,10000],[81,93,10000],[81,94,10000],[81,95,10000],[81,96,10000],[81,97,10000],[81,98,10000],[81,99,10000],[82,83,1],[82,84,10000],[82,85,10000],[82,86,10000],[82,87,10000],[82,88,10000],[82,89,10000],[82,90,10000],[82,91,10000],[82,92,10000],[82,93,10000],[82,94,10000],[82,95,10000],[82,96,10000],[82,97,10000],[82,98,10000],[82,99,10000],[83,84,1],[83,85,10000],[83,86,10000],[83,87,10000],[83,88,10000],[83,89,10000],[83,90,10000],[83,91,10000],[83,92,10000],[83,93,10000],[83,94,10000],[83,95,10000],[83,96,10000],[83,97,10000],[83,98,10000],[83,99,10000],[84,85,1],[84,86,10000],[84,87,10000],[84,88,10000],[84,89,10000],[84,90,10000],[84,91,10000],[84,92,10000],[84,93,10000],[84,94,10000],[84,95,10000],[84,96,10000],[84,97,10000],[84,98,10000],[84,99,10000],[85,86,1],[85,87,10000],[85,88,10000],[85,89,10000],[85,90,10000],[85,91,10000],[85,92,10000],[85,93,10000],[85,94,10000],[85,95,10000],[85,96,10000],[85,97,10000],[85,98,10000],[85,99,10000],[86,87,1],[86,88,10000],[86,89,10000],[86,90,10000],[86,91,10000],[86,92,10000],[86,93,10000],[86,94,10000],[86,95,10000],[86,96,10000],[86,97,10000],[86,98,10000],[86,99,10000],[87,88,1],[87,89,10000],[87,90,10000],[87,91,10000],[87,92,10000],[87,93,10000],[87,94,10000],[87,95,10000],[87,96,10000],[87,97,10000],[87,98,10000],[87,99,10000],[88,89,1],[88,90,10000],[88,91,10000],[88,92,10000],[88,93,10000],[88,94,10000],[88,95,10000],[88,96,10000],[88,97,10000],[88,98,10000],[88,99,10000],[89,90,1],[89,91,10000],[89,92,10000],[89,93,10000],[89,94,10000],[89,95,10000],[89,96,10000],[89,97,10000],[89,98,10000],[89,99,10000],[90,91,1],[90,92,10000],[90,93,10000],[90,94,10000],[90,95,10000],[90,96,10000],[90,97,10000],[90,98,10000],[90,99,10000],[91,92,1],[91,93,10000],[91,94,10000],[91,95,10000],[91,96,10000],[91,97,10000],[91,98,10000],[91,99,10000],[92,93,1],[92,94,10000],[92,95,10000],[92,96,10000],[92,97,10000],[92,98,10000],[92,99,10000],[93,94,1],[93,95,10000],[93,96,10000],[93,97,10000],[93,98,10000],[93,99,10000],[94,95,1],[94,96,10000],[94,97,10000],[94,98,10000],[94,99,10000],[95,96,1],[95,97,10000],[95,98,10000],[95,99,10000],[96,97,1],[96,98,10000],[96,99,10000],[97,98,1],[97,99,10000],[98,99,1]]", "0", "99", "99"]], "expected": [5, -1, 7, 10000, 500, 200, -1, -1, 10, 20, 21, 40, 700, 400, 10, 10, 3, 7, 5, -1, 21, 15, 20, 20, 8, 30, 12, 9, -1, 16, 8, 50, 5, 15, 14, 22, 25, -1, 30, 18, 14, 12, 25, 21, 100, 7, 15, 13, 50, 18, 22, 66, 99], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "944", "slug": "check-completeness-of-a-binary-tree", "id": 944, "title": "Check Completeness of a Binary Tree", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/check-completeness-of-a-binary-tree/", "examples": [{"input": "root = [1,2,3,4,5,6]", "output": "true", "explanation": "Every level is full, so the tree satisfies the completeness rule."}, {"input": "root = [1,2,3,4,5,null,7]", "output": "false", "explanation": "Node 3 is missing its left child yet has a right child 7, which breaks left-alignment."}, {"input": "root = [1,null,2]", "output": "false", "explanation": "The root lacks a left child while holding a right child, so the tree is incomplete."}], "hints": ["Walk the tree level by level, enqueueing empty child slots as well as real nodes.", "Once the first empty slot appears, any later real node disqualifies the tree.", "An empty tree counts as complete."], "statement": "A binary tree is complete when every level except possibly the last is entirely filled, and all nodes of the last level sit as far left as possible. Equivalently, a level-order walk never meets a present node after the first missing slot.\n\nGiven the level-order serialization `root` of a binary tree, decide whether the tree is complete.\n\n**Constraints:**\n- The tree holds between 0 and 100 nodes.\n- Node values are integers fitting in a 32-bit signed range.\n", "solution": "## Approach\n\nWalk the tree in level order while remembering whether a missing child slot has been seen. Enqueue both children of every node (including nulls). The first null marks the point after which no real node may appear; encountering a real node afterwards proves the tree is incomplete. An empty tree passes trivially.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) for n nodes, each visited once.\n- **Space Complexity:** O(n) for the breadth-first queue in the worst case.\n\n## Implementation\n\n```python\nfrom collections import deque\n\nclass Solution:\n def isCompleteTree(self, root) -> bool:\n if root is None:\n return True\n q = deque([root])\n gap_seen = False\n while q:\n cur = q.popleft()\n if cur is None:\n gap_seen = True\n else:\n if gap_seen:\n return False\n q.append(cur.left)\n q.append(cur.right)\n return True\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 IsCompleteTree(root *TreeNode) bool {\n return false\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\nclass Solution:\n def isCompleteTree(self, root) -> bool:\n return False", "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;\n\nclass Solution {\npublic:\n bool isCompleteTree(TreeNode* root) {\n return false;\n }\n};"}, "fn": "isCompleteTree", "params": [{"name": "root", "type": "tree_node"}], "outputType": "boolean", "tests": [["[1,2,3,4,5,6]"], ["[1,2,3,4,5,null,7]"], ["[1,null,2]"], ["[1]"], ["[]"], ["[1,2,3,4,null,null,7]"], ["[1,2,null,3]"], ["[1,2,3,4,5,6,7,8,9,10,11,12]"], ["[1,2,3,4,5,null,null]"], ["[1,2,3,null,5,6,7]"], ["[1,2,3,4,5,6,7,8]"], ["[1,2,3,4,5,6,null,null,null,10]"], ["[3,1,2]"], ["[1,2,3,null,null,6]"], ["[1,2,3,4,5,6,7,8,9,10]"], ["[5,4,6,3,null,null,7]"], ["[1,null,2,3]"], ["[1,2,3,4,5,6,7,null,null,10,11]"], ["[2,1,3,null,4]"], ["[1,2,3,4,null,6,7]"], ["[1,2,3,4,5,6,7,8,9]"], ["[1,2,3,4,5,6,7,8,9,10,11]"], ["[10,20,30,40,50]"], ["[1,2,3,null,5]"], ["[1,2,null,4,5,6,7]"], ["[1,2,3,4,5,null,7,8]"], ["[7,3,9,1,5,null,10]"], ["[1,2,3,4,5,6,7,null,9]"]], "expected": [true, false, false, true, true, false, false, true, true, false, true, false, true, false, true, false, false, false, false, false, true, true, true, false, false, false, false, false], "loose": false}
|