offcode 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1038) hide show
  1. package/README.md +38 -2
  2. package/data/index.json +1 -0
  3. package/data/problems/01-matrix.json +1 -0
  4. package/data/problems/1-bit-and-2-bit-characters.json +1 -0
  5. package/data/problems/132-pattern.json +1 -0
  6. package/data/problems/2-keys-keyboard.json +1 -0
  7. package/data/problems/24-game.json +1 -0
  8. package/data/problems/3sum-closest.json +1 -0
  9. package/data/problems/3sum-smaller.json +1 -0
  10. package/data/problems/3sum-with-multiplicity.json +1 -0
  11. package/data/problems/3sum.json +1 -0
  12. package/data/problems/4-keys-keyboard.json +1 -0
  13. package/data/problems/4sum-ii.json +1 -0
  14. package/data/problems/4sum.json +1 -0
  15. package/data/problems/accounts-merge.json +1 -0
  16. package/data/problems/add-binary.json +1 -0
  17. package/data/problems/add-bold-tag-in-string.json +1 -0
  18. package/data/problems/add-digits.json +1 -0
  19. package/data/problems/add-one-row-to-tree.json +1 -0
  20. package/data/problems/add-strings.json +1 -0
  21. package/data/problems/add-to-array-form-of-integer.json +1 -0
  22. package/data/problems/add-two-numbers-ii.json +1 -0
  23. package/data/problems/add-two-numbers.json +1 -0
  24. package/data/problems/additive-number.json +1 -0
  25. package/data/problems/advantage-shuffle.json +1 -0
  26. package/data/problems/alien-dictionary.json +1 -0
  27. package/data/problems/all-nodes-distance-k-in-binary-tree.json +1 -0
  28. package/data/problems/all-oone-data-structure.json +1 -0
  29. package/data/problems/all-paths-from-source-to-target.json +1 -0
  30. package/data/problems/all-possible-full-binary-trees.json +1 -0
  31. package/data/problems/ambiguous-coordinates.json +1 -0
  32. package/data/problems/android-unlock-patterns.json +1 -0
  33. package/data/problems/arithmetic-slices-ii-subsequence.json +1 -0
  34. package/data/problems/arithmetic-slices.json +1 -0
  35. package/data/problems/arranging-coins.json +1 -0
  36. package/data/problems/array-nesting.json +1 -0
  37. package/data/problems/array-of-doubled-pairs.json +1 -0
  38. package/data/problems/array-partition.json +1 -0
  39. package/data/problems/assign-cookies.json +1 -0
  40. package/data/problems/asteroid-collision.json +1 -0
  41. package/data/problems/available-captures-for-rook.json +1 -0
  42. package/data/problems/average-of-levels-in-binary-tree.json +1 -0
  43. package/data/problems/backspace-string-compare.json +1 -0
  44. package/data/problems/bag-of-tokens.json +1 -0
  45. package/data/problems/balanced-binary-tree.json +1 -0
  46. package/data/problems/base-7.json +1 -0
  47. package/data/problems/baseball-game.json +1 -0
  48. package/data/problems/basic-absolute-value.json +1 -0
  49. package/data/problems/basic-array-max.json +1 -0
  50. package/data/problems/basic-array-min.json +1 -0
  51. package/data/problems/basic-array-sum-rec.json +1 -0
  52. package/data/problems/basic-array-sum.json +1 -0
  53. package/data/problems/basic-average-floor.json +1 -0
  54. package/data/problems/basic-bubble-sort.json +1 -0
  55. package/data/problems/basic-calculator-ii.json +1 -0
  56. package/data/problems/basic-calculator-iii.json +1 -0
  57. package/data/problems/basic-calculator-iv.json +1 -0
  58. package/data/problems/basic-calculator.json +1 -0
  59. package/data/problems/basic-collatz-steps.json +1 -0
  60. package/data/problems/basic-contains-value.json +1 -0
  61. package/data/problems/basic-count-above.json +1 -0
  62. package/data/problems/basic-count-char.json +1 -0
  63. package/data/problems/basic-count-digits.json +1 -0
  64. package/data/problems/basic-count-evens.json +1 -0
  65. package/data/problems/basic-count-pairs.json +1 -0
  66. package/data/problems/basic-count-vowels.json +1 -0
  67. package/data/problems/basic-count-words.json +1 -0
  68. package/data/problems/basic-countdown.json +1 -0
  69. package/data/problems/basic-double-array.json +1 -0
  70. package/data/problems/basic-factorial-rec.json +1 -0
  71. package/data/problems/basic-factorial.json +1 -0
  72. package/data/problems/basic-fibonacci.json +1 -0
  73. package/data/problems/basic-find-index.json +1 -0
  74. package/data/problems/basic-gcd.json +1 -0
  75. package/data/problems/basic-grade-letter.json +1 -0
  76. package/data/problems/basic-has-duplicate.json +1 -0
  77. package/data/problems/basic-is-even.json +1 -0
  78. package/data/problems/basic-is-leap-year.json +1 -0
  79. package/data/problems/basic-is-sorted.json +1 -0
  80. package/data/problems/basic-max-frequency.json +1 -0
  81. package/data/problems/basic-max-of-three.json +1 -0
  82. package/data/problems/basic-max-of-two.json +1 -0
  83. package/data/problems/basic-palindrome-text.json +1 -0
  84. package/data/problems/basic-power-rec.json +1 -0
  85. package/data/problems/basic-power.json +1 -0
  86. package/data/problems/basic-repeat-string.json +1 -0
  87. package/data/problems/basic-reverse-array.json +1 -0
  88. package/data/problems/basic-reverse-number.json +1 -0
  89. package/data/problems/basic-reverse-text-rec.json +1 -0
  90. package/data/problems/basic-reverse-text.json +1 -0
  91. package/data/problems/basic-second-largest.json +1 -0
  92. package/data/problems/basic-sort-two.json +1 -0
  93. package/data/problems/basic-staircase.json +1 -0
  94. package/data/problems/basic-string-length.json +1 -0
  95. package/data/problems/basic-sum-1-to-n.json +1 -0
  96. package/data/problems/basic-sum-digits-rec.json +1 -0
  97. package/data/problems/basic-sum-multiples.json +1 -0
  98. package/data/problems/basic-sum-of-digits.json +1 -0
  99. package/data/problems/basic-temperature-advice.json +1 -0
  100. package/data/problems/basic-to-upper.json +1 -0
  101. package/data/problems/basic-triangle-sum.json +1 -0
  102. package/data/problems/battleships-in-a-board.json +1 -0
  103. package/data/problems/beautiful-arrangement-ii.json +1 -0
  104. package/data/problems/beautiful-arrangement.json +1 -0
  105. package/data/problems/beautiful-array.json +1 -0
  106. package/data/problems/best-meeting-point.json +1 -0
  107. package/data/problems/best-time-to-buy-and-sell-stock-ii.json +1 -0
  108. package/data/problems/best-time-to-buy-and-sell-stock-iii.json +1 -0
  109. package/data/problems/best-time-to-buy-and-sell-stock-iv.json +1 -0
  110. package/data/problems/best-time-to-buy-and-sell-stock-with-cooldown.json +1 -0
  111. package/data/problems/best-time-to-buy-and-sell-stock-with-transaction-fee.json +1 -0
  112. package/data/problems/best-time-to-buy-and-sell-stock.json +1 -0
  113. package/data/problems/binary-gap.json +1 -0
  114. package/data/problems/binary-number-with-alternating-bits.json +1 -0
  115. package/data/problems/binary-search-tree-iterator.json +1 -0
  116. package/data/problems/binary-search.json +1 -0
  117. package/data/problems/binary-subarrays-with-sum.json +1 -0
  118. package/data/problems/binary-tree-cameras.json +1 -0
  119. package/data/problems/binary-tree-inorder-traversal.json +1 -0
  120. package/data/problems/binary-tree-level-order-traversal-ii.json +1 -0
  121. package/data/problems/binary-tree-level-order-traversal.json +1 -0
  122. package/data/problems/binary-tree-longest-consecutive-sequence-ii.json +1 -0
  123. package/data/problems/binary-tree-longest-consecutive-sequence.json +1 -0
  124. package/data/problems/binary-tree-maximum-path-sum.json +1 -0
  125. package/data/problems/binary-tree-paths.json +1 -0
  126. package/data/problems/binary-tree-postorder-traversal.json +1 -0
  127. package/data/problems/binary-tree-preorder-traversal.json +1 -0
  128. package/data/problems/binary-tree-pruning.json +1 -0
  129. package/data/problems/binary-tree-right-side-view.json +1 -0
  130. package/data/problems/binary-tree-tilt.json +1 -0
  131. package/data/problems/binary-tree-upside-down.json +1 -0
  132. package/data/problems/binary-tree-vertical-order-traversal.json +1 -0
  133. package/data/problems/binary-tree-zigzag-level-order-traversal.json +1 -0
  134. package/data/problems/binary-trees-with-factors.json +1 -0
  135. package/data/problems/binary-watch.json +1 -0
  136. package/data/problems/bitwise-and-of-numbers-range.json +1 -0
  137. package/data/problems/bitwise-ors-of-subarrays.json +1 -0
  138. package/data/problems/boats-to-save-people.json +1 -0
  139. package/data/problems/bold-words-in-string.json +1 -0
  140. package/data/problems/bomb-enemy.json +1 -0
  141. package/data/problems/boundary-of-binary-tree.json +1 -0
  142. package/data/problems/brick-wall.json +1 -0
  143. package/data/problems/bricks-falling-when-hit.json +1 -0
  144. package/data/problems/broken-calculator.json +1 -0
  145. package/data/problems/buddy-strings.json +1 -0
  146. package/data/problems/build-a-matrix-with-conditions.json +1 -0
  147. package/data/problems/bulb-switcher-ii.json +1 -0
  148. package/data/problems/bulb-switcher.json +1 -0
  149. package/data/problems/bulls-and-cows.json +1 -0
  150. package/data/problems/burst-balloons.json +1 -0
  151. package/data/problems/bus-routes.json +1 -0
  152. package/data/problems/can-i-win.json +1 -0
  153. package/data/problems/can-place-flowers.json +1 -0
  154. package/data/problems/candy-crush.json +1 -0
  155. package/data/problems/candy.json +1 -0
  156. package/data/problems/capacity-to-ship-packages-within-d-days.json +1 -0
  157. package/data/problems/car-fleet.json +1 -0
  158. package/data/problems/car-pooling.json +1 -0
  159. package/data/problems/card-flipping-game.json +1 -0
  160. package/data/problems/cat-and-mouse.json +1 -0
  161. package/data/problems/chalkboard-xor-game.json +1 -0
  162. package/data/problems/champagne-tower.json +1 -0
  163. package/data/problems/cheapest-flights-within-k-stops.json +1 -0
  164. package/data/problems/check-completeness-of-a-binary-tree.json +1 -0
  165. package/data/problems/cherry-pickup.json +1 -0
  166. package/data/problems/circular-array-loop.json +1 -0
  167. package/data/problems/climbing-stairs.json +1 -0
  168. package/data/problems/clone-graph.json +1 -0
  169. package/data/problems/closest-binary-search-tree-value-ii.json +1 -0
  170. package/data/problems/closest-binary-search-tree-value.json +1 -0
  171. package/data/problems/closest-leaf-in-a-binary-tree.json +1 -0
  172. package/data/problems/coin-change-ii.json +1 -0
  173. package/data/problems/coin-change.json +1 -0
  174. package/data/problems/coin-path.json +1 -0
  175. package/data/problems/combination-sum-ii.json +1 -0
  176. package/data/problems/combination-sum-iii.json +1 -0
  177. package/data/problems/combination-sum-iv.json +1 -0
  178. package/data/problems/combination-sum.json +1 -0
  179. package/data/problems/combinations.json +1 -0
  180. package/data/problems/compare-version-numbers.json +1 -0
  181. package/data/problems/complete-binary-tree-inserter.json +1 -0
  182. package/data/problems/complex-number-multiplication.json +1 -0
  183. package/data/problems/concatenated-words.json +1 -0
  184. package/data/problems/concatenation-of-array.json +1 -0
  185. package/data/problems/consecutive-numbers-sum.json +1 -0
  186. package/data/problems/construct-binary-tree-from-inorder-and-postorder-traversal.json +1 -0
  187. package/data/problems/construct-binary-tree-from-preorder-and-inorder-traversal.json +1 -0
  188. package/data/problems/construct-binary-tree-from-preorder-and-postorder-traversal.json +1 -0
  189. package/data/problems/construct-binary-tree-from-string.json +1 -0
  190. package/data/problems/construct-quad-tree.json +1 -0
  191. package/data/problems/construct-string-from-binary-tree.json +1 -0
  192. package/data/problems/construct-the-rectangle.json +1 -0
  193. package/data/problems/contain-virus.json +1 -0
  194. package/data/problems/container-with-most-water.json +1 -0
  195. package/data/problems/contains-duplicate-ii.json +1 -0
  196. package/data/problems/contains-duplicate-iii.json +1 -0
  197. package/data/problems/contains-duplicate.json +1 -0
  198. package/data/problems/contiguous-array.json +1 -0
  199. package/data/problems/continuous-subarray-sum.json +1 -0
  200. package/data/problems/convert-a-number-to-hexadecimal.json +1 -0
  201. package/data/problems/convert-binary-search-tree-to-sorted-doubly-linked-list.json +1 -0
  202. package/data/problems/convert-bst-to-greater-tree.json +1 -0
  203. package/data/problems/convert-sorted-array-to-binary-search-tree.json +1 -0
  204. package/data/problems/convert-sorted-list-to-binary-search-tree.json +1 -0
  205. package/data/problems/convex-polygon.json +1 -0
  206. package/data/problems/copy-list-with-random-pointer.json +1 -0
  207. package/data/problems/count-and-say.json +1 -0
  208. package/data/problems/count-binary-substrings.json +1 -0
  209. package/data/problems/count-complete-tree-nodes.json +1 -0
  210. package/data/problems/count-different-palindromic-subsequences.json +1 -0
  211. package/data/problems/count-good-nodes-in-binary-tree.json +1 -0
  212. package/data/problems/count-numbers-with-unique-digits.json +1 -0
  213. package/data/problems/count-of-range-sum.json +1 -0
  214. package/data/problems/count-of-smaller-numbers-after-self.json +1 -0
  215. package/data/problems/count-primes.json +1 -0
  216. package/data/problems/count-the-repetitions.json +1 -0
  217. package/data/problems/count-unique-characters-of-all-substrings-of-a-given-string.json +1 -0
  218. package/data/problems/count-univalue-subtrees.json +1 -0
  219. package/data/problems/counting-bits.json +1 -0
  220. package/data/problems/couples-holding-hands.json +1 -0
  221. package/data/problems/course-schedule-ii.json +1 -0
  222. package/data/problems/course-schedule-iii.json +1 -0
  223. package/data/problems/course-schedule-iv.json +1 -0
  224. package/data/problems/course-schedule.json +1 -0
  225. package/data/problems/cousins-in-binary-tree.json +1 -0
  226. package/data/problems/cracking-the-safe.json +1 -0
  227. package/data/problems/create-maximum-number.json +1 -0
  228. package/data/problems/custom-sort-string.json +1 -0
  229. package/data/problems/cut-off-trees-for-golf-event.json +1 -0
  230. package/data/problems/daily-temperatures.json +1 -0
  231. package/data/problems/data-stream-as-disjoint-intervals.json +1 -0
  232. package/data/problems/decode-string.json +1 -0
  233. package/data/problems/decode-ways-ii.json +1 -0
  234. package/data/problems/decode-ways.json +1 -0
  235. package/data/problems/decoded-string-at-index.json +1 -0
  236. package/data/problems/degree-of-an-array.json +1 -0
  237. package/data/problems/delete-and-earn.json +1 -0
  238. package/data/problems/delete-columns-to-make-sorted-ii.json +1 -0
  239. package/data/problems/delete-columns-to-make-sorted-iii.json +1 -0
  240. package/data/problems/delete-columns-to-make-sorted.json +1 -0
  241. package/data/problems/delete-leaves-with-a-given-value.json +1 -0
  242. package/data/problems/delete-node-in-a-bst.json +1 -0
  243. package/data/problems/delete-node-in-a-linked-list.json +1 -0
  244. package/data/problems/delete-operation-for-two-strings.json +1 -0
  245. package/data/problems/design-add-and-search-words-data-structure.json +1 -0
  246. package/data/problems/design-circular-deque.json +1 -0
  247. package/data/problems/design-circular-queue.json +1 -0
  248. package/data/problems/design-compressed-string-iterator.json +1 -0
  249. package/data/problems/design-excel-sum-formula.json +1 -0
  250. package/data/problems/design-hashmap.json +1 -0
  251. package/data/problems/design-hashset.json +1 -0
  252. package/data/problems/design-hit-counter.json +1 -0
  253. package/data/problems/design-in-memory-file-system.json +1 -0
  254. package/data/problems/design-linked-list.json +1 -0
  255. package/data/problems/design-log-storage-system.json +1 -0
  256. package/data/problems/design-phone-directory.json +1 -0
  257. package/data/problems/design-search-autocomplete-system.json +1 -0
  258. package/data/problems/design-snake-game.json +1 -0
  259. package/data/problems/design-tic-tac-toe.json +1 -0
  260. package/data/problems/design-twitter.json +1 -0
  261. package/data/problems/detect-capital.json +1 -0
  262. package/data/problems/detect-squares.json +1 -0
  263. package/data/problems/di-string-match.json +1 -0
  264. package/data/problems/diagonal-traverse.json +1 -0
  265. package/data/problems/diameter-of-binary-tree.json +1 -0
  266. package/data/problems/different-ways-to-add-parentheses.json +1 -0
  267. package/data/problems/distinct-subsequences-ii.json +1 -0
  268. package/data/problems/distinct-subsequences.json +1 -0
  269. package/data/problems/distribute-candies.json +1 -0
  270. package/data/problems/distribute-coins-in-binary-tree.json +1 -0
  271. package/data/problems/divide-two-integers.json +1 -0
  272. package/data/problems/domino-and-tromino-tiling.json +1 -0
  273. package/data/problems/dota2-senate.json +1 -0
  274. package/data/problems/dungeon-game.json +1 -0
  275. package/data/problems/edit-distance.json +1 -0
  276. package/data/problems/elimination-game.json +1 -0
  277. package/data/problems/employee-free-time.json +1 -0
  278. package/data/problems/employee-importance.json +1 -0
  279. package/data/problems/encode-and-decode-strings.json +1 -0
  280. package/data/problems/encode-and-decode-tinyurl.json +1 -0
  281. package/data/problems/encode-n-ary-tree-to-binary-tree.json +1 -0
  282. package/data/problems/encode-string-with-shortest-length.json +1 -0
  283. package/data/problems/equal-rational-numbers.json +1 -0
  284. package/data/problems/equal-tree-partition.json +1 -0
  285. package/data/problems/erect-the-fence.json +1 -0
  286. package/data/problems/escape-the-ghosts.json +1 -0
  287. package/data/problems/evaluate-division.json +1 -0
  288. package/data/problems/evaluate-reverse-polish-notation.json +1 -0
  289. package/data/problems/exam-room.json +1 -0
  290. package/data/problems/excel-sheet-column-number.json +1 -0
  291. package/data/problems/excel-sheet-column-title.json +1 -0
  292. package/data/problems/exclusive-time-of-functions.json +1 -0
  293. package/data/problems/expression-add-operators.json +1 -0
  294. package/data/problems/expressive-words.json +1 -0
  295. package/data/problems/extra-characters-in-a-string.json +1 -0
  296. package/data/problems/factor-combinations.json +1 -0
  297. package/data/problems/factorial-trailing-zeroes.json +1 -0
  298. package/data/problems/fair-candy-swap.json +1 -0
  299. package/data/problems/falling-squares.json +1 -0
  300. package/data/problems/fibonacci-number.json +1 -0
  301. package/data/problems/find-all-anagrams-in-a-string.json +1 -0
  302. package/data/problems/find-all-duplicates-in-an-array.json +1 -0
  303. package/data/problems/find-all-numbers-disappeared-in-an-array.json +1 -0
  304. package/data/problems/find-anagram-mappings.json +1 -0
  305. package/data/problems/find-and-replace-in-string.json +1 -0
  306. package/data/problems/find-and-replace-pattern.json +1 -0
  307. package/data/problems/find-bottom-left-tree-value.json +1 -0
  308. package/data/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree.json +1 -0
  309. package/data/problems/find-duplicate-file-in-system.json +1 -0
  310. package/data/problems/find-duplicate-subtrees.json +1 -0
  311. package/data/problems/find-eventual-safe-states.json +1 -0
  312. package/data/problems/find-first-and-last-position-of-element-in-sorted-array.json +1 -0
  313. package/data/problems/find-in-mountain-array.json +1 -0
  314. package/data/problems/find-k-closest-elements.json +1 -0
  315. package/data/problems/find-k-pairs-with-smallest-sums.json +1 -0
  316. package/data/problems/find-k-th-smallest-pair-distance.json +1 -0
  317. package/data/problems/find-largest-value-in-each-tree-row.json +1 -0
  318. package/data/problems/find-leaves-of-binary-tree.json +1 -0
  319. package/data/problems/find-median-from-data-stream.json +1 -0
  320. package/data/problems/find-minimum-in-rotated-sorted-array-ii.json +1 -0
  321. package/data/problems/find-minimum-in-rotated-sorted-array.json +1 -0
  322. package/data/problems/find-mode-in-binary-search-tree.json +1 -0
  323. package/data/problems/find-peak-element.json +1 -0
  324. package/data/problems/find-permutation.json +1 -0
  325. package/data/problems/find-pivot-index.json +1 -0
  326. package/data/problems/find-right-interval.json +1 -0
  327. package/data/problems/find-smallest-letter-greater-than-target.json +1 -0
  328. package/data/problems/find-the-celebrity.json +1 -0
  329. package/data/problems/find-the-closest-palindrome.json +1 -0
  330. package/data/problems/find-the-derangement-of-an-array.json +1 -0
  331. package/data/problems/find-the-difference.json +1 -0
  332. package/data/problems/find-the-duplicate-number.json +1 -0
  333. package/data/problems/find-the-index-of-the-first-occurrence-in-a-string.json +1 -0
  334. package/data/problems/find-the-shortest-superstring.json +1 -0
  335. package/data/problems/find-the-town-judge.json +1 -0
  336. package/data/problems/first-bad-version.json +1 -0
  337. package/data/problems/first-missing-positive.json +1 -0
  338. package/data/problems/first-unique-character-in-a-string.json +1 -0
  339. package/data/problems/fizz-buzz.json +1 -0
  340. package/data/problems/flatten-2d-vector.json +1 -0
  341. package/data/problems/flatten-a-multilevel-doubly-linked-list.json +1 -0
  342. package/data/problems/flatten-binary-tree-to-linked-list.json +1 -0
  343. package/data/problems/flatten-nested-list-iterator.json +1 -0
  344. package/data/problems/flip-binary-tree-to-match-preorder-traversal.json +1 -0
  345. package/data/problems/flip-equivalent-binary-trees.json +1 -0
  346. package/data/problems/flip-game-ii.json +1 -0
  347. package/data/problems/flip-game.json +1 -0
  348. package/data/problems/flip-string-to-monotone-increasing.json +1 -0
  349. package/data/problems/flipping-an-image.json +1 -0
  350. package/data/problems/flood-fill.json +1 -0
  351. package/data/problems/fraction-addition-and-subtraction.json +1 -0
  352. package/data/problems/fraction-to-recurring-decimal.json +1 -0
  353. package/data/problems/freedom-trail.json +1 -0
  354. package/data/problems/friends-of-appropriate-ages.json +1 -0
  355. package/data/problems/frog-jump.json +1 -0
  356. package/data/problems/fruit-into-baskets.json +1 -0
  357. package/data/problems/game-of-life.json +1 -0
  358. package/data/problems/gas-station.json +1 -0
  359. package/data/problems/generalized-abbreviation.json +1 -0
  360. package/data/problems/generate-parentheses.json +1 -0
  361. package/data/problems/generate-random-point-in-a-circle.json +1 -0
  362. package/data/problems/global-and-local-inversions.json +1 -0
  363. package/data/problems/goat-latin.json +1 -0
  364. package/data/problems/graph-valid-tree.json +1 -0
  365. package/data/problems/gray-code.json +1 -0
  366. package/data/problems/greatest-common-divisor-of-strings.json +1 -0
  367. package/data/problems/greatest-common-divisor-traversal.json +1 -0
  368. package/data/problems/group-anagrams.json +1 -0
  369. package/data/problems/group-shifted-strings.json +1 -0
  370. package/data/problems/groups-of-special-equivalent-strings.json +1 -0
  371. package/data/problems/guess-number-higher-or-lower-ii.json +1 -0
  372. package/data/problems/guess-number-higher-or-lower.json +1 -0
  373. package/data/problems/guess-the-word.json +1 -0
  374. package/data/problems/h-index-ii.json +1 -0
  375. package/data/problems/h-index.json +1 -0
  376. package/data/problems/hamming-distance.json +1 -0
  377. package/data/problems/hand-of-straights.json +1 -0
  378. package/data/problems/happy-number.json +1 -0
  379. package/data/problems/heaters.json +1 -0
  380. package/data/problems/house-robber-ii.json +1 -0
  381. package/data/problems/house-robber-iii.json +1 -0
  382. package/data/problems/house-robber.json +1 -0
  383. package/data/problems/image-overlap.json +1 -0
  384. package/data/problems/image-smoother.json +1 -0
  385. package/data/problems/implement-magic-dictionary.json +1 -0
  386. package/data/problems/implement-queue-using-stacks.json +1 -0
  387. package/data/problems/implement-rand10-using-rand7.json +1 -0
  388. package/data/problems/implement-stack-using-queues.json +1 -0
  389. package/data/problems/implement-trie-prefix-tree.json +1 -0
  390. package/data/problems/increasing-order-search-tree.json +1 -0
  391. package/data/problems/increasing-triplet-subsequence.json +1 -0
  392. package/data/problems/inorder-successor-in-bst-ii.json +1 -0
  393. package/data/problems/inorder-successor-in-bst.json +1 -0
  394. package/data/problems/insert-delete-getrandom-o1-duplicates-allowed.json +1 -0
  395. package/data/problems/insert-delete-getrandom-o1.json +1 -0
  396. package/data/problems/insert-greatest-common-divisors-in-linked-list.json +1 -0
  397. package/data/problems/insert-interval.json +1 -0
  398. package/data/problems/insert-into-a-binary-search-tree.json +1 -0
  399. package/data/problems/insert-into-a-sorted-circular-linked-list.json +1 -0
  400. package/data/problems/insertion-sort-list.json +1 -0
  401. package/data/problems/integer-break.json +1 -0
  402. package/data/problems/integer-replacement.json +1 -0
  403. package/data/problems/integer-to-english-words.json +1 -0
  404. package/data/problems/integer-to-roman.json +1 -0
  405. package/data/problems/interleaving-string.json +1 -0
  406. package/data/problems/intersection-of-two-arrays-ii.json +1 -0
  407. package/data/problems/intersection-of-two-arrays.json +1 -0
  408. package/data/problems/intersection-of-two-linked-lists.json +1 -0
  409. package/data/problems/interval-list-intersections.json +1 -0
  410. package/data/problems/invert-binary-tree.json +1 -0
  411. package/data/problems/ip-to-cidr.json +1 -0
  412. package/data/problems/ipo.json +1 -0
  413. package/data/problems/is-graph-bipartite.json +1 -0
  414. package/data/problems/is-subsequence.json +1 -0
  415. package/data/problems/island-perimeter.json +1 -0
  416. package/data/problems/isomorphic-strings.json +1 -0
  417. package/data/problems/jewels-and-stones.json +1 -0
  418. package/data/problems/jump-game-ii.json +1 -0
  419. package/data/problems/jump-game-vii.json +1 -0
  420. package/data/problems/jump-game.json +1 -0
  421. package/data/problems/k-closest-points-to-origin.json +1 -0
  422. package/data/problems/k-diff-pairs-in-an-array.json +1 -0
  423. package/data/problems/k-empty-slots.json +1 -0
  424. package/data/problems/k-inverse-pairs-array.json +1 -0
  425. package/data/problems/k-similar-strings.json +1 -0
  426. package/data/problems/k-th-smallest-in-lexicographical-order.json +1 -0
  427. package/data/problems/k-th-smallest-prime-fraction.json +1 -0
  428. package/data/problems/k-th-symbol-in-grammar.json +1 -0
  429. package/data/problems/keyboard-row.json +1 -0
  430. package/data/problems/keys-and-rooms.json +1 -0
  431. package/data/problems/kill-process.json +1 -0
  432. package/data/problems/knight-dialer.json +1 -0
  433. package/data/problems/knight-probability-in-chessboard.json +1 -0
  434. package/data/problems/koko-eating-bananas.json +1 -0
  435. package/data/problems/kth-largest-element-in-a-stream.json +1 -0
  436. package/data/problems/kth-largest-element-in-an-array.json +1 -0
  437. package/data/problems/kth-smallest-element-in-a-bst.json +1 -0
  438. package/data/problems/kth-smallest-element-in-a-sorted-matrix.json +1 -0
  439. package/data/problems/kth-smallest-number-in-multiplication-table.json +1 -0
  440. package/data/problems/largest-bst-subtree.json +1 -0
  441. package/data/problems/largest-component-size-by-common-factor.json +1 -0
  442. package/data/problems/largest-divisible-subset.json +1 -0
  443. package/data/problems/largest-number-at-least-twice-of-others.json +1 -0
  444. package/data/problems/largest-number.json +1 -0
  445. package/data/problems/largest-palindrome-product.json +1 -0
  446. package/data/problems/largest-perimeter-triangle.json +1 -0
  447. package/data/problems/largest-plus-sign.json +1 -0
  448. package/data/problems/largest-rectangle-in-histogram.json +1 -0
  449. package/data/problems/largest-sum-of-averages.json +1 -0
  450. package/data/problems/largest-time-for-given-digits.json +1 -0
  451. package/data/problems/largest-triangle-area.json +1 -0
  452. package/data/problems/last-stone-weight-ii.json +1 -0
  453. package/data/problems/last-stone-weight.json +1 -0
  454. package/data/problems/leaf-similar-trees.json +1 -0
  455. package/data/problems/least-operators-to-express-number.json +1 -0
  456. package/data/problems/lemonade-change.json +1 -0
  457. package/data/problems/length-of-last-word.json +1 -0
  458. package/data/problems/length-of-longest-fibonacci-subsequence.json +1 -0
  459. package/data/problems/letter-case-permutation.json +1 -0
  460. package/data/problems/letter-combinations-of-a-phone-number.json +1 -0
  461. package/data/problems/lexicographical-numbers.json +1 -0
  462. package/data/problems/lfu-cache.json +1 -0
  463. package/data/problems/license-key-formatting.json +1 -0
  464. package/data/problems/line-reflection.json +1 -0
  465. package/data/problems/linked-list-components.json +1 -0
  466. package/data/problems/linked-list-cycle-ii.json +1 -0
  467. package/data/problems/linked-list-cycle.json +1 -0
  468. package/data/problems/linked-list-random-node.json +1 -0
  469. package/data/problems/logger-rate-limiter.json +1 -0
  470. package/data/problems/logical-or-of-two-binary-grids-represented-as-quad-trees.json +1 -0
  471. package/data/problems/lonely-pixel-i.json +1 -0
  472. package/data/problems/lonely-pixel-ii.json +1 -0
  473. package/data/problems/long-pressed-name.json +1 -0
  474. package/data/problems/longest-absolute-file-path.json +1 -0
  475. package/data/problems/longest-common-prefix.json +1 -0
  476. package/data/problems/longest-common-subsequence.json +1 -0
  477. package/data/problems/longest-consecutive-sequence.json +1 -0
  478. package/data/problems/longest-continuous-increasing-subsequence.json +1 -0
  479. package/data/problems/longest-happy-string.json +1 -0
  480. package/data/problems/longest-harmonious-subsequence.json +1 -0
  481. package/data/problems/longest-increasing-path-in-a-matrix.json +1 -0
  482. package/data/problems/longest-increasing-subsequence.json +1 -0
  483. package/data/problems/longest-line-of-consecutive-one-in-matrix.json +1 -0
  484. package/data/problems/longest-mountain-in-array.json +1 -0
  485. package/data/problems/longest-palindrome.json +1 -0
  486. package/data/problems/longest-palindromic-subsequence.json +1 -0
  487. package/data/problems/longest-palindromic-substring.json +1 -0
  488. package/data/problems/longest-repeating-character-replacement.json +1 -0
  489. package/data/problems/longest-substring-with-at-least-k-repeating-characters.json +1 -0
  490. package/data/problems/longest-substring-with-at-most-k-distinct-characters.json +1 -0
  491. package/data/problems/longest-substring-with-at-most-two-distinct-characters.json +1 -0
  492. package/data/problems/longest-substring-without-repeating-characters.json +1 -0
  493. package/data/problems/longest-turbulent-subarray.json +1 -0
  494. package/data/problems/longest-uncommon-subsequence-i.json +1 -0
  495. package/data/problems/longest-uncommon-subsequence-ii.json +1 -0
  496. package/data/problems/longest-univalue-path.json +1 -0
  497. package/data/problems/longest-valid-parentheses.json +1 -0
  498. package/data/problems/longest-word-in-dictionary-through-deleting.json +1 -0
  499. package/data/problems/longest-word-in-dictionary.json +1 -0
  500. package/data/problems/loud-and-rich.json +1 -0
  501. package/data/problems/lowest-common-ancestor-of-a-binary-search-tree.json +1 -0
  502. package/data/problems/lowest-common-ancestor-of-a-binary-tree.json +1 -0
  503. package/data/problems/lru-cache.json +1 -0
  504. package/data/problems/magic-squares-in-grid.json +1 -0
  505. package/data/problems/magical-string.json +1 -0
  506. package/data/problems/majority-element-ii.json +1 -0
  507. package/data/problems/majority-element.json +1 -0
  508. package/data/problems/making-a-large-island.json +1 -0
  509. package/data/problems/map-sum-pairs.json +1 -0
  510. package/data/problems/masking-personal-information.json +1 -0
  511. package/data/problems/matchsticks-to-square.json +1 -0
  512. package/data/problems/max-area-of-island.json +1 -0
  513. package/data/problems/max-chunks-to-make-sorted-ii.json +1 -0
  514. package/data/problems/max-chunks-to-make-sorted.json +1 -0
  515. package/data/problems/max-consecutive-ones-ii.json +1 -0
  516. package/data/problems/max-consecutive-ones.json +1 -0
  517. package/data/problems/max-increase-to-keep-city-skyline.json +1 -0
  518. package/data/problems/max-points-on-a-line.json +1 -0
  519. package/data/problems/max-stack.json +1 -0
  520. package/data/problems/max-sum-of-rectangle-no-larger-than-k.json +1 -0
  521. package/data/problems/maximal-rectangle.json +1 -0
  522. package/data/problems/maximal-square.json +1 -0
  523. package/data/problems/maximize-distance-to-closest-person.json +1 -0
  524. package/data/problems/maximum-average-subarray-i.json +1 -0
  525. package/data/problems/maximum-average-subarray-ii.json +1 -0
  526. package/data/problems/maximum-binary-tree-ii.json +1 -0
  527. package/data/problems/maximum-binary-tree.json +1 -0
  528. package/data/problems/maximum-depth-of-binary-tree.json +1 -0
  529. package/data/problems/maximum-depth-of-n-ary-tree.json +1 -0
  530. package/data/problems/maximum-distance-in-arrays.json +1 -0
  531. package/data/problems/maximum-frequency-stack.json +1 -0
  532. package/data/problems/maximum-gap.json +1 -0
  533. package/data/problems/maximum-length-of-pair-chain.json +1 -0
  534. package/data/problems/maximum-length-of-repeated-subarray.json +1 -0
  535. package/data/problems/maximum-product-of-three-numbers.json +1 -0
  536. package/data/problems/maximum-product-of-word-lengths.json +1 -0
  537. package/data/problems/maximum-product-subarray.json +1 -0
  538. package/data/problems/maximum-size-subarray-sum-equals-k.json +1 -0
  539. package/data/problems/maximum-subarray.json +1 -0
  540. package/data/problems/maximum-sum-circular-subarray.json +1 -0
  541. package/data/problems/maximum-sum-of-3-non-overlapping-subarrays.json +1 -0
  542. package/data/problems/maximum-swap.json +1 -0
  543. package/data/problems/maximum-vacation-days.json +1 -0
  544. package/data/problems/maximum-width-of-binary-tree.json +1 -0
  545. package/data/problems/maximum-width-ramp.json +1 -0
  546. package/data/problems/maximum-xor-of-two-numbers-in-an-array.json +1 -0
  547. package/data/problems/median-of-two-sorted-arrays.json +1 -0
  548. package/data/problems/meeting-rooms-ii.json +1 -0
  549. package/data/problems/meeting-rooms-iii.json +1 -0
  550. package/data/problems/meeting-rooms.json +1 -0
  551. package/data/problems/merge-intervals.json +1 -0
  552. package/data/problems/merge-k-sorted-lists.json +1 -0
  553. package/data/problems/merge-sorted-array.json +1 -0
  554. package/data/problems/merge-strings-alternately.json +1 -0
  555. package/data/problems/merge-triplets-to-form-target-triplet.json +1 -0
  556. package/data/problems/merge-two-binary-trees.json +1 -0
  557. package/data/problems/merge-two-sorted-lists.json +1 -0
  558. package/data/problems/middle-of-the-linked-list.json +1 -0
  559. package/data/problems/min-cost-climbing-stairs.json +1 -0
  560. package/data/problems/min-cost-to-connect-all-points.json +1 -0
  561. package/data/problems/min-stack.json +1 -0
  562. package/data/problems/minesweeper.json +1 -0
  563. package/data/problems/mini-parser.json +1 -0
  564. package/data/problems/minimize-malware-spread-ii.json +1 -0
  565. package/data/problems/minimize-malware-spread.json +1 -0
  566. package/data/problems/minimize-max-distance-to-gas-station.json +1 -0
  567. package/data/problems/minimum-absolute-difference-in-bst.json +1 -0
  568. package/data/problems/minimum-add-to-make-parentheses-valid.json +1 -0
  569. package/data/problems/minimum-area-rectangle-ii.json +1 -0
  570. package/data/problems/minimum-area-rectangle.json +1 -0
  571. package/data/problems/minimum-array-end.json +1 -0
  572. package/data/problems/minimum-ascii-delete-sum-for-two-strings.json +1 -0
  573. package/data/problems/minimum-cost-for-tickets.json +1 -0
  574. package/data/problems/minimum-cost-to-hire-k-workers.json +1 -0
  575. package/data/problems/minimum-cost-to-merge-stones.json +1 -0
  576. package/data/problems/minimum-depth-of-binary-tree.json +1 -0
  577. package/data/problems/minimum-distance-between-bst-nodes.json +1 -0
  578. package/data/problems/minimum-factorization.json +1 -0
  579. package/data/problems/minimum-falling-path-sum.json +1 -0
  580. package/data/problems/minimum-genetic-mutation.json +1 -0
  581. package/data/problems/minimum-height-trees.json +1 -0
  582. package/data/problems/minimum-increment-to-make-array-unique.json +1 -0
  583. package/data/problems/minimum-index-sum-of-two-lists.json +1 -0
  584. package/data/problems/minimum-interval-to-include-each-query.json +1 -0
  585. package/data/problems/minimum-moves-to-equal-array-elements-ii.json +1 -0
  586. package/data/problems/minimum-moves-to-equal-array-elements.json +1 -0
  587. package/data/problems/minimum-number-of-arrows-to-burst-balloons.json +1 -0
  588. package/data/problems/minimum-number-of-k-consecutive-bit-flips.json +1 -0
  589. package/data/problems/minimum-number-of-refueling-stops.json +1 -0
  590. package/data/problems/minimum-path-sum.json +1 -0
  591. package/data/problems/minimum-size-subarray-sum.json +1 -0
  592. package/data/problems/minimum-swaps-to-make-sequences-increasing.json +1 -0
  593. package/data/problems/minimum-time-difference.json +1 -0
  594. package/data/problems/minimum-unique-word-abbreviation.json +1 -0
  595. package/data/problems/minimum-window-subsequence.json +1 -0
  596. package/data/problems/minimum-window-substring.json +1 -0
  597. package/data/problems/mirror-reflection.json +1 -0
  598. package/data/problems/missing-number.json +1 -0
  599. package/data/problems/missing-ranges.json +1 -0
  600. package/data/problems/monotone-increasing-digits.json +1 -0
  601. package/data/problems/monotonic-array.json +1 -0
  602. package/data/problems/most-common-word.json +1 -0
  603. package/data/problems/most-frequent-subtree-sum.json +1 -0
  604. package/data/problems/most-profit-assigning-work.json +1 -0
  605. package/data/problems/most-stones-removed-with-same-row-or-column.json +1 -0
  606. package/data/problems/move-zeroes.json +1 -0
  607. package/data/problems/moving-average-from-data-stream.json +1 -0
  608. package/data/problems/multiply-strings.json +1 -0
  609. package/data/problems/my-calendar-i.json +1 -0
  610. package/data/problems/my-calendar-ii.json +1 -0
  611. package/data/problems/my-calendar-iii.json +1 -0
  612. package/data/problems/n-ary-tree-level-order-traversal.json +1 -0
  613. package/data/problems/n-ary-tree-postorder-traversal.json +1 -0
  614. package/data/problems/n-ary-tree-preorder-traversal.json +1 -0
  615. package/data/problems/n-queens-ii.json +1 -0
  616. package/data/problems/n-queens.json +1 -0
  617. package/data/problems/n-repeated-element-in-size-2n-array.json +1 -0
  618. package/data/problems/n-th-tribonacci-number.json +1 -0
  619. package/data/problems/nested-list-weight-sum-ii.json +1 -0
  620. package/data/problems/nested-list-weight-sum.json +1 -0
  621. package/data/problems/network-delay-time.json +1 -0
  622. package/data/problems/new-21-game.json +1 -0
  623. package/data/problems/next-closest-time.json +1 -0
  624. package/data/problems/next-greater-element-i.json +1 -0
  625. package/data/problems/next-greater-element-ii.json +1 -0
  626. package/data/problems/next-greater-element-iii.json +1 -0
  627. package/data/problems/next-permutation.json +1 -0
  628. package/data/problems/nim-game.json +1 -0
  629. package/data/problems/non-decreasing-array.json +1 -0
  630. package/data/problems/non-decreasing-subsequences.json +1 -0
  631. package/data/problems/non-negative-integers-without-consecutive-ones.json +1 -0
  632. package/data/problems/non-overlapping-intervals.json +1 -0
  633. package/data/problems/nth-digit.json +1 -0
  634. package/data/problems/nth-magical-number.json +1 -0
  635. package/data/problems/number-complement.json +1 -0
  636. package/data/problems/number-of-1-bits.json +1 -0
  637. package/data/problems/number-of-atoms.json +1 -0
  638. package/data/problems/number-of-boomerangs.json +1 -0
  639. package/data/problems/number-of-connected-components-in-an-undirected-graph.json +1 -0
  640. package/data/problems/number-of-corner-rectangles.json +1 -0
  641. package/data/problems/number-of-digit-one.json +1 -0
  642. package/data/problems/number-of-distinct-islands-ii.json +1 -0
  643. package/data/problems/number-of-distinct-islands.json +1 -0
  644. package/data/problems/number-of-islands-ii.json +1 -0
  645. package/data/problems/number-of-islands.json +1 -0
  646. package/data/problems/number-of-lines-to-write-string.json +1 -0
  647. package/data/problems/number-of-longest-increasing-subsequence.json +1 -0
  648. package/data/problems/number-of-matching-subsequences.json +1 -0
  649. package/data/problems/number-of-music-playlists.json +1 -0
  650. package/data/problems/number-of-provinces.json +1 -0
  651. package/data/problems/number-of-recent-calls.json +1 -0
  652. package/data/problems/number-of-segments-in-a-string.json +1 -0
  653. package/data/problems/number-of-squareful-arrays.json +1 -0
  654. package/data/problems/number-of-subarrays-with-bounded-maximum.json +1 -0
  655. package/data/problems/numbers-at-most-n-given-digit-set.json +1 -0
  656. package/data/problems/numbers-with-same-consecutive-differences.json +1 -0
  657. package/data/problems/odd-even-jump.json +1 -0
  658. package/data/problems/odd-even-linked-list.json +1 -0
  659. package/data/problems/one-edit-distance.json +1 -0
  660. package/data/problems/ones-and-zeroes.json +1 -0
  661. package/data/problems/online-election.json +1 -0
  662. package/data/problems/online-stock-span.json +1 -0
  663. package/data/problems/open-the-lock.json +1 -0
  664. package/data/problems/optimal-account-balancing.json +1 -0
  665. package/data/problems/optimal-division.json +1 -0
  666. package/data/problems/orderly-queue.json +1 -0
  667. package/data/problems/out-of-boundary-paths.json +1 -0
  668. package/data/problems/output-contest-matches.json +1 -0
  669. package/data/problems/pacific-atlantic-water-flow.json +1 -0
  670. package/data/problems/paint-fence.json +1 -0
  671. package/data/problems/paint-house-ii.json +1 -0
  672. package/data/problems/paint-house.json +1 -0
  673. package/data/problems/palindrome-linked-list.json +1 -0
  674. package/data/problems/palindrome-number.json +1 -0
  675. package/data/problems/palindrome-pairs.json +1 -0
  676. package/data/problems/palindrome-partitioning-ii.json +1 -0
  677. package/data/problems/palindrome-partitioning.json +1 -0
  678. package/data/problems/palindrome-permutation-ii.json +1 -0
  679. package/data/problems/palindrome-permutation.json +1 -0
  680. package/data/problems/palindromic-substrings.json +1 -0
  681. package/data/problems/pancake-sorting.json +1 -0
  682. package/data/problems/parse-lisp-expression.json +1 -0
  683. package/data/problems/partition-array-into-disjoint-intervals.json +1 -0
  684. package/data/problems/partition-equal-subset-sum.json +1 -0
  685. package/data/problems/partition-labels.json +1 -0
  686. package/data/problems/partition-list.json +1 -0
  687. package/data/problems/partition-to-k-equal-sum-subsets.json +1 -0
  688. package/data/problems/pascals-triangle-ii.json +1 -0
  689. package/data/problems/pascals-triangle.json +1 -0
  690. package/data/problems/patching-array.json +1 -0
  691. package/data/problems/path-sum-ii.json +1 -0
  692. package/data/problems/path-sum-iii.json +1 -0
  693. package/data/problems/path-sum-iv.json +1 -0
  694. package/data/problems/path-sum.json +1 -0
  695. package/data/problems/path-with-minimum-effort.json +1 -0
  696. package/data/problems/peak-index-in-a-mountain-array.json +1 -0
  697. package/data/problems/peeking-iterator.json +1 -0
  698. package/data/problems/perfect-number.json +1 -0
  699. package/data/problems/perfect-rectangle.json +1 -0
  700. package/data/problems/perfect-squares.json +1 -0
  701. package/data/problems/permutation-in-string.json +1 -0
  702. package/data/problems/permutation-sequence.json +1 -0
  703. package/data/problems/permutations-ii.json +1 -0
  704. package/data/problems/permutations.json +1 -0
  705. package/data/problems/plus-one-linked-list.json +1 -0
  706. package/data/problems/plus-one.json +1 -0
  707. package/data/problems/poor-pigs.json +1 -0
  708. package/data/problems/populating-next-right-pointers-in-each-node-ii.json +1 -0
  709. package/data/problems/populating-next-right-pointers-in-each-node.json +1 -0
  710. package/data/problems/positions-of-large-groups.json +1 -0
  711. package/data/problems/possible-bipartition.json +1 -0
  712. package/data/problems/pour-water.json +1 -0
  713. package/data/problems/power-of-four.json +1 -0
  714. package/data/problems/power-of-three.json +1 -0
  715. package/data/problems/power-of-two.json +1 -0
  716. package/data/problems/powerful-integers.json +1 -0
  717. package/data/problems/powx-n.json +1 -0
  718. package/data/problems/predict-the-winner.json +1 -0
  719. package/data/problems/prefix-and-suffix-search.json +1 -0
  720. package/data/problems/preimage-size-of-factorial-zeroes-function.json +1 -0
  721. package/data/problems/prime-number-of-set-bits-in-binary-representation.json +1 -0
  722. package/data/problems/prime-palindrome.json +1 -0
  723. package/data/problems/print-binary-tree.json +1 -0
  724. package/data/problems/prison-cells-after-n-days.json +1 -0
  725. package/data/problems/product-of-array-except-self.json +1 -0
  726. package/data/problems/profitable-schemes.json +1 -0
  727. package/data/problems/projection-area-of-3d-shapes.json +1 -0
  728. package/data/problems/push-dominoes.json +1 -0
  729. package/data/problems/pyramid-transition-matrix.json +1 -0
  730. package/data/problems/queue-reconstruction-by-height.json +1 -0
  731. package/data/problems/rabbits-in-forest.json +1 -0
  732. package/data/problems/race-car.json +1 -0
  733. package/data/problems/random-flip-matrix.json +1 -0
  734. package/data/problems/random-pick-index.json +1 -0
  735. package/data/problems/random-pick-with-blacklist.json +1 -0
  736. package/data/problems/random-pick-with-weight.json +1 -0
  737. package/data/problems/random-point-in-non-overlapping-rectangles.json +1 -0
  738. package/data/problems/range-addition-ii.json +1 -0
  739. package/data/problems/range-addition.json +1 -0
  740. package/data/problems/range-module.json +1 -0
  741. package/data/problems/range-sum-of-bst.json +1 -0
  742. package/data/problems/range-sum-query-2d-immutable.json +1 -0
  743. package/data/problems/range-sum-query-2d-mutable.json +1 -0
  744. package/data/problems/range-sum-query-immutable.json +1 -0
  745. package/data/problems/range-sum-query-mutable.json +1 -0
  746. package/data/problems/ransom-note.json +1 -0
  747. package/data/problems/reach-a-number.json +1 -0
  748. package/data/problems/reachable-nodes-in-subdivided-graph.json +1 -0
  749. package/data/problems/reaching-points.json +1 -0
  750. package/data/problems/read-n-characters-given-read4-ii-call-multiple-times.json +1 -0
  751. package/data/problems/read-n-characters-given-read4.json +1 -0
  752. package/data/problems/rearrange-string-k-distance-apart.json +1 -0
  753. package/data/problems/reconstruct-itinerary.json +1 -0
  754. package/data/problems/reconstruct-original-digits-from-english.json +1 -0
  755. package/data/problems/recover-binary-search-tree.json +1 -0
  756. package/data/problems/rectangle-area-ii.json +1 -0
  757. package/data/problems/rectangle-area.json +1 -0
  758. package/data/problems/rectangle-overlap.json +1 -0
  759. package/data/problems/redundant-connection-ii.json +1 -0
  760. package/data/problems/redundant-connection.json +1 -0
  761. package/data/problems/regions-cut-by-slashes.json +1 -0
  762. package/data/problems/regular-expression-matching.json +1 -0
  763. package/data/problems/relative-ranks.json +1 -0
  764. package/data/problems/remove-9.json +1 -0
  765. package/data/problems/remove-boxes.json +1 -0
  766. package/data/problems/remove-comments.json +1 -0
  767. package/data/problems/remove-duplicate-letters.json +1 -0
  768. package/data/problems/remove-duplicates-from-sorted-array-ii.json +1 -0
  769. package/data/problems/remove-duplicates-from-sorted-array.json +1 -0
  770. package/data/problems/remove-duplicates-from-sorted-list-ii.json +1 -0
  771. package/data/problems/remove-duplicates-from-sorted-list.json +1 -0
  772. package/data/problems/remove-element.json +1 -0
  773. package/data/problems/remove-invalid-parentheses.json +1 -0
  774. package/data/problems/remove-k-digits.json +1 -0
  775. package/data/problems/remove-linked-list-elements.json +1 -0
  776. package/data/problems/remove-nth-node-from-end-of-list.json +1 -0
  777. package/data/problems/reorder-data-in-log-files.json +1 -0
  778. package/data/problems/reorder-list.json +1 -0
  779. package/data/problems/reordered-power-of-2.json +1 -0
  780. package/data/problems/reorganize-string.json +1 -0
  781. package/data/problems/repeated-dna-sequences.json +1 -0
  782. package/data/problems/repeated-string-match.json +1 -0
  783. package/data/problems/repeated-substring-pattern.json +1 -0
  784. package/data/problems/replace-words.json +1 -0
  785. package/data/problems/reshape-the-matrix.json +1 -0
  786. package/data/problems/restore-ip-addresses.json +1 -0
  787. package/data/problems/reveal-cards-in-increasing-order.json +1 -0
  788. package/data/problems/reverse-bits.json +1 -0
  789. package/data/problems/reverse-integer.json +1 -0
  790. package/data/problems/reverse-linked-list-ii.json +1 -0
  791. package/data/problems/reverse-linked-list.json +1 -0
  792. package/data/problems/reverse-nodes-in-k-group.json +1 -0
  793. package/data/problems/reverse-only-letters.json +1 -0
  794. package/data/problems/reverse-pairs.json +1 -0
  795. package/data/problems/reverse-string-ii.json +1 -0
  796. package/data/problems/reverse-string.json +1 -0
  797. package/data/problems/reverse-vowels-of-a-string.json +1 -0
  798. package/data/problems/reverse-words-in-a-string-ii.json +1 -0
  799. package/data/problems/reverse-words-in-a-string-iii.json +1 -0
  800. package/data/problems/reverse-words-in-a-string.json +1 -0
  801. package/data/problems/rle-iterator.json +1 -0
  802. package/data/problems/robot-return-to-origin.json +1 -0
  803. package/data/problems/robot-room-cleaner.json +1 -0
  804. package/data/problems/roman-to-integer.json +1 -0
  805. package/data/problems/rotate-array.json +1 -0
  806. package/data/problems/rotate-function.json +1 -0
  807. package/data/problems/rotate-image.json +1 -0
  808. package/data/problems/rotate-list.json +1 -0
  809. package/data/problems/rotate-string.json +1 -0
  810. package/data/problems/rotated-digits.json +1 -0
  811. package/data/problems/rotting-oranges.json +1 -0
  812. package/data/problems/russian-doll-envelopes.json +1 -0
  813. package/data/problems/same-tree.json +1 -0
  814. package/data/problems/satisfiability-of-equality-equations.json +1 -0
  815. package/data/problems/score-after-flipping-matrix.json +1 -0
  816. package/data/problems/score-of-parentheses.json +1 -0
  817. package/data/problems/scramble-string.json +1 -0
  818. package/data/problems/search-a-2d-matrix-ii.json +1 -0
  819. package/data/problems/search-a-2d-matrix.json +1 -0
  820. package/data/problems/search-in-a-binary-search-tree.json +1 -0
  821. package/data/problems/search-in-a-sorted-array-of-unknown-size.json +1 -0
  822. package/data/problems/search-in-rotated-sorted-array-ii.json +1 -0
  823. package/data/problems/search-in-rotated-sorted-array.json +1 -0
  824. package/data/problems/search-insert-position.json +1 -0
  825. package/data/problems/second-minimum-node-in-a-binary-tree.json +1 -0
  826. package/data/problems/self-crossing.json +1 -0
  827. package/data/problems/self-dividing-numbers.json +1 -0
  828. package/data/problems/sentence-screen-fitting.json +1 -0
  829. package/data/problems/sentence-similarity-ii.json +1 -0
  830. package/data/problems/sentence-similarity.json +1 -0
  831. package/data/problems/sequence-reconstruction.json +1 -0
  832. package/data/problems/serialize-and-deserialize-binary-tree.json +1 -0
  833. package/data/problems/serialize-and-deserialize-bst.json +1 -0
  834. package/data/problems/serialize-and-deserialize-n-ary-tree.json +1 -0
  835. package/data/problems/set-intersection-size-at-least-two.json +1 -0
  836. package/data/problems/set-matrix-zeroes.json +1 -0
  837. package/data/problems/set-mismatch.json +1 -0
  838. package/data/problems/shifting-letters.json +1 -0
  839. package/data/problems/shopping-offers.json +1 -0
  840. package/data/problems/short-encoding-of-words.json +1 -0
  841. package/data/problems/shortest-bridge.json +1 -0
  842. package/data/problems/shortest-completing-word.json +1 -0
  843. package/data/problems/shortest-distance-from-all-buildings.json +1 -0
  844. package/data/problems/shortest-distance-to-a-character.json +1 -0
  845. package/data/problems/shortest-palindrome.json +1 -0
  846. package/data/problems/shortest-path-to-get-all-keys.json +1 -0
  847. package/data/problems/shortest-path-visiting-all-nodes.json +1 -0
  848. package/data/problems/shortest-subarray-with-sum-at-least-k.json +1 -0
  849. package/data/problems/shortest-unsorted-continuous-subarray.json +1 -0
  850. package/data/problems/shortest-word-distance-ii.json +1 -0
  851. package/data/problems/shortest-word-distance-iii.json +1 -0
  852. package/data/problems/shortest-word-distance.json +1 -0
  853. package/data/problems/shuffle-an-array.json +1 -0
  854. package/data/problems/similar-rgb-color.json +1 -0
  855. package/data/problems/similar-string-groups.json +1 -0
  856. package/data/problems/simplify-path.json +1 -0
  857. package/data/problems/single-element-in-a-sorted-array.json +1 -0
  858. package/data/problems/single-number-ii.json +1 -0
  859. package/data/problems/single-number-iii.json +1 -0
  860. package/data/problems/single-number.json +1 -0
  861. package/data/problems/single-threaded-cpu.json +1 -0
  862. package/data/problems/sliding-puzzle.json +1 -0
  863. package/data/problems/sliding-window-maximum.json +1 -0
  864. package/data/problems/sliding-window-median.json +1 -0
  865. package/data/problems/smallest-good-base.json +1 -0
  866. package/data/problems/smallest-range-covering-elements-from-k-lists.json +1 -0
  867. package/data/problems/smallest-range-i.json +1 -0
  868. package/data/problems/smallest-range-ii.json +1 -0
  869. package/data/problems/smallest-rectangle-enclosing-black-pixels.json +1 -0
  870. package/data/problems/smallest-rotation-with-highest-score.json +1 -0
  871. package/data/problems/smallest-string-starting-from-leaf.json +1 -0
  872. package/data/problems/smallest-subtree-with-all-the-deepest-nodes.json +1 -0
  873. package/data/problems/snakes-and-ladders.json +1 -0
  874. package/data/problems/solve-the-equation.json +1 -0
  875. package/data/problems/sort-an-array.json +1 -0
  876. package/data/problems/sort-array-by-parity-ii.json +1 -0
  877. package/data/problems/sort-array-by-parity.json +1 -0
  878. package/data/problems/sort-characters-by-frequency.json +1 -0
  879. package/data/problems/sort-colors.json +1 -0
  880. package/data/problems/sort-list.json +1 -0
  881. package/data/problems/sort-transformed-array.json +1 -0
  882. package/data/problems/soup-servings.json +1 -0
  883. package/data/problems/sparse-matrix-multiplication.json +1 -0
  884. package/data/problems/special-binary-string.json +1 -0
  885. package/data/problems/spiral-matrix-ii.json +1 -0
  886. package/data/problems/spiral-matrix-iii.json +1 -0
  887. package/data/problems/spiral-matrix.json +1 -0
  888. package/data/problems/split-array-into-consecutive-subsequences.json +1 -0
  889. package/data/problems/split-array-into-fibonacci-sequence.json +1 -0
  890. package/data/problems/split-array-largest-sum.json +1 -0
  891. package/data/problems/split-array-with-equal-sum.json +1 -0
  892. package/data/problems/split-array-with-same-average.json +1 -0
  893. package/data/problems/split-bst.json +1 -0
  894. package/data/problems/split-concatenated-strings.json +1 -0
  895. package/data/problems/split-linked-list-in-parts.json +1 -0
  896. package/data/problems/sqrtx.json +1 -0
  897. package/data/problems/squares-of-a-sorted-array.json +1 -0
  898. package/data/problems/squirrel-simulation.json +1 -0
  899. package/data/problems/stamping-the-sequence.json +1 -0
  900. package/data/problems/stickers-to-spell-word.json +1 -0
  901. package/data/problems/stone-game-ii.json +1 -0
  902. package/data/problems/stone-game-iii.json +1 -0
  903. package/data/problems/stone-game.json +1 -0
  904. package/data/problems/strange-printer.json +1 -0
  905. package/data/problems/string-compression.json +1 -0
  906. package/data/problems/string-to-integer-atoi.json +1 -0
  907. package/data/problems/string-without-aaa-or-bbb.json +1 -0
  908. package/data/problems/strobogrammatic-number-ii.json +1 -0
  909. package/data/problems/strobogrammatic-number-iii.json +1 -0
  910. package/data/problems/strobogrammatic-number.json +1 -0
  911. package/data/problems/strong-password-checker.json +1 -0
  912. package/data/problems/student-attendance-record-i.json +1 -0
  913. package/data/problems/student-attendance-record-ii.json +1 -0
  914. package/data/problems/subarray-product-less-than-k.json +1 -0
  915. package/data/problems/subarray-sum-equals-k.json +1 -0
  916. package/data/problems/subarray-sums-divisible-by-k.json +1 -0
  917. package/data/problems/subarrays-with-k-different-integers.json +1 -0
  918. package/data/problems/subdomain-visit-count.json +1 -0
  919. package/data/problems/subsets-ii.json +1 -0
  920. package/data/problems/subsets.json +1 -0
  921. package/data/problems/substring-with-concatenation-of-all-words.json +1 -0
  922. package/data/problems/subtree-of-another-tree.json +1 -0
  923. package/data/problems/sudoku-solver.json +1 -0
  924. package/data/problems/sum-of-all-subset-xor-totals.json +1 -0
  925. package/data/problems/sum-of-distances-in-tree.json +1 -0
  926. package/data/problems/sum-of-even-numbers-after-queries.json +1 -0
  927. package/data/problems/sum-of-left-leaves.json +1 -0
  928. package/data/problems/sum-of-square-numbers.json +1 -0
  929. package/data/problems/sum-of-subarray-minimums.json +1 -0
  930. package/data/problems/sum-of-subsequence-widths.json +1 -0
  931. package/data/problems/sum-of-two-integers.json +1 -0
  932. package/data/problems/sum-root-to-leaf-numbers.json +1 -0
  933. package/data/problems/summary-ranges.json +1 -0
  934. package/data/problems/super-egg-drop.json +1 -0
  935. package/data/problems/super-palindromes.json +1 -0
  936. package/data/problems/super-pow.json +1 -0
  937. package/data/problems/super-ugly-number.json +1 -0
  938. package/data/problems/super-washing-machines.json +1 -0
  939. package/data/problems/surface-area-of-3d-shapes.json +1 -0
  940. package/data/problems/surrounded-regions.json +1 -0
  941. package/data/problems/swap-adjacent-in-lr-string.json +1 -0
  942. package/data/problems/swap-nodes-in-pairs.json +1 -0
  943. package/data/problems/swim-in-rising-water.json +1 -0
  944. package/data/problems/symmetric-tree.json +1 -0
  945. package/data/problems/tag-validator.json +1 -0
  946. package/data/problems/tallest-billboard.json +1 -0
  947. package/data/problems/target-sum.json +1 -0
  948. package/data/problems/task-scheduler.json +1 -0
  949. package/data/problems/teemo-attacking.json +1 -0
  950. package/data/problems/ternary-expression-parser.json +1 -0
  951. package/data/problems/text-justification.json +1 -0
  952. package/data/problems/the-maze-ii.json +1 -0
  953. package/data/problems/the-maze-iii.json +1 -0
  954. package/data/problems/the-maze.json +1 -0
  955. package/data/problems/the-skyline-problem.json +1 -0
  956. package/data/problems/third-maximum-number.json +1 -0
  957. package/data/problems/three-equal-parts.json +1 -0
  958. package/data/problems/time-based-key-value-store.json +1 -0
  959. package/data/problems/to-lower-case.json +1 -0
  960. package/data/problems/toeplitz-matrix.json +1 -0
  961. package/data/problems/top-k-frequent-elements.json +1 -0
  962. package/data/problems/top-k-frequent-words.json +1 -0
  963. package/data/problems/total-hamming-distance.json +1 -0
  964. package/data/problems/transform-to-chessboard.json +1 -0
  965. package/data/problems/transpose-matrix.json +1 -0
  966. package/data/problems/trapping-rain-water-ii.json +1 -0
  967. package/data/problems/trapping-rain-water.json +1 -0
  968. package/data/problems/triangle.json +1 -0
  969. package/data/problems/trim-a-binary-search-tree.json +1 -0
  970. package/data/problems/triples-with-bitwise-and-equal-to-zero.json +1 -0
  971. package/data/problems/two-sum-ii-input-array-is-sorted.json +1 -0
  972. package/data/problems/two-sum-iii-data-structure-design.json +1 -0
  973. package/data/problems/two-sum-iv-input-is-a-bst.json +1 -0
  974. package/data/problems/two-sum.json +1 -0
  975. package/data/problems/ugly-number-ii.json +1 -0
  976. package/data/problems/ugly-number.json +1 -0
  977. package/data/problems/uncommon-words-from-two-sentences.json +1 -0
  978. package/data/problems/unique-binary-search-trees-ii.json +1 -0
  979. package/data/problems/unique-binary-search-trees.json +1 -0
  980. package/data/problems/unique-email-addresses.json +1 -0
  981. package/data/problems/unique-morse-code-words.json +1 -0
  982. package/data/problems/unique-paths-ii.json +1 -0
  983. package/data/problems/unique-paths-iii.json +1 -0
  984. package/data/problems/unique-paths.json +1 -0
  985. package/data/problems/unique-substrings-in-wraparound-string.json +1 -0
  986. package/data/problems/unique-word-abbreviation.json +1 -0
  987. package/data/problems/univalued-binary-tree.json +1 -0
  988. package/data/problems/utf-8-validation.json +1 -0
  989. package/data/problems/valid-anagram.json +1 -0
  990. package/data/problems/valid-mountain-array.json +1 -0
  991. package/data/problems/valid-number.json +1 -0
  992. package/data/problems/valid-palindrome-ii.json +1 -0
  993. package/data/problems/valid-palindrome.json +1 -0
  994. package/data/problems/valid-parentheses.json +1 -0
  995. package/data/problems/valid-parenthesis-string.json +1 -0
  996. package/data/problems/valid-perfect-square.json +1 -0
  997. package/data/problems/valid-permutations-for-di-sequence.json +1 -0
  998. package/data/problems/valid-square.json +1 -0
  999. package/data/problems/valid-sudoku.json +1 -0
  1000. package/data/problems/valid-tic-tac-toe-state.json +1 -0
  1001. package/data/problems/valid-triangle-number.json +1 -0
  1002. package/data/problems/valid-word-abbreviation.json +1 -0
  1003. package/data/problems/valid-word-square.json +1 -0
  1004. package/data/problems/validate-binary-search-tree.json +1 -0
  1005. package/data/problems/validate-ip-address.json +1 -0
  1006. package/data/problems/validate-stack-sequences.json +1 -0
  1007. package/data/problems/verify-preorder-sequence-in-binary-search-tree.json +1 -0
  1008. package/data/problems/verify-preorder-serialization-of-a-binary-tree.json +1 -0
  1009. package/data/problems/verifying-an-alien-dictionary.json +1 -0
  1010. package/data/problems/vertical-order-traversal-of-a-binary-tree.json +1 -0
  1011. package/data/problems/vowel-spellchecker.json +1 -0
  1012. package/data/problems/walking-robot-simulation.json +1 -0
  1013. package/data/problems/walls-and-gates.json +1 -0
  1014. package/data/problems/water-and-jug-problem.json +1 -0
  1015. package/data/problems/wiggle-sort-ii.json +1 -0
  1016. package/data/problems/wiggle-sort.json +1 -0
  1017. package/data/problems/wiggle-subsequence.json +1 -0
  1018. package/data/problems/wildcard-matching.json +1 -0
  1019. package/data/problems/word-abbreviation.json +1 -0
  1020. package/data/problems/word-break-ii.json +1 -0
  1021. package/data/problems/word-break.json +1 -0
  1022. package/data/problems/word-ladder-ii.json +1 -0
  1023. package/data/problems/word-ladder.json +1 -0
  1024. package/data/problems/word-pattern-ii.json +1 -0
  1025. package/data/problems/word-pattern.json +1 -0
  1026. package/data/problems/word-search-ii.json +1 -0
  1027. package/data/problems/word-search.json +1 -0
  1028. package/data/problems/word-squares.json +1 -0
  1029. package/data/problems/word-subsets.json +1 -0
  1030. package/data/problems/x-of-a-kind-in-a-deck-of-cards.json +1 -0
  1031. package/data/problems/zigzag-conversion.json +1 -0
  1032. package/data/problems/zigzag-iterator.json +1 -0
  1033. package/data/problems/zuma-game.json +1 -0
  1034. package/dist/cli.js +793 -0
  1035. package/dist/web/assets/index-DCYvZg7a.js +150 -0
  1036. package/dist/web/assets/index-gSBueMfH.css +1 -0
  1037. package/dist/web/index.html +13 -0
  1038. package/package.json +44 -4
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "544", "slug": "sliding-window-median", "id": 544, "title": "Sliding Window Median", "difficulty": "Hard", "category": "heap", "link": "https://leetcode.com/problems/sliding-window-median/", "examples": [{"input": "nums = [1,3,-1,-3,5,3,6,7], k = 3", "output": "[\"1.0\",\"-1.0\",\"-1.0\",\"3.0\",\"5.0\",\"6.0\"]", "explanation": "Sorted windows give middles 1, -1, -1, 3, 5, 6."}, {"input": "nums = [1,2,3,4,2,3,1,4,2], k = 3", "output": "[\"2.0\",\"3.0\",\"3.0\",\"3.0\",\"2.0\",\"3.0\",\"2.0\"]", "explanation": "Each triple contributes its middle value."}], "hints": ["Adaptation: format each median with default double-to-string; the checker allows 1e-5 error.", "Keep two balanced heaps with lazy deletions so insert, erase, and median are logarithmic.", "For even k average the two heap tops using double arithmetic."], "statement": "Slide a window of exactly `k` spots from the left end of `nums` to the right end, one step at a time. For each placement, sort that slice in your head and take its middle value \u2014 or the mean of the two middle values when `k` is even. Collect those medians in order.\n\n**Portable adaptation:** Medians can be fractional (ending in `.5`), and this judge has no double type. Each median is therefore returned as a decimal string (for example `\"2.5\"` or `\"1.0\"`), and grading accepts any decimal within `1e-5` of the true value.\n\n**Constraints:**\n\n- `1 <= k <= nums.length <= 10^5`\n- `-2^31 <= nums[i] <= 2^31 - 1`\n- Answers within `1e-5` of truth are accepted.\n", "solution": "## Approach\n\nMaintain the current window in two heaps: a max-heap holds the lower half and a min-heap holds the upper half, with sizes kept within one of each other. Insertions go to the appropriate heap, removals are recorded lazily in a delay map and pruned from heap tops, and rebalancing restores the size rule. The median is then either the max-heap top (odd window) or the mean of both tops (even window), formatted as a decimal string.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log k) for n windows with heap operations.\n- **Space Complexity:** O(k) for the heaps and delay map.\n\n## Implementation\n\n```python\nimport heapq\nfrom collections import defaultdict\nfrom typing import List\n\nclass Solution:\n def medianSlidingWindow(self, nums: List[int], k: int) -> List[str]:\n small: List[int] = [] # max-heap via negatives\n large: List[int] = [] # min-heap\n delayed: dict = defaultdict(int)\n small_size = 0\n large_size = 0\n\n def prune(heap, is_small: bool) -> None:\n while heap:\n v = -heap[0] if is_small else heap[0]\n if delayed.get(v, 0) == 0:\n break\n heapq.heappop(heap)\n delayed[v] -= 1\n if delayed[v] == 0:\n del delayed[v]\n\n def balance() -> None:\n nonlocal small_size, large_size\n if small_size > large_size + 1:\n v = -heapq.heappop(small)\n heapq.heappush(large, v)\n small_size -= 1\n large_size += 1\n prune(small, True)\n elif small_size < large_size:\n v = heapq.heappop(large)\n heapq.heappush(small, -v)\n small_size += 1\n large_size -= 1\n prune(large, False)\n\n out: List[str] = []\n for i, v in enumerate(nums):\n if not small or v <= -small[0]:\n heapq.heappush(small, -v)\n small_size += 1\n else:\n heapq.heappush(large, v)\n large_size += 1\n balance()\n if i >= k:\n old = nums[i - k]\n delayed[old] += 1\n if old <= -small[0]:\n small_size -= 1\n if old == -small[0]:\n prune(small, True)\n else:\n large_size -= 1\n if large and old == large[0]:\n prune(large, False)\n balance()\n if i >= k - 1:\n if k % 2 == 1:\n out.append(repr(float(-small[0])))\n else:\n out.append(repr((-small[0] + large[0]) / 2.0))\n return out\n```\n", "starter": {"go": "package main\n\nfunc MedianSlidingWindow(nums []int, k int) []string {\n return []string{}\n}", "python": "from typing import List\nclass Solution:\n def medianSlidingWindow(self, nums: List[int], k: int) -> List[str]:\n return []\n", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<string> medianSlidingWindow(vector<int>& nums, int k) {\n return {};\n }\n};"}, "fn": "medianSlidingWindow", "params": [{"name": "nums", "type": "int_array"}, {"name": "k", "type": "int"}], "outputType": "string_list", "tests": [["[1,3,-1,-3,5,3,6,7]", "3"], ["[1,2,3,4,2,3,1,4,2]", "3"], ["[1,4,2,3]", "4"], ["[1]", "1"], ["[5,5,5,5]", "2"], ["[1,2,3,4,5]", "1"], ["[5,4,3,2,1]", "5"], ["[0,0,0,0,0]", "3"], ["[-1,-2,-3,-4]", "2"], ["[2147483647,-2147483648,0,1]", "2"], ["[1,3,2,6,7,8,9]", "4"], ["[4,1,7,2,9,3]", "3"], ["[2,2,2,2,2,2]", "4"], ["[9,8,7,6,5,4,3,2,1]", "3"], ["[1,2]", "2"], ["[3,1,2]", "2"], ["[-5,10,-3,8,0]", "3"], ["[100,50,25,75,125]", "5"], ["[1,2,3,4]", "2"], ["[5,2,2,7,8]", "3"], ["[0,1,2,3,4,5]", "6"], ["[10,-10,10,-10]", "4"], ["[7,9,3,1,5]", "1"], ["[2,1]", "1"], ["[1000000,-1000000,500000]", "3"], ["[3,3,3,3,3]", "5"], ["[6,5,4,3,2,1]", "2"], ["[1,3,5,7,9,11]", "3"], ["[4,4,4,1,1,1]", "3"], ["[2147483647,2147483647,-2147483648]", "3"]], "expected": [["1.0", "-1.0", "-1.0", "3.0", "5.0", "6.0"], ["2.0", "3.0", "3.0", "3.0", "2.0", "3.0", "2.0"], ["2.5"], ["1.0"], ["5.0", "5.0", "5.0"], ["1.0", "2.0", "3.0", "4.0", "5.0"], ["3.0"], ["0.0", "0.0", "0.0"], ["-1.5", "-2.5", "-3.5"], ["-0.5", "-1.073741824E9", "0.5"], ["2.5", "4.5", "6.5", "7.5"], ["4.0", "2.0", "7.0", "3.0"], ["2.0", "2.0", "2.0"], ["8.0", "7.0", "6.0", "5.0", "4.0", "3.0", "2.0"], ["1.5"], ["2.0", "1.5"], ["-3.0", "8.0", "0.0"], ["75.0"], ["1.5", "2.5", "3.5"], ["2.0", "2.0", "7.0"], ["2.5"], ["0.0"], ["7.0", "9.0", "3.0", "1.0", "5.0"], ["2.0", "1.0"], ["500000.0"], ["3.0"], ["5.5", "4.5", "3.5", "2.5", "1.5"], ["3.0", "5.0", "7.0", "9.0"], ["4.0", "4.0", "1.0", "1.0"], ["2.147483647E9"]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "547", "slug": "smallest-good-base", "id": 547, "title": "Smallest Good Base", "difficulty": "Hard", "category": "math", "link": "https://leetcode.com/problems/smallest-good-base/", "examples": [{"input": "n = \"13\"", "output": "\"3\"", "explanation": "13 is 111 in base 3."}, {"input": "n = \"4681\"", "output": "\"8\"", "explanation": "4681 is 11111 in base 8."}, {"input": "n = \"1000000000000000000\"", "output": "\"999999999999999999\"", "explanation": "Only 11 in base n-1 works."}], "hints": ["A longer all-ones run means a smaller base, so try long lengths first.", "For a fixed length, the value grows with the base: binary-search it.", "Accumulate 1+k+...+k^m with early exit once the sum passes n to avoid overflow."], "statement": "An integer `n` (given as its decimal text) has a *good base* `k >= 2` when writing `n` in base `k` uses only the digit `1` \u2014 that is, `n = 1 + k + k^2 + ... + k^m` for some length `m >= 1`. Every `n >= 3` has at least the trivial base `n - 1` (form `11`).\n\nReturn the smallest such base, again as decimal text.\n\n**Constraints:**\n\n- `n` is an integer in `[3, 10^18]` with no leading zeroes.\n", "solution": "## Approach\n\nA longer block of ones implies a smaller base, so examine possible exponents from large to small. For a fixed exponent `m` (meaning `m+1` ones), the geometric sum grows monotonically in the base, which allows binary search between 2 and roughly `n^(1/m)`. Summation stops early as soon as the partial total passes `n`, keeping arithmetic inside 64 bits. The first base found while scanning exponents downward is the smallest good base; the fallback `n-1` (form `11`) always works.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log^2 n) \u2014 up to 60 exponents times a logarithmic binary search.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def smallestGoodBase(self, n: str) -> str:\n N = int(n)\n max_m = N.bit_length() - 1\n for m in range(max_m, 0, -1):\n lo, hi = 2, int(round(N ** (1.0 / m))) + 1\n hi = max(hi, 2)\n hi = min(hi, N - 1)\n while lo <= hi:\n mid = (lo + hi) // 2\n s = 1\n cur = 1\n overflow = False\n for _ in range(m):\n if cur > N // mid:\n overflow = True\n break\n cur *= mid\n s += cur\n if s > N:\n overflow = True\n break\n if not overflow and s == N:\n return str(mid)\n if overflow or s > N:\n hi = mid - 1\n else:\n lo = mid + 1\n return str(N - 1)\n```\n", "starter": {"go": "package main\n\nfunc SmallestGoodBase(n string) string {\n return \"\"\n}", "python": "class Solution:\n def smallestGoodBase(self, n: str) -> str:\n return \"\"\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n string smallestGoodBase(string n) {\n return \"\";\n }\n};"}, "fn": "smallestGoodBase", "params": [{"name": "n", "type": "string"}], "outputType": "string", "tests": [["13"], ["4681"], ["1000000000000000000"], ["3"], ["4"], ["7"], ["8"], ["15"], ["21"], ["31"], ["8191"], ["121"], ["1000"], ["999999999999999999"], ["100000000000000000"], ["160"], ["225"], ["1023"], ["1000000"], ["1099511627775"], ["9"], ["63"], ["255"], ["26"], ["100"], ["10000"], ["999999"], ["123456789"], ["99999999999999999"], ["1048575"]], "expected": ["3", "8", "999999999999999999", "2", "3", "2", "7", "2", "4", "2", "2", "3", "999", "999999999999999998", "99999999999999999", "159", "224", "2", "999999", "2", "8", "2", "2", "25", "99", "9999", "999998", "123456788", "99999999999999998", "2"], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "654", "slug": "smallest-range-covering-elements-from-k-lists", "id": 654, "title": "Smallest Range Covering Elements from K Lists", "difficulty": "Hard", "category": "heap", "link": "https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists/", "examples": [{"input": "nums = [[4,10,15,24,26],[0,9,12,20],[5,18,22,30]]", "output": "[20,24]", "explanation": "20 comes from list 2, 22/24 from others; span 4 is minimal."}, {"input": "nums = [[1,2,3],[1,2,3],[1,2,3]]", "output": "[1,1]", "explanation": "Picking 1 from each list gives a zero-width range."}, {"input": "nums = [[10,10],[11,11]]", "output": "[10,11]", "explanation": "One entry per list forces [10,11]."}], "hints": ["Seed a min-heap with the first entry of every list and record the maximum among them.", "Repeatedly pop the minimum: the current [min, max] is a candidate covering all lists.", "Then advance inside the popped list (updating the max) until some list runs dry; keep the shortest candidate, breaking ties by smaller start.", "Adaptation: the nested input maps to int_array_2d and the two-element answer maps to int_array in this judge."], "statement": "You are given `k` sorted integer lists. Find the narrowest interval `[a, b]` that contains at least one number from every list.\n\nCompare candidates by width `b - a` first; when widths tie, prefer the smaller start `a`. Return the winning pair.\n\n**Constraints:**\n- At least one list is present; each list is sorted increasingly.\n- Values fit comfortably in 32-bit signed range.\n\n*Adaptation: the nested input maps to `int_array_2d` and the two-element answer maps to `int_array` in this judge, even though the natural statement uses lists of lists.*\n", "solution": "## Approach\n\nPush the head of every list into a min-heap and note the largest head as the running maximum, so [heap-min, running-max] always covers all lists. Pop the minimum to form a candidate, keep it when it narrows the best span (or ties with a smaller start), then push the next element from the same list and refresh the maximum. Stop once any list is exhausted, since no further range can cover it.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(N log k), where N is total elements and k the list count.\n- **Space Complexity:** O(k) for the heap.\n\n## Implementation\n\n```python\nfrom typing import List\nimport heapq\nclass Solution:\n def smallestRange(self, nums: List[List[int]]) -> List[int]:\n pq = []\n cur_max = float(\"-inf\")\n for i, lst in enumerate(nums):\n heapq.heappush(pq, (lst[0], i, 0))\n cur_max = max(cur_max, lst[0])\n best_a, best_b = 0, float(\"inf\")\n while True:\n v, li, ei = heapq.heappop(pq)\n if cur_max - v < best_b - best_a or (cur_max - v == best_b - best_a and v < best_a):\n best_a, best_b = v, cur_max\n if ei + 1 >= len(nums[li]):\n break\n nv = nums[li][ei + 1]\n heapq.heappush(pq, (nv, li, ei + 1))\n cur_max = max(cur_max, nv)\n return [best_a, best_b]\n```\n", "starter": {"go": "package main\n\nfunc SmallestRange(nums [][]int) []int {\n \n}", "python": "from typing import List\nclass Solution:\n def smallestRange(self, nums: List[List[int]]) -> List[int]:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<int> smallestRange(vector<vector<int>>& nums) {\n return {};\n }\n};"}, "fn": "smallestRange", "params": [{"name": "nums", "type": "int_array_2d"}], "outputType": "int_array", "tests": [["[[4,10,15,24,26],[0,9,12,20],[5,18,22,30]]"], ["[[1,2,3],[1,2,3],[1,2,3]]"], ["[[10,10],[11,11]]"], ["[[1]]"], ["[[1,5],[2,6]]"], ["[[1,2,3],[4,5,6]]"], ["[[1,10],[2,11],[3,12]]"], ["[[0,0,0],[1,1,1]]"], ["[[-5,-2,0],[1,2,3]]"], ["[[1,2],[3,4],[5,6]]"], ["[[4,4,4],[4,4,4]]"], ["[[1,100],[50,51],[49,52]]"], ["[[10,20,30],[5,15,25],[1,2,35]]"], ["[[1,2,3,4,5]]"], ["[[1,3,5],[2,4,6],[0,7]]"], ["[[-10,-5,0,5],[1,2]]"], ["[[18,28],[2,22],[17,29]]"], ["[[1,2,3],[1,2,3,4],[1,2]]"], ["[[100,200],[150,300],[120,180]]"], ["[[0,9],[4,10],[8,12]]"], ["[[1,4,7],[2,5,8],[3,6,9]]"], ["[[5],[10],[15],[20]]"], ["[[-3,-1,4],[0,2],[1,3,5]]"], ["[[1,2],[1,3],[1,4]]"], ["[[6,10,15],[3,8,20]]"], ["[[0,5,10],[1,6,11],[2,7,12]]"], ["[[25,30],[5,10,15,20]]"], ["[[1,9],[2,8],[3,7],[4,6]]"]], "expected": [[20, 24], [1, 1], [10, 11], [1, 1], [1, 2], [3, 4], [1, 3], [0, 1], [0, 1], [2, 5], [4, 4], [1, 50], [2, 10], [1, 1], [0, 2], [0, 1], [17, 22], [1, 1], [100, 150], [8, 10], [1, 3], [5, 20], [-1, 1], [1, 1], [6, 8], [0, 2], [20, 25], [1, 4]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "897", "slug": "smallest-range-i", "id": 897, "title": "Smallest Range I", "difficulty": "Easy", "category": "array", "link": "https://leetcode.com/problems/smallest-range-i/", "examples": [{"input": "nums = [1], k = 0", "output": "0", "explanation": "Only one element exists, so the score is 0 however it is shifted."}, {"input": "nums = [0,10], k = 2", "output": "6", "explanation": "Move 0 up to 2 and 10 down to 8; the spread becomes 8 - 2 = 6, which is the best possible."}, {"input": "nums = [1,3,6], k = 3", "output": "0", "explanation": "Shift every value to 4 (1 + 3, 3 + 1, 6 - 2); all equal, so the score is 0."}], "hints": ["Only the smallest and largest values matter: everything else lands between them after shifting.", "Push the minimum up by k and pull the maximum down by k; if they cross, the answer is 0.", "The result is max(0, max(nums) - min(nums) - 2 * k)."], "statement": "You are given an integer array `nums` and an integer `k`. For each element you may pick a shift amount between `-k` and `k` (each element gets its own choice, and choosing `0` leaves it unchanged) and add it to that element.\n\nAfter all shifts, the score is the difference between the largest and the smallest value. Return the smallest score you can achieve.\n\n**Constraints:**\n- `1 <= nums.length <= 50`\n- `0 <= nums[i] <= 10000`\n- `0 <= k <= 10000`\n", "solution": "## Approach\n\nOnly the extreme values influence the spread, since every shifted element stays between the shifted minimum and the shifted maximum. Raising the minimum by the full `k` and lowering the maximum by the full `k` squeezes the interval as much as possible, and the bounds can cross, in which case every element can be made equal.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) to scan for the minimum and maximum.\n- **Space Complexity:** O(1) extra space.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def smallestRangeI(self, nums: List[int], k: int) -> int:\n return max(0, max(nums) - min(nums) - 2 * k)\n```\n", "starter": {"go": "package main\n\nfunc SmallestRangeI(nums []int, k int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def smallestRangeI(self, nums: List[int], k: int) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int smallestRangeI(vector<int>& nums, int k) {\n return 0;\n }\n};"}, "fn": "smallestRangeI", "params": [{"name": "nums", "type": "int_array"}, {"name": "k", "type": "int"}], "outputType": "int", "tests": [["[1]", "0"], ["[0,10]", "2"], ["[1,3,6]", "3"], ["[2,7,2]", "1"], ["[10,10,10]", "5"], ["[0,0,0]", "0"], ["[1,100]", "50"], ["[1,100]", "10"], ["[5]", "100"], ["[4,9,2,7]", "2"], ["[10000,0]", "10000"], ["[10000,0]", "0"], ["[3,1,4,1,5,9,2,6]", "3"], ["[7,7,7,7]", "0"], ["[0,5]", "3"], ["[0,6]", "3"], ["[0,7]", "3"], ["[100,200,300]", "50"], ["[1,2,3,4,5]", "0"], ["[1,2,3,4,5]", "2"], ["[1,2,3,4,5]", "1"], ["[8,3]", "4"], ["[8,3]", "2"], ["[50,50]", "0"], ["[0,10000]", "4999"], ["[0,10000]", "5000"], ["[9,1,8,2,7]", "2"], ["[6,6,1]", "4"]], "expected": [0, 6, 0, 3, 0, 0, 0, 79, 0, 3, 0, 10000, 2, 0, 0, 0, 1, 100, 4, 0, 2, 0, 1, 0, 2, 0, 4, 0], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "899", "slug": "smallest-range-ii", "id": 899, "title": "Smallest Range II", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/smallest-range-ii/", "examples": [{"input": "nums = [1], k = 0", "output": "0", "explanation": "A single element always has spread 0."}, {"input": "nums = [0,10], k = 2", "output": "6", "explanation": "Adjust to 2 and 8 (or -2 and 12); the best spread is 6."}, {"input": "nums = [1,3,6], k = 3", "output": "3", "explanation": "Adjust to 4, 6 and 3 (each shifted by exactly 3); the spread is 6 - 3 = 3, which is optimal."}], "hints": ["Sort the array first: in an optimal answer the values raised by k form a prefix and the lowered ones a suffix (or vice versa).", "Try every split point between the raised group and the lowered group and measure max minus min of the two boundary values.", "The initial spread (no effective split) is also a candidate; take the minimum over all splits."], "statement": "You are given an integer array `nums` and an integer `k`. You must adjust every element by exactly `k`: each `nums[i]` becomes either `nums[i] + k` or `nums[i] - k` (your choice per element).\n\nAfter all adjustments, the score is the difference between the largest and the smallest value. Return the smallest score you can achieve.\n\n**Constraints:**\n- `1 <= nums.length <= 2000`\n- `0 <= nums[i] <= 10000`\n- `0 <= k <= 10000`\n", "solution": "## Approach\n\nSort the values. In an optimal assignment there is a dividing line: smaller elements are raised and larger ones are lowered (any interleaving can be uncrossed without hurting the spread). For each possible dividing line the spread is determined by the largest of the two group maxima minus the smallest of the two group minima. Checking every line plus the untouched spread gives the optimum.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log n) for sorting, then O(n) for the scan.\n- **Space Complexity:** O(n) for the sorted copy (O(1) extra besides sorting).\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def smallestRangeII(self, nums: List[int], k: int) -> int:\n a = sorted(nums)\n ans = a[-1] - a[0]\n for i in range(1, len(a)):\n hi = max(a[i - 1] + k, a[-1] - k)\n lo = min(a[0] + k, a[i] - k)\n ans = min(ans, hi - lo)\n return ans\n```\n", "starter": {"go": "package main\n\nfunc SmallestRangeII(nums []int, k int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def smallestRangeII(self, nums: List[int], k: int) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int smallestRangeII(vector<int>& nums, int k) {\n return 0;\n }\n};"}, "fn": "smallestRangeII", "params": [{"name": "nums", "type": "int_array"}, {"name": "k", "type": "int"}], "outputType": "int", "tests": [["[1]", "0"], ["[0,10]", "2"], ["[1,3,6]", "3"], ["[2,7,2]", "1"], ["[10,10,10]", "5"], ["[0,0,0]", "0"], ["[1,100]", "50"], ["[1,100]", "10"], ["[5]", "100"], ["[4,9,2,7]", "2"], ["[10000,0]", "10000"], ["[10000,0]", "0"], ["[3,1,4,1,5,9,2,6]", "3"], ["[7,7,7,7]", "0"], ["[0,5]", "3"], ["[0,6]", "3"], ["[0,7]", "3"], ["[100,200,300]", "50"], ["[1,2,3,4,5]", "0"], ["[1,2,3,4,5]", "2"], ["[1,2,3,4,5]", "1"], ["[8,3]", "4"], ["[8,3]", "2"], ["[50,50]", "0"], ["[0,10000]", "4999"], ["[0,10000]", "5000"], ["[9,1,8,2,7]", "2"], ["[6,6,1]", "4"]], "expected": [0, 6, 3, 3, 0, 0, 1, 79, 0, 3, 10000, 10000, 5, 0, 1, 0, 1, 100, 4, 3, 2, 3, 1, 0, 2, 0, 4, 3], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "395", "slug": "smallest-rectangle-enclosing-black-pixels", "id": 395, "title": "Smallest Rectangle Enclosing Black Pixels", "difficulty": "Hard", "category": "matrix", "link": "https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels/", "examples": [{"input": "image = [[\"0\",\"0\",\"1\",\"0\"],[\"0\",\"1\",\"1\",\"0\"],[\"0\",\"1\",\"0\",\"0\"]], x = 0, y = 2", "output": "6", "explanation": "Rows 0..2 and columns 1..2 enclose every black pixel."}, {"input": "image = [[\"1\"]], x = 0, y = 0", "output": "1", "explanation": "One pixel covers area 1."}, {"input": "image = [[\"1\",\"1\"],[\"1\",\"1\"]], x = 1, y = 1", "output": "4", "explanation": "The full 2 x 2 frame is black."}], "hints": ["The answer is (lowest black row .. highest) times (leftmost .. rightmost black column).", "One linear scan of the picture suffices to find those four extremes.", "The given (x, y) only guarantees a black pixel exists; the bounds still come from the whole picture."], "statement": "A binary picture is given as rows of `'0'` (white) and `'1'` (black) characters holding at\nleast one black pixel; all black pixels link together through shared sides. You are also\ngiven the coordinates `(x, y)` of one black pixel. Return the area of the smallest\naxis-aligned rectangle that covers every black pixel.\n\n**Constraints:**\n- `1 <= m, n <= 850`\n- `image[x][y] == '1'`.\n- The picture contains at least one `'1'`, all linked 4-directionally.\n", "solution": "## Approach\n\nScan every cell once, tracking the extreme black rows and columns; the enclosing area is height times width of that bounding box.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m x n)\n- **Space Complexity:** O(1)\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def minArea(self, image: List[List[str]], x: int, y: int) -> int:\n top = bottom = x\n left = right = y\n for i, row in enumerate(image):\n for j, c in enumerate(row):\n if c == '1':\n top, bottom = min(top, i), max(bottom, i)\n left, right = min(left, j), max(right, j)\n return (bottom - top + 1) * (right - left + 1)\n```\n", "starter": {"go": "package main\n\nfunc MinArea(image [][]byte, x int, y int) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def minArea(self, image: List[List[str]], x: int, y: int) -> int:\n ", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int minArea(vector<vector<char>>& image, int x, int y) {\n return 0;\n }\n};"}, "fn": "minArea", "params": [{"name": "image", "type": "char_array_2d"}, {"name": "x", "type": "int"}, {"name": "y", "type": "int"}], "outputType": "int", "tests": [["[[\"0\",\"0\",\"1\",\"0\"],[\"0\",\"1\",\"1\",\"0\"],[\"0\",\"1\",\"0\",\"0\"]]", "0", "2"], ["[[\"1\"]]", "0", "0"], ["[[\"1\",\"1\"],[\"1\",\"1\"]]", "1", "1"], ["[[\"0\",\"1\",\"0\"],[\"0\",\"1\",\"0\"]]", "0", "1"], ["[[\"1\",\"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\",\"0\"]]", "4", "3"], ["[[\"0\",\"0\"],[\"0\",\"0\"],[\"0\",\"0\"],[\"1\",\"0\"]]", "3", "0"], ["[[\"0\"],[\"0\"],[\"0\"],[\"0\"],[\"1\"]]", "4", "0"], ["[[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"1\",\"0\",\"0\"],[\"0\",\"1\",\"0\",\"0\"]]", "3", "1"], ["[[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"1\",\"1\"]]", "1", "2"], ["[[\"0\",\"1\"]]", "0", "1"], ["[[\"1\",\"1\",\"1\"],[\"1\",\"1\",\"1\"]]", "0", "0"], ["[[\"1\"],[\"1\"],[\"1\"]]", "2", "0"], ["[[\"1\"],[\"1\"],[\"1\"]]", "1", "0"], ["[[\"0\",\"0\"],[\"0\",\"1\"],[\"0\",\"1\"]]", "1", "1"], ["[[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"1\",\"1\",\"0\"],[\"0\",\"1\",\"1\",\"0\"]]", "1", "2"], ["[[\"0\",\"0\",\"0\",\"0\",\"1\"],[\"0\",\"0\",\"0\",\"0\",\"1\"],[\"0\",\"0\",\"0\",\"0\",\"0\"]]", "1", "4"], ["[[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"1\"],[\"0\",\"0\",\"0\",\"1\"],[\"0\",\"0\",\"0\",\"1\"],[\"0\",\"0\",\"0\",\"0\"]]", "2", "3"], ["[[\"1\",\"0\",\"0\",\"0\"]]", "0", "0"], ["[[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\"],[\"1\",\"0\",\"0\",\"0\"]]", "4", "0"], ["[[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"1\",\"0\"]]", "4", "2"], ["[[\"0\"],[\"1\"],[\"1\"],[\"0\"]]", "2", "0"], ["[[\"1\"],[\"1\"],[\"0\"]]", "1", "0"], ["[[\"1\",\"1\"]]", "0", "0"], ["[[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"1\",\"1\",\"0\"],[\"0\",\"1\",\"1\",\"0\"],[\"0\",\"0\",\"0\",\"0\"]]", "3", "2"], ["[[\"0\",\"0\"],[\"1\",\"1\"]]", "1", "0"], ["[[\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"1\"],[\"0\",\"0\",\"0\",\"1\"]]", "2", "3"], ["[[\"0\",\"0\",\"0\",\"0\",\"0\"],[\"0\",\"1\",\"1\",\"1\",\"0\"],[\"0\",\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\",\"0\"]]", "1", "3"], ["[[\"1\"]]", "0", "0"], ["[[\"0\",\"0\",\"1\",\"0\"],[\"0\",\"0\",\"0\",\"0\"]]", "0", "2"]], "expected": [6, 1, 4, 2, 1, 1, 1, 1, 2, 2, 1, 6, 3, 3, 2, 4, 2, 3, 1, 1, 1, 2, 2, 2, 4, 2, 2, 3, 1, 1], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "796", "slug": "smallest-rotation-with-highest-score", "id": 796, "title": "Smallest Rotation with Highest Score", "difficulty": "Hard", "category": "array", "link": "https://leetcode.com/problems/smallest-rotation-with-highest-score/", "examples": [{"input": "nums = [2,3,1,4,0]", "output": "3", "explanation": "Rotation 3 gives the unique top score of 4."}, {"input": "nums = [1,3,0,2,4]", "output": "0", "explanation": "Rotation 0 ties for the best score."}, {"input": "nums = [0]", "output": "0", "explanation": "Only one rotation exists."}], "hints": ["Each element contributes to a contiguous circular interval of rotations; add +1 over that interval with a difference array.", "For the element at index j with value v, the scoring rotations form the forward interval from j + 1 to j - v.", "Prefix-summing the difference array yields every score, then the first maximum is the answer."], "statement": "You are handed an array `nums` of length `n` where each entry satisfies `0 <= nums[i] < n`. Rotating left by `k` produces a new arrangement `rot` with `rot[i] = nums[(i + k) % n]`. The score of that rotation counts indices with `rot[i] <= i`.\n\nReturn the smallest rotation index `k` that achieves the highest possible score. If several rotations tie, pick the least `k`.\n\n**Constraints:**\n- `1 <= nums.length <= 2000`\n- `0 <= nums[i] < nums.length`\n", "solution": "## Approach\n\nFix an element originally at index `j` with value `v`; it scores exactly for those rotations whose shifted position is at least `v`. Those rotations form one circular interval from `j + 1` to `j - v`. Adding one over every such interval with a difference array and prefix-summing gives all scores, and the first index with the maximum wins.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), one interval update per element plus one scan.\n- **Space Complexity:** O(n) for the difference array.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def bestRotation(self, nums: List[int]) -> int:\n n = len(nums)\n if n == 0:\n return 0\n diff = [0] * (n + 1)\n for j, v in enumerate(nums):\n start = (j + 1) % n\n end = (j - v) % n\n if start <= end:\n diff[start] += 1\n diff[end + 1] -= 1\n else:\n diff[start] += 1\n diff[n] -= 1\n diff[0] += 1\n diff[end + 1] -= 1\n best = mx = cur = 0\n mx = -1\n for k in range(n):\n cur += diff[k]\n if cur > mx:\n mx = cur\n best = k\n return best\n```\n", "starter": {"go": "package main\n\nfunc BestRotation(nums []int) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def bestRotation(self, nums: List[int]) -> int:\n return 0", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int bestRotation(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "bestRotation", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[2, 3, 1, 4, 0]"], ["[1, 3, 0, 2, 4]"], ["[0]"], ["[0, 0]"], ["[1, 0]"], ["[0, 1]"], ["[1, 1, 1]"], ["[2, 2, 2]"], ["[0, 1, 2]"], ["[2, 1, 0]"], ["[3, 2, 1, 0]"], ["[0, 0, 0, 0]"], ["[1, 2, 3, 4, 0]"], ["[4, 3, 2, 1, 0]"], ["[0, 1, 2, 3, 4]"], ["[2, 0, 1]"], ["[1, 0, 2]"], ["[0, 2, 1]"], ["[5, 4, 3, 2, 1, 0]"], ["[0, 0, 1, 1, 2, 2]"], ["[3, 3, 3, 3]"], ["[4, 0, 1, 2, 3]"], ["[2, 3, 1, 4, 0, 5]"], ["[1]"], ["[0, 1, 2, 3, 4, 5, 6, 7]"], ["[7, 6, 5, 4, 3, 2, 1, 0]"], ["[3, 1, 2]"], ["[4, 4, 4, 4, 4]"]], "expected": [3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 4, 0, 0, 1, 0, 0, 1, 0, 0, 1, 4, 0, 0, 1, 0, 0], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "971", "slug": "smallest-string-starting-from-leaf", "id": 971, "title": "Smallest String Starting From Leaf", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/smallest-string-starting-from-leaf/", "examples": [{"input": "root = [0,1,2,3,4,3,4]", "output": "\"dba\"", "explanation": "Leaf-to-root strings include dba, eba and others; dba is the smallest."}, {"input": "root = [25,1,3,1,3,0,2]", "output": "\"adz\"", "explanation": "The covering leaf strings are compared; adz is minimal."}, {"input": "root = [2,2,1,null,1,0,null,0]", "output": "\"abc\"", "explanation": "Only a few root paths exist and abc is the smallest leaf-up spelling."}], "hints": ["Map node values 0..25 to letters a..z and read each root-to-leaf path backwards (leaf first).", "Depth-first search carrying the current root-to-leaf character path lets you build each candidate at the leaf.", "Keep the lexicographically smallest candidate across all leaves."], "statement": "Each node of the binary tree holds an integer `0` to `25`, encoding letters `a` to `z` (`0` is `a`, `25` is `z`).\n\nFor every leaf (a node with no children), write the letters along the path from that leaf up to the root, leaf first. Among all such leaf-to-root strings, return the lexicographically smallest one.\n\n**Constraints:**\n- `1 <= number of nodes <= 8500`\n- `0 <= node value <= 25`\n", "solution": "## Approach\n\nDo a depth-first walk carrying the root-to-leaf letters seen so far. At each leaf, reverse the accumulated path to obtain the leaf-to-root spelling and keep the smallest across leaves via lexicographic comparison. Backtracking restores the path for sibling subtrees.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n * h), where n is the node count and h is the height, due to reversing leaf paths.\n- **Space Complexity:** O(h) for recursion and the current path.\n\n## Implementation\n\n```python\nclass Solution:\n def smallestFromLeaf(self, root) -> str:\n self.best = None\n path = []\n def dfs(node):\n if not node:\n return\n path.append(chr(ord('a') + node.val))\n if not node.left and not node.right:\n cand = ''.join(reversed(path))\n if self.best is None or cand < self.best:\n self.best = cand\n else:\n dfs(node.left)\n dfs(node.right)\n path.pop()\n dfs(root)\n return self.best or ''\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 SmallestFromLeaf(root *TreeNode) string {\n \n}", "python": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, val=0, left=None, right=None):\n# self.val = val\n# self.left = left\n# self.right = right\nclass Solution:\n def smallestFromLeaf(self, root) -> 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 TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n string smallestFromLeaf(TreeNode* root) {\n return \"\";\n }\n};"}, "fn": "smallestFromLeaf", "params": [{"name": "root", "type": "tree_node"}], "outputType": "string", "tests": [["[0,1,2,3,4,3,4]"], ["[25,1,3,1,3,0,2]"], ["[2,2,1,null,1,0,null,0]"], ["[0]"], ["[25]"], ["[0,1]"], ["[1,0]"], ["[0,null,1]"], ["[2,1,0]"], ["[0,1,2]"], ["[3,2,1,0]"], ["[25,25,25]"], ["[0,0,0,0,0]"], ["[1,2,3,4,5,6,7]"], ["[7,6,5,4,3,2,1]"], ["[0,1,null,2,null,3]"], ["[2,null,1,null,0]"], ["[4,3,2,1,0]"], ["[0,5,5,1,1,1,1]"], ["[10,5,15,3,7,12,20]"], ["[25,1,null,0,null,2]"], ["[3,9,20,null,null,15,7]"], ["[1,2,3,4,null,null,5]"], ["[0,1,2,3,4,5,6,7,8,9,10,11,12,13]"], ["[5,4,3,2,1,0]"], ["[2,2,2,2,2]"], ["[13,12,11,10,9,8]"], ["[0,null,25,null,0,null,25]"]], "expected": ["dba", "adz", "abc", "a", "z", "ba", "ab", "ba", "ac", "ba", "acd", "zz", "aa", "ecb", "bfh", "dcba", "abc", "ade", "bfa", "dfk", "cabz", "hud", "ecb", "hdba", "adf", "cc", "iln", "zaza"], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "860", "slug": "smallest-subtree-with-all-the-deepest-nodes", "id": 860, "title": "Smallest Subtree with All the Deepest Nodes", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/", "examples": [{"input": "root = [3,5,1,6,2,0,8,null,null,7,4]", "output": "[2,7,4]", "explanation": "Deepest leaves 7 and 4 meet at 2."}, {"input": "root = [1]", "output": "[1]", "explanation": "Only one node."}, {"input": "root = [0,1,3,null,2]", "output": "[2]", "explanation": "Single deepest leaf 2."}], "hints": ["Depth of a subtree is one plus the larger of its children's depths; an empty child has depth zero.", "If the left and right depths match, the current node is the meeting point of the deepest leaves below it.", "Otherwise the answer lies entirely in the deeper side, so recurse there."], "statement": "You are given the root of a binary tree in level-order form. Among all nodes, look at those sitting at the greatest depth (the longest root-to-leaf distance).\n\nFind the smallest subtree that holds every such deepest node. Return the root of that subtree, again encoded in level-order form.\n\nIntuitively, walk down until the branches holding the deepest leaves finally meet; that meeting point is the answer.\n\n**Constraints:**\n- The tree holds `1 <= n <= 500` nodes.\n- `0 <= node.val <= 500`\n- All values are unique.\n", "solution": "## Approach\n\nReturn both the depth and the answer for each subtree. An empty spot has depth zero and no answer. For a node, compare the depths from its children: equal depths mean the current node is the lowest common holder of all deepest leaves, while an imbalance means the answer comes from the deeper side with depth increased by one.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the number of nodes. Each node is visited once.\n- **Space Complexity:** O(h) recursion depth, where h is the tree height.\n\n## Implementation\n\n```python\nclass Solution:\n def subtreeWithAllDeepest(self, root):\n def helper(n):\n if not n:\n return (None, 0)\n ln, ld = helper(n.left)\n rn, rd = helper(n.right)\n if ld == rd:\n return (n, ld + 1)\n if ld > rd:\n return (ln, ld + 1)\n return (rn, rd + 1)\n return helper(root)[0]\n```\n", "starter": {"go": "// Definition for a binary tree node.\n// type TreeNode struct {\n// Val int\n// Left *TreeNode\n// Right *TreeNode\n// }\npackage main\n\nfunc SubtreeWithAllDeepest(root *TreeNode) *TreeNode {\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\nclass Solution:\n def subtreeWithAllDeepest(self, root):\n pass", "cpp": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode* left, TreeNode* right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n TreeNode* subtreeWithAllDeepest(TreeNode* root) {\n return nullptr;\n }\n};"}, "fn": "subtreeWithAllDeepest", "params": [{"name": "root", "type": "tree_node"}], "outputType": "tree_node", "tests": [["[3,5,1,6,2,0,8,null,null,7,4]"], ["[1]"], ["[0,1,3,null,2]"], ["[1,2,3,4,5,6,7]"], ["[1,2,null,3]"], ["[1,null,2,null,3]"], ["[0,1,2]"], ["[0,3,1,4,null,2]"], ["[1,2,3,4,null,null,null,5]"], ["[10,5,15,3,7,12,20]"], ["[1,2,3,null,4,null,5]"], ["[0]"], ["[5,1,2,3,4]"], ["[1,2]"], ["[2,1]"], ["[1,2,3,4,5,null,6]"], ["[0,1,null,2,null,3]"], ["[3,1,4,null,2]"], ["[7,3,9,1,5,null,10]"], ["[1,null,2,3,4]"], ["[0,1,2,3,null,null,4]"], ["[100,50,150,25,75,125,175]"], ["[1,2,3,4,5,6,null]"], ["[9,8,7,6,5]"], ["[1,2,3,null,null,4,5]"], ["[0,2,1,3,null,null,null,4]"], ["[11,10,12,9,null,null,13]"], ["[1,2,3,4,null,5,6,null,null,7]"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "898", "slug": "snakes-and-ladders", "id": 898, "title": "Snakes and Ladders", "difficulty": "Medium", "category": "graph", "link": "https://leetcode.com/problems/snakes-and-ladders/", "examples": [{"input": "board = [[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,35,-1,-1,13,-1],[-1,-1,-1,-1,-1,-1],[-1,15,-1,-1,-1,-1]]", "output": "4", "explanation": "Climb the ladder from square 2 to 15, then advance and ride the remaining jumps to reach square 36 in 4 throws."}, {"input": "board = [[-1,-1],[-1,3]]", "output": "1", "explanation": "Roll from square 1 to square 2, whose ladder leads directly to square 4."}, {"input": "board = [[-1,-1,-1],[-1,-1,-1],[-1,-1,-1]]", "output": "2", "explanation": "With no snakes or ladders, two throws of 6 reach square 9 (1 -> 7 -> 9)."}], "hints": ["Number the squares from 1 at the bottom-left, snaking back and forth each row, so every cell maps to exactly one square.", "From each square the reachable squares are the next 1 to 6 labels (capped at n squared), following any snake or ladder immediately.", "Breadth-first search over squares gives the fewest throws; return -1 when the last square is never reached."], "statement": "An `n x n` board holds the squares numbered `1` to `n * n`. Numbering starts at the bottom-left corner with `1`, runs left to right across the bottom row, then continues right to left on the row above, alternating direction on every row (boustrophedon order).\n\nEach cell is either `-1` (nothing happens there) or the number of a destination square: landing on it via a die throw forces an immediate jump to that destination (a ladder when the destination is larger, a snake when it is smaller). You start on square `1`. Each throw lets you pick any of the next 1 to 6 squares ahead (never past `n * n`); if the chosen square holds a jump, you take it at once. Return the smallest number of throws needed to land exactly on square `n * n`, or `-1` if it cannot be reached.\n\n**Constraints:**\n- `n == board.length == board[i].length`\n- `2 <= n <= 20`\n- `board[i][j]` is `-1` or an integer in `[1, n * n]`\n", "solution": "## Approach\n\nLabel every cell with its square number by walking rows from the bottom, flipping the column direction on alternate rows. From a square, each die outcome leads to one of the following six labels (clamped to the final square), with snakes and ladders applied instantly. Since every throw costs the same, breadth-first search from square 1 yields the minimum throw count, and an unvisited final square means it is unreachable.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^2), each square is enqueued at most once with up to 6 transitions.\n- **Space Complexity:** O(n^2) for the distance table and queue.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import deque\nclass Solution:\n def snakesAndLadders(self, board: List[List[int]]) -> int:\n n = len(board)\n target = n * n\n def coords(s: int):\n q, r = divmod(s - 1, n)\n row = n - 1 - q\n col = r if q % 2 == 0 else n - 1 - r\n return row, col\n dist = {1: 0}\n dq = deque([1])\n while dq:\n cur = dq.popleft()\n if cur == target:\n return dist[cur]\n for nxt in range(cur + 1, min(cur + 6, target) + 1):\n r, c = coords(nxt)\n dest = board[r][c] if board[r][c] != -1 else nxt\n if dest not in dist:\n dist[dest] = dist[cur] + 1\n dq.append(dest)\n return -1\n```\n", "starter": {"go": "package main\n\nfunc SnakesAndLadders(board [][]int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def snakesAndLadders(self, board: List[List[int]]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int snakesAndLadders(vector<vector<int>>& board) {\n return 0;\n }\n};"}, "fn": "snakesAndLadders", "params": [{"name": "board", "type": "int_array_2d"}], "outputType": "int", "tests": [["[[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,35,-1,-1,13,-1],[-1,-1,-1,-1,-1,-1],[-1,15,-1,-1,-1,-1]]"], ["[[-1,-1],[-1,3]]"], ["[[-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, -1, -1]]"], ["[[-1, -1, 13, -1, -1, -1], [-1, -1, -1, 36, -1, -1], [-1, -1, -1, -1, -1, 31], [-1, -1, 9, 30, 25, 13], [-1, -1, 34, 3, 14, -1], [24, 15, 5, -1, 25, -1]]"], ["[[-1, -1, -1], [4, 7, -1], [-1, -1, -1]]"], ["[[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]"], ["[[-1, -1, -1, -1], [14, -1, -1, -1], [-1, 1, -1, 9], [-1, -1, -1, -1]]"], ["[[-1, 4], [-1, -1]]"], ["[[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]"], ["[[-1, -1, -1], [-1, -1, -1], [-1, 1, -1]]"], ["[[-1, -1], [-1, 4]]"], ["[[-1, -1, 4, -1], [-1, -1, -1, -1], [12, -1, -1, 3], [-1, -1, 5, 10]]"], ["[[-1, -1, -1, -1, 17, 10], [-1, -1, 29, 16, -1, -1], [-1, -1, -1, -1, -1, 27], [-1, 18, -1, -1, -1, -1], [-1, -1, -1, 5, 30, -1], [-1, 19, -1, 24, -1, 17]]"], ["[[-1, -1, -1, 16], [-1, -1, -1, -1], [11, -1, 11, 1], [-1, 14, -1, -1]]"], ["[[8, -1, -1], [5, -1, -1], [-1, -1, -1]]"], ["[[-1, -1], [-1, -1]]"], ["[[-1, 29, -1, 8, -1, 17], [-1, -1, -1, -1, -1, 23], [34, -1, 29, -1, -1, -1], [-1, -1, -1, 2, -1, -1], [19, -1, 14, -1, -1, -1], [-1, 9, 35, -1, -1, -1]]"], ["[[-1, 6, -1, 11], [-1, -1, 8, 9], [-1, -1, 3, -1], [13, -1, 14, -1]]"], ["[[4, -1, -1], [8, -1, 2], [5, -1, -1]]"], ["[[-1, -1, -1], [-1, -1, -1], [-1, 6, 1]]"], ["[[-1, 6, -1], [7, -1, -1], [-1, -1, -1]]"], ["[[-1, -1, -1], [-1, 3, -1], [-1, 4, -1]]"], ["[[-1, 13, -1, 5, -1], [-1, -1, -1, -1, 11], [-1, -1, 23, 3, 21], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]"], ["[[-1, 4, -1], [-1, 4, -1], [-1, -1, -1]]"], ["[[-1, -1, -1], [-1, -1, 8], [-1, 1, -1]]"], ["[[-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-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": [4, 1, 2, -1, 2, 2, 2, 4, 3, 1, 3, 2, 1, 2, 3, 2, 2, 1, 2, 2, 2, 2, 2, 2, 3, 2, 2, 6], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "662", "slug": "solve-the-equation", "id": 662, "title": "Solve the Equation", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/solve-the-equation/", "examples": [{"input": "equation = \"x+5-3+x=6+x-2\"", "output": "\"x=2\"", "explanation": "The left side groups to 2x+2 and the right side to x+4, so x = 2."}, {"input": "equation = \"x=x\"", "output": "\"Infinite solutions\""}, {"input": "equation = \"2x=x\"", "output": "\"x=0\""}], "hints": ["Parse each side separately into (x-coefficient, constant) by scanning sign by sign.", "A missing number before x means 1; a lone sign before x means +1 or -1.", "Move everything to one side: (lc - rc) * x = rconst - lconst, then branch on a zero coefficient."], "statement": "You get a string equation with exactly one `=` sign, for example `\"x+5-3+x=6+x-2\"`. Each side is a sum of integer constants and `x` terms such as `\"2x\"`, `\"-x\"`, or `\"x\"`. There are no parentheses and no powers.\n\nSolve for `x` and implement `solveEquation(equation)`:\n\n- If exactly one integer solution exists, return `\"x=<value>\"`, e.g. `\"x=2\"`.\n- If every integer satisfies the equation, return `\"Infinite solutions\"`.\n- If no value satisfies it, return `\"No solution\"`.\n\n**Constraints:**\n- `3 <= equation.length <= 1000`\n- The equation holds digits, `x`, `+`, `-`, and exactly one `=`.\n- Every term is valid; a bare `x` means coefficient 1 and `-x` means -1.\n- If a unique solution exists, it fits in a 32-bit signed integer.\n", "solution": "## Approach\n\nSplit the equation at `=` and fold each side into a pair of (x coefficient, constant) with a single left-to-right scan that tracks the current sign. A digit run followed by `x` adds to the coefficient (defaulting to 1 when no digits precede it); otherwise it adds to the constant. Subtracting the right pair from the left pair reduces the problem to `cx * x = cc`, which yields the three answer shapes directly.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the equation length. Each character is visited once.\n- **Space Complexity:** O(1) beyond the input.\n\n## Implementation\n\n```python\nclass Solution:\n def solveEquation(self, equation: str) -> str:\n def parse(s):\n coeff = con = i = 0\n n = len(s)\n while i < n:\n sign = 1\n if s[i] == \"+\":\n i += 1\n elif s[i] == \"-\":\n sign = -1\n i += 1\n num, has = 0, False\n while i < n and s[i].isdigit():\n num = num * 10 + int(s[i])\n i += 1\n has = True\n if i < n and s[i] == \"x\":\n coeff += sign * (num if has else 1)\n i += 1\n else:\n con += sign * num\n return coeff, con\n left, right = equation.split(\"=\")\n lc, lcon = parse(left)\n rc, rcon = parse(right)\n cx, cc = lc - rc, rcon - lcon\n if cx == 0:\n return \"Infinite solutions\" if cc == 0 else \"No solution\"\n return f\"x={cc // cx}\"\n```\n", "starter": {"go": "package main\n\nfunc SolveEquation(equation string) string {\n return \"\"\n}", "python": "from typing import List\nclass Solution:\n def solveEquation(self, equation: str) -> str:\n pass", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n string solveEquation(string equation) {\n return \"\";\n }\n};"}, "fn": "solveEquation", "params": [{"name": "equation", "type": "string"}], "outputType": "string", "tests": [["x+5-3+x=6+x-2"], ["x=x"], ["2x=x"], ["x=x+1"], ["2x+3x-6x=x+2"], ["3x=33+22+11"], ["-x=-1"], ["x+1=x+1"], ["2x+1=2x+1"], ["2x+1=2x+2"], ["0x=0"], ["0x=1"], ["x-1=2"], ["2-x=0"], ["10x-5=5"], ["x-5x+3=7"], ["100=10x"], ["-2x+4=0"], ["x+100=200"], ["99x=99"], ["1+1=x"], ["2=x"], ["x=2"], ["3x+2=11"], ["-x+5=3"], ["4x-8=12"], ["7=7"], ["8=9"]], "expected": ["x=2", "Infinite solutions", "x=0", "No solution", "x=-1", "x=22", "x=1", "Infinite solutions", "Infinite solutions", "No solution", "Infinite solutions", "No solution", "x=3", "x=2", "x=1", "x=-1", "x=10", "x=2", "x=100", "x=1", "x=2", "x=2", "x=2", "x=3", "x=2", "x=5", "Infinite solutions", "No solution"], "loose": false}