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": "814", "slug": "ambiguous-coordinates", "id": 814, "title": "Ambiguous Coordinates", "difficulty": "Medium", "category": "backtracking", "link": "https://leetcode.com/problems/ambiguous-coordinates/", "examples": [{"input": "s = \"(123)\"", "output": "[\"(1, 23)\",\"(1, 2.3)\",\"(12, 3)\",\"(1.2, 3)\"] (order may vary)", "explanation": "Splitting the digits as 1|23 and 12|3 and decorating each side with an optional decimal point yields four valid pairs."}, {"input": "s = \"(00011)\"", "output": "[\"(0.001, 1)\"]", "explanation": "Leading-zero and trailing-zero rules leave only one legal rendering."}, {"input": "s = \"(0123)\"", "output": "[\"(0, 123)\",\"(0, 12.3)\",\"(0, 1.23)\",\"(0.1, 23)\",\"(0.1, 2.3)\",\"(0.12, 3)\"] (order may vary)", "explanation": "The left part must stay 0 or 0.xxx while the right part varies freely."}], "hints": ["Strip the outer parentheses, then try every split of the inner digits into left and right halves.", "A piece is valid as an integer when it is exactly 0 or has no leading zero; as a decimal it needs no leading zero unless it starts with 0. and no trailing zero in the fraction."], "statement": "You receive a parenthesized digit string such as `\"(123)\"`. Imagine removing the parentheses, cutting the remaining digits into two non-empty halves, and optionally inserting one decimal point inside each half to form two numbers. List every distinct coordinate pair that follows the standard numeric spelling rules.\n\nA half without a dot is legal when it is exactly `\"0\"` or does not start with `0`. A half with a dot `\"A.B\"` is legal when `A` is `\"0\"` or has no leading zero, and `B` does not end with `0` (so no trailing zeros after the point). Report each pair as `\"(left, right)\"`.\n\nAdaptation note: this task uses the portable `string_list` output type; ordering is ignored during judging (lists are compared sorted).\n\n**Constraints:**\n- `4 <= s.length <= 12`\n- `s` starts with `(` and ends with `)`.\n- The inside holds only digits `0-9`.\n", "solution": "## Approach\n\nRemove the surrounding parentheses and try every way to split the digit core into a left and right half. For each half, generate all legal numbers: a single digit is always fine; otherwise handle the leading-zero and trailing-zero cases first, and in the general case offer the plain integer plus every single-dot placement. Pair every left option with every right option and format as `\"(a, b)\"`. Sorting at comparison time makes order irrelevant.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^3) for n inner digits, dominated by building decimal strings.\n- **Space Complexity:** O(n^2) for the option lists and output.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def ambiguousCoordinates(self, s: str) -> List[str]:\n t = s[1:-1]\n def make(part: str) -> List[str]:\n n = len(part)\n if n == 0:\n return []\n if n == 1:\n return [part]\n if part[0] == '0' and part[-1] == '0':\n return []\n if part[0] == '0':\n return [\"0.\" + part[1:]]\n if part[-1] == '0':\n return [part]\n out = [part]\n for i in range(1, n):\n out.append(part[:i] + \".\" + part[i:])\n return out\n res = []\n for i in range(1, len(t)):\n for a in make(t[:i]):\n for b in make(t[i:]):\n res.append(f\"({a}, {b})\")\n return res\n```\n", "starter": {"go": "package main\n\nfunc AmbiguousCoordinates(s string) []string {\n return []string{}\n}", "python": "from typing import List\n\nclass Solution:\n def ambiguousCoordinates(self, s: str) -> List[str]:\n return []\n", "cpp": "#include <string>\n#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<string> ambiguousCoordinates(string s) {\n return {};\n }\n};"}, "fn": "ambiguousCoordinates", "params": [{"name": "s", "type": "string"}], "outputType": "string_list", "tests": [["(123)"], ["(00011)"], ["(0123)"], ["(00)"], ["(11)"], ["(0000)"], ["(100)"], ["(0010)"], ["(1234)"], ["(999)"], ["(1010)"], ["(0101)"], ["(10)"], ["(12)"], ["(345)"], ["(00001)"], ["(1000)"], ["(1203)"], ["(10203)"], ["(00)"], ["(01)"], ["(10)"], ["(110)"], ["(0110)"], ["(12345)"], ["(5432)"], ["(10000)"], ["(9999)"]], "expected": [["(1, 23)", "(1, 2.3)", "(12, 3)", "(1.2, 3)"], ["(0, 0.011)", "(0.001, 1)"], ["(0, 123)", "(0, 1.23)", "(0, 12.3)", "(0.1, 23)", "(0.1, 2.3)", "(0.12, 3)"], ["(0, 0)"], ["(1, 1)"], [], ["(10, 0)"], ["(0.01, 0)"], ["(1, 234)", "(1, 2.34)", "(1, 23.4)", "(12, 34)", "(12, 3.4)", "(1.2, 34)", "(1.2, 3.4)", "(123, 4)", "(1.23, 4)", "(12.3, 4)"], ["(9, 99)", "(9, 9.9)", "(99, 9)", "(9.9, 9)"], ["(10, 10)", "(101, 0)", "(1.01, 0)", "(10.1, 0)"], ["(0, 101)", "(0, 1.01)", "(0, 10.1)", "(0.1, 0.1)"], ["(1, 0)"], ["(1, 2)"], ["(3, 45)", "(3, 4.5)", "(34, 5)", "(3.4, 5)"], ["(0, 0.001)"], ["(100, 0)"], ["(1, 203)", "(1, 2.03)", "(1, 20.3)", "(12, 0.3)", "(1.2, 0.3)", "(120, 3)"], ["(1, 0.203)", "(10, 203)", "(10, 2.03)", "(10, 20.3)", "(102, 0.3)", "(1.02, 0.3)", "(10.2, 0.3)", "(1020, 3)"], ["(0, 0)"], ["(0, 1)"], ["(1, 0)"], ["(1, 10)", "(11, 0)", "(1.1, 0)"], ["(0, 110)", "(0.1, 10)", "(0.11, 0)"], ["(1, 2345)", "(1, 2.345)", "(1, 23.45)", "(1, 234.5)", "(12, 345)", "(12, 3.45)", "(12, 34.5)", "(1.2, 345)", "(1.2, 3.45)", "(1.2, 34.5)", "(123, 45)", "(123, 4.5)", "(1.23, 45)", "(1.23, 4.5)", "(12.3, 45)", "(12.3, 4.5)", "(1234, 5)", "(1.234, 5)", "(12.34, 5)", "(123.4, 5)"], ["(5, 432)", "(5, 4.32)", "(5, 43.2)", "(54, 32)", "(54, 3.2)", "(5.4, 32)", "(5.4, 3.2)", "(543, 2)", "(5.43, 2)", "(54.3, 2)"], ["(1000, 0)"], ["(9, 999)", "(9, 9.99)", "(9, 99.9)", "(99, 99)", "(99, 9.9)", "(9.9, 99)", "(9.9, 9.9)", "(999, 9)", "(9.99, 9)", "(99.9, 9)"]], "loose": true}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "431", "slug": "android-unlock-patterns", "id": 431, "title": "Android Unlock Patterns", "difficulty": "Medium", "category": "backtracking", "link": "https://leetcode.com/problems/android-unlock-patterns/", "examples": [{"input": "m = 1, n = 1", "output": "9", "explanation": "Nine choices for a single dot."}, {"input": "m = 1, n = 2", "output": "65", "explanation": "9 singles plus 56 valid ordered pairs."}, {"input": "m = 2, n = 2", "output": "56", "explanation": "Only the valid two-hop patterns count."}], "hints": ["Precompute the jumped dot for every ordered pair (most pairs need none).", "Depth-first search over used-dot masks, adding to the total whenever length reaches [m, n].", "Exploit symmetry: corners (1,3,7,9) match, edges (2,4,6,8) match, center (5) is unique."], "statement": "A phone lock screen shows nine dots in a 3x3 grid numbered row by row:\n\n```\n1 2 3\n4 5 6\n7 8 9\n```\n\nA pattern is an ordered sequence of distinct dots with length between `m` and `n` inclusive. After touching a dot, the next dot is chosen under one movement rule: sliding straight over an untouched intermediate dot is forbidden \u2014 such a jump is allowed only when the dot being jumped over has already been visited. Diagonal neighbours, side neighbours, and knight-style hops that cross no dot are always permitted.\n\nGiven `m` and `n`, count every valid pattern whose length falls in `[m, n]`.\n\n**Constraints:**\n- `1 <= m <= n <= 9`\n", "solution": "## Approach\n\nRecord, for every ordered dot pair, which intermediate dot a straight jump would cross (zero when none exists). Then depth-first search over subsets: from the current dot, try each unused next dot whose crossing requirement is empty or already visited, marking it and continuing. Paths whose length lands inside `[m, n]` each contribute one. Rotational symmetry cuts the work to three starts \u2014 a corner, an edge, and the center \u2014 multiplied by 4, 4, and 1.\n\n## Complexity Analysis\n\n- **Time Complexity:** Proportional to explored patterns (bounded by P(9,9) with pruning), trivial for 9 dots.\n- **Space Complexity:** O(9) for the visited flags plus recursion depth.\n\n## Implementation\n\n```python\nclass Solution:\n def numberOfPatterns(self, m: int, n: int) -> int:\n skip = [[0] * 10 for _ in range(10)]\n for a, b, mid in [(1,3,2),(3,1,2),(1,7,4),(7,1,4),(3,9,6),(9,3,6),\n (7,9,8),(9,7,8),(1,9,5),(9,1,5),(2,8,5),(8,2,5),\n (3,7,5),(7,3,5),(4,6,5),(6,4,5)]:\n skip[a][b] = mid\n used = [False] * 10\n def dfs(cur, length):\n used[cur] = True\n length += 1\n total = 1 if length >= m else 0\n if length < n:\n for nxt in range(1, 10):\n if not used[nxt] and (skip[cur][nxt] == 0 or used[skip[cur][nxt]]):\n total += dfs(nxt, length)\n used[cur] = False\n return total\n return dfs(1, 0) * 4 + dfs(2, 0) * 4 + dfs(5, 0)\n```\n", "starter": {"go": "package main\n\nfunc NumberOfPatterns(m int, n int) int {\n return 0\n}", "python": "class Solution:\n def numberOfPatterns(self, m: int, n: int) -> int:\n pass", "cpp": "class Solution {\npublic:\n int numberOfPatterns(int m, int n) {\n return 0;\n }\n};"}, "fn": "numberOfPatterns", "params": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}], "outputType": "int", "tests": [["1", "1"], ["1", "2"], ["1", "3"], ["1", "4"], ["1", "5"], ["1", "6"], ["1", "7"], ["1", "8"], ["1", "9"], ["2", "2"], ["2", "3"], ["2", "4"], ["2", "5"], ["2", "6"], ["2", "7"], ["2", "8"], ["2", "9"], ["3", "3"], ["3", "4"], ["3", "5"], ["3", "6"], ["3", "7"], ["3", "8"], ["3", "9"], ["4", "4"], ["4", "5"], ["4", "6"], ["4", "7"], ["4", "8"], ["4", "9"], ["5", "5"], ["5", "6"], ["5", "7"], ["5", "8"], ["5", "9"], ["6", "6"], ["6", "7"], ["6", "8"], ["6", "9"], ["7", "7"], ["7", "8"], ["7", "9"], ["8", "8"], ["8", "9"], ["9", "9"]], "expected": [9, 65, 385, 2009, 9161, 35177, 108089, 248793, 389497, 56, 376, 2000, 9152, 35168, 108080, 248784, 389488, 320, 1944, 9096, 35112, 108024, 248728, 389432, 1624, 8776, 34792, 107704, 248408, 389112, 7152, 33168, 106080, 246784, 387488, 26016, 98928, 239632, 380336, 72912, 213616, 354320, 140704, 281408, 140704], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "514", "slug": "arithmetic-slices-ii-subsequence", "id": 514, "title": "Arithmetic Slices II - Subsequence", "difficulty": "Hard", "category": "dp", "link": "https://leetcode.com/problems/arithmetic-slices-ii-subsequence/", "examples": [{"input": "nums = [2,4,6,8,10]", "output": "7", "explanation": "Five triples with gap 2 plus [2,6,10] plus the length-5 progression."}, {"input": "nums = [7,7,7,7,7]", "output": "16", "explanation": "All 10 triples plus 5 quadruples plus 1 quintuple."}], "hints": ["For each pair (j,i) record the gap; every earlier pair ending at j with the same gap extends to i.", "Keep per-index maps from gap to count of weak pairs (length >= 2) ending there.", "Only extensions that reach length 3 or more add to the answer."], "statement": "You are given an integer list `nums`. A subsequence keeps the original order but may skip entries. It counts as arithmetic when it holds at least three numbers and the gap between consecutive numbers never changes.\n\nCount all such arithmetic subsequences. Overlapping subsequences that use different positions count separately even when their values look the same.\n\n**Constraints:**\n- `1 <= nums.length <= 1000`\n- `-2^31 <= nums[i] <= 2^31 - 1`\n", "solution": "## Approach\n\nFor each index `i`, keep a map from gap value to how many subsequences of length at least two end at `i` with that gap. When pairing `j < i`, the gap `nums[i]-nums[j]` extends every such subsequence ending at `j` into a longer arithmetic subsequence ending at `i`, and each extension adds one valid answer of length at least three. The pair itself starts a new weak pair for future extensions.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^2), one gap examined per index pair.\n- **Space Complexity:** O(n^2) for the per-index gap maps in the worst case.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import defaultdict\nclass Solution:\n def numberOfArithmeticSlices(self, nums: List[int]) -> int:\n n = len(nums)\n dp = [defaultdict(int) for _ in range(n)]\n ans = 0\n for i in range(n):\n for j in range(i):\n d = nums[i] - nums[j]\n cj = dp[j][d]\n ci = dp[i][d]\n ans += cj\n dp[i][d] = ci + cj + 1\n return ans\n```\n", "starter": {"go": "package main\n\nfunc NumberOfArithmeticSlices(nums []int) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def numberOfArithmeticSlices(self, nums: List[int]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int numberOfArithmeticSlices(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "numberOfArithmeticSlices", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[2,4,6,8,10]"], ["[7,7,7,7,7]"], ["[1,2,3]"], ["[1,3,5]"], ["[1,2]"], ["[1]"], ["[1,1,1]"], ["[0,0,0,0]"], ["[1,2,3,4]"], ["[4,3,2,1]"], ["[1,5,9,13]"], ["[2,2,3,4]"], ["[7,7,7]"], ["[1,2,3,5,7]"], ["[0,1,2,3,4]"], ["[10,0,10,0,10]"], ["[1,2,3,4,5]"], ["[5,4,3,2,1]"], ["[1,1,1,1,1,1]"], ["[0,2,4,6,8,10]"], ["[1,3,7,9]"], ["[-1,0,1,2,3]"], ["[100,0,-100,-200]"], ["[2,4,8,16]"], ["[1,2,4,8]"], ["[3,6,9,12,15,18]"], ["[0,0,1,1,2,2]"], ["[2147483647,0,-2147483648]"]], "expected": [7, 16, 1, 1, 0, 0, 1, 5, 3, 3, 3, 2, 1, 4, 7, 1, 7, 7, 42, 12, 0, 7, 3, 0, 0, 12, 8, 0], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "486", "slug": "arithmetic-slices", "id": 486, "title": "Arithmetic Slices", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/arithmetic-slices/", "examples": [{"input": "nums = [1,2,3,4]", "output": "3", "explanation": "Slices [1,2,3], [2,3,4] and [1,2,3,4] share a constant step."}, {"input": "nums = [1]", "output": "0", "explanation": "Fewer than three elements can never form a slice."}, {"input": "nums = [7,7,7,7]", "output": "3", "explanation": "Every contiguous run of length at least 3 with zero step counts."}], "hints": ["A slice needs at least three entries with equal gaps between neighbours.", "Extending a run ending at i adds as many new slices as the current streak length.", "Keep a running streak: reset on a gap change, otherwise grow and accumulate."], "statement": "Call an array arithmetic when it holds at least three numbers and every neighbouring gap is identical \u2014 for instance `[3,-1,-5,-9]` steps by `-4` each time.\n\nGiven `nums`, count how many of its contiguous subarrays (of length three or more) are arithmetic. Overlapping slices each count separately.\n\n**Constraints:**\n- `1 <= nums.length <= 5000`\n- `-1000 <= nums[i] <= 1000`\n", "solution": "## Approach\n\nScan triples from left to right while remembering how many arithmetic slices end at the previous position. When the current gap matches the prior gap, each slice ending before extends by one element plus the new length-3 window, so the running count grows by one and adds to the total; a mismatched gap resets the streak.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def numberOfArithmeticSlices(self, nums: List[int]) -> int:\n if len(nums) < 3:\n return 0\n total = cur = 0\n for i in range(2, len(nums)):\n if nums[i] - nums[i - 1] == nums[i - 1] - nums[i - 2]:\n cur += 1\n total += cur\n else:\n cur = 0\n return total\n```\n", "starter": {"go": "package main\n\nfunc NumberOfArithmeticSlices(nums []int) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def numberOfArithmeticSlices(self, nums: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int numberOfArithmeticSlices(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "numberOfArithmeticSlices", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[1,2,3,4]"], ["[1]"], ["[7,7,7,7]"], ["[1,3,5,7,9]"], ["[1,2]"], ["[1,2,3]"], ["[1,2,4]"], ["[3,-1,-5,-9]"], ["[1,1,1,1,1]"], ["[1,2,3,5,7,9]"], ["[1,2,3,4,5]"], ["[5,4,3,2,1]"], ["[1,3,6,10,15]"], ["[0,0,0,0,0,0]"], ["[1,2,3,4,6,8,10]"], ["[-5,-4,-3,-2,-1]"], ["[1,1,2,2,3,3]"], ["[2,4,6,8,10,12]"], ["[1,5,9,13,17,20]"], ["[0,1,2,3,5,7,9,11]"], ["[10,10,10]"], ["[1,2,3,7,7,7,7]"], ["[4,4,4,4,5,5,5,5]"], ["[1,0,-1,-2,-3]"], ["[1000,-1000,1000,-1000]"], ["[1,2,3,4,5,6]"], ["[9,7,5,3,1]"], ["[1,4,7,10]"], ["[2,2,3,4,5]"], ["[5,5,5,6,6,6]"]], "expected": [3, 0, 3, 6, 0, 1, 0, 3, 6, 4, 6, 6, 0, 10, 6, 6, 0, 10, 6, 9, 1, 4, 6, 6, 0, 10, 6, 3, 3, 2], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "509", "slug": "arranging-coins", "id": 509, "title": "Arranging Coins", "difficulty": "Easy", "category": "math", "link": "https://leetcode.com/problems/arranging-coins/", "examples": [{"input": "n = 5", "output": "2", "explanation": "Rows of 1 and 2 use 3 coins; 2 remain, too few for row 3."}, {"input": "n = 8", "output": "3", "explanation": "Rows of 1, 2 and 3 use 6 coins; 2 remain, too few for row 4."}], "hints": ["Rows 1 through k need k*(k+1)/2 coins in total.", "Solve k*(k+1)/2 <= n directly with the quadratic formula.", "Use 64-bit math for 8*n to avoid overflow, then floor the result."], "statement": "You have `n` coins. You stack them row by row: the first row uses `1` coin, the second row uses `2` coins, the third uses `3`, and so on. Each new row needs one more coin than the previous row.\n\nReport how many full rows you can build before running out of coins. Any leftover coins that cannot fill the next row are ignored.\n\n**Constraints:**\n- `1 <= n <= 2^31 - 1`\n", "solution": "## Approach\n\nRows `1` through `k` consume `k*(k+1)/2` coins. The wanted `k` is the largest value with that sum at most `n`. Solving the quadratic equality gives `k = (sqrt(1+8n)-1)/2`, floored to an integer.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1) arithmetic.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nimport math\nclass Solution:\n def arrangeCoins(self, n: int) -> int:\n return int((math.sqrt(1 + 8 * n) - 1) // 2)\n```\n", "starter": {"go": "package main\n\nfunc ArrangeCoins(n int) int {\n return 0\n}", "python": "class Solution:\n def arrangeCoins(self, n: int) -> int:\n pass", "cpp": "class Solution {\npublic:\n int arrangeCoins(int n) {\n return 0;\n }\n};"}, "fn": "arrangeCoins", "params": [{"name": "n", "type": "int"}], "outputType": "int", "tests": [["5"], ["8"], ["1"], ["2"], ["3"], ["4"], ["6"], ["10"], ["15"], ["21"], ["100"], ["1000"], ["1000000"], ["2147483647"], ["2147483646"], ["1802720259"], ["7"], ["9"], ["11"], ["55"], ["12"], ["13"], ["14"], ["16"], ["18"], ["20"], ["25"], ["28"]], "expected": [2, 3, 1, 1, 2, 2, 3, 4, 5, 6, 13, 44, 1413, 65535, 65535, 60044, 3, 3, 4, 10, 4, 4, 4, 5, 5, 5, 6, 7], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "620", "slug": "array-nesting", "id": 620, "title": "Array Nesting", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/array-nesting/", "examples": [{"input": "nums = [5,4,0,3,1,6,2]", "output": "4", "explanation": "Chain 0 -> 5 -> 6 -> 2 visits four values."}, {"input": "nums = [0,1,2]", "output": "1", "explanation": "Every element is a self-loop."}, {"input": "nums = [1,2,0]", "output": "3", "explanation": "One cycle covers all indices."}], "hints": ["Follow indices from each unvisited start, counting steps until you return to a visited index.", "Mark every index you walk over so each position is processed only once overall.", "The answer is the longest walk; it always corresponds to the longest cycle."], "statement": "Given a permutation `nums` of `0..n-1`, define the chain starting at `k` by repeated indexing: `k, nums[k], nums[nums[k]]`, and so on until a value repeats. Let `S(k)` be the set of distinct values on that chain. Return the largest possible `|S(k)|` over all starts.\n\nBecause every index has exactly one outgoing edge, the chains are disjoint cycles with trees feeding into them; the longest chain always equals the longest directed cycle. Marking visited indices keeps the total work linear.\n\n**Constraints:**\n- `1 <= nums.length <= 2 * 10^4`\n- `nums` is a permutation of `[0, nums.length - 1]`.\n", "solution": "## Approach\n\nWalk the index graph with a global visited set. From each fresh start, follow `nums[k]` links until hitting visited ground, counting steps; every index is claimed once, so the whole procedure is linear. The longest such walk equals the longest cycle, which is the required maximum chain length.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), each index visited at most once.\n- **Space Complexity:** O(n) for the visited flags.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def arrayNesting(self, nums: List[int]) -> int:\n seen = [False] * len(nums)\n best = 0\n for i in range(len(nums)):\n if seen[i]:\n continue\n cur, ln = i, 0\n while not seen[cur]:\n seen[cur] = True\n cur = nums[cur]\n ln += 1\n best = max(best, ln)\n return best\n```\n", "starter": {"go": "package main\n\nfunc ArrayNesting(nums []int) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def arrayNesting(self, nums: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int arrayNesting(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "arrayNesting", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[5,4,0,3,1,6,2]"], ["[0,1,2]"], ["[1,2,0]"], ["[0]"], ["[1,0]"], ["[2,0,1]"], ["[4,3,2,1,0]"], ["[1,3,0,4,2]"], ["[5,4,0,3,1,6,2]"], ["[2,1,0]"], ["[1,0,3,2]"], ["[3,2,1,0]"], ["[0,2,1]"], ["[1,2,3,0]"], ["[4,0,1,2,3]"], ["[2,3,4,5,0,1]"], ["[0,1,4,6,2,3,5]"], ["[4,5,3,7,0,1,2,6]"], ["[2,3,0,7,4,5,1,8,6]"], ["[0,9,7,4,2,3,6,1,5,8]"], ["[4,3,5,9,8,6,7,1,2,10,0]"], ["[11,0,4,5,7,1,9,6,10,2,8,3]"], ["[1,10,6,5,8,11,4,7,9,2,12,0,3]"], ["[7,6,2,3,5,8,10,0,12,13,11,4,9,1]"], ["[7,13,10,8,4,14,6,3,12,9,1,0,2,5,11]"], ["[8,2,14,15,1,3,4,9,6,13,7,10,5,11,12,0]"], ["[4,0,8,2,14,6,19,12,9,1,13,16,5,3,11,18,15,17,10,7]"], ["[20,0,21,14,12,15,23,17,6,4,18,7,10,19,16,5,24,22,3,2,13,11,1,8,9]"]], "expected": [4, 1, 3, 1, 2, 3, 2, 5, 4, 2, 2, 2, 2, 4, 5, 3, 3, 4, 5, 8, 11, 5, 7, 10, 12, 11, 14, 11], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "940", "slug": "array-of-doubled-pairs", "id": 940, "title": "Array of Doubled Pairs", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/array-of-doubled-pairs/", "examples": [{"input": "arr = [3,1,3,6]", "output": "false", "explanation": "The 1 has no doubling partner."}, {"input": "arr = [2,1,2,6]", "output": "false", "explanation": "Leftover values cannot pair up."}, {"input": "arr = [4,-2,2,-4]", "output": "true", "explanation": "Pairs (-2,-4) and (2,4)."}], "hints": ["Count occurrences, then handle values from the smallest absolute value upward so halves are settled before their doubles.", "Each copy of x consumes one copy of 2*x; zeros are special and need an even count.", "Sorting keys by absolute value keeps negative pairs (like -2 with -4) working the same way."], "statement": "Decide whether the array can be split into pairs where one entry doubles the other.\n\nThe array length is even. You must partition all entries into pairs `(a, b)` with `b = 2 * a`. Zeros pair with zeros, negatives follow the same doubling rule (for example `-2` pairs with `-4`), and every element is used exactly once.\n\nGiven `arr`, return `true` when such a pairing exists and `false` otherwise.\n\n**Constraints:**\n- `2 <= arr.length <= 3 * 10^4`\n- Length is even.\n- `-10^5 <= arr[i] <= 10^5`\n", "solution": "## Approach\n\nCount every value, then process distinct values from the smallest absolute value upward. Copies of `x` must be matched by the same number of copies of `2*x`, which is still untouched because its magnitude is larger. Zeros can only pair among themselves, so their count must be even. If every demand is met, the pairing exists.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log n) for sorting distinct keys.\n- **Space Complexity:** O(n) for the frequency table.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import Counter\nclass Solution:\n def canReorderDoubled(self, arr: List[int]) -> bool:\n cnt = Counter(arr)\n for x in sorted(cnt, key=abs):\n c = cnt[x]\n if c == 0:\n continue\n if x == 0:\n if c % 2:\n return False\n cnt[x] = 0\n continue\n if cnt.get(2 * x, 0) < c:\n return False\n cnt[2 * x] -= c\n return True\n```\n", "starter": {"go": "package main\n\nfunc CanReorderDoubled(arr []int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def canReorderDoubled(self, arr: List[int]) -> bool:\n pass", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n bool canReorderDoubled(vector<int>& arr) {\n return 0;\n }\n};"}, "fn": "canReorderDoubled", "params": [{"name": "arr", "type": "int_array"}], "outputType": "boolean", "tests": [["[3, 1, 3, 6]"], ["[2, 1, 2, 6]"], ["[4, -2, 2, -4]"], ["[1, 2, 4, 8]"], ["[3, 6, 9, 18]"], ["[0, 0]"], ["[0, 0, 0, 0]"], ["[1, 1, 2, 2]"], ["[1, 1, 1, 2]"], ["[-1, -2, -4, -8]"], ["[5, 10, 15, 30]"], ["[1, 3, 5, 7]"], ["[2, 2, 4, 4]"], ["[1, 2, 2, 4]"], ["[0, 0, 1, 2]"], ["[-5, -10, 5, 10]"], ["[7, 7, 14, 14]"], ["[1, 1, 1, 1, 2, 2]"], ["[2, 4, 4, 8]"], ["[6, 3, 0, 0]"], ["[1, 2, 4, 4, 8, 16]"], ["[10, 20, 40, 80]"], ["[-2, -6, 3, 6]"], ["[0, 1, 2, 0]"], ["[4, 4, 8, 16]"], ["[12, 6, 3, 1]"], ["[2, 6, 3, 12]"], ["[8, 4, 2, 1]"]], "expected": [false, false, true, true, true, true, true, true, false, true, true, false, true, true, true, true, true, false, true, true, false, true, false, true, false, false, false, true], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "616", "slug": "array-partition", "id": 616, "title": "Array Partition", "difficulty": "Easy", "category": "array", "link": "https://leetcode.com/problems/array-partition/", "examples": [{"input": "nums = [1,4,3,2]", "output": "4", "explanation": "Pairs (1,2) and (3,4) give 1 + 3."}, {"input": "nums = [6,2,6,5,1,2]", "output": "9", "explanation": "Pairs (1,2), (2,5), (6,6) give 1 + 2 + 6."}, {"input": "nums = [1,2]", "output": "1", "explanation": "The single pair contributes 1."}], "hints": ["Sort the array so neighbors are as close in value as possible.", "Pair adjacent elements; each pair's minimum is the element at the even index.", "Adding up indices 0, 2, 4, ... of the sorted array gives the optimum."], "statement": "Given an integer array `nums` containing an even number of elements, split it into pairs so that the sum of the smaller element of each pair is as large as possible, and return that maximum sum.\n\nPairing two numbers contributes the lesser of the two. To push the total upward, small values should be sacrificed together so that larger values survive as the kept minimum of their pairs.\n\n**Constraints:**\n- `2 <= nums.length <= 2 * 10^4`, and the length is even.\n- `-10^4 <= nums[i] <= 10^4`\n", "solution": "## Approach\n\nSort the numbers, then pair neighbors: (smallest, second smallest), and so on. Each pair donates its first element, so summing every other entry of the sorted array is optimal \u2014 any crossing pairing can be uncrossed without hurting the total.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log n) for sorting n numbers.\n- **Space Complexity:** O(1) extra besides the sort.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def arrayPairSum(self, nums: List[int]) -> int:\n nums.sort()\n return sum(nums[::2])\n```\n", "starter": {"go": "package main\n\nfunc ArrayPairSum(nums []int) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def arrayPairSum(self, nums: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int arrayPairSum(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "arrayPairSum", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[1,4,3,2]"], ["[6,2,6,5,1,2]"], ["[1,2]"], ["[1,1,1,1]"], ["[7,3,5,9,1,6]"], ["[10000,-10000,0,5]"], ["[1,2,3,4,5,6,7,8]"], ["[8,7,6,5,4,3,2,1]"], ["[-1,-2,-3,-4]"], ["[0,0,0,0,0,0]"], ["[5,5,5,5]"], ["[1,100,101,102]"], ["[3,3,2,2,1,1]"], ["[-5,10,-3,8,2,-1]"], ["[9,1,8,2,7,3]"], ["[4,4,4,4,4,4]"], ["[11,22]"], ["[100,1]"], ["[2,2]"], ["[0,1]"], ["[5,4,3,2,1,0]"], ["[-10,-20,30,40]"], ["[6,6,1,1]"], ["[13,7,5,9,11,3]"], ["[42,42]"], ["[999,1000]"], ["[1,3,5,7,9,11,13,15]"], ["[2,4,6,8,10,12]"]], "expected": [4, 9, 1, 2, 13, -9995, 16, 16, -6, 0, 10, 102, 6, 2, 12, 12, 11, 1, 2, 0, 6, 10, 7, 21, 42, 999, 28, 18], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "522", "slug": "assign-cookies", "id": 522, "title": "Assign Cookies", "difficulty": "Easy", "category": "greedy", "link": "https://leetcode.com/problems/assign-cookies/", "examples": [{"input": "g = [1,2,3], s = [1,1]", "output": "1", "explanation": "Only one cookie can satisfy a child: one size-1 cookie covers the child with greed 1, and the other cookie is too small for greed 2 or 3."}, {"input": "g = [1,2], s = [1,2,3]", "output": "2", "explanation": "Hand the size-1 cookie to the first child and the size-2 cookie to the second child."}, {"input": "g = [10,9,8,7], s = [5,6,7,8]", "output": "2", "explanation": "The two biggest cookies satisfy the two least greedy children."}], "hints": ["Sort both arrays, then always satisfy the least greedy remaining child with the smallest cookie that fits.", "Walk through the cookies once with two pointers: advance the child pointer only when the current cookie is big enough."], "statement": "You are handing out cookies to a group of children. Child `i` has a greed factor `g[i]`, which is the smallest cookie size that will make that child content. Cookie `j` has size `s[j]`.\n\nA cookie of size `x` satisfies a child of greed `y` exactly when `x >= y`. Each child receives at most one cookie, and each cookie can be given to at most one child.\n\nReturn the largest number of children that can be made content.\n\n**Constraints:**\n- `1 <= g.length, s.length <= 3 * 10^4`\n- `1 <= g[i], s[j] <= 2^31 - 1`\n", "solution": "## Approach\n\nSort the greed factors and the cookie sizes. Then sweep through the cookies from smallest to largest, always offering the current cookie to the least greedy child who is still waiting. Whenever a cookie is big enough, count one more content child and move to the next child; otherwise skip the cookie. This greedy pairing is optimal because using the smallest fitting cookie never harms future assignments.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log n + m log m), dominated by sorting the two arrays.\n- **Space Complexity:** O(1) extra space besides sorting.\n\n## Implementation\n\n```python\nclass Solution:\n def findContentChildren(self, g: list, s: list) -> int:\n g = sorted(g)\n s = sorted(s)\n child = 0\n for cookie in s:\n if child < len(g) and cookie >= g[child]:\n child += 1\n return child\n```\n", "starter": {"go": "package main\n\nfunc FindContentChildren(g []int, s []int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def findContentChildren(self, g: List[int], s: List[int]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int findContentChildren(vector<int>& g, vector<int>& s) {\n return 0;\n }\n};"}, "fn": "findContentChildren", "params": [{"name": "g", "type": "int_array"}, {"name": "s", "type": "int_array"}], "outputType": "int", "tests": [["[1,2,3]", "[1,1]"], ["[1,2]", "[1,2,3]"], ["[10,9,8,7]", "[5,6,7,8]"], ["[1]", "[1]"], ["[1]", "[2]"], ["[2]", "[1]"], ["[1,2,3]", "[3,2,1]"], ["[5,6,7]", "[1,2,3]"], ["[1,2,7,8]", "[1,3,5,9,10]"], ["[1,2,3,4,5]", "[1,1,1,1,10]"], ["[2,2,2]", "[1,2,2,2]"], ["[3]", "[1,2,3,4]"], ["[1,2,3,4]", "[4,4,4,4]"], ["[7,7,7,7]", "[7]"], ["[1,2,3]", "[1,2]"], ["@javascript:JSON.stringify(Array(30000).fill(1))", "@javascript:JSON.stringify(Array(30000).fill(1))"], ["[1,2,3,4,5]", "[5,5,5,5,5]"], ["[5]", "[1,2,3,4,5]"], ["[1,1,1]", "[1]"], ["[2,3,4]", "[1,2]"], ["[1,10,20]", "[10,10,10]"], ["[3,3,3]", "[3,3,3]"], ["[100,200,300]", "[50,150,250,350]"], ["[1,2]", "[3]"], ["[4,5,6]", "[4,5,6]"], ["[8,9]", "[7,8,9,10]"], ["[1,3,5,7,9]", "[2,4,6,8,10]"], ["[10]", "[10]"]], "expected": [1, 2, 2, 1, 1, 0, 3, 0, 4, 2, 3, 1, 4, 1, 2, 30000, 5, 1, 1, 1, 2, 3, 3, 1, 3, 2, 5, 1], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "179", "slug": "asteroid-collision", "id": 179, "title": "Asteroid Collision", "difficulty": "Medium", "category": "stack", "link": "https://leetcode.com/problems/asteroid-collision/", "examples": [{"input": "asteroids = [5,10,-5]", "output": "[5,10]", "explanation": "The 10 and -5 collide resulting in 10. The 5 and 10 never collide."}, {"input": "asteroids = [8,-8]", "output": "[]", "explanation": "The 8 and -8 collide exploding each other."}, {"input": "asteroids = [10,2,-5]", "output": "[10]", "explanation": "The 2 and -5 collide resulting in -5. The 10 and -5 collide resulting in 10."}], "hints": ["Keep survivors in a stack; only a right-moving top and a left-moving incoming asteroid can collide.", "While the incoming left-moving asteroid destroys smaller right-moving tops, pop them; if sizes are equal, pop the top and discard the incoming one."], "statement": "A single-file line of space rocks is described by the array `asteroids`: the magnitude of each entry gives that rock's size, while its sign gives its travel direction \u2014 a positive value drifts right and a negative value drifts left. Every rock advances at an identical pace.\n\nSimulate the line until nothing else can crash and report the survivors in their original left-to-right order. Whenever two rocks travelling toward each other connect, the lighter one shatters; when both weigh the same, each shatters. Rocks already heading the same way never catch up to one another, so they never connect.\n\n**Constraints:**\n\n- `2 <= asteroids.length <= 10^4`\n- `-1000 <= asteroids[i] <= 1000`\n- `asteroids[i] != 0`\n", "solution": "## Approach\n\nKeep survivors in a stack. Only a right-moving stack top (`> 0`) and a\nleft-moving incoming asteroid (`< 0`) can collide. While such a collision is\npossible, compare sizes: pop a smaller top, destroy both on equal sizes, or\ndiscard the incoming asteroid when the top is larger. Otherwise push the\nincoming asteroid.\n\n## Complexity Analysis\n\n- **Time Complexity:** `O(n)`, each asteroid is pushed and popped at most once.\n- **Space Complexity:** `O(n)` for the stack of survivors.\n\n## Implementation\n\n```python\nfrom typing import List\n\n\nclass Solution:\n def asteroidCollision(self, asteroids: List[int]) -> List[int]:\n stack: List[int] = []\n for a in asteroids:\n alive = True\n while alive and a < 0 and stack and stack[-1] > 0:\n top = stack[-1]\n if top < -a:\n stack.pop()\n elif top == -a:\n stack.pop()\n alive = False\n else:\n alive = False\n if alive:\n stack.append(a)\n return stack\n```\n", "starter": {"go": "package main\n\nfunc AsteroidCollision(asteroids []int) []int {\n return []int{}\n}", "python": "from typing import List\n\nclass Solution:\n def asteroidCollision(self, asteroids: List[int]) -> List[int]:\n return []\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<int> asteroidCollision(vector<int>& asteroids) {\n return {};\n }\n};"}, "fn": "asteroidCollision", "params": [{"name": "asteroids", "type": "int_array"}], "outputType": "int_array", "tests": [["[5,10,-5]"], ["[8,-8]"], ["[10,2,-5]"], ["[-2,-1,1,2]"], ["[3,5,-6,2,-1,4]"], ["[-2,-2,1,-2]"], ["[1,-1]"], ["[1,2,3,-4]"], ["[-5,5,-5,5]"], ["[10,-10,10,-10]"], ["[1,1,-2,-2]"], ["[-3,1,2,-2,-2]"], ["[1000,-1000]"], ["@javascript:JSON.stringify(Array.from({length:10000},(_,i)=>i%2===0?1000:-1000))"], ["@javascript:JSON.stringify(Array.from({length:10000},(_,i)=>i<5000?1000:-1000))"], ["[5,1]"], ["[-5,-1]"], ["[1,2,3]"], ["[-1,-2,-3]"], ["[2,-2]"], ["[-2,2]"], ["[5,-5,5,-5,5]"], ["[3,-3,3]"], ["[1,2,-2]"], ["[-1,1,-1,1]"], ["[10,10,-10]"], ["[5,10,15,-20]"], ["[2,3,-10]"], ["[1000,1000,-1000]"], ["[-3,-2,-1,1,2,3]"]], "expected": [[5, 10], [], [10], [-2, -1, 1, 2], [-6, 2, 4], [-2, -2, -2], [], [-4], [-5, 5], [], [-2, -2], [-3, -2], [], [], [], [5, 1], [-5, -1], [1, 2, 3], [-1, -2, -3], [], [-2, 2], [5], [3], [1], [-1, 1], [10], [-20], [-10], [1000], [-3, -2, -1, 1, 2, 3]], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "980", "slug": "available-captures-for-rook", "id": 980, "title": "Available Captures for Rook", "difficulty": "Easy", "category": "matrix", "link": "https://leetcode.com/problems/available-captures-for-rook/", "examples": [{"input": "board = [[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"R\",\".\",\".\",\".\",\"p\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"]]", "output": "3", "explanation": "The rook takes the pawns above, below and to the right."}, {"input": "board = [[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"R\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"]]", "output": "0", "explanation": "No pawn shares the rook's row or column."}, {"input": "board = [[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\"p\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\"R\",\".\",\"B\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\"B\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"]]", "output": "1", "explanation": "Only the pawn above the rook is reachable; bishops block the other lines."}], "hints": ["Locate the rook first, then walk outward step by step in each of the four straight directions.", "Stop a direction at the first non-empty cell: count it only for 'p', and halt silently for 'B'.", "Adaptation: the board is a char_array_2d of 'R', '.', 'B' and 'p'; in Rust it arrives as its encoded string. At most four captures are possible."], "statement": "An 8x8 chessboard is given as a grid of characters. Exactly one cell holds the\nwhite rook `'R'`. Other cells hold pawns `'p'`, bishops `'B'`, or empty\nsquares `'.'`.\n\nThe rook moves like in chess: it slides any number of squares horizontally or\nvertically, but it cannot jump over a bishop, and it stops at the first piece\nit meets in each of the four directions. A pawn is capturable when it is the\nfirst piece the rook meets along some direction.\n\nReturn how many pawns the rook can capture (from `0` to `4`).\n\n**Constraints:**\n- The board is 8x8 with exactly one `'R'`.\n- Every cell is `'R'`, `'.'`, `'B'` or `'p'`.\n", "solution": "## Approach\n\nFind the rook's cell with a single scan of the board. From there, step outward\nin each of the four straight directions one square at a time. Empty squares\nare skipped; the first bishop ends that direction with no capture, while the\nfirst pawn adds one capture and ends the direction. Adding the results of all\nfour walks gives the answer.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m * n), where m and n are the board dimensions (8x8 here). The rook search plus four bounded walks each touch a cell at most a few times.\n- **Space Complexity:** O(1) extra memory.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def numRookCaptures(self, board: List[List[str]]) -> int:\n rx = ry = -1\n for i, row in enumerate(board):\n for j, c in enumerate(row):\n if c == 'R':\n rx, ry = i, j\n ans = 0\n for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):\n x, y = rx + dx, ry + dy\n while 0 <= x < len(board) and 0 <= y < len(board[0]):\n if board[x][y] == 'B':\n break\n if board[x][y] == 'p':\n ans += 1\n break\n x += dx\n y += dy\n return ans\n```\n", "starter": {"go": "package main\n\nfunc NumRookCaptures(board [][]byte) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def numRookCaptures(self, board: List[List[str]]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int numRookCaptures(vector<vector<char>>& board) {\n return 0;\n }\n};"}, "fn": "numRookCaptures", "params": [{"name": "board", "type": "char_array_2d"}], "outputType": "int", "tests": [["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"p\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"R\", \".\", \".\", \".\", \"p\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"p\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\"p\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"B\", \".\", \".\", \".\", \".\"], [\".\", \".\", \"B\", \"R\", \"B\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"B\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \"p\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \"p\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \"R\", \"B\", \"p\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \"B\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \"R\", \".\", \"B\", \"p\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \"p\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \"B\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"B\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\"B\", \".\", \".\", \".\", \"R\", \"p\", \".\", \".\"], [\".\", \".\", \".\", \".\", \"p\", \".\", \".\", \".\"]]"], ["[[\"B\", \".\", \".\", \".\", \".\", \"p\", \"R\", \"p\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \"p\", \"B\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \"B\", \".\", \".\", \".\", \".\", \".\", \".\"], [\"p\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \"R\", \"p\", \".\", \".\"], [\".\", \".\", \".\", \".\", \"p\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \"B\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \"p\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \"p\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \"R\", \".\", \"p\", \".\"], [\".\", \".\", \".\", \".\", \"p\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\"p\", \"R\", \"p\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \"p\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \"B\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \"p\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \"p\", \".\", \".\"], [\".\", \".\", \"p\", \"B\", \".\", \"R\", \"B\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\"R\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\"p\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \"B\", \"p\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \"p\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \"p\", \"B\", \".\", \"R\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \"p\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \"p\", \"p\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\"p\", \".\", \".\", \".\", \".\", \"R\", \"p\", \".\"], [\"B\", \".\", \".\", \".\", \".\", \"p\", \".\", \".\"]]"], ["[[\".\", \".\", \"p\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \"R\", \".\", \"p\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \"p\"], [\".\", \"p\", \".\", \".\", \".\", \".\", \".\", \"R\"], [\".\", \".\", \".\", \".\", \".\", \"p\", \".\", \".\"], [\".\", \"p\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \"p\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \"p\", \"R\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \"B\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\"p\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\"R\", \".\", \"B\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\"R\", \".\", \"p\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\"B\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\"p\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \"p\", \".\", \".\"]]"], ["[[\".\", \".\", \"p\", \".\", \".\", \".\", \".\", \"R\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \"B\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \"B\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \"p\", \".\"], [\".\", \".\", \".\", \".\", \".\", \"p\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"B\", \".\", \"R\", \".\", \"p\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \"p\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"B\", \".\", \"p\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \"R\", \"p\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \"p\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"B\", \".\", \".\", \".\", \".\"], [\".\", \".\", \"p\", \"R\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"B\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"p\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"R\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"p\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \"B\", \".\", \".\"], [\".\", \"p\", \".\", \".\", \"B\", \"R\", \".\", \"B\"], [\".\", \"p\", \".\", \".\", \".\", \"p\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"p\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\"p\", \"R\", \".\", \"p\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \".\", \".\", \".\", \".\", \"p\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \"B\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \"R\", \"p\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \"p\", \".\"]]"], ["[[\".\", \".\", \"p\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \"R\", \"p\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \"p\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"], ["[[\".\", \".\", \"R\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \"B\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"]]"]], "expected": [3, 0, 1, 0, 2, 2, 2, 3, 3, 1, 1, 2, 3, 2, 2, 2, 1, 1, 1, 3, 3, 1, 2, 1, 2, 2, 3, 0], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "659", "slug": "average-of-levels-in-binary-tree", "id": 659, "title": "Average of Levels in Binary Tree", "difficulty": "Easy", "category": "tree", "link": "https://leetcode.com/problems/average-of-levels-in-binary-tree/", "examples": [{"input": "root = [3,9,20,null,null,15,7]", "output": "[\"3.0\",\"14.5\",\"11.0\"]", "explanation": "Level 0 is [3]; level 1 is [9,20] with mean 14.5; level 2 is [15,7] with mean 11.0."}, {"input": "root = [3,9,20,15,7]", "output": "[\"3.0\",\"14.5\",\"11.0\"]", "explanation": "Level 0 is [3]; level 1 is [9,20]; level 2 is [15,7]."}, {"input": "root = [1]", "output": "[\"1.0\"]"}], "hints": ["Walk the tree level by level with a queue, summing values and counting nodes per depth.", "Format each mean with Double.toString (or the language default) and return levels top-down.", "Judging parses each entry as a double with 1e-5 tolerance, so any equivalent decimal form is fine."], "statement": "For every depth of a binary tree, compute the mean of the node values sitting on that depth. The root is depth 0, its children depth 1, and so on.\n\nBecause this judge only handles portable value types, averages travel as decimal strings: parse each output entry as a double. An answer is accepted when every level's parsed value sits within `1e-5` of the true mean (relative or absolute). Return the levels top-down.\n\n**Constraints:**\n- The tree has `1..10^4` nodes.\n- `-10^5 <= Node.val <= 10^5`\n- Outputs are finite decimal strings parseable as doubles.\n", "solution": "## Approach\n\nRun a breadth-first walk starting at the root. For each depth, drain exactly the current queue size, accumulate the node values, push any children, and record the quotient as a decimal string. Levels are naturally emitted from top to bottom.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the node count. Each node is dequeued once.\n- **Space Complexity:** O(w) for the queue holding the widest level.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import deque\n\nclass Solution:\n def averageOfLevels(self, root) -> List[str]:\n if not root:\n return []\n q = deque([root])\n ans = []\n while q:\n total = 0\n n = len(q)\n for _ in range(n):\n node = q.popleft()\n total += node.val\n if node.left:\n q.append(node.left)\n if node.right:\n q.append(node.right)\n ans.append(str(total / n))\n return ans\n```\n", "starter": {"go": "// Definition for a binary tree node.\n// type TreeNode struct {\n// Val int\n// Left *TreeNode\n// Right *TreeNode\n// }\npackage main\n\nfunc AverageOfLevels(root *TreeNode) []string {\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 averageOfLevels(self, root) -> List[str]:\n pass", "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};\n*/\n#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n vector<string> averageOfLevels(TreeNode* root) {\n return {};\n }\n};"}, "fn": "averageOfLevels", "params": [{"name": "root", "type": "tree_node"}], "outputType": "string_list", "tests": [["[3,9,20,null,null,15,7]"], ["[3,9,20,15,7]"], ["[1]"], ["[1,2,3,4,5,6,7]"], ["[1,null,2,null,3,null,4]"], ["[5,4,8,11,null,13,4,7,2,null,null,null,1]"], ["[-1,-2,-3]"], ["[0,0,0,0]"], ["[100000,-100000,100000]"], ["[1,2,null,3,null,4]"], ["[10,5,15,3,7,null,18]"], ["[1,2,3]"], ["[2147483647]"], ["[2,1,3,null,4,null,5]"], ["[1,null,3,2,4,null,null,null,5]"], ["[6,2,8,0,4,7,9,null,null,3,5]"], ["[1,2,2,3,4,4,3]"], ["[0]"], ["[-5,-10,0,3,null,null,7]"], ["[3,1,null,null,2]"], ["[9,8,7,6,5,4,3,2,1]"], ["[1,2,3,4,null,null,5,6,null,null,7]"], ["[100,50,150,25,75,125,175]"], ["[-100000]"], ["[4,2,9,3,5,null,7]"], ["[1,null,2,3]"], ["[8,3,10,1,6,null,14,null,null,4,7,13]"], ["[2,null,3,null,4,null,5,null,6]"]], "expected": [["3.0", "14.5", "11.0"], ["3.0", "14.5", "11.0"], ["1.0"], ["1.0", "2.5", "5.5"], ["1.0", "2.0", "3.0", "4.0"], ["5.0", "6.0", "9.333333333333334", "3.3333333333333335"], ["-1.0", "-2.5"], ["0.0", "0.0", "0.0"], ["100000.0", "0.0"], ["1.0", "2.0", "3.0", "4.0"], ["10.0", "10.0", "9.333333333333334"], ["1.0", "2.5"], ["2.147483647E9"], ["2.0", "2.0", "4.5"], ["1.0", "3.0", "3.0", "5.0"], ["6.0", "5.0", "5.0", "4.0"], ["1.0", "2.0", "3.5"], ["0.0"], ["-5.0", "-5.0", "5.0"], ["3.0", "1.0", "2.0"], ["9.0", "7.5", "4.5", "1.5"], ["1.0", "2.5", "4.5", "6.5"], ["100.0", "100.0", "100.0"], ["-100000.0"], ["4.0", "5.5", "5.0"], ["1.0", "2.0", "3.0"], ["8.0", "6.5", "7.0", "8.0"], ["2.0", "3.0", "4.0", "5.0", "6.0"]], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "842", "slug": "backspace-string-compare", "id": 842, "title": "Backspace String Compare", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/backspace-string-compare/", "examples": [{"input": "s = \"ab#c\", t = \"ad#c\"", "output": "true", "explanation": "Both reduce to ac."}, {"input": "s = \"ab##\", t = \"c#d#\"", "output": "true", "explanation": "Both reduce to empty."}, {"input": "s = \"a#c\", t = \"b\"", "output": "false", "explanation": "Results c versus b differ."}], "hints": ["Simulate each string with a stack-like builder: append letters, pop on '#' when possible.", "Alternatively walk both strings from the end, skipping erased characters with a counter, for O(1) extra space.", "Compare the two reduced forms for equality."], "statement": "Check whether two edited texts end up identical.\n\nEach input holds lowercase letters plus the symbol `#`, which erases the most recent not-yet-erased letter before it (like a backspace key). If no letter exists, the eraser does nothing. Build the final text of `s` and of `t` under these rules and return `true` when both results match.\n\n**Constraints:**\n- `1 <= s.length, t.length <= 200`\n- Strings hold lowercase letters and `#`.\n", "solution": "## Approach\n\nReplay each string left to right with a builder: letters append, while `#` removes the last kept letter when one exists. The two reduced texts are then compared directly for equality.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n + m), where n and m are the input lengths.\n- **Space Complexity:** O(n + m) for the two builders (a two-pointer variant reaches O(1)).\n\n## Implementation\n\n```python\nclass Solution:\n def backspaceCompare(self, s: str, t: str) -> bool:\n def build(x):\n buf = []\n for c in x:\n if c == '#':\n if buf:\n buf.pop()\n else:\n buf.append(c)\n return ''.join(buf)\n return build(s) == build(t)\n```\n", "starter": {"go": "package main\n\nfunc BackspaceCompare(s string, t string) bool {\n return false\n}", "python": "class Solution:\n def backspaceCompare(self, s: str, t: str) -> bool:\n return False\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool backspaceCompare(string s, string t) {\n return false;\n }\n};"}, "fn": "backspaceCompare", "params": [{"name": "s", "type": "string"}, {"name": "t", "type": "string"}], "outputType": "boolean", "tests": [["ab#c", "ad#c"], ["ab##", "c#d#"], ["a#c", "b"], ["a##c", "#a#c"], ["a", "a"], ["a", "b"], ["#", "#"], ["###", "##"], ["abc", "abc"], ["ab#c", "ac"], ["a#", ""], ["", ""], ["bxj##tw", "bxo#j##tw"], ["bbbextm", "bbb#extm"], ["y#fo##f", "y#f#o##f"], ["nzp#o#g", "b#nzp#o#g"], ["a#b#c#d#", ""], ["abcdef", "abcdef"], ["a#b", "b"], ["ab#d", "ad"], ["xy#z", "xzz#"], ["xywrrmp", "xywrrmu#p"], ["a##", "b##"], ["####", ""], ["abc##d", "ad"], ["c#b#a", "a"], ["ab#c#d", "ad"], ["qwer#ty", "qwerty#"]], "expected": [true, true, false, true, true, false, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, false], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "935", "slug": "bag-of-tokens", "id": 935, "title": "Bag of Tokens", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/bag-of-tokens/", "examples": [{"input": "tokens = [100], power = 150", "output": "1", "explanation": "One affordable face-up play."}, {"input": "tokens = [100,200,300,400], power = 200", "output": "2", "explanation": "Two cheap wins peak the score at 2."}, {"input": "tokens = [71,55,82], power = 54", "output": "0", "explanation": "Nothing affordable, no points to trade."}], "hints": ["Sort the tokens so the cheapest wins and the richest refuels are easy to pick.", "Always spend the cheapest affordable token face-up; only when stuck, cash in the priciest remaining token face-down.", "Record the best score seen, since late trades can dip before climbing again."], "statement": "Turn power and tokens into the highest achievable score.\n\nYou start with `power` energy and score zero, plus a bag of token values. Each token can be spent at most once in one of two directions: playing it face-up costs its value in power and earns one score point (needs enough power), while playing it face-down spends one score point to gain its value in power (needs a point to spend). You may stop whenever you like.\n\nGiven `tokens` and `power`, return the greatest score reachable at any moment.\n\n**Constraints:**\n- `0 <= tokens.length <= 1000`\n- `0 <= tokens[i], power <= 10^4`\n", "solution": "## Approach\n\nSort the tokens. Repeatedly play the cheapest affordable token face-up for a point; when nothing is affordable, trade one point for the most expensive remaining token's power. Because cheap wins cost the least and rich trades refuel the most, this two-pointer routine reaches every worthwhile state. The peak score met along the way is the answer.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log n) for sorting, then linear play.\n- **Space Complexity:** O(n) for the sorted copy.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def bagOfTokensScore(self, tokens: List[int], power: int) -> int:\n t = sorted(tokens)\n l, r = 0, len(t) - 1\n score = best = 0\n while l <= r:\n if power >= t[l]:\n power -= t[l]\n l += 1\n score += 1\n best = max(best, score)\n elif score > 0:\n power += t[r]\n r -= 1\n score -= 1\n else:\n break\n return best\n```\n", "starter": {"go": "package main\n\nfunc BagOfTokensScore(tokens []int, power int) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def bagOfTokensScore(self, tokens: List[int], power: int) -> int:\n pass", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n int bagOfTokensScore(vector<int>& tokens, int power) {\n return 0;\n }\n};"}, "fn": "bagOfTokensScore", "params": [{"name": "tokens", "type": "int_array"}, {"name": "power", "type": "int"}], "outputType": "int", "tests": [["[100]", "50"], ["[200, 100]", "150"], ["[100, 200, 300, 400]", "200"], ["[]", "50"], ["[100]", "100"], ["[50]", "100"], ["[100, 200]", "100"], ["[71, 55, 82]", "54"], ["[26]", "51"], ["[81, 91, 31]", "73"], ["[0]", "0"], ["[0, 0]", "0"], ["[100, 200, 300]", "0"], ["[150, 35, 50]", "50"], ["[10, 20, 30, 40]", "30"], ["[25, 50, 75, 100]", "50"], ["[300]", "200"], ["[200]", "300"], ["[10, 10, 10]", "10"], ["[5, 5, 5, 5]", "5"], ["[1000]", "1000"], ["[100, 100]", "150"], ["[30, 40, 50, 60]", "70"], ["[10000]", "0"], ["[0, 100]", "50"], ["[60, 60, 60]", "60"], ["[20, 30, 40, 50]", "60"], ["[1, 2, 3, 4, 5]", "5"]], "expected": [0, 1, 2, 0, 1, 1, 1, 0, 1, 1, 1, 2, 0, 1, 2, 2, 0, 1, 1, 1, 1, 1, 2, 0, 1, 1, 2, 3], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "98", "slug": "balanced-binary-tree", "id": 98, "title": "Balanced Binary Tree", "difficulty": "Easy", "category": "tree", "link": "https://leetcode.com/problems/balanced-binary-tree/", "examples": [{"input": "root = [3,9,20,null,null,15,7]", "output": "true", "explanation": "At every node, the heights of the left and right subtrees differ by at most 1."}, {"input": "root = [1,2,2,3,3,null,null,4,4]", "output": "false", "explanation": "Some node has left and right subtree heights differing by more than 1."}, {"input": "root = []", "output": "true", "explanation": "At every node, the heights of the left and right subtrees differ by at most 1."}], "hints": ["Compute subtree heights from the leaves upward rather than recomputing each height for every ancestor.", "If either child subtree is already unbalanced, or their heights differ by more than one, the whole tree is unbalanced.", "An empty subtree has height zero and is balanced."], "statement": "Given the root of a binary tree, determine whether it is height-balanced.\n\nA binary tree is height-balanced when, for every node, the heights of its left\nand right subtrees differ by at most one.\n\n**Constraints:**\n\n- The tree contains between `0` and `5000` nodes.\n- `-10^4 <= node.val <= 10^4`\n", "solution": "## Approach\n\nUse iterative postorder so child heights are available before their parent is checked. If any node's child heights differ by more than one, return `False`; otherwise store its height and continue. This avoids recursion-depth limits on tall valid inputs.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n).\n- **Space Complexity:** O(n) for the traversal order and height table.\n\n## Implementation\n\n```python\nclass Solution:\n def isBalanced(self, root) -> bool:\n if root is None:\n return True\n\n order = []\n stack = [root]\n while stack:\n node = stack.pop()\n order.append(node)\n if node.left is not None:\n stack.append(node.left)\n if node.right is not None:\n stack.append(node.right)\n\n heights = {}\n for node in reversed(order):\n left = heights.get(node.left, 0)\n right = heights.get(node.right, 0)\n if abs(left - right) > 1:\n return False\n heights[node] = 1 + max(left, right)\n return True\n```\n", "starter": {"go": "package main\n\nfunc IsBalanced(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\n\nclass Solution:\n def isBalanced(self, root) -> bool:\n pass\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};\n*/\nclass Solution {\npublic:\n bool isBalanced(TreeNode* root) {\n return false;\n }\n};"}, "fn": "isBalanced", "params": [{"name": "root", "type": "tree_node", "visualizeType": "tree_node"}], "outputType": "boolean", "tests": [["[]"], ["[1]"], ["[1,2]"], ["[1,null,2]"], ["[1,2,3]"], ["[3,9,20,null,null,15,7]"], ["[1,2,2,3,3,null,null,4,4]"], ["[1,2,null,3]"], ["[1,null,2,null,3]"], ["[1,2,null,3,null,4]"], ["[1,null,2,null,3,null,4]"], ["[1,2,null,null,3]"], ["[1,null,2,3]"], ["[1,2,3,4,5,6,7]"], ["[1,2,3,4,5,null,7]"], ["[1,2,3,4,null,null,7]"], ["[1,2,3,4,null,null,7,5,null,null,8]"], ["[1,2,3,null,4,5,null]"], ["[1,2,3,null,4,null,5]"], ["[0,0,0,0,0,0,0]"], ["[-1,-2,-3,-4,-5,-6,-7]"], ["[1,2,3,4,5,6,7,8]"], ["[1,2,3,4,5,6,7,8,9]"], ["[1,2,3,4,5,6,7,8,9,10]"], ["[1,2,3,4,null,null,5,6,null,null,7]"], ["[1,2,3,null,4,5,null,6,null,null,7]"], ["[1,2,3,4,null,5,null,6,null,7]"], ["[5,4,6,3,null,null,7,2,null,null,8]"], ["[5,4,6,null,3,7,null,null,2,null,8]"], ["[10,5,15,3,7,12,18,1,4,6,8,11,13,17,20]"], ["[10,5,15,3,7,null,18,1,null,6,8,17,20]"], ["[10,5,15,null,7,12,null,6,8,11,13]"], ["[8,4,12,2,6,10,14,1,3,5,7,9,11,13,15]"], ["[8,4,12,2,6,10,14,1,null,null,7,9,null,null,15]"], ["[8,4,12,null,6,10,null,5,7,9,11]"], ["[10000,-10000,0]"], ["[10000,-10000,null,0]"], ["[-10000,null,10000,null,0]"], ["[1,2,3,4,null,null,5,6,7,8,9]"], ["[1,2,3,null,4,5,null,6,7,8,9]"], ["[1,2,3,4,5,null,null,6,null,null,7,8,null,null,9]"], ["[50,25,75,12,37,62,87,6,18,31,43,56,68,81,93]"], ["[50,25,75,12,null,62,87,6,18,56,68,null,93]"], ["[3,1,4,null,2,null,5]"], ["[3,1,4,null,2,null,5,null,null,null,6]"], ["[0,-1,1,-2,null,null,2,-3,null,null,3]"], ["[0,-1,1,null,-2,2,null,null,-3,null,3]"], ["[1,2,null,3,null,4,null,5,null,6]"], ["[1,null,2,null,3,null,4,null,5,null,6]"], ["[1,2,null,null,3,4,null,null,5,6]"], ["[1,null,2,3,null,null,4,5,null,null,6]"], ["[4,2,6,1,3,5,7]"], ["[4,2,6,1,3,5,7,null,null,null,null,null,null,null,8]"], ["[2,1,3,null,null,null,4,null,5]"], ["[2,1,4,null,null,3,5,null,null,null,6]"], ["@javascript:JSON.stringify(Array.from({length:4999},(_,i)=>10000-(i%20001)))"], ["@javascript:JSON.stringify(Array.from({length:5000},(_,i)=>(i%20001)-10000))"]], "expected": [true, true, true, true, true, true, false, false, false, false, false, false, false, true, true, true, false, true, true, true, true, true, true, true, false, false, false, false, false, true, false, false, true, true, false, true, false, false, false, false, false, true, false, true, false, false, false, false, false, false, false, true, true, false, false, true, true], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "566", "slug": "base-7", "id": 566, "title": "Base 7", "difficulty": "Easy", "category": "math", "link": "https://leetcode.com/problems/base-7/", "examples": [{"input": "num = 100", "output": "\"202\"", "explanation": "2*49 + 0*7 + 2 equals 100 in decimal."}, {"input": "num = -7", "output": "\"-10\"", "explanation": "Seven in base seven is 10, with the negative sign preserved."}], "hints": ["Handle zero as a special case returning \"0\".", "Record the sign, work with the absolute value, and collect remainders modulo 7.", "Reverse the collected digits and reattach the minus sign when needed."], "statement": "Write the supplied decimal integer in base seven. Use digits `0` through `6` with standard positional weighting. Zero is written as `\"0\"`. Negative inputs carry a leading minus sign followed by the base-seven form of the absolute value. No extra leading zeros appear.\n\nReturn the resulting text.\n\n**Constraints:**\n- `-10^7 <= num <= 10^7`\n", "solution": "## Approach\n\nZero maps directly to `\"0\"`. Otherwise remember the sign and repeatedly take the remainder modulo seven, building digits from least to most significant. Reversing the collected digits and restoring the sign yields the base-seven text.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log_7 |num|) digit steps.\n- **Space Complexity:** O(log_7 |num|) for the output.\n\n## Implementation\n\n```python\nclass Solution:\n def convertToBase7(self, num: int) -> str:\n if num == 0:\n return \"0\"\n neg = num < 0\n n = abs(num)\n ds = []\n while n > 0:\n ds.append(str(n % 7))\n n //= 7\n if neg:\n ds.append(\"-\")\n return \"\".join(reversed(ds))\n```\n", "starter": {"go": "package main\n\nfunc ConvertToBase7(num int) string {\n \n}", "python": "class Solution:\n def convertToBase7(self, num: int) -> str:\n pass\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n string convertToBase7(int num) {\n return \"\";\n }\n};"}, "fn": "convertToBase7", "params": [{"name": "num", "type": "int"}], "outputType": "string", "tests": [["100"], ["-7"], ["0"], ["1"], ["-1"], ["6"], ["7"], ["8"], ["-8"], ["49"], ["-49"], ["50"], ["-50"], ["342"], ["-342"], ["10000000"], ["-10000000"], ["9999999"], ["2"], ["13"], ["-13"], ["14"], ["-14"], ["48"], ["-48"], ["343"], ["-343"], ["202"]], "expected": ["202", "-10", "0", "1", "-1", "6", "10", "11", "-11", "100", "-100", "101", "-101", "666", "-666", "150666343", "-150666343", "150666342", "2", "16", "-16", "20", "-20", "66", "-66", "1000", "-1000", "406"], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "176", "slug": "baseball-game", "id": 176, "title": "Baseball Game", "difficulty": "Easy", "category": "stack", "link": "https://leetcode.com/problems/baseball-game/", "examples": [{"input": "operations = [\"5\",\"2\",\"C\",\"D\",\"+\"]", "output": "30", "explanation": "\"5\" - Add 5 to the record, record is now [5]. \"2\" - Add 2 to the record, record is now [5, 2]. \"C\" - Invalidate and remove the previous score, record is now [5]. \"D\" - Add 2 * 5 = 10 to the record, record is now [5, 10]. \"+\" - Add 5 + 10 = 15 to the record, record is now [5, 10, 15]. The sum is 30."}, {"input": "operations = [\"5\",\"-2\",\"4\",\"C\",\"D\",\"9\",\"+\",\"+\"]", "output": "27", "explanation": "\"5\" - Add 5, record is [5]. \"-2\" - Add -2, record is [5, -2]. \"4\" - Add 4, record is [5, -2, 4]. \"C\" - Remove 4, record is [5, -2]. \"D\" - Add 2 * -2 = -4, record is [5, -2, -4]. \"9\" - Add 9, record is [5, -2, -4, 9]. \"+\" - Add -4 + 9 = 5, record is [5, -2, -4, 9, 5]. \"+\" - Add 9 + 5 = 14, record is [5, -2, -4, 9, 5, 14]. The sum is 27."}, {"input": "operations = [\"1\",\"C\"]", "output": "0", "explanation": "\"1\" - Add 1 to the record, record is now [1]. \"C\" - Invalidate and remove the previous score, record is now []. The sum is 0."}], "hints": ["Keep a stack (list) of valid scores and update it for each operation.", "For '+' push the sum of the last two scores; for 'D' push twice the last score; for 'C' pop the last score; otherwise parse and push the integer."], "statement": "You are scor\u00ading an odd baseball match, starting from a blank scoresheet. Process the entries of the string list `operations` one after another, updating a running record as follows:\n\n- a numeric string `x`: append a fresh score of `x` to the record.\n- `'+'`: append a fresh score equal to the total of the two most recent recorded scores.\n- `'D'`: append a fresh score worth twice the most recent recorded score.\n- `'C'`: erase the most recent recorded score, as if it had never happened.\n\nAfter the whole list has been consumed, add together every score still left on the record and return that total.\n\nEvery generated case keeps each intermediate value and the final answer inside a 32-bit signed integer, and every requested operation is guaranteed to be applicable when it appears.\n\n**Constraints:**\n\n- `1 <= operations.length <= 1000`\n- `operations[i]` is `\"C\"`, `\"D\"`, `\"+\"`, or a string representing an integer in the range `[-3 * 10^4, 3 * 10^4]`.\n- For operation `\"+\"`, there will always be at least two previous scores on the record.\n- For operations `\"C\"` and `\"D\"`, there will always be at least one previous score on the record.\n", "solution": "## Approach\n\nKeep a stack of the currently valid scores. Scan `operations` once: an integer string is parsed and pushed, `\"C\"` pops the last score, `\"D\"` pushes twice the last score, and `\"+\"` pushes the sum of the last two scores (pop the top briefly to peek the second value, then restore it). Finally sum every value left in the stack.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the number of operations. Each operation does O(1) stack work.\n- **Space Complexity:** O(n) for the stack of valid scores.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def calPoints(self, operations: List[str]) -> int:\n stack: List[int] = []\n for op in operations:\n if op == \"C\":\n stack.pop()\n elif op == \"D\":\n stack.append(2 * stack[-1])\n elif op == \"+\":\n stack.append(stack[-1] + stack[-2])\n else:\n stack.append(int(op))\n return sum(stack)\n```\n", "starter": {"go": "package main\n\nfunc CalPoints(operations []string) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def calPoints(self, operations: List[str]) -> int:\n return 0\n", "cpp": "#include <string>\n#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int calPoints(vector<string>& operations) {\n return 0;\n }\n};"}, "fn": "calPoints", "params": [{"name": "operations", "type": "string_array"}], "outputType": "int", "tests": [["[\"5\",\"2\",\"C\",\"D\",\"+\"]"], ["[\"5\",\"-2\",\"4\",\"C\",\"D\",\"9\",\"+\",\"+\"]"], ["[\"1\",\"C\"]"], ["[\"1\"]"], ["[\"1\",\"2\",\"+\",\"D\",\"C\"]"], ["[\"-3\",\"-2\",\"+\",\"D\"]"], ["[\"5\",\"D\",\"D\",\"+\"]"], ["[\"1\",\"2\",\"3\",\"+\",\"+\"]"], ["[\"10\",\"20\",\"C\",\"C\",\"5\"]"], ["[\"0\",\"0\",\"+\",\"D\"]"], ["[\"30000\",\"-30000\",\"+\",\"D\",\"C\"]"], ["[\"1\",\"2\",\"3\",\"4\",\"5\",\"+\",\"D\",\"C\",\"+\"]"], ["@javascript:JSON.stringify([...Array(200).fill(\"1\"),...Array(40).fill(\"+\")])"], ["[\"5\"]"], ["[\"5\",\"2\"]"], ["[\"5\",\"2\",\"+\"]"], ["[\"5\",\"2\",\"+\",\"D\"]"], ["[\"1\",\"C\",\"2\"]"], ["[\"10\",\"10\",\"+\",\"C\",\"D\"]"], ["[\"-10\",\"-20\",\"-30\"]"], ["[\"0\"]"], ["[\"0\",\"C\"]"], ["[\"2\",\"3\",\"D\",\"+\"]"], ["[\"1\",\"2\",\"D\",\"D\",\"+\"]"], ["[\"100\",\"200\",\"C\",\"300\"]"], ["[\"1\",\"2\",\"C\",\"C\",\"3\"]"], ["[\"-5\",\"D\",\"+\",\"C\"]"], ["[\"7\",\"8\",\"+\",\"D\",\"C\",\"C\"]"], ["[\"3\",\"4\",\"5\",\"C\",\"C\",\"6\"]"], ["[\"50\",\"-50\",\"+\",\"D\",\"+\"]"]], "expected": [30, 27, 0, 1, 6, -20, 65, 19, 5, 0, 0, 38, 701408930, 5, 7, 14, 28, 2, 40, -60, 0, 0, 20, 27, 400, 3, -15, 15, 9, 0], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b8", "slug": "basic-absolute-value", "id": 8, "title": "Absolute Value", "difficulty": "Easy", "category": "if-else", "link": null, "examples": [{"input": "n = -5", "output": "5", "explanation": "The absolute value of -5 is 5."}, {"input": "n = 3", "output": "3", "explanation": "Positive numbers are unchanged."}], "hints": ["Branch on whether `n` is negative.", "Negating a negative number makes it positive."], "statement": "Return the absolute value of `n`: the number itself when it is zero or positive, and its negation when it is negative.\n\n**Constraints:**\n- ``-10^9 <= n <= 10^9``\n", "solution": "## Approach\n\nUse one if statement to detect negative inputs. Negate those inputs and return non-negative inputs unchanged.\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 absVal(self, n: int) -> int:\n if n < 0:\n return -n\n return n\n```\n", "starter": {"go": "package main\n\nfunc AbsVal(n int) int {\n return 0\n}", "python": "class Solution:\n def absVal(self, n: int) -> int:\n return 0\n", "cpp": "\nclass Solution {\npublic:\n int absVal(int n) {\n return 0;\n }\n};"}, "fn": "absVal", "params": [{"name": "n", "type": "int"}], "outputType": "int", "tests": [["-5"], ["3"], ["0"], ["-1"], ["1"], ["-1000000000"], ["1000000000"], ["-999"], ["10"], ["-10"], ["100"], ["-100"], ["999999999"], ["-999999998"], ["7"], ["-7"], ["123456789"], ["-123456789"], ["42"], ["-42"], ["5"], ["2"], ["-2"], ["99"], ["-99"], ["555555555"], ["-555555555"], ["777"], ["-777"], ["1000001"], ["-1000001"]], "expected": [5, 3, 0, 1, 1, 1000000000, 1000000000, 999, 10, 10, 100, 100, 999999999, 999999998, 7, 7, 123456789, 123456789, 42, 42, 5, 2, 2, 99, 99, 555555555, 555555555, 777, 777, 1000001, 1000001], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b18", "slug": "basic-array-max", "id": 18, "title": "Array Maximum", "difficulty": "Easy", "category": "arrays", "link": null, "examples": [{"input": "nums = [3,1,4,2]", "output": "4", "explanation": "4 is the largest."}, {"input": "nums = [-7,-2,-9]", "output": "-2", "explanation": "-2 is the largest."}], "hints": ["Start with the first element as the best guess.", "Compare every other element against it with an `if`."], "statement": "Return the largest value in the array `nums`. The array always contains at least one number.\n\n**Constraints:**\n- ``1 <= nums.length <= 1000``\n- ``-10^9 <= nums[i] <= 10^9``\n", "solution": "## Approach\n\nSeed the answer with the first element. Scan the rest of the array, replacing the answer whenever a larger value appears.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def arrayMax(self, nums: List[int]) -> int:\n best = nums[0]\n for x in nums[1:]:\n if x > best:\n best = x\n return best\n```\n", "starter": {"go": "package main\n\nfunc ArrayMax(nums []int) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def arrayMax(self, nums: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int arrayMax(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "arrayMax", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[3,1,4,2]"], ["[-7,-2,-9]"], ["[5]"], ["[1,1,1]"], ["[1,2,3,4,5]"], ["[5,4,3,2,1]"], ["[-1000000000,1000000000]"], ["[9, 3, 7, 1]"], ["[100, -100, 50]"], ["[8, 8, 8, 8]"], ["[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"], ["[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]"], ["[-1, -2, -3, -4]"], ["[42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]"], ["[-747818, -460346, 527056, 45178, -556555, -641347, -242913, 765678, -186462, 294642, -879798, -783531, 976386, -823111, 872880, 601176, -244613, -148345, 308762, 773233, -949838, -909710, -208291, -1188, 249101, -343699, -112181, 635037, -753751]"], ["[8214, -32920, -483290, -45035, 313483, 972465, 451699, 815441, 151967, 110581, 808060, -746167, 659344, 560117, -745208, 977450, -490643, 392695, -673255, 118791, -981618, -6612, -392214, 695383, -372388, 110328, 401343, 181382, -188967, 531832, 173446, 268989, -207716, 107918]"], ["[241953, -712381, -920745, 110698, -543978, -174084, -194710, -426448, -292036, 417829]"], ["[-290007, -348020, -276527, -355389, 941922, -5520, 727952, -675647, 808013, -775005, -852043, 884082, 570754, 382172, 118079, 686654, 118045, -297391, 145664, 867006, 333296, -97171, -143997, -6356]"], ["[-953734, -102667, -558231, -701739, 321697, 204445, 601249, 654837, -359117, 749910, 712698, -46757, 372948, -304178, -933837, -300073, -485106, -666874, -485913, 91270, -259358, -995828, 632531, 407671, 731125, -224575, -480818, -796096, 913511, 959238, 49319, -158275, 536715, 415123, -102271]"], ["[105321, 875985, 420747, 259711, -282174, -50374, -407328, -64342, 941492, 346922, 349228, -591777, 796816, -623765, 183131, -101057, 863519, 448749, 773818, -178383, 606531, -34811]"], ["[-416025, -215202, 895416, 215224, 806062, -105187, 362960, -885162, -140667, -280473, 414005, -487046, -792431, -909995, 130140, -268674, 294324, 329552, 566474, 395563, 925475, -43132]"], ["[-265903, 346218, 134558, 6766]"], ["[-426858, -147414, 39121, 756072, -447394, -582052, -935918, 883766, -351502, 283154, 298065, -816716]"], ["[722928, -852396, 520217, -227072, 616999, -229989, 816702, -881399, -230201, -849127, -972221, -81196, -865724, 227685, -387274, -170691, 933589, 470673, -756440, 383568, 710575, 492453]"], ["[43882, 435352, -121926, -654807, 144598, 904715, 90989, 923451, -721212]"], ["[-405266, -964617, 475503, 951858, -899720, -474743, 826170, 879332, -104255, 576480, -109480, 92959, -54682, 125544, -516687]"], ["[935223, -618788]"]], "expected": [4, -2, 5, 1, 5, 5, 1000000000, 9, 100, 8, 9, 10, -1, 42, 976386, 977450, 417829, 941922, 959238, 941492, 925475, 346218, 883766, 933589, 923451, 951858, 935223], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b19", "slug": "basic-array-min", "id": 19, "title": "Array Minimum", "difficulty": "Easy", "category": "arrays", "link": null, "examples": [{"input": "nums = [3,1,4,2]", "output": "1", "explanation": "1 is the smallest."}, {"input": "nums = [-7,-2,-9]", "output": "-9", "explanation": "-9 is the smallest."}], "hints": ["Mirror the maximum problem but flip the comparison.", "Start with the first element."], "statement": "Return the smallest value in the array `nums`. The array always contains at least one number.\n\n**Constraints:**\n- ``1 <= nums.length <= 1000``\n- ``-10^9 <= nums[i] <= 10^9``\n", "solution": "## Approach\n\nSeed the answer with the first element. Scan the rest, keeping the smaller value each time a new minimum appears.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def arrayMin(self, nums: List[int]) -> int:\n best = nums[0]\n for x in nums[1:]:\n if x < best:\n best = x\n return best\n```\n", "starter": {"go": "package main\n\nfunc ArrayMin(nums []int) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def arrayMin(self, nums: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int arrayMin(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "arrayMin", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[3,1,4,2]"], ["[-7,-2,-9]"], ["[5]"], ["[1,1,1]"], ["[1,2,3,4,5]"], ["[5,4,3,2,1]"], ["[-1000000000,1000000000]"], ["[9, 3, 7, 1]"], ["[100, -100, 50]"], ["[8, 8, 8, 8]"], ["[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"], ["[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]"], ["[-1, -2, -3, -4]"], ["[42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]"], ["[715627, -383124, -453762, 925343, 488027, 395699, 574991, -254323, -238978, 537305, 371090, -519728, 235585, -29237, 843923]"], ["[48237, 807472, -185345, -523681, 305817, -29920, 615105, 460592, 423390, -413967, -177744, 201275, 223852, -262903, 970130, 618926, 385659, -500806, 547120, 722525, -620702, 74556, -2674, 915363, 98387, 91465, -412377, 249994, 166586, -534330, -803095, 631114, -704683, 158468, -223135, 739302, 700364, 144917, 862470, -798339]"], ["[-776804, 889692, 870004, 953404, 484182, -167520, 96954, -171665, 919273, -480406, -395385, -738839, -342264, 652114, -748008, -277498, 41004, -658626]"], ["[618755, -980747, 527745, -928062, -476498, -949709, 538225, 465043, 802736, -819806, 130171]"], ["[-312709, 155428, 673531, -471646, 657789, -646699, 724810, -987376, 139146, 671848, -319645, 734817, 856975, 492568, 744590, 278289, -232229, 526468, 565295, 141632, 503315, 523081, -885152, 502350, 305950, 479080, 19247, -91349, 587117]"], ["[368944, -938793, 83771, -989621, -377207, 236506, -111730, -19639, 507629, -185037, -626547, -176586, -752793, -56452, -292933, 667076, -860248, 529992, -404722, 382867, -92140, -289472, 144284, 108194, -780842, 856370, 39088, 720308, 987900, 476090, -762679, 885705, 922184, 429131, -599676, -640420]"], ["[957755, -580758, 276725, -56265, -895751, 736975, 260910, 943997, 637233, 583759, -228334, -714277, 515431, 125675, -701454, -911588, 148265, 495710, 641672, 625832, -120814, 699710, -223212, 23741, -321554, -68210, 301453, -38427, 73817, -174260]"], ["[-298079, -649262, -15677, 105198, -678621, -434662, -875458, -877632, -506870, 696957, -802764, -409296, -829554, 464257, 17886, -575462, 29159, 131442, 698636, 47199, 84767, -690297, 135808, 231872, -191092, -150971, -752205, 533119, -785149]"], ["[452018, 734842, 211516, 966510, 232629, -630622, -930846, -638329, 484209, -182623, -161931, 377770, 118079, 528242, -281198, -361603, 758676, 635492, -361936, 264433, 986304, -733743, -433880, 115350, -266668, 710900]"], ["[551086, 10257, -879578, -470507, -34061, 46737, 182932, -62505, 671745, -851903, 936920, 744706, 890161, -441855, 17390, 223460, -623558, -283340, 734975, -513831, 206400, -64408, -707372, -354919, 672299, 266519, 128271, 634494, 679939, 211179]"], ["[37624, -951250, -214930, -306337, 330191, -615333, -987317, -164424, -981597, 202197, -756294, -111300, -636218, 203401, 614901]"], ["[211129, 177965, -822412, -91406]"], ["[924057, 284924, -391597, -819086, 736317, 283032, -126976, 702734, -656576, 947648, 306911, -488046, -25424, 56489, 480750, 292521, 778725, 705473, 859198, -775360, 693901, 70141, -216058, -872169, -396380, 749578, 976541, 740434, 877271, 109825]"]], "expected": [1, -9, 5, 1, 1, 1, -1000000000, 1, -100, 8, 0, 1, -4, 42, -519728, -803095, -776804, -980747, -987376, -989621, -911588, -877632, -930846, -879578, -987317, -822412, -872169], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b48", "slug": "basic-array-sum-rec", "id": 48, "title": "Array Sum (Recursive)", "difficulty": "Easy", "category": "recursion", "link": null, "examples": [{"input": "nums = [1,2,3]", "output": "6", "explanation": "1+2+3 = 6."}, {"input": "nums = []", "output": "0", "explanation": "Base case."}], "hints": ["Peel off index 0 and recurse on the remainder.", "Use a helper that carries the current index."], "statement": "Return the sum of all numbers in `nums`, computed recursively: the sum of an empty array is 0, otherwise add the first element to the sum of the rest.\n\n**Constraints:**\n- ``0 <= nums.length <= 200``\n- ``-1000 <= nums[i] <= 1000``\n", "solution": "## Approach\n\nRecurse over the array index: past-the-end returns zero, otherwise add the current element to the recursive sum of the suffix.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n).\n- **Space Complexity:** O(n).\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def arraySumRec(self, nums: List[int]) -> int:\n if not nums:\n return 0\n return nums[0] + self.arraySumRec(nums[1:])\n```\n", "starter": {"go": "package main\n\nfunc ArraySumRec(nums []int) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def arraySumRec(self, nums: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int arraySumRec(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "arraySumRec", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[1,2,3]"], ["[]"], ["[5]"], ["[-1,-2,3]"], ["[0,0,0]"], ["[10,20,30,40]"], ["[4, 5, 6]"], ["[10, -10, 10, -10]"], ["[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]"], ["[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]"], ["[-1000, 1000, -1000, 1000]"], ["[-70, -954, 549, 597, 781, -734, 514, -866, -369, 537, -218, 17, -871, -70, -352, 141, 188, -235, 543, 127, 444, -40, -434, 770, -396, 100, -707]"], ["[568, 906, 949, 775, -710, 719, 766, -812, -91, -457, -448, 164, 79, 283, 800, 75, -209, 113, 371, 931, -506, -371, -997, 620]"], ["[-821, -715, -559, -962, -672, -712, 445, -60, 282, -641, 892, 680, 968, -359, -368, -184, -982, -299, -372, 144, 283, -450, 325, 896, 118, 155]"], ["[114, 202, -192, -182, 407, 832, -980, 576, 486, 716, -190, 274, -724, -845, 612, -630, 947, -626, 592, 15, -201, -14, -323, 394, -595, 257, -961, -674]"], ["[-827, 755, 992, -33, 189, -705, -85, -313, 30, -305, -843, -192, 441, 333, 36, 92, 175, -432, 485, -610, 628]"], ["[595, -110, 865, 529, 912, 984, 349, 646, -71, 74, 976, 367, 460, -651, -25, 486, -169]"], ["[51, 305, 515, 400, 753, 981, 395, 287, -856, 212, 610, 255, -26, -608, -113, -424, 659, 503, -271, -288, 30, -607, 112, -400, 442, -268, -116, 485, 26, -198, -836, -272, 265, 103, -754, -598, -690, 871, 623, 31, -675, -374, -125, -525, -69, -768, -81, -732, -403, 84, -391, 507, -252]"], ["[650, 211, 711, -687, -972, -169, 273, -592, 765, -526, -144, -749, 140, -933, 100, 870, 208, -315, -590, 950, -41, 232, -30, 249, -375, 541, -717, 655, -291, -334, 897, 296, 648, -286, 499, 917, 55, -534, 873, 861, 294, -478, -761, -886, 592, 531, -194, 155, 763]"], ["[595, 71, 569, 386, 252, -783, 230, 898, -316, -487, -613]"], ["[-834, -692, 410, -815, 505, 516, 293]"], ["[183, -575, -841, 225, 333, 190, -928, 4, -436, -497, -386, -418, 107, 409, -435, -760, 578, -124, 554, 826, -843, 489, 695, -396, -152, -273, 811, 254, 87, -262, -584, 920, 253, 258, 658, 33, -432, -809, 522, -703, -955]"], ["[-17, -677, 64, 75, 487, -431, 1, -127, 214, 280, 82, 333, -425, -516, -17, 785, -433, -175, 673, 252, -122, 823, -458, 534, -715, 243, -547, -90, 45, 58, 229, -474, -782, -606, 246, -92, 568, 202, 771, -674, -26, -110, -799, 491, 808, 626, -245, -509, -368, -203, -947, -1, 734, -92, -216, -435, -310, -486, -801]"], ["[-95, -817, -70, 814, -571, -260, 5, 255, -256, 621, 846, -220, -197, 746, 769, 484, -875, 353, 204, 867, -913, 904, -829, 613]"], ["[459, 747, 236, 178, -286]"], ["[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]"]], "expected": [6, 0, 5, 0, 0, 100, 15, 0, 30, 210, 0, -1008, 3518, -2968, -713, -189, 6217, -2215, 3332, 802, -617, -2420, -3302, 2378, 1334, 200], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b17", "slug": "basic-array-sum", "id": 17, "title": "Array Sum", "difficulty": "Easy", "category": "arrays", "link": null, "examples": [{"input": "nums = [1,2,3]", "output": "6", "explanation": "1+2+3 = 6."}, {"input": "nums = []", "output": "0", "explanation": "An empty array sums to 0."}], "hints": ["Loop over the array and accumulate a total.", "Start the total at 0 so empty arrays work."], "statement": "Return the sum of all numbers in the array `nums`. An empty array sums to 0.\n\n**Constraints:**\n- ``0 <= nums.length <= 1000``\n- ``-1000 <= nums[i] <= 1000``\n", "solution": "## Approach\n\nWalk through the array once, adding each element to a running total that starts at zero.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def arraySum(self, nums: List[int]) -> int:\n total = 0\n for x in nums:\n total += x\n return total\n```\n", "starter": {"go": "package main\n\nfunc ArraySum(nums []int) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def arraySum(self, nums: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int arraySum(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "arraySum", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[1,2,3]"], ["[]"], ["[-1,-2,3]"], ["[5]"], ["[0,0,0]"], ["[-5,5]"], ["[1000,-1000,500]"], ["[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]"], ["[10, -3, 7]"], ["[100, 200, 300]"], ["[-1000, 1000]"], ["[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]"], ["[-5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5]"], ["[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"], ["[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]"], ["[-25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]"], ["[394, -159, -32, 619, 741, 339, 697, 102, 644, 991, -541, -668, 486, 173, -800, 716, -720, -476, -230, 659, -497, -312, -932, 295, 60, -904, 977, 749, -839, 327, -515, 397, 897, -464, 82, -138, -48]"], ["[-144, 573, 681, -200, -38, -818, -175, -752, -258, -895, 587, 595, -961, -862, -92, 367, 309, 160, -982, -371, -352, 751, -290, 104, 320, 400, 63, 824, 19, -819, -383, -673, -120, -598, 897, -771]"], ["[-978, -674, -730, -898, -708]"], ["[-364]"], ["[-968, -634, 24, -892, -507, 186, 841, 449, -370, 428, 206, -946, -696, 11, -173, -116, -288, 105, -687, -543, 751, -946]"], ["[239, -421, 692, 330, -314, 855, -226, -333, -909, -703, 91, 708, 671, 991, -17, -418, -742, 653, -767, -356, 740, -223, 457, 660, -477, 53, 117, -749, -797, 146, -861, -943, -782]"], ["[283, -8, 779, -47, -488, -397, 607, 360, 253, -492, 602, -460, 702, -541, 174, 348, 964, -593, -490]"], ["[1000, -494, -900, 893, 150, 20, -622, -506, -765, 424, -434, 483, -222, 566, -997, 498, -423, 148, 891]"], ["[645, -678, 365, -107, 974, -534]"], ["[-200, 551, 112, 829, -901, 74, -373, 12, -760, -678, -657, 918, 577, -315, 38, -597, -938, -527, -607, 603, 8, -409, 453, 381, -41, 299, 311, 927, 97, 668, 145]"], ["[-558, 838, -922, -271, -939, -601, 777]"], ["[-541, -702, -781, 441, 677]"]], "expected": [6, 0, 0, 5, 0, 0, 500, 1000, 14, 600, 0, 50, -100, 0, 1275, 0, 2070, -3904, -3988, -364, -4765, -2635, 1556, -290, 665, 0, -1676, -906], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b23", "slug": "basic-average-floor", "id": 23, "title": "Floor Average", "difficulty": "Easy", "category": "arrays", "link": null, "examples": [{"input": "nums = [1,2,3]", "output": "2", "explanation": "The average is exactly 2."}, {"input": "nums = [1,2]", "output": "1", "explanation": "The average 1.5 rounds down to 1."}], "hints": ["First compute the sum.", "Then divide by the length using integer division."], "statement": "Return the average of the numbers in `nums`, rounded down to an integer. All numbers are zero or positive, so plain integer division gives the answer. The array always contains at least one number.\n\n**Constraints:**\n- ``1 <= nums.length <= 1000``\n- ``0 <= nums[i] <= 1000``\n", "solution": "## Approach\n\nAdd up all elements, then divide by the count with integer division, which discards any fraction.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def avgFloor(self, nums: List[int]) -> int:\n return sum(nums) // len(nums)\n```\n", "starter": {"go": "package main\n\nfunc AvgFloor(nums []int) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def avgFloor(self, nums: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int avgFloor(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "avgFloor", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[1,2,3]"], ["[1,2]"], ["[10]"], ["[0,0,5]"], ["[7,7,7,7]"], ["[0]"], ["[1000,1000]"], ["[2, 3]"], ["[5, 5, 5, 6]"], ["[0, 0, 0, 1]"], ["[100, 200]"], ["[1, 1, 1, 1, 2]"], ["[999, 1000]"], ["[3, 3, 4]"], ["[10, 20, 30, 41]"], ["[7]"], ["[0, 10]"], ["[500, 500, 501]"], ["[1, 1000]"], ["[250, 250, 250, 251]"], ["[636, 260, 407, 96, 716, 534, 131, 312, 530, 697, 123, 50, 15, 328, 594, 613, 34, 572]"], ["[90, 539, 949, 948, 87, 510, 564, 740, 294, 571, 935, 124, 746, 196, 469, 331, 159, 140, 985, 647, 731, 209, 308, 80, 304, 890, 942, 946, 301]"], ["[374, 463, 707, 257, 532, 385, 377, 276, 915, 966, 570, 758, 989, 637, 162, 275, 628, 0, 828, 525, 490, 683, 142, 952, 270, 353, 987, 41, 878]"], ["[51, 785, 580]"], ["[752, 540, 908, 478, 330, 180]"], ["[660, 186, 214, 807, 680, 326, 399, 390]"]], "expected": [2, 1, 10, 1, 7, 0, 1000, 2, 5, 0, 150, 1, 999, 3, 25, 7, 5, 500, 500, 250, 369, 508, 531, 472, 531, 457], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b38", "slug": "basic-bubble-sort", "id": 38, "title": "Bubble Sort", "difficulty": "Easy", "category": "nested-loops", "link": null, "examples": [{"input": "nums = [3,1,2]", "output": "[1,2,3]", "explanation": "Sorted ascending."}, {"input": "nums = []", "output": "[]", "explanation": "Nothing to sort."}], "hints": ["Repeat passes over the array, swapping neighbors that are out of order.", "After enough passes the largest unsorted value bubbles to its place each round."], "statement": "Return a sorted copy of `nums` in ascending order. Implement the classic bubble sort (repeated passes swapping adjacent out-of-order elements), or any correct sort \u2014 the judge only checks the result.\n\n**Constraints:**\n- ``0 <= nums.length <= 500``\n- ``-10^9 <= nums[i] <= 10^9``\n", "solution": "## Approach\n\nClone the input and run bubble sort passes. Each pass pushes the largest remaining value to its final slot through adjacent swaps.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^2).\n- **Space Complexity:** O(n).\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def bubbleSort(self, nums: List[int]) -> List[int]:\n a = list(nums)\n for i in range(len(a)):\n for j in range(len(a) - 1 - i):\n if a[j] > a[j + 1]:\n a[j], a[j + 1] = a[j + 1], a[j]\n return a\n```\n", "starter": {"go": "package main\n\nfunc BubbleSort(nums []int) []int {\n return []int{}\n}", "python": "from typing import List\n\nclass Solution:\n def bubbleSort(self, nums: List[int]) -> List[int]:\n return []\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<int> bubbleSort(vector<int>& nums) {\n return {};\n }\n};"}, "fn": "bubbleSort", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int_array", "tests": [["[3,1,2]"], ["[]"], ["[5,4,3,2,1]"], ["[1]"], ["[1,2,3]"], ["[2,1]"], ["[5,5,5]"], ["[-3,0,-1,2]"], ["[2, 1]"], ["[5, 1, 4, 2, 3]"], ["[9, 7, 5, 3, 1]"], ["[1, 3, 2, 5, 4]"], ["[6, 6, 6, 5]"], ["[-2, -5, 0, 3, -1]"], ["[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]"], ["[3, 1, 2, 1, 3, 2]"], ["[42, 17]"], ["[100, -100, 50, -50, 0]"], ["[2, 2, 1, 1, 3, 3]"], ["[7, 3, 9, 1, 5]"], ["[63, 29, 99, 82, -68, 62, -26, 82, 53, -94, 3, 92, 28, -20, 13, 27, -24, -40, -45, -67, -59, -79, -77, 2, -39, 37, 28, -1, -48, -17]"], ["[-18, 86, 63, -20, 11, 90, 46, 25, -5, -27, 82, -77, 39, 99, 60, -71, -26, -40, -16]"], ["[97, 100, 58, -70, -3, 53, -56]"], ["[85, 68, 56, -68, 38, 78, -98, -7, -22, -24, -70, -10, 44, -63, 53, 26, -54, -48, 34, 90, 63, -84, -32, 68, -92, -15, -75, 68, 21, -96, 8, 35, -29, 41, -57]"], ["[49, 36, -15, -100, 28, 8, -20, -44, 75, -4, 58, -26, -13, 7, 17, 73, -29, 67, -53, 24, -80, -73, 22, -9, 26, 70, 68, -31, -66, 94, 83, -56, 100, 43, -76, -85, -55, 93, -55]"], ["[-81]"], ["[300, 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]"]], "expected": [[1, 2, 3], [], [1, 2, 3, 4, 5], [1], [1, 2, 3], [1, 2], [5, 5, 5], [-3, -1, 0, 2], [1, 2], [1, 2, 3, 4, 5], [1, 3, 5, 7, 9], [1, 2, 3, 4, 5], [5, 6, 6, 6], [-5, -2, -1, 0, 3], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 1, 2, 2, 3, 3], [17, 42], [-100, -50, 0, 50, 100], [1, 1, 2, 2, 3, 3], [1, 3, 5, 7, 9], [-94, -79, -77, -68, -67, -59, -48, -45, -40, -39, -26, -24, -20, -17, -1, 2, 3, 13, 27, 28, 28, 29, 37, 53, 62, 63, 82, 82, 92, 99], [-77, -71, -40, -27, -26, -20, -18, -16, -5, 11, 25, 39, 46, 60, 63, 82, 86, 90, 99], [-70, -56, -3, 53, 58, 97, 100], [-98, -96, -92, -84, -75, -70, -68, -63, -57, -54, -48, -32, -29, -24, -22, -15, -10, -7, 8, 21, 26, 34, 35, 38, 41, 44, 53, 56, 63, 68, 68, 68, 78, 85, 90], [-100, -85, -80, -76, -73, -66, -56, -55, -55, -53, -44, -31, -29, -26, -20, -15, -13, -9, -4, 7, 8, 17, 22, 24, 26, 28, 36, 43, 49, 58, 67, 68, 70, 73, 75, 83, 93, 94, 100], [-81], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300]], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "340", "slug": "basic-calculator-ii", "id": 340, "title": "Basic Calculator II", "difficulty": "Medium", "category": "stack", "link": "https://leetcode.com/problems/basic-calculator-ii/", "examples": [{"explanation": "The product 2*2 = 4 is computed first, then 3 + 4 = 7.", "input": "s = \"3+2*2\"", "output": "7"}, {"explanation": "3/2 = 1.5, truncated toward zero to 1.", "input": "s = \" 3/2 \"", "output": "1"}, {"explanation": "5/2 truncates to 2, then 3 + 2 = 5.", "input": "s = \" 3+5 / 2 \"", "output": "5"}], "hints": ["Split the expression into terms: immediately fold '*' and '/' into the current term, and only add completed terms on '+' or '-'.", "Keep the last term and the running result: '+' adds the term, '-' subtracts it, '*'/'/' merge into it.", "Process the final number after the loop ends; remember division truncates toward zero."], "statement": "You are given a string `s` holding an arithmetic expression with non-negative integers and the operators `+`, `-`, `*` and `/`, plus spaces. There are no parentheses. Multiplication and division bind tighter than addition and subtraction, and division truncates toward zero.\n\nEvaluate the expression and return its integer value. The expression is always valid and every intermediate value fits in a 32-bit signed integer.\n\n**Constraints:**\n- `1 <= s.length <= 3 * 10^5`\n- `s` consists of digits, `'+'`, `'-'`, `'*'`, `'/'` and spaces.\n", "solution": "## Approach\n\nMake one pass while remembering the pending operator and the number being built. Whenever an operator (or the end of input) is reached, apply the *previous* operator: `+`/`-` bank the current term into the result and start a new signed term, while `*`/`/` merge directly into the current term. This gives multiplication and division their higher precedence with constant memory, and the final term is added at the end.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), a single scan.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def calculate(self, s: str) -> int:\n result = 0\n last = 0\n num = 0\n op = \"+\"\n for i, c in enumerate(s):\n if c.isdigit():\n num = num * 10 + int(c)\n if (not c.isdigit() and c != \" \") or i == len(s) - 1:\n if op == \"+\":\n result += last\n last = num\n elif op == \"-\":\n result += last\n last = -num\n elif op == \"*\":\n last = last * num\n elif op == \"/\":\n last = int(last / num)\n op = c\n num = 0\n return result + last\n```\n", "starter": {"go": "package main\n\nfunc Calculate(s string) int {\n return 0\n}", "python": "class Solution:\n def calculate(self, s: str) -> int:\n return 0\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n int calculate(string s) {\n return 0;\n }\n};"}, "fn": "calculate", "params": [{"name": "s", "type": "string"}], "outputType": "int", "tests": [["3+2*2"], [" 3/2 "], [" 3+5 / 2 "], ["1"], ["0"], ["42"], ["1+1"], ["2*3*4"], ["100/10/2"], ["2-3*4"], ["14-3/2"], ["1*2-3/4+5*6-7*8+9/10"], [" 30 "], ["0*5+3"], ["5-10/3"], ["12/5+18/7"], ["1000000+2000000*2"], ["3+2*2-8/4"], ["9-4*2+12/3"], ["2*5/3"], ["1-1+1-1+1"], ["6/2*3"], ["10-2*5"], ["8/3*3"], ["100/3"], ["7*7-7/7"], ["0/1+0*5"], ["2147483647"]], "expected": [7, 1, 5, 1, 0, 42, 2, 24, 5, -10, 13, -24, 30, 3, 2, 4, 5000000, 5, 5, 3, 1, 9, 0, 6, 33, 48, 0, 2147483647], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "772", "slug": "basic-calculator-iii", "id": 772, "title": "Basic Calculator III", "difficulty": "Hard", "category": "stack", "link": "https://leetcode.com/problems/basic-calculator-iii/", "examples": [{"input": "s = \"1+1\"", "output": "2"}, {"input": "s = \"6-4/2\"", "output": "4", "explanation": "Division first: 6 - 2 = 4."}, {"input": "s = \"2*(5+5*2)/3+(6/2+8)\"", "output": "21", "explanation": "Parentheses, then * and /, then +."}], "hints": ["Parse with precedence levels: an expression handles + and -, a term handles * and /, and a factor handles numbers, parentheses, and unary signs.", "Portable note: the formula is a plain string; skip spaces and treat a leading - (or one after '(') as negation.", "Integer division must truncate toward zero, which Java and most languages do natively for ints."], "statement": "Implement a calculator for the string `s`, which holds non-negative integers, the four operators `+`, `-`, `*`, `/`, parentheses `(` `)`, and spaces. Division between integers discards any fractional part toward zero (for example `5 / 2` is `2` and `-5 / 2` is `-2`).\n\nEvaluate using the standard order: innermost parentheses first, then multiplication and division left to right, then addition and subtraction left to right. A leading minus or a minus right after `(` acts as a unary negation.\n\nReturn the integer result. This is a portable string adaptation: the formula travels as a plain string and the answer is a plain integer.\n\n**Constraints:**\n- `1 <= s.length <= 10^4`\n- `s` holds only digits, `+`, `-`, `*`, `/`, `(`, `)`, and spaces\n- `s` is a valid expression; division by zero never occurs\n- Intermediate results fit in a signed 32-bit integer\n", "solution": "## Approach\n\nEvaluate with a small recursive-descent parser mirroring precedence. An expression combines terms with plus and minus, a term combines factors with multiply and divide, and a factor consumes an optional unary sign followed by either a parenthesized expression or a decimal number. Spaces are skipped everywhere, and integer division truncates toward zero.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) where n is the string length; each character is consumed once.\n- **Space Complexity:** O(d) for recursion depth d (parenthesis nesting).\n\n## Implementation\n\n```python\nclass Solution:\n def calculate(self, s: str) -> int:\n n = len(s)\n pos = [0]\n def skip():\n while pos[0] < n and s[pos[0]] == ' ':\n pos[0] += 1\n def parse_expr():\n v = parse_term()\n while True:\n skip()\n if pos[0] < n and s[pos[0]] in '+-':\n op = s[pos[0]]\n pos[0] += 1\n t = parse_term()\n v = v + t if op == '+' else v - t\n else:\n break\n return v\n def parse_term():\n v = parse_factor()\n while True:\n skip()\n if pos[0] < n and s[pos[0]] in '*/':\n op = s[pos[0]]\n pos[0] += 1\n f = parse_factor()\n if op == '*':\n v = v * f\n else:\n v = abs(v) // abs(f) * (1 if (v >= 0) == (f >= 0) else -1) if f != 0 else 0\n else:\n break\n return v\n def parse_factor():\n skip()\n if pos[0] < n and s[pos[0]] in '+-':\n op = s[pos[0]]\n pos[0] += 1\n f = parse_factor()\n return -f if op == '-' else f\n if pos[0] < n and s[pos[0]] == '(':\n pos[0] += 1\n v = parse_expr()\n skip()\n if pos[0] < n and s[pos[0]] == ')':\n pos[0] += 1\n return v\n num = 0\n has = False\n while pos[0] < n and s[pos[0]].isdigit():\n num = num * 10 + int(s[pos[0]])\n pos[0] += 1\n has = True\n return num if has else 0\n return parse_expr()\n```\n", "starter": {"go": "package main\n\nfunc Calculate(s string) int {\n return 0\n}", "python": "class Solution:\n def calculate(self, s: str) -> int:\n return 0\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n int calculate(string s) {\n return 0;\n }\n};"}, "fn": "calculate", "params": [{"name": "s", "type": "string"}], "outputType": "int", "tests": [["1+1"], ["6-4/2"], ["2*(5+5*2)/3+(6/2+8)"], ["3+2*2"], [" 3/2 "], [" 3+5 / 2 "], ["(1+(4+5+2)-3)+(6+8)"], ["2*(5+5*2)/3"], ["0"], ["1"], ["-1+2"], ["(-1+2)"], ["2-3-4"], ["2*3-4"], ["10/3"], ["-10/3"], ["10/-3"], ["(2+6*3+5-(3*14/7+2)*5)+3"], ["1+2+3+4+5"], ["100*100"], ["(1)"], ["((2+3)*4)"], ["14-3/2"], ["5*(4-2)/2"], ["100/10/2"], ["2-(5-(3-(1)))"], [" 2 * (3 + (4 * 5)) "], ["12*(3+4)-5*6/3+8"]], "expected": [2, 4, 21, 7, 1, 5, 23, 10, 0, 1, 1, 1, -5, 2, 3, -3, -3, -12, 15, 10000, 1, 20, 13, 5, 5, -1, 46, 82], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "770", "slug": "basic-calculator-iv", "id": 770, "title": "Basic Calculator IV", "difficulty": "Hard", "category": "stack", "link": "https://leetcode.com/problems/basic-calculator-iv/", "examples": [{"input": "expression = \"e + 8 - a + 5\", evalvars = [\"e\"], evalints = [1]", "output": "[\"-1*a\",\"14\"]", "explanation": "Substituting e=1 leaves 14 - a."}, {"input": "expression = \"e - 8 + temperature - pressure\", evalvars = [\"e\",\"temperature\"], evalints = [1,12]", "output": "[\"-1*pressure\",\"5\"]", "explanation": "Known vars collapse to the constant 5."}, {"input": "expression = \"(e + 8) * (e - 8)\", evalvars = [], evalints = []", "output": "[\"1*e*e\",\"-64\"]", "explanation": "Expands to e*e - 64."}], "hints": ["Represent a polynomial as a map from sorted variable list to coefficient; addition merges maps and multiplication takes pairwise products with merged sorted keys.", "Parse with standard precedence (parentheses, then *, then +-) and replace any variable found in the eval map by its constant.", "Portable note: the expression is a plain string and the answer is a string list ordered by degree descending then variable part ascending."], "statement": "You are given an arithmetic `expression` built from non-negative integers, lowercase-letter variables (possibly several letters long), parentheses, and the operators `+`, `-`, `*`. Chunks and operators are separated by spaces, and the usual precedence applies: parentheses first, then multiplication, then addition and subtraction.\n\nTwo companion arrays describe known variables: `evalvars[k]` names a variable and `evalints[k]` gives its integer value. Every other variable stays free.\n\nEvaluate the expression, substituting the known variables, and return the simplified polynomial as a list of strings with this portable layout:\n\n- Each non-constant term is written `coefficient*var1*var2*...` with its free variables in lexicographic order (repeats kept, e.g. `a*a*b`). A coefficient of `1` or `-1` is still printed (`1*a`, `-1*a`).\n- A constant term is written as just its coefficient.\n- Terms with a zero coefficient are dropped; an all-zero result is the empty list `[]`.\n- Order terms by descending degree (variable count), breaking ties by lexicographic order of the variable part.\n\nThis judge has no floating or map types, so the expression travels as a plain string and the answer travels as a string list (`string_list`); known values travel as a string array plus an integer array.\n\n**Constraints:**\n- `1 <= expression.length <= 200`\n- `expression` is valid and uses only digits, lowercase letters, `+`, `-`, `*`, `(`, `)`, and spaces\n- `0 <= evalvars.length <= 100`, `evalvars.length == evalints.length`\n- Each `evalvars[i]` holds 1+ lowercase letters; all names are distinct\n- `-10^4 <= evalints[i] <= 10^4`\n- All intermediate values fit in a signed 32-bit integer\n", "solution": "## Approach\n\nModel every subexpression as a dictionary from a sorted tuple of free variables to its coefficient. Parsing follows precedence: an expression joins terms with plus or minus, a term joins factors with multiplication, and a factor is a number, a variable (or its known value), a parenthesized group, or a signed factor. Adding merges dictionaries while multiplying forms all pairwise products with concatenated and re-sorted keys. A final filter drops zero coefficients and sorts by degree then variable text.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n * t^2) where n is the expression length and t is the term count, dominated by products.\n- **Space Complexity:** O(t * d) for the dictionaries, with d the max degree.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import defaultdict\nclass Solution:\n def basicCalculatorIV(self, expression: str, evalvars: List[str], evalints: List[int]) -> List[str]:\n sub = dict(zip(evalvars, evalints))\n s = expression\n n = len(s)\n pos = [0]\n def skip():\n while pos[0] < n and s[pos[0]] == ' ':\n pos[0] += 1\n def add(a, b, sign=1):\n r = defaultdict(int, a)\n for k, v in b.items():\n r[k] = r.get(k, 0) + sign * v\n return dict(r)\n def mul(a, b):\n r = defaultdict(int)\n for k1, v1 in a.items():\n for k2, v2 in b.items():\n key = tuple(sorted(k1 + k2))\n r[key] += v1 * v2\n return dict(r)\n def parse_expr():\n res = parse_term()\n while True:\n skip()\n if pos[0] < n and s[pos[0]] in '+-':\n op = s[pos[0]]\n pos[0] += 1\n t = parse_term()\n res = add(res, t, 1 if op == '+' else -1)\n else:\n break\n return res\n def parse_term():\n res = parse_factor()\n while True:\n skip()\n if pos[0] < n and s[pos[0]] == '*':\n pos[0] += 1\n res = mul(res, parse_factor())\n else:\n break\n return res\n def parse_factor():\n skip()\n if pos[0] < n and s[pos[0]] == '(':\n pos[0] += 1\n e = parse_expr()\n skip()\n if pos[0] < n and s[pos[0]] == ')':\n pos[0] += 1\n return e\n if pos[0] < n and s[pos[0]] in '+-':\n op = s[pos[0]]\n pos[0] += 1\n f = parse_factor()\n if op == '-':\n return {k: -v for k, v in f.items()}\n return f\n if pos[0] < n and s[pos[0]].isdigit():\n num = 0\n while pos[0] < n and s[pos[0]].isdigit():\n num = num * 10 + int(s[pos[0]])\n pos[0] += 1\n return {(): num}\n if pos[0] < n and s[pos[0]].islower():\n j = pos[0]\n while pos[0] < n and s[pos[0]].islower():\n pos[0] += 1\n name = s[j:pos[0]]\n if name in sub:\n return {(): sub[name]}\n return {(name,): 1}\n return {}\n poly = parse_expr()\n terms = [(k, v) for k, v in poly.items() if v != 0]\n terms.sort(key=lambda e: (-len(e[0]), \"*\".join(e[0])))\n ans = []\n for k, v in terms:\n if len(k) == 0:\n ans.append(str(v))\n else:\n ans.append(str(v) + \"*\" + \"*\".join(k))\n return ans\n```\n", "starter": {"go": "package main\n\nfunc BasicCalculatorIV(expression string, evalvars []string, evalints []int) []string {\n return nil\n}", "python": "from typing import List\nclass Solution:\n def basicCalculatorIV(self, expression: str, evalvars: List[str], evalints: List[int]) -> List[str]:\n return []\n", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n vector<string> basicCalculatorIV(string expression, vector<string>& evalvars, vector<int>& evalints) {\n return {};\n }\n};"}, "fn": "basicCalculatorIV", "params": [{"name": "expression", "type": "string"}, {"name": "evalvars", "type": "string_array"}, {"name": "evalints", "type": "int_array"}], "outputType": "string_list", "tests": [["e + 8 - a + 5", "['e']", "[1]"], ["e - 8 + temperature - pressure", "['e', 'temperature']", "[1,12]"], ["(e + 8) * (e - 8)", "[]", "[]"], ["7 - 7", "[]", "[]"], ["a * b * c + b * a * c * 4", "[]", "[]"], ["x + 1", "['x']", "[5]"], ["x * x - x", "['x']", "[3]"], ["(a - b) * (b - c)", "[]", "[]"], ["2 * 3 + 4", "[]", "[]"], ["a + b + c", "['b']", "[2]"], ["a * (b + c)", "[]", "[]"], ["(a + b) * (a + b)", "[]", "[]"], ["e * e * e", "['e']", "[2]"], ["x - y", "[]", "[]"], ["5", "[]", "[]"], ["abc + abc", "[]", "[]"], ["a * b + c * d", "['a', 'c']", "[2,3]"], ["(x + 1) * (x + 1)", "[]", "[]"], ["a - a", "[]", "[]"], ["2 * (3 + 4)", "[]", "[]"], ["foo * bar - foo * bar", "[]", "[]"], ["(a + 2) * (b + 3)", "[]", "[]"], ["x * y * z", "['y']", "[0]"], ["10 - 3 * 2", "[]", "[]"], ["(a - b) * (a - b)", "[]", "[]"], ["m + n * 2 - m", "[]", "[]"], ["a * (b * (c + d))", "[]", "[]"], ["z + z + z", "['z']", "[1]"]], "expected": null, "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": false, "label": "339", "slug": "basic-calculator", "id": 339, "title": "Basic Calculator", "difficulty": "Hard", "category": "stack", "link": "https://leetcode.com/problems/basic-calculator/", "examples": [{"explanation": "One plus one is two.", "input": "s = \"1 + 1\"", "output": "2"}, {"explanation": "Spaces are ignored; 2 - 1 + 2 = 3.", "input": "s = \" 2-1 + 2 \"", "output": "3"}, {"explanation": "The inner groups give 12 and 14; 1 + 11 - 3 = 9, then 9 + 14 = 23.", "input": "s = \"(1+(4+5+2)-3)+(6+8)\"", "output": "23"}], "hints": ["Track a running total, the current number, and a sign (+1/-1); on '+' or '-' first fold the pending number into the total.", "On '(' push the current total and sign onto a stack and restart both; on ')' fold the pending number, then combine with the popped sign and total.", "A leading minus (or one right after '(') works naturally if the sign starts at +1 and flips on '-'."], "statement": "You are given a string `s` holding an arithmetic expression with non-negative integers, the operators `+` and `-`, parentheses `(` and `)`, and spaces. Evaluate the expression and return its integer value.\n\nDivision never appears. Numbers may have multiple digits, a minus may be unary (as in `-2` or `(-3+1)`), and the expression is always valid.\n\n**Constraints:**\n- `1 <= s.length <= 3 * 10^5`\n- `s` consists of digits, `'+'`, `'-'`, `'('`, `')'` and spaces.\n- Every number fits in a 32-bit signed integer and the result fits as well.\n", "solution": "## Approach\n\nScan once while keeping the running total, the number being built, and its sign. Each `+` or `-` first folds the pending number into the total, then sets the new sign. An opening bracket pushes the enclosing total and sign and restarts both; a closing bracket folds the pending number, multiplies by the popped sign, and adds the popped total. This handles nesting and unary minus without recursion.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), a single left-to-right scan.\n- **Space Complexity:** O(n) for the stack in the worst case of deep nesting.\n\n## Implementation\n\n```python\nclass Solution:\n def calculate(self, s: str) -> int:\n stack = []\n result = 0\n num = 0\n sign = 1\n for c in s:\n if c.isdigit():\n num = num * 10 + int(c)\n elif c == \"+\":\n result += sign * num\n num = 0\n sign = 1\n elif c == \"-\":\n result += sign * num\n num = 0\n sign = -1\n elif c == \"(\":\n stack.append(result)\n stack.append(sign)\n result = 0\n sign = 1\n elif c == \")\":\n result += sign * num\n num = 0\n result *= stack.pop()\n result += stack.pop()\n return result + sign * num\n```\n", "starter": {"go": "package main\n\nfunc Calculate(s string) int {\n return 0\n}", "python": "class Solution:\n def calculate(self, s: str) -> int:\n return 0\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n int calculate(string s) {\n return 0;\n }\n};"}, "fn": "calculate", "params": [{"name": "s", "type": "string"}], "outputType": "int", "tests": [["1 + 1"], [" 2-1 + 2 "], ["(1+(4+5+2)-3)+(6+8)"], ["1"], ["0"], ["2147483647"], ["1-( -2)"], ["-2+1"], ["-(3+2)"], ["((1))"], ["(7)-(0)+(4)"], ["1+2+3+4+5"], ["10-20+30-40"], ["(1+(2+(3+(4+5))))"], ["100-(100-100)"], ["2-(5-(3-(1)))"], [" 30 "], ["12-(5-3)+8-(10+2)"], ["(0-1)+(0-2)"], ["1-(2-(3-(4-(5-6))))"], ["123+456-789"], ["(100+200)-(50+25)-(10-5)"], ["0-(0-(0-1))"], ["99"], ["(2+3)-(4-1)+(5-(2+1))"], ["1000000+2000000-500000"], ["((10+20)-(5+5))+((3-1)+2)"], ["5-((3-2)+1)"]], "expected": [2, 3, 23, 1, 0, 2147483647, 3, -1, -5, 1, 11, 15, -20, 15, 100, -1, 30, 6, -3, -3, -210, 220, -1, 99, 4, 2500000, 24, 3], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b50", "slug": "basic-collatz-steps", "id": 50, "title": "Collatz Steps", "difficulty": "Easy", "category": "recursion", "link": null, "examples": [{"input": "n = 3", "output": "7", "explanation": "3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 takes 7 steps."}, {"input": "n = 1", "output": "0", "explanation": "Already at 1."}], "hints": ["The base case is `n == 1`.", "Otherwise add 1 to the recursive step count for the next value."], "statement": "Return how many steps the Collatz process takes to reach 1 starting from `n`: if `n` is 1 take 0 steps; if `n` is even halve it; if odd compute `3*n + 1`. Count each move as one step.\n\n**Constraints:**\n- ``1 <= n <= 100000``\n", "solution": "## Approach\n\nStop at one with zero steps. Otherwise take one Collatz move and add one to the recursive count for the resulting value.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(steps).\n- **Space Complexity:** O(steps).\n\n## Implementation\n\n```python\nclass Solution:\n def collatzSteps(self, n: int) -> int:\n if n == 1:\n return 0\n if n % 2 == 0:\n return 1 + self.collatzSteps(n // 2)\n return 1 + self.collatzSteps(3 * n + 1)\n```\n", "starter": {"go": "package main\n\nfunc CollatzSteps(n int) int {\n return 0\n}", "python": "class Solution:\n def collatzSteps(self, n: int) -> int:\n return 0\n", "cpp": "\nclass Solution {\npublic:\n int collatzSteps(int n) {\n return 0;\n }\n};"}, "fn": "collatzSteps", "params": [{"name": "n", "type": "int"}], "outputType": "int", "tests": [["3"], ["1"], ["6"], ["2"], ["4"], ["5"], ["27"], ["100"], ["7"], ["8"], ["9"], ["10"], ["11"], ["12"], ["15"], ["16"], ["19"], ["20"], ["32"], ["50"], ["1000"], ["99999"], ["100000"], ["837"], ["8379"], ["77031"]], "expected": [7, 0, 8, 1, 2, 5, 111, 25, 16, 3, 19, 6, 14, 9, 17, 4, 20, 7, 5, 24, 111, 226, 128, 41, 158, 350], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b22", "slug": "basic-contains-value", "id": 22, "title": "Contains Value", "difficulty": "Easy", "category": "arrays", "link": null, "examples": [{"input": "nums = [5,3,7], target = 7", "output": "true", "explanation": "7 is in the array."}, {"input": "nums = [5,3,7], target = 9", "output": "false", "explanation": "9 is not in the array."}], "hints": ["Same scan as Find Index, but return a boolean.", "Return `true` on the first match and `false` at the end."], "statement": "Return `true` if `target` appears anywhere in `nums`, otherwise return `false`.\n\n**Constraints:**\n- ``0 <= nums.length <= 1000``\n- ``-10^9 <= nums[i], target <= 10^9``\n", "solution": "## Approach\n\nScan each element and return true the moment the target is seen. When the loop ends without a match, return false.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def containsValue(self, nums: List[int], target: int) -> bool:\n for x in nums:\n if x == target:\n return True\n return False\n```\n", "starter": {"go": "package main\n\nfunc ContainsValue(nums []int, target int) bool {\n return false\n}", "python": "from typing import List\n\nclass Solution:\n def containsValue(self, nums: List[int], target: int) -> bool:\n return False\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n bool containsValue(vector<int>& nums, int target) {\n return false;\n }\n};"}, "fn": "containsValue", "params": [{"name": "nums", "type": "int_array"}, {"name": "target", "type": "int"}], "outputType": "boolean", "tests": [["[5,3,7]", "7"], ["[5,3,7]", "9"], ["[]", "1"], ["[1]", "1"], ["[1,1,1]", "2"], ["[-5,0,5]", "0"], ["[1, 2, 3]", "2"], ["[1, 2, 3]", "5"], ["[]", "0"], ["[9, 9, 9]", "9"], ["[-1, -2]", "-2"], ["[0, 0]", "1"], ["[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]", "49"], ["[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]", "50"], ["[5, 5, 6]", "6"], ["[4]", "4"], ["[4]", "5"], ["[-1000000000, 0, 1000000000]", "0"], ["[7, 3, 9, 1]", "3"], ["[2, 4, 6, 8]", "7"], ["[1]", "0"], ["[10, 20]", "20"], ["[3, 3, 3]", "4"], ["[8, 6, 7, 5, 3, 0, 9]", "0"], ["[100, 200]", "150"], ["[-7]", "-7"]], "expected": [true, false, false, true, false, true, true, false, false, true, true, false, true, false, true, true, false, true, true, false, false, true, false, true, false, true], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b26", "slug": "basic-count-above", "id": 26, "title": "Count Above Threshold", "difficulty": "Easy", "category": "arrays", "link": null, "examples": [{"input": "nums = [1,5,10], t = 4", "output": "2", "explanation": "5 and 10 exceed 4."}, {"input": "nums = [1,2,3], t = 5", "output": "0", "explanation": "Nothing exceeds 5."}], "hints": ["Loop with a counter like Count Evens.", "The condition is `x > t`."], "statement": "Return how many numbers in `nums` are strictly greater than the threshold `t`.\n\n**Constraints:**\n- ``0 <= nums.length <= 1000``\n- ``-10^9 <= nums[i], t <= 10^9``\n", "solution": "## Approach\n\nScan the array counting each element that is strictly larger than the threshold.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def countAbove(self, nums: List[int], t: int) -> int:\n count = 0\n for x in nums:\n if x > t:\n count += 1\n return count\n```\n", "starter": {"go": "package main\n\nfunc CountAbove(nums []int, t int) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def countAbove(self, nums: List[int], t: int) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int countAbove(vector<int>& nums, int t) {\n return 0;\n }\n};"}, "fn": "countAbove", "params": [{"name": "nums", "type": "int_array"}, {"name": "t", "type": "int"}], "outputType": "int", "tests": [["[1,5,10]", "4"], ["[1,2,3]", "5"], ["[]", "0"], ["[5,5,5]", "5"], ["[6,6,6]", "5"], ["[-1,-2,3]", "0"], ["[1, 2, 3, 4]", "2"], ["[5, 5, 5]", "4"], ["[5, 5, 5]", "6"], ["[]", "10"], ["[-5, -1, 0, 1]", "-2"], ["[10, 20, 30]", "30"], ["[10, 20, 30]", "29"], ["[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]", "10"], ["[3, 3, 3]", "3"], ["[100, 200, 300]", "150"], ["[1]", "0"], ["[0]", "0"], ["[-10, -20]", "-15"], ["[7, 8, 9]", "9"], ["[7, 8, 9]", "6"], ["[4, 4, 5, 5, 6]", "4"], ["[2, 2, 2, 3]", "2"], ["[1000000000]", "999999999"], ["[-1000000000]", "-1000000000"], ["[1, 100, 1000]", "50"]], "expected": [2, 0, 0, 0, 3, 1, 2, 3, 0, 0, 3, 0, 1, 9, 0, 2, 1, 0, 1, 0, 3, 3, 1, 1, 0, 2], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b31", "slug": "basic-count-char", "id": 31, "title": "Count Character", "difficulty": "Easy", "category": "strings", "link": null, "examples": [{"input": "s = \"hello\", ch = \"l\"", "output": "2", "explanation": "l appears twice in hello."}, {"input": "s = \"hello\", ch = \"z\"", "output": "0", "explanation": "z never appears."}], "hints": ["Loop over `s` and compare each character with `ch`.", "Count with an integer that starts at 0."], "statement": "Return how many times the single character `ch` appears in the string `s`. The match is case-sensitive.\n\n**Constraints:**\n- ``0 <= s.length <= 1000``\n- ``ch` is exactly one character`\n", "solution": "## Approach\n\nTake the target character from the one-letter string. Scan the text and count every position holding that character.\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 countChar(self, s: str, ch: str) -> int:\n count = 0\n for c in s:\n if c == ch:\n count += 1\n return count\n```\n", "starter": {"go": "package main\n\nfunc CountChar(s string, ch string) int {\n return 0\n}", "python": "class Solution:\n def countChar(self, s: str, ch: str) -> int:\n return 0\n", "cpp": "#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n int countChar(string s, string ch) {\n return 0;\n }\n};"}, "fn": "countChar", "params": [{"name": "s", "type": "string"}, {"name": "ch", "type": "string"}], "outputType": "int", "tests": [["hello", "l"], ["hello", "z"], ["", "a"], ["aaa", "a"], ["AaAa", "A"], ["AaAa", "a"], ["hello world", " "], ["abcabc", "b"], ["Hello World", "o"], ["Hello World", "H"], ["", "x"], [" ", " "], ["aAaA", "a"], ["112233", "2"], ["mississippi", "s"], ["mississippi", "i"], ["test", "t"], ["Test", "t"], ["zzzz", "z"], ["abcd", "e"], ["hello!", "!"], ["a b c", " "], ["11211", "1"], ["xyxyxy", "y"], ["q", "q"], ["q", "w"]], "expected": [2, 0, 0, 3, 2, 2, 1, 2, 2, 1, 0, 3, 2, 2, 4, 4, 2, 1, 4, 0, 1, 2, 4, 3, 1, 0], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b11", "slug": "basic-count-digits", "id": 11, "title": "Count Digits", "difficulty": "Easy", "category": "loops", "link": null, "examples": [{"input": "n = 123", "output": "3", "explanation": "123 has three digits."}, {"input": "n = 0", "output": "1", "explanation": "0 is written with one digit."}], "hints": ["Repeatedly divide by 10 and count the steps.", "Handle 0 as a special case before the loop."], "statement": "Return how many decimal digits `n` has. For example, `123` has 3 digits. The number `0` has 1 digit.\n\n**Constraints:**\n- ``0 <= n <= 10^9``\n", "solution": "## Approach\n\nTreat zero as a special case returning one. Otherwise divide by ten in a loop, counting each division until nothing remains.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log n).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def countDigits(self, n: int) -> int:\n if n == 0:\n return 1\n count = 0\n while n > 0:\n count += 1\n n //= 10\n return count\n```\n", "starter": {"go": "package main\n\nfunc CountDigits(n int) int {\n return 0\n}", "python": "class Solution:\n def countDigits(self, n: int) -> int:\n return 0\n", "cpp": "\nclass Solution {\npublic:\n int countDigits(int n) {\n return 0;\n }\n};"}, "fn": "countDigits", "params": [{"name": "n", "type": "int"}], "outputType": "int", "tests": [["123"], ["0"], ["1000"], ["5"], ["9"], ["10"], ["99"], ["100"], ["12345"], ["1000000000"], ["7"], ["42"], ["101"], ["999"], ["1001"], ["9999"], ["10000"], ["123456"], ["999999999"], ["500000000"], ["11"], ["22"], ["100000"], ["1000000"], ["10000000"], ["100000000"]], "expected": [3, 1, 4, 1, 1, 2, 2, 3, 5, 10, 1, 2, 3, 3, 4, 4, 5, 6, 9, 9, 2, 2, 6, 7, 8, 9], "loose": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"basic": true, "label": "b20", "slug": "basic-count-evens", "id": 20, "title": "Count Evens", "difficulty": "Easy", "category": "arrays", "link": null, "examples": [{"input": "nums = [1,2,3,4]", "output": "2", "explanation": "2 and 4 are even."}, {"input": "nums = [1,3,5]", "output": "0", "explanation": "None are even."}], "hints": ["Loop over the array with a counter.", "Increment the counter when `x % 2 == 0`."], "statement": "Return how many numbers in the array `nums` are even.\n\n**Constraints:**\n- ``0 <= nums.length <= 1000``\n- ``-10^9 <= nums[i] <= 10^9``\n", "solution": "## Approach\n\nScan the array with a counter starting at zero. Bump the counter for each element divisible by two.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def countEvens(self, nums: List[int]) -> int:\n count = 0\n for x in nums:\n if x % 2 == 0:\n count += 1\n return count\n```\n", "starter": {"go": "package main\n\nfunc CountEvens(nums []int) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def countEvens(self, nums: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int countEvens(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "countEvens", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[1,2,3,4]"], ["[1,3,5]"], ["[]"], ["[0,0,0]"], ["[-2,-3,-4]"], ["[2]"], ["[1]"], ["[9, 3, 7, 1]"], ["[100, -100, 50]"], ["[8, 8, 8, 8]"], ["[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"], ["[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]"], ["[-1, -2, -3, -4]"], ["[42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]"], ["[973408, -751417, 628175, -989704, 470404, -809581, 955818, -217664, -573452, -356604]"], ["[-10363, -259165, -711598, -519077, 83302, 7287, 525175, 487899, 584838, 64166, 484937, 224264, 190561, 941936, -484638, 263342, -325430, 123021, 308933]"], ["[-516170, -411338, 740431, -826157, -681745, 681422, -796804, -425124, 537209]"], ["[66912, -323840, -514467, -889353, -82786, 190792, -433561, -650873, 224802, 174174, -882994, 509845, -683455, 786578, -87113, 130256, -84818]"], ["[-116447, -831548, 78923, -404675, -903930, 210660, 594594, -941177, -186304, 554572, 611118, -417153, 529932, 96699]"], ["[490708, -995878, -897838]"], ["[80512, 643236, -564156, -629701, 759714]"], ["[-187665, 769774, -921621, 644851, -142527, -536125, 500013, 925342, 162513, -105564, 533631, -687410, -521322, -553690, 229308, -244764, -633914, 219913, 962589, -102347, 755093, -203529, 106978, 879575, 968267, -562015, -875435, -818065, 354835, 163220, 78084, -717532, 4723, 329014, -473866]"], ["[191731, 522795, -343018, 585745, 66114, -214305, 966076, -981374, -208360, 550276, -208574, -507062, 632254, 959698, 113172, 735724, 607107, 396679, -918605, 867025, -568138, 249309, 361489, 832623, -844248, 36728, -126920, 656054, 813622, -675063, 873433, -599366, 765185, -354259, -342995]"], ["[742060, 695023, -279759, 267748]"], ["[-163424, 116157, -142057, -96783, 232190, -460772, -180929, -326250, 127074, 687539, -50748, -340472, -203305, 424129, -196226, -290310, -628566, -629330, -838096, -653535, -100262, -342772, 663906, 288854, 521156, 688147, -18295, -429086, -81777, -177497, 922706, 90240, -51732, 608931, 931058, -866060, -845289, 532765, -578731]"], ["[837178, -824067, 748698, -791211, 141473, -300299, 870344, 750688, 107038, -216158, 983586, -160255, 23786, -775777, 213386, -73046, -642481, 226058, 224879, -153284, -38945, -104805, -898173, -808963, 158269, -740583, -703011]"], ["[-53452, -813329, 974518, 856100, 72200, -293456, -723075, 771564, 946042, -699972, -115733, -108532, -47563, -838565, 767512, 244430, 550260, -665710, 503656, -658868, -98228, 430465, -34986, 661839, -966752, -262466, -527638, -89931]"]], "expected": [2, 0, 0, 3, 2, 1, 0, 0, 3, 4, 5, 5, 2, 30, 7, 9, 5, 10, 8, 3, 4, 15, 19, 2, 23, 12, 20], "loose": false}
|