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": "448", "slug": "plus-one-linked-list", "id": 448, "title": "Plus One Linked List", "difficulty": "Medium", "category": "linked-list", "link": "https://leetcode.com/problems/plus-one-linked-list/", "examples": [{"input": "head = [1,2,3]", "output": "[1,2,4]", "explanation": "123 + 1 = 124."}, {"input": "head = [9,9]", "output": "[1,0,0]", "explanation": "99 + 1 = 100."}, {"input": "head = [0]", "output": "[1]", "explanation": "0 + 1 = 1."}], "hints": ["Find the rightmost digit that is not 9; it absorbs the carry.", "If no such digit exists, prepend a new node with value 1 and set the rest to 0.", "Otherwise increment that digit and set every digit after it to 0."], "statement": "Add one to a number stored digit-by-digit in forward order in a linked list.\n\nEach node of the singly linked list holds one decimal digit, with the most significant digit at the head. Interpret the whole chain as a non-negative integer without leading zeros (except the single digit `0` itself) and return the head of the list that represents the value plus one. The length may grow by one digit when every digit rolls over, for example `[9,9]` becoming `[1,0,0]`.\n\n**Constraints:**\n- `1 <= number of nodes <= 100`\n- `0 <= Node.val <= 9`\n- The digits contain no leading zeros except the number zero itself.\n", "solution": "## Approach\n\nScan for the rightmost non-nine digit. When one exists, bump it by one and zero out its suffix; the prefix stays untouched. When every digit is nine, place a fresh leading one in front and turn the whole tail to zeros.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the number of nodes, for the right-to-left carry pass.\n- **Space Complexity:** O(1) extra besides the possible new head node (O(n) with a recursive carry).\n\n## Implementation\n\n```python\nclass Solution:\n def plusOne(self, head):\n carry = self._add(head)\n if carry:\n n = ListNode(1)\n n.next = head\n return n\n return head\n\n def _add(self, node):\n if node is None:\n return 1\n c = self._add(node.next)\n s = node.val + c\n node.val = s % 10\n return s // 10\n```\n", "starter": {"go": "package main\n\n/*\nDefinition for singly-linked list.\ntype ListNode struct {\n Val int\n Next *ListNode\n}\n*/\n\nfunc PlusOne(head *ListNode) *ListNode {\n return nil\n}", "python": "# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\n\nclass Solution:\n def plusOne(self, head):\n pass\n", "cpp": "/*\nstruct ListNode {\n int val;\n ListNode *next;\n ListNode(): val(0), next(nullptr) {}\n ListNode(int x): val(x), next(nullptr) {}\n ListNode(int x, ListNode* next): val(x), next(next) {}\n};\n*/\nclass Solution {\npublic:\n ListNode* plusOne(ListNode* head) {\n return nullptr;\n }\n};"}, "fn": "plusOne", "params": [{"name": "head", "type": "list_node"}], "outputType": "list_node", "tests": [["[1,2,3]"], ["[9,9]"], ["[0]"], ["[9]"], ["[1]"], ["[8,9,9]"], ["[9,8,9]"], ["[1,9,9,9]"], ["[9,9,9]"], ["[9,9,9,9]"], ["[1,0,0,0]"], ["[2,7,4]"], ["[5]"], ["[1,2,9]"], ["[9,0,9]"], ["[1,1,1,1]"], ["[7,9,9,9,9]"], ["[4,9,3,9]"], ["[9,9,0,9]"], ["[3,2,1]"], ["[6,6,6,9]"], ["[1,9]"], ["[8,9]"], ["[9,1]"], ["[2,9,9,9,9,9]"], ["[5,4,3,2,1]"], ["[9,9,9,9,9,9]"], ["[1,0,9]"], ["[4,5,6,7,8]"], ["[1,0]"], ["[9,0,0,9]"], ["[2,0,0,0,9]"]], "expected": [[1, 2, 4], [1, 0, 0], [1], [1, 0], [2], [9, 0, 0], [9, 9, 0], [2, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 1], [2, 7, 5], [6], [1, 3, 0], [9, 1, 0], [1, 1, 1, 2], [8, 0, 0, 0, 0], [4, 9, 4, 0], [9, 9, 1, 0], [3, 2, 2], [6, 6, 7, 0], [2, 0], [9, 0], [9, 2], [3, 0, 0, 0, 0, 0], [5, 4, 3, 2, 2], [1, 0, 0, 0, 0, 0, 0], [1, 1, 0], [4, 5, 6, 7, 9], [1, 1], [9, 0, 1, 0], [2, 0, 0, 1, 0]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "146", "slug": "plus-one", "id": 146, "title": "Plus One", "difficulty": "Easy", "category": "math", "link": "https://leetcode.com/problems/plus-one/", "examples": [{"input": "digits = [1,2,3]", "output": "[1,2,4]", "explanation": "Adding 1 to [1, 2, 3] gives [1, 2, 4]."}, {"input": "digits = [4,3,2,1]", "output": "[4,3,2,2]", "explanation": "Adding 1 to [4, 3, 2, 1] gives [4, 3, 2, 2]."}, {"input": "digits = [9,9]", "output": "[1,0,0]", "explanation": "Adding 1 to 99 produces 100."}], "hints": ["Process the digits from right to left, just as in elementary addition.", "Stop as soon as a digit is smaller than 9; otherwise turn each trailing 9 into 0.", "If every digit was 9, return a new array one element longer with a leading 1."], "statement": "You are given a nonempty array of decimal digits representing a nonnegative integer. The most significant digit is first, and the representation has no leading zero unless the number itself is zero.\n\nAdd one to the integer and return its digit array. Do not convert the entire input to a built-in integer type, because the array may represent a value larger than that type can hold.\n\n**Constraints:**\n- `1 <= digits.length <= 100`\n- `0 <= digits[i] <= 9`\n- `digits` has no leading zero unless it is exactly `[0]`\n", "solution": "## Approach\n\nCopy the input and scan its digits from right to left. Increment the first digit smaller than `9`; every trailing `9` becomes `0` while the carry continues. If every digit was `9`, prepend a new leading `1`.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the number of digits.\n- **Space Complexity:** O(n) for the returned digit array.\n\n## Implementation\n\n```python\nfrom typing import List\n\n\nclass Solution:\n def plusOne(self, digits: List[int]) -> List[int]:\n result = digits[:]\n for index in range(len(result) - 1, -1, -1):\n if result[index] < 9:\n result[index] += 1\n return result\n result[index] = 0\n return [1] + result\n```\n", "starter": {"go": "package main\n\nfunc PlusOne(digits []int) []int {\n return []int{}\n}", "python": "from typing import List\n\nclass Solution:\n def plusOne(self, digits: List[int]) -> List[int]:\n return []\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<int> plusOne(vector<int>& digits) {\n return {};\n }\n};"}, "fn": "plusOne", "params": [{"name": "digits", "type": "int_array"}], "outputType": "int_array", "tests": [["[0]"], ["[1]"], ["[2]"], ["[3]"], ["[4]"], ["[5]"], ["[6]"], ["[7]"], ["[8]"], ["[9]"], ["[1,0]"], ["[1,1]"], ["[1,8]"], ["[1,9]"], ["[2,9]"], ["[5,0]"], ["[5,9]"], ["[8,9]"], ["[9,0]"], ["[9,9]"], ["[1,0,0]"], ["[1,0,9]"], ["[1,2,3]"], ["[1,9,9]"], ["[2,9,9]"], ["[4,3,2,1]"], ["[5,0,9]"], ["[8,9,9]"], ["[9,0,9]"], ["[9,9,9]"], ["[1,2,9,9]"], ["[1,9,9,9]"], ["[2,0,0,0]"], ["[2,9,9,9]"], ["[7,8,9,9]"], ["[8,9,9,9]"], ["[9,0,0,0]"], ["[9,9,0,9]"], ["[9,9,9,0]"], ["[9,9,9,9]"], ["[1,2,3,4,5]"], ["[1,2,3,9,9]"], ["[3,9,9,9,9]"], ["[8,0,8,0,9]"], ["[9,9,9,9,9]"], ["[1,2,3,4,5,6,7,8,9,0]"], ["[1,9,9,9,9,9,9,9,9,9]"], ["[8,9,9,9,9,9,9,9,9,9]"], ["[9,0,9,9,9,9,9,9,9,9]"], ["[9,9,9,9,9,9,9,9,9,9]"], ["[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]"], ["[9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9]"], ["[1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,9]"], ["[9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9]"], ["[2,1,4,7,4,8,3,6,4,7]"], ["[6,2,5,0,4,0,9,9,9,9,9]"], ["[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9]"], ["[7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]"], ["[3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6]"], ["[5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,9,9]"], ["@javascript:JSON.stringify([1,...Array(98).fill(9)])"], ["@javascript:JSON.stringify([1,...Array(99).fill(0)])"], ["@javascript:JSON.stringify(Array(100).fill(9))"]], "expected": [[1], [2], [3], [4], [5], [6], [7], [8], [9], [1, 0], [1, 1], [1, 2], [1, 9], [2, 0], [3, 0], [5, 1], [6, 0], [9, 0], [9, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 2, 4], [2, 0, 0], [3, 0, 0], [4, 3, 2, 2], [5, 1, 0], [9, 0, 0], [9, 1, 0], [1, 0, 0, 0], [1, 3, 0, 0], [2, 0, 0, 0], [2, 0, 0, 1], [3, 0, 0, 0], [7, 9, 0, 0], [9, 0, 0, 0], [9, 0, 0, 1], [9, 9, 1, 0], [9, 9, 9, 1], [1, 0, 0, 0, 0], [1, 2, 3, 4, 6], [1, 2, 4, 0, 0], [4, 0, 0, 0, 0], [8, 0, 8, 1, 0], [1, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1], [2, 0, 0, 0, 0, 0, 0, 0, 0, 0], [9, 0, 0, 0, 0, 0, 0, 0, 0, 0], [9, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0], [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, 0, 0], [2, 1, 4, 7, 4, 8, 3, 6, 4, 8], [6, 2, 5, 0, 4, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8], [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 7], [5, 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, 0, 0], [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "525", "slug": "poor-pigs", "id": 525, "title": "Poor Pigs", "difficulty": "Hard", "category": "math", "link": "https://leetcode.com/problems/poor-pigs/", "examples": [{"input": "buckets = 1000, minutesToDie = 15, minutesToTest = 60", "output": "5"}, {"input": "buckets = 4, minutesToDie = 15, minutesToTest = 15", "output": "2", "explanation": "With one round of testing each pig has 2 outcomes, and 2 pigs cover 2 * 2 = 4 buckets."}, {"input": "buckets = 4, minutesToDie = 15, minutesToTest = 30", "output": "2", "explanation": "Two rounds give each pig 3 outcomes, so 2 pigs cover 3 * 3 = 9 buckets, but 1 pig covers only 3."}], "hints": ["The number of full test rounds is `minutesToTest / minutesToDie` (integer division), so each pig distinguishes `rounds + 1` outcomes.", "Find the smallest `p` with `(rounds + 1)^p >= buckets`."], "statement": "There are `buckets` buckets of liquid, and exactly one of them is poisoned. A pig that drinks the poison dies `minutesToDie` minutes later; otherwise it survives. You have `minutesToTest` minutes in total, and within that window a pig can drink in several rounds: after each round you wait long enough to see which pigs die before the next round.\n\nWith `r` full rounds available, one pig can distinguish `r + 1` different outcomes (dying in round 1, 2, ..., `r`, or surviving everything). With `p` pigs the number of distinguishable outcomes multiplies to `(r + 1)^p`.\n\nReturn the smallest number of pigs needed to guarantee finding the poisoned bucket in time.\n\n**Constraints:**\n- `1 <= buckets <= 1000`\n- `1 <= minutesToDie, minutesToTest <= 100`\n", "solution": "## Approach\n\nCompute the number of full rounds as integer division of the total time by the time to die. Each pig then has `rounds + 1` observable outcomes, and `p` pigs jointly cover `(rounds + 1)^p` buckets. Grow the pig count until the coverage reaches the number of buckets; that count is minimal because any smaller count covers fewer buckets.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(p), where p is the answer (a handful of multiplications).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def poorPigs(self, buckets: int, minutesToDie: int, minutesToTest: int) -> int:\n states = minutesToTest // minutesToDie + 1\n pigs = 0\n coverage = 1\n while coverage < buckets:\n pigs += 1\n coverage *= states\n return pigs\n```\n", "starter": {"go": "package main\n\nfunc PoorPigs(buckets int, minutesToDie int, minutesToTest int) int {\n \n}", "python": "class Solution:\n def poorPigs(self, buckets: int, minutesToDie: int, minutesToTest: int) -> int:\n pass", "cpp": "class Solution {\npublic:\n int poorPigs(int buckets, int minutesToDie, int minutesToTest) {\n return 0;\n }\n};"}, "fn": "poorPigs", "params": [{"name": "buckets", "type": "int"}, {"name": "minutesToDie", "type": "int"}, {"name": "minutesToTest", "type": "int"}], "outputType": "int", "tests": [["1000", "15", "60"], ["4", "15", "15"], ["4", "15", "30"], ["1", "15", "15"], ["2", "15", "15"], ["3", "15", "15"], ["8", "15", "15"], ["9", "15", "15"], ["25", "15", "60"], ["125", "12", "60"], ["1000", "12", "60"], ["1000", "15", "15"], ["5", "10", "100"], ["100", "10", "100"], ["27", "15", "45"], ["8", "15", "30"], ["16", "15", "30"], ["100", "15", "60"], ["1000", "10", "100"], ["500", "20", "60"], ["81", "15", "60"], ["10", "10", "10"], ["32", "10", "10"], ["64", "15", "30"], ["1000", "1", "100"], ["1", "1", "1"], ["2", "1", "1"], ["1000", "50", "100"]], "expected": [5, 2, 2, 0, 1, 2, 3, 4, 2, 3, 4, 10, 1, 2, 3, 2, 3, 3, 3, 5, 3, 4, 5, 4, 2, 0, 1, 7], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "294", "slug": "populating-next-right-pointers-in-each-node-ii", "id": 294, "title": "Populating Next Right Pointers in Each Node II", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/", "examples": [{"input": "root = [1,2,3,4,5,null,7]", "output": "[1,2,3,4,5,null,7]", "explanation": "Row 2 links 2 -> 3 and row 3 links 4 -> 5 -> 7; the serialized shape is unchanged."}, {"input": "root = []", "output": "[]", "explanation": "Nothing to link."}], "hints": ["Breadth-first search links each row regardless of missing children.", "A constant-space method chains the next row using a dummy head while walking the current row via established links.", "Adaptation: the original Node type carries a next pointer which this judge does not model; return the same tree and the checker confirms its values and shape are preserved."], "statement": "Extend neighbor linking to any binary tree, not just perfect ones.\n\nFor every node, imagine an arrow to the closest node on the same depth to its right (or nothing if it is the row's last node). Fill in all such arrows level by level and return the root.\n\n**Constraints:**\n- `0 <= number of nodes <= 6000`\n- `-100 <= Node.val <= 100`\n\n**Adaptation note:** The original statement uses a `Node` type with `left`, `right`, and `next` fields. This judge models only `TreeNode` (`val`, `left`, `right`); neighbor links cannot be serialized, so solutions return the same tree and grading verifies that values and structure are preserved.\n", "solution": "## Approach\n\nA queue-based level walk handles arbitrary shapes: each row is processed left to right, which matches the desired neighbor order even when children are missing. In the full `Node` version each node (except the row tail) would be assigned its queue successor as `next`. Here the `TreeNode` lacks that field, so the walk simply visits rows and returns the root, keeping values and links intact.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), one queue visit per node.\n- **Space Complexity:** O(n) with a queue (O(1) with the dummy-head chaining technique).\n\n## Implementation\n\n```python\nfrom collections import deque\nclass Solution:\n def connect(self, root):\n # Adaptation: TreeNode has no `next` field; walk levels and return root.\n if not root:\n return None\n q = deque([root])\n while q:\n for _ in range(len(q)):\n n = q.popleft()\n # In Node formulation: n.next = next node in row or None\n if n.left:\n q.append(n.left)\n if n.right:\n q.append(n.right)\n return root\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 Connect(root *TreeNode) *TreeNode {\n \n}", "python": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, val=0, left=None, right=None):\n# self.val = val\n# self.left = left\n# self.right = right\n\nclass Solution:\n def connect(self, root):\n pass\n", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\nclass Solution {\npublic:\n TreeNode* connect(TreeNode* root) {\n \n }\n};"}, "fn": "connect", "params": [{"name": "root", "type": "tree_node", "visualizeType": "tree_node"}], "outputType": "tree_node", "tests": [["[1,2,3,4,5,null,7]"], ["[]"], ["[1]"], ["[1,2,3,4,5,6,7]"], ["[1,2,null,3,4]"], ["[1,2,3,4,null,null,5]"], ["[3,9,20,null,null,15,7]"], ["[1,null,2,3,4]"], ["[2,1,3]"], ["[1,2,3,4,5]"], ["[5,4,6,3,null,null,7]"], ["[10,5,15,2,7,12,20]"], ["[1,null,2,null,3,null,4]"], ["[4,2,6,1,3,5,7]"], ["[0]"], ["[-5,-10,0]"], ["[100,50,150,25,75]"], ["[7,3,10,2,5,null,12]"], ["[6,3,9,1,4,8,10]"], ["[2,null,3,null,4,null,5]"], ["[8,3,10,1,6,null,14]"], ["[5,null,4,null,3,null,2]"], ["[1,2,3,4,null,null,5,6]"], ["[9,5,12,3,7,10,15]"], ["[15,10,20,8,12,17,25]"], ["[1,2,3,null,4,null,5]"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "293", "slug": "populating-next-right-pointers-in-each-node", "id": 293, "title": "Populating Next Right Pointers in Each Node", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/populating-next-right-pointers-in-each-node/", "examples": [{"input": "root = [1,2,3,4,5,6,7]", "output": "[1,2,3,4,5,6,7]", "explanation": "Every level is fully filled; after linking, nodes on each row point left-to-right and the structure serializes unchanged."}, {"input": "root = []", "output": "[]", "explanation": "Nothing to link."}], "hints": ["Process the tree one level at a time; within a level link each node to its successor.", "Because the tree is perfect, each parent connects its two children and bridges the right child to the next parent's left child.", "Breadth-first search with a queue solves it generally; a constant-space walk can reuse already-built links.", "Adaptation: the original Node type carries a next pointer which this judge does not model; return the same tree and the checker confirms its values and shape are preserved."], "statement": "Consider a perfect binary tree \u2014 every interior node has two children and all leaves sit on the same depth. Conceptually, each node should gain a link to its nearest neighbor on the same level (or nothing at the row end).\n\nLink every level left-to-right using these neighbor pointers, ideally reusing constant extra space by walking the already-linked upper row. Return the root afterwards.\n\n**Constraints:**\n- `0 <= number of nodes <= 2^12 - 1`\n- `-1000 <= Node.val <= 1000`\n- The input is a perfect binary tree.\n\n**Adaptation note:** The original statement uses a `Node` type with `left`, `right`, and `next` fields. This judge models only `TreeNode` (`val`, `left`, `right`); neighbor links cannot be serialized, so solutions return the same tree and grading verifies that values and structure are preserved. Document your level-linking logic in comments.\n", "solution": "## Approach\n\nBreadth-first search visits each level left to right, which is exactly the order neighbor links would follow. In the full `Node` formulation each dequeued node (except the last in its row) would point to the next queued node, and the row's last node would point to null; parents in a perfect tree additionally bridge their right child to the next parent's left child. Because this judge's `TreeNode` has no `next` field, the implementation performs the level walk and returns the root unchanged, preserving values and shape.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), one visit per node.\n- **Space Complexity:** O(n) with a queue (O(1) with the classic next-pointer walk on a perfect tree).\n\n## Implementation\n\n```python\nfrom collections import deque\nclass Solution:\n def connect(self, root):\n # Adaptation: TreeNode has no `next` field; walk levels and return root.\n if not root:\n return None\n q = deque([root])\n while q:\n for _ in range(len(q)):\n n = q.popleft()\n # In Node formulation: n.next = q[0] if same level remains else None\n if n.left:\n q.append(n.left)\n if n.right:\n q.append(n.right)\n return root\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 Connect(root *TreeNode) *TreeNode {\n \n}", "python": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, val=0, left=None, right=None):\n# self.val = val\n# self.left = left\n# self.right = right\n\nclass Solution:\n def connect(self, root):\n pass\n", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\nclass Solution {\npublic:\n TreeNode* connect(TreeNode* root) {\n \n }\n};"}, "fn": "connect", "params": [{"name": "root", "type": "tree_node", "visualizeType": "tree_node"}], "outputType": "tree_node", "tests": [["[1,2,3,4,5,6,7]"], ["[]"], ["[1,2,3]"], ["[1]"], ["[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]"], ["[5,4,6,3,null,null,7]"], ["[10,5,15,2,7,12,20]"], ["[4,2,6,1,3,5,7]"], ["[7,3,10,2,5,null,12]"], ["[6,3,9,1,4,8,10]"], ["[2,1,3]"], ["[0,-1,1]"], ["[1,2,3,4,5,6,7,8]"], ["[100,50,150,25,75,125,175]"], ["[8,3,10,1,6,null,14]"], ["[9,5,12,3,7,10,15]"], ["[15,10,20,8,12,17,25]"], ["[3,9,20,15,7]"], ["[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]"], ["[11,22,33,44,55,66,77]"], ["[1,2,3,4,5,6,7,8,9]"], ["[5,3,8,1,4,7,9]"], ["[2,1,3,4,5,6,7]"], ["[42]"], ["[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]"], ["[3,1,4,null,2]"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "828", "slug": "positions-of-large-groups", "id": 828, "title": "Positions of Large Groups", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/positions-of-large-groups/", "examples": [{"input": "s = \"abbxxxxzzy\"", "output": "[[3,6]]", "explanation": "Only the run of x's qualifies."}, {"input": "s = \"abc\"", "output": "[]", "explanation": "Every run has length 1."}, {"input": "s = \"abcdddeeeeaabbbcd\"", "output": "[[3,5],[6,9],[12,14]]"}], "hints": ["Walk the string once, tracking where the current run of equal letters started.", "A run ends when the next character differs or the string ends; record it only if its length is 3 or more.", "Pairs are naturally produced in increasing order, so no extra sorting is needed."], "statement": "Given a string `s` of lowercase letters, a large group is a maximal run of the same character with length at least 3. Maximal means the run cannot be extended on either side with the same letter. Return the start and end indices of every large group as `[start, end]` pairs in left-to-right order.\n\n**Constraints:**\n- `1 <= s.length <= 1000`\n- `s` consists of lowercase English letters only\n", "solution": "## Approach\n\nScan the string once while remembering where the current run of identical letters began. Whenever the next character differs (or the string ends), measure the run length and keep the [start, end] pair if it reaches 3. Because runs are found left to right, the collected pairs are already in the required order.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) where n is the string length.\n- **Space Complexity:** O(1) besides the output list.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def largeGroupPositions(self, s: str) -> List[List[int]]:\n ans = []\n n = len(s)\n start = 0\n for i in range(n + 1):\n if i == n or s[i] != s[start]:\n if i - start >= 3:\n ans.append([start, i - 1])\n start = i\n return ans\n```\n", "starter": {"go": "package main\n\nfunc LargeGroupPositions(s string) [][]int {\n \n}", "python": "from typing import List\nclass Solution:\n def largeGroupPositions(self, s: str) -> List[List[int]]:\n pass", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n vector<vector<int>> largeGroupPositions(string s) {\n return {};\n }\n};"}, "fn": "largeGroupPositions", "params": [{"name": "s", "type": "string"}], "outputType": "int_list_2d", "tests": [["abbxxxxzzy"], ["abc"], ["abcdddeeeeaabbbcd"], ["aaa"], ["aa"], ["a"], ["aaaa"], ["abbccc"], ["aaabbb"], ["aaabbbccc"], ["zzzzzzzzzz"], ["abcdefg"], ["aabbbcc"], ["abcdefffg"], ["nnnooopppqqq"], ["abbbcccddeeee"], ["xxxyyyzzz"], ["aabbccddeeffgg"], ["aaabaaa"], ["baaaab"], ["lll"], ["abbxxxxzzywww"], ["abcdddeeeeaabbbcdxxx"], ["qwerrrtyyyyuu"], ["mississippi"], ["aaabbbaaacccaaaddd"], ["abcdefghijklmnopqrstuvwxyz"], ["aabbbaaabbbbaaaabbbb"]], "expected": [[[3, 6]], [], [[3, 5], [6, 9], [12, 14]], [[0, 2]], [], [], [[0, 3]], [[3, 5]], [[0, 2], [3, 5]], [[0, 2], [3, 5], [6, 8]], [[0, 9]], [], [[2, 4]], [[5, 7]], [[0, 2], [3, 5], [6, 8], [9, 11]], [[1, 3], [4, 6], [9, 12]], [[0, 2], [3, 5], [6, 8]], [], [[0, 2], [4, 6]], [[1, 4]], [[0, 2]], [[3, 6], [10, 12]], [[3, 5], [6, 9], [12, 14], [17, 19]], [[3, 5], [7, 10]], [], [[0, 2], [3, 5], [6, 8], [9, 11], [12, 14], [15, 17]], [], [[2, 4], [5, 7], [8, 11], [12, 15], [16, 19]]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "877", "slug": "possible-bipartition", "id": 877, "title": "Possible Bipartition", "difficulty": "Medium", "category": "graph", "link": "https://leetcode.com/problems/possible-bipartition/", "examples": [{"input": "n = 4, dislikes = [[1,2],[1,3],[2,4]]", "output": "true", "explanation": "Put 1 and 4 in one group and 2 and 3 in the other; every rival pair is separated."}, {"input": "n = 3, dislikes = [[1,2],[1,3],[2,3]]", "output": "false", "explanation": "All three people pairwise dislike each other, so two groups can never separate every pair."}, {"input": "n = 5, dislikes = [[1,2],[2,3],[3,4],[4,5],[1,5]]", "output": "false", "explanation": "The rivalries form a ring of five, an odd cycle that no two-group split can satisfy."}], "hints": ["View rivalries as graph edges and paint the graph with two colors so neighbors always differ.", "Run BFS/DFS from every unpainted person; a neighbor that already wears the same color proves the split is impossible."], "statement": "There are `n` people numbered `1` to `n`. Each pair in `dislikes` holds two people who refuse to sit in the same group. Decide whether everyone can be split into two groups so that every rival pair lands in different groups.\n\nReturn `true` when such a split exists and `false` otherwise.\n\n**Constraints:**\n- `1 <= n <= 2000`\n- `1 <= dislikes.length <= 10^4`\n- `dislikes[i] = [a, b]` with `1 <= a, b <= n` and `a != b`\n", "solution": "## Approach\n\nTreat each rivalry as an undirected graph edge and try to paint every person one of two colors so that neighbors always differ. A BFS from each unpainted person assigns forced colors outward; reaching a neighbor that already carries the same color exposes an odd cycle and proves the answer false. If every component paints cleanly, the two color classes form a valid split.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n + E), where E is the number of rivalry pairs. Each person and edge is processed once.\n- **Space Complexity:** O(n + E) for the adjacency lists, colors, and queue.\n\n## Implementation\n\n```python\nfrom collections import deque\nfrom typing import List\n\nclass Solution:\n def possibleBipartition(self, n: int, dislikes: List[List[int]]) -> bool:\n g = [[] for _ in range(n + 1)]\n for a, b in dislikes:\n g[a].append(b)\n g[b].append(a)\n color = [0] * (n + 1)\n for i in range(1, n + 1):\n if color[i] != 0:\n continue\n color[i] = 1\n q = deque([i])\n while q:\n u = q.popleft()\n for v in g[u]:\n if color[v] == 0:\n color[v] = -color[u]\n q.append(v)\n elif color[v] == color[u]:\n return False\n return True\n```\n", "starter": {"go": "package main\n\nfunc PossibleBipartition(n int, dislikes [][]int) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def possibleBipartition(self, n: int, dislikes: List[List[int]]) -> bool:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool possibleBipartition(int n, vector<vector<int>>& dislikes) {\n return false;\n }\n};"}, "fn": "possibleBipartition", "params": [{"name": "n", "type": "int"}, {"name": "dislikes", "type": "int_array_2d"}], "outputType": "boolean", "tests": [["4", "[[1,2],[1,3],[2,4]]"], ["3", "[[1,2],[1,3],[2,3]]"], ["5", "[[1,2],[2,3],[3,4],[4,5],[1,5]]"], ["1", "[]"], ["2", "[[1,2]]"], ["2", "[]"], ["4", "[[1,2],[3,4]]"], ["4", "[[1,2],[2,3],[3,4],[4,1]]"], ["4", "[[1,2],[2,3],[3,1]]"], ["6", "[[1,2],[2,3],[3,4],[4,5],[5,6]]"], ["6", "[[1,2],[2,3],[3,4],[4,5],[5,6],[6,1]]"], ["5", "[[1,3],[2,4],[3,5],[1,5]]"], ["5", "[[1,2],[3,4]]"], ["7", "[[1,2],[2,3],[4,5],[5,6],[6,7]]"], ["3", "[]"], ["4", "[[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]"], ["6", "[[1,4],[1,5],[1,6],[2,4],[2,5],[2,6],[3,4],[3,5],[3,6]]"], ["6", "[[1,2],[1,3],[1,4],[1,5],[1,6]]"], ["8", "[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8]]"], ["8", "[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,1]]"], ["10", "[[1,2],[2,3],[1,3],[4,5],[5,6],[4,6]]"], ["10", "[[1,2],[3,4],[5,6],[7,8],[9,10]]"], ["9", "[[1,2],[2,3],[4,5],[5,6],[7,8],[8,9],[1,4],[4,7],[2,5],[5,8],[3,6],[6,9]]"], ["9", "[[1,2],[2,3],[4,5],[5,6],[7,8],[8,9],[1,4],[4,7],[2,5],[5,8],[3,6],[6,9],[1,5]]"], ["15", "[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11],[11,12],[12,13],[13,14],[14,15]]"], ["15", "[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11],[11,12],[12,13],[13,14],[14,15],[1,3]]"], ["20", "[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11],[11,12],[12,13],[13,14],[14,15],[15,16],[16,17],[17,18],[18,19],[19,20],[20,1]]"], ["20", "[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11],[11,12],[12,13],[13,14],[14,15],[15,16],[16,17],[17,18],[18,19],[19,1]]"]], "expected": [true, false, false, true, true, true, true, true, false, true, true, false, true, true, true, false, true, true, true, false, false, true, true, false, true, false, true, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "757", "slug": "pour-water", "id": 757, "title": "Pour Water", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/pour-water/", "examples": [{"input": "heights = [2,1,1,2,1,2,2], volume = 4, k = 3", "output": "[2,2,2,3,2,2,2]", "explanation": "Two left, one right, one stays."}, {"input": "heights = [1,2,3,4], volume = 2, k = 2", "output": "[2,3,3,4]", "explanation": "Both drift left."}, {"input": "heights = [3,1,3], volume = 5, k = 1", "output": "[4,4,4]", "explanation": "Dip fills then levels out."}], "hints": ["Handle units sequentially; each decision sees all previously placed water.", "To probe left, scan outward while heights do not rise and track the lowest position; only move when it beats the start level.", "Try the left side before the right side, and stay put when neither side improves."], "statement": "You are given terrain heights `heights`, a number of water units `volume`, and a drop index `k`.\n\nProcess the units one at a time. For each unit, decide where it settles by this rule. First look left: walk left while the level (terrain plus water already placed) never rises, and remember the leftmost lowest reachable spot. If that spot sits lower than the drop column, the unit rests there. Otherwise perform the mirror search to the right. If neither side offers a lower home, the unit stays at `k`. Each settled unit raises its column by one before the next unit falls.\n\nReturn the final levels after all units settle. The input array may be updated in place.\n\n**Constraints:**\n- `1 <= heights.length <= 100`\n- `0 <= heights[i] <= 99`\n- `0 <= volume <= 2000`\n- `0 <= k < heights.length`\n", "solution": "## Approach\n\nPour units one by one. For each unit, scan left while levels never rise, remembering the lowest reachable column; if it sits below the drop column, place the water there. Otherwise repeat the scan to the right. When neither side improves, raise the drop column itself. Updating levels immediately keeps later units aware of earlier ones.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(volume * n), where n is the terrain length, since each unit scans at most the whole array twice.\n- **Space Complexity:** O(1) besides the input array.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def pourWater(self, heights: List[int], volume: int, k: int) -> List[int]:\n n = len(heights)\n for _ in range(volume):\n best = k\n for i in range(k - 1, -1, -1):\n if heights[i] > heights[best]:\n break\n if heights[i] < heights[best]:\n best = i\n if best != k:\n heights[best] += 1\n continue\n best = k\n for i in range(k + 1, n):\n if heights[i] > heights[best]:\n break\n if heights[i] < heights[best]:\n best = i\n heights[best] += 1\n return heights\n```\n", "starter": {"go": "package main\n\nfunc PourWater(heights []int, volume int, k int) []int {\n return heights\n}", "python": "from typing import List\nclass Solution:\n def pourWater(self, heights: List[int], volume: int, k: int) -> List[int]:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<int> pourWater(vector<int>& heights, int volume, int k) {\n return {};\n }\n};"}, "fn": "pourWater", "params": [{"name": "heights", "type": "int_array"}, {"name": "volume", "type": "int"}, {"name": "k", "type": "int"}], "outputType": "int_array", "tests": [["[2,1,1,2,1,2,2]", "4", "3"], ["[1,2,3,4]", "2", "2"], ["[3,1,3]", "5", "1"], ["[1,2,3,4]", "0", "2"], ["[5]", "10", "0"], ["[0,0,0]", "3", "1"], ["[3,2,1]", "2", "0"], ["[1,2,3]", "2", "2"], ["[2,1,1,2,1,2,2]", "1", "3"], ["[2,1,1,2,1,2,2]", "0", "0"], ["[0]", "5", "0"], ["[4,4,4]", "3", "1"], ["[5,4,3,2,1]", "3", "4"], ["[1,2,1,2,1]", "4", "2"], ["[0,1,0]", "2", "1"], ["[2,2,2]", "2", "0"], ["[2,2,2]", "2", "2"], ["[1,0,2,1,0,1,3]", "5", "3"], ["[6,5,4,3,2,1]", "4", "0"], ["[1,2,3,4,5]", "5", "0"], ["[3,3,3,3]", "4", "2"], ["[0,2,0]", "4", "1"], ["[1,1,1,1]", "1", "1"], ["[4,1,4]", "3", "1"], ["[2,3,1,2]", "3", "1"], ["[0,0,5,0,0]", "6", "2"], ["[1,3,2]", "2", "1"], ["[2,1,2]", "3", "1"]], "expected": [[2, 2, 2, 3, 2, 2, 2], [2, 3, 3, 4], [4, 4, 4], [1, 2, 3, 4], [15], [1, 1, 1], [3, 3, 2], [2, 3, 3], [2, 1, 2, 2, 1, 2, 2], [2, 1, 1, 2, 1, 2, 2], [5], [5, 5, 5], [5, 4, 3, 3, 3], [2, 2, 3, 2, 2], [1, 1, 1], [3, 3, 2], [2, 3, 3], [2, 2, 2, 2, 1, 1, 3], [6, 5, 4, 4, 3, 3], [4, 4, 3, 4, 5], [4, 4, 4, 4], [2, 2, 2], [1, 2, 1, 1], [4, 4, 4], [3, 3, 3, 2], [3, 3, 5, 0, 0], [3, 3, 2], [3, 3, 2]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "425", "slug": "power-of-four", "id": 425, "title": "Power of Four", "difficulty": "Easy", "category": "math", "link": "https://leetcode.com/problems/power-of-four/", "examples": [{"input": "n = 16", "output": "true", "explanation": "16 is 4 squared."}, {"input": "n = 5", "output": "false", "explanation": "No integer exponent of 4 equals 5."}, {"input": "n = 1", "output": "true", "explanation": "4 to the power 0 is 1."}], "hints": ["A power of four is a power of two whose single set bit sits in an odd position.", "Check positivity, a single set bit, and divisibility of (n - 1) by 3."], "statement": "Given an integer `n`, decide whether it can be written as a power of four \u2014 that is, whether some non-negative integer `x` satisfies `n == 4^x` (1, 4, 16, 64, ...).\n\nReturn `true` for such values and `false` otherwise. Zero, negatives, and numbers with odd prime factors never qualify.\n\n**Constraints:**\n- `-2^31 <= n <= 2^31 - 1`\n", "solution": "## Approach\n\nA power of four must be positive and hold exactly one binary 1, which the classic `n & (n-1)` test confirms. Among powers of two, only those with the lone bit in an even slot (values 1, 4, 16, ...) are powers of four; these are precisely the powers of two one less than a multiple of three. Combining the three checks decides membership in constant time.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def isPowerOfFour(self, n: int) -> bool:\n return n > 0 and (n & (n - 1)) == 0 and (n - 1) % 3 == 0\n```\n", "starter": {"go": "package main\n\nfunc IsPowerOfFour(n int) bool {\n return false\n}", "python": "class Solution:\n def isPowerOfFour(self, n: int) -> bool:\n pass", "cpp": "class Solution {\npublic:\n bool isPowerOfFour(int n) {\n return false;\n }\n};"}, "fn": "isPowerOfFour", "params": [{"name": "n", "type": "int"}], "outputType": "boolean", "tests": [["16"], ["5"], ["1"], ["0"], ["2"], ["3"], ["4"], ["8"], ["32"], ["64"], ["256"], ["1024"], ["4096"], ["65536"], ["262144"], ["1048576"], ["1073741824"], ["-4"], ["-16"], ["-1"], ["6"], ["12"], ["15"], ["17"], ["20"], ["24"], ["48"], ["100"], ["2147483647"], ["-2147483648"]], "expected": [true, false, true, false, false, false, true, false, false, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "413", "slug": "power-of-three", "id": 413, "title": "Power of Three", "difficulty": "Easy", "category": "math", "link": "https://leetcode.com/problems/power-of-three/", "examples": [{"explanation": "27 equals 3 multiplied by itself 3 times.", "input": "n = 27", "output": "true"}, {"explanation": "No power of 3 equals 0.", "input": "n = 0", "output": "false"}, {"explanation": "Powers of 3 are positive, so -1 is impossible.", "input": "n = -1", "output": "false"}], "hints": ["Any power of 3 is positive, so non-positive inputs are immediately false.", "The largest power of 3 fitting in 32 bits is 3^19 = 1162261467, and every smaller power divides it.", "Alternatively divide out factors of 3 in a loop until the value is no longer divisible."], "statement": "Given an integer `n`, decide whether it can be written as `3` raised to some non-negative integer power (`1, 3, 9, 27, ...`). Return `true` when such an exponent exists and `false` otherwise.\n\n**Constraints:**\n- `-2^31 <= n <= 2^31 - 1`\n", "solution": "## Approach\n\nEvery power of 3 below 2^31 divides the largest one, 3^19 = 1162261467, and no other positive integer does. So the test reduces to checking positivity plus this single divisibility. Equivalently, one can repeatedly divide by 3 and see whether the remainder reaches 1.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def isPowerOfThree(self, n: int) -> bool:\n return n > 0 and 1162261467 % n == 0\n```\n", "starter": {"go": "package main\n\nfunc IsPowerOfThree(n int) bool {\n \n}", "python": "class Solution:\n def isPowerOfThree(self, n: int) -> bool:\n pass", "cpp": "class Solution {\npublic:\n bool isPowerOfThree(int n) {\n return false;\n }\n};"}, "fn": "isPowerOfThree", "params": [{"name": "n", "type": "int"}], "outputType": "boolean", "tests": [["27"], ["0"], ["-1"], ["1"], ["3"], ["9"], ["81"], ["243"], ["2"], ["4"], ["6"], ["8"], ["10"], ["12"], ["18"], ["45"], ["100"], ["1162261467"], ["387420489"], ["129140163"], ["2147483647"], ["-2147483648"], ["-3"], ["-9"], ["-27"], ["5"], ["7"], ["28"], ["59049"], ["1594323"]], "expected": [true, false, false, true, true, true, true, true, false, false, false, false, false, false, false, false, false, true, true, true, false, false, false, false, false, false, false, false, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "342", "slug": "power-of-two", "id": 342, "title": "Power of Two", "difficulty": "Easy", "category": "binary", "link": "https://leetcode.com/problems/power-of-two/", "examples": [{"input": "n = 1", "output": "true", "explanation": "2^0 equals 1."}, {"input": "n = 16", "output": "true", "explanation": "2^4 equals 16."}, {"input": "n = 3", "output": "false", "explanation": "No integer power of two equals 3."}], "hints": ["A positive power of two has exactly one bit set in binary.", "For n > 0, the expression (n & (n - 1)) == 0 detects a single set bit."], "statement": "Given an integer `n`, determine whether it is a power of two.\n\nAn integer is a power of two when some non-negative integer `x` satisfies `n == 2^x`. In binary this means exactly one bit is set and the value is positive.\n\nReturn `true` when `n` meets that definition, otherwise return `false`.\n\n**Constraints:**\n- `-2^31 <= n <= 2^31 - 1`\n", "solution": "## Approach\n\nA positive integer is a power of two exactly when its binary form contains a single set bit. Clearing the lowest set bit with `n & (n - 1)` leaves zero only in that case. Non-positive inputs can never qualify, so they return `False` immediately.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1), a constant number of bit operations.\n- **Space Complexity:** O(1), no extra storage.\n\n## Implementation\n\n```python\nclass Solution:\n def isPowerOfTwo(self, n: int) -> bool:\n return n > 0 and (n & (n - 1)) == 0\n```\n", "starter": {"go": "package main\n\nfunc IsPowerOfTwo(n int) bool {\n \n}", "python": "class Solution:\n def isPowerOfTwo(self, n: int) -> bool:\n pass", "cpp": "class Solution {\npublic:\n bool isPowerOfTwo(int n) {\n return false;\n }\n};"}, "fn": "isPowerOfTwo", "params": [{"name": "n", "type": "int"}], "outputType": "boolean", "tests": [["1"], ["16"], ["3"], ["0"], ["-1"], ["-16"], ["2"], ["4"], ["5"], ["8"], ["6"], ["1024"], ["1023"], ["1025"], ["1073741824"], ["2147483647"], ["-2147483648"], ["536870912"], ["536870911"], ["64"], ["32"], ["128"], ["256"], ["12"], ["7"], ["100"], ["2048"], ["2097152"], ["-2"], ["1073741823"]], "expected": [true, true, false, false, false, false, true, true, false, true, false, true, false, false, true, false, false, true, false, true, true, true, true, false, false, false, true, true, false, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "956", "slug": "powerful-integers", "id": 956, "title": "Powerful Integers", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/powerful-integers/", "examples": [{"input": "x = 2, y = 3, bound = 10", "output": "[2,3,4,5,7,9,10]", "explanation": "The sums 2^i + 3^j within bound are 2, 3, 4, 5, 7, 9 and 10 (order does not matter)."}, {"input": "x = 3, y = 5, bound = 15", "output": "[2,4,6,8,10,14]", "explanation": "Reachable sums are 2, 4, 6, 8, 10 and 14; everything else overshoots the bound."}, {"input": "x = 2, y = 1, bound = 10", "output": "[2,3,5,9]", "explanation": "Since 1^j is always 1, the sums are 2, 3, 5 and 9."}], "hints": ["Loop over powers of x and, nested inside, powers of y, keeping sums within bound.", "A base of 1 never grows \u2014 take its single power and move on to avoid an infinite loop.", "Deduplicate with a set; order is irrelevant to the judge."], "statement": "Call an integer powerful when it can be written as `x^i + y^j` for some non-negative integers `i` and `j`. Given `x`, `y` and `bound`, return every powerful integer that does not exceed `bound`, in increasing order, as an integer list. Any order is accepted by the judge.\n\n**Constraints:**\n- `1 <= x, y <= 100`\n- `0 <= bound <= 10^6`\n- The answers form an integer list.\n", "solution": "## Approach\n\nEnumerate all powers of x up to the bound, and for each enumerate all powers of y while the sum stays within the bound. Collect the sums in a set to drop duplicates, then sort. When x or y equals 1 its powers never grow, so stop after the first one to avoid looping forever. Only logarithmically many powers exist, so the double loop is tiny.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log^2 bound) power pairs.\n- **Space Complexity:** O(answer size) for the result set.\n\n## Implementation\n\n```python\nclass Solution:\n def powerfulIntegers(self, x: int, y: int, bound: int) -> list[int]:\n s = set()\n px = 1\n while px <= bound:\n py = 1\n while px + py <= bound:\n s.add(px + py)\n if y == 1:\n break\n py *= y\n if x == 1:\n break\n px *= x\n return sorted(s)\n```\n", "starter": {"go": "package main\n\nfunc PowerfulIntegers(x int, y int, bound int) []int {\n return nil\n}", "python": "from typing import List\nclass Solution:\n def powerfulIntegers(self, x: int, y: int, bound: int) -> List[int]:\n return []", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<int> powerfulIntegers(int x, int y, int bound) {\n return {};\n }\n};"}, "fn": "powerfulIntegers", "params": [{"name": "x", "type": "int"}, {"name": "y", "type": "int"}, {"name": "bound", "type": "int"}], "outputType": "int_list", "tests": [["2", "3", "10"], ["3", "5", "15"], ["2", "1", "10"], ["1", "1", "10"], ["1", "1", "0"], ["2", "2", "0"], ["100", "100", "1000000"], ["1", "2", "100"], ["2", "3", "0"], ["2", "3", "1"], ["2", "3", "2"], ["2", "3", "3"], ["2", "3", "4"], ["2", "3", "5"], ["3", "3", "10"], ["5", "5", "50"], ["1", "100", "100"], ["100", "1", "100"], ["2", "4", "20"], ["4", "2", "20"], ["3", "2", "30"], ["2", "5", "50"], ["7", "7", "100"], ["1", "3", "7"], ["3", "1", "7"], ["10", "10", "200"], ["2", "6", "40"], ["9", "9", "200"]], "expected": [[2, 3, 4, 5, 7, 9, 10], [2, 4, 6, 8, 10, 14], [2, 3, 5, 9], [2], [], [], [2, 101, 200, 10001, 10100, 20000], [2, 3, 5, 9, 17, 33, 65], [], [], [2], [2, 3], [2, 3, 4], [2, 3, 4, 5], [2, 4, 6, 10], [2, 6, 10, 26, 30, 50], [2], [2], [2, 3, 5, 6, 8, 9, 12, 17, 18, 20], [2, 3, 5, 6, 8, 9, 12, 17, 18, 20], [2, 3, 4, 5, 7, 9, 10, 11, 13, 17, 19, 25, 28, 29], [2, 3, 5, 6, 7, 9, 13, 17, 21, 26, 27, 29, 33, 37, 41], [2, 8, 14, 50, 56, 98], [2, 4], [2, 4], [2, 11, 20, 101, 110, 200], [2, 3, 5, 7, 8, 9, 10, 14, 17, 22, 33, 37, 38, 40], [2, 10, 18, 82, 90, 162]], "loose": true}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "147", "slug": "powx-n", "id": 147, "title": "Pow(x, n)", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/powx-n/", "examples": [{"input": "x = \"2.0\", n = 10", "output": "\"1024.0\"", "explanation": "\"2.0\"^10 = \"1024.0\"."}, {"input": "x = \"2.1\", n = 3", "output": "\"9.261\"", "explanation": "\"2.1\"^3 = \"9.261\"."}, {"input": "x = \"2.0\", n = -2", "output": "\"0.25\"", "explanation": "\"2.0\"^-2 = \"0.25\"."}], "hints": ["This is a portable adaptation: parse the input string as a double and return a finite, double-parseable decimal string.", "Use exponentiation by squaring, halving the exponent at each step.", "Store the exponent in a wider signed integer before negating it so the minimum 32-bit exponent is handled safely.", "For a negative exponent, invert the base and use the positive magnitude of the exponent."], "statement": "Implement exponentiation for a decimal base `x` and a 32-bit integer exponent `n`.\n\nReturn `x` raised to `n`. Your algorithm should run in `O(log |n|)` time rather than multiplying `|n|` times.\n\n**Portable string adaptation:** The base is supplied as a valid finite decimal string so every supported language receives the same input. Parse `x` as a double-precision floating-point value and return the result as a decimal string that can be parsed as a double. Scientific notation is allowed. Answers are checked with absolute and relative tolerance. `NaN`, infinity, and malformed output strings are rejected.\n\n**Constraints:**\n- `-100 < x < 100`\n- `-2^31 <= n <= 2^31 - 1`\n- Either `x != 0` or `n > 0`\n- `-10^4 <= x^n <= 10^4`\n", "solution": "## Approach\n\nParse the portable string base as a double and use exponentiation by squaring. For a negative exponent, invert the base and negate the exponent before repeatedly consuming one binary exponent bit. Format the final double with 17 significant digits so the returned string round-trips reliably through a double parser.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log |n|), because each iteration halves the exponent.\n- **Space Complexity:** O(1), excluding the returned decimal string.\n\n## Implementation\n\n```python\nclass Solution:\n def myPow(self, x: str, n: int) -> str:\n base = float(x)\n exponent = n\n if exponent < 0:\n base = 1.0 / base\n exponent = -exponent\n\n result = 1.0\n while exponent > 0:\n if exponent % 2 == 1:\n result *= base\n base *= base\n exponent //= 2\n return format(result, \".17g\")\n```\n", "starter": {"go": "package main\n\nfunc MyPow(x string, n int) string {\n return \"\"\n}", "python": "class Solution:\n def myPow(self, x: str, n: int) -> str:\n return \"\"\n", "cpp": "#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n string myPow(string x, int n) {\n return \"\";\n }\n};"}, "fn": "myPow", "params": [{"name": "x", "type": "string"}, {"name": "n", "type": "int"}], "outputType": "string", "tests": [["2.0", "10"], ["2.1", "3"], ["2.0", "-2"], ["-2.0", "5"], ["-2.0", "6"], ["0", "1"], ["0.0", "5"], ["0", "2147483647"], ["1", "-2147483648"], ["-1", "-2147483648"], ["-1", "2147483647"], ["1", "2147483647"], ["1.5", "0"], ["0.5", "10"], ["0.5", "-10"], ["10", "-8"], ["0.1", "8"], ["1.01", "100"], ["0.99", "100"], ["1.0001", "10000"], ["0.9999", "10000"], ["3", "7"], ["3", "-7"], ["-3", "-7"], ["-3", "-8"], ["5", "5"], ["5", "-12"], ["1.25", "20"], ["0.8", "20"], ["2.5", "8"], ["2.5", "-15"], ["-0.5", "9"], ["-0.5", "-9"], ["7", "1"], ["7", "-1"], ["-7", "1"], ["-7", "-1"], ["99.999", "2"], ["-21.5", "3"], ["0.0001", "2"], ["99.999", "-2"], ["9.999", "4"], ["0.125", "7"], ["8", "-7"], ["1.2", "30"], ["1.2", "-30"], ["-1.2", "31"], ["-1.2", "-31"], ["2", "13"], ["2", "-30"], ["-2", "13"], ["-2", "-31"], ["1.0000001", "1000000"], ["0.9999999", "1000000"], ["1.000001", "100000"], ["0.999999", "100000"], ["2.225", "4"], ["-4.75", "4"], ["-4.75", "3"], ["6.022", "5"], ["3.1415926535", "2"], ["2.718281828", "3"], ["0.3333333333", "5"], ["1.4142135623", "10"], ["-1.4142135623", "11"], ["+2.5", "6"], ["0002.500", "-4"], ["-0.0", "7"], ["42.125", "1"], ["42.125", "0"], ["99.99999999999999", "1"], ["-99.99999999999999", "1"], ["10", "4"], ["-20", "3"], ["2.2250738585072014e-308", "1"], ["-2.2250738585072014e-308", "1"], ["0.999999999", "-2147483648"], ["1.0000001", "-2147483647"], ["1.000000001", "2147483647"], ["0.9999999", "2147483646"]], "expected": ["1024.0", "9.261000000000001", "0.25", "-32.0", "64.0", "0.0", "0.0", "0.0", "1.0", "1.0", "-1.0", "1.0", "1.0", "9.765625E-4", "1024.0", "1.0000000000000008E-8", "1.0000000000000008E-8", "2.704813829421529", "0.3660323412732289", "2.718145926824356", "0.36786104643302414", "2187.0", "4.5724737082761767E-4", "-4.5724737082761767E-4", "1.5241579027587256E-4", "3125.0", "4.096000000000006E-9", "86.73617379884035", "0.011529215046068495", "1525.87890625", "1.0737418240000018E-6", "-0.001953125", "-512.0", "7.0", "0.14285714285714285", "-7.0", "-0.14285714285714285", "9999.800001", "-9938.375", "1.0E-8", "1.0000200003000041E-4", "9996.000599960003", "4.76837158203125E-7", "4.76837158203125E-7", "237.37631379976966", "0.004212720233087435", "-284.8515765597236", "-0.0035106001942395294", "8192.0", "9.313225746154785E-10", "-8192.0", "-4.656612873077393E-10", "1.1051709126081526", "0.9048374135477304", "1.1051708628105146", "0.9048373727913885", "24.508687890625005", "509.06640625", "-107.171875", "7919.609280312835", "9.869604400525171", "20.085536913011932", "0.0041152263353909455", "31.999999983460484", "-45.254833970209596", "244.140625", "0.02560000000000001", "-0.0", "42.125", "1.0", "99.99999999999999", "-99.99999999999999", "10000.0", "-8000.0", "2.2250738585072014E-308", "-2.2250738585072014E-308", "8.563284397535678", "5.444710603638906E-94", "8.563284388972392", "5.444595631078263E-94"], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "550", "slug": "predict-the-winner", "id": 550, "title": "Predict the Winner", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/predict-the-winner/", "examples": [{"input": "nums = [1,5,2]", "output": "false", "explanation": "Second player always secures the 5 and wins."}, {"input": "nums = [1,5,233,7]", "output": "true", "explanation": "First player takes 1 then 233 to win."}, {"input": "nums = [1]", "output": "true", "explanation": "Single pick wins."}], "hints": ["Track the best net lead the player to move can build on any interval.", "An interval's value is the better of taking the left or right end minus the opponent's reply.", "Non-negative lead over the whole array means the first player ties or wins."], "statement": "Two opponents alternately remove one number from either tip of an array `nums`, adding it to their own total. The first player moves first, and both sides play perfectly to maximize their own final total. A drawn total still counts as a first-player success.\n\nDecide whether the first player can finish with at least as many points as the second.\n\n**Constraints:**\n\n- `1 <= nums.length <= 20`\n- `0 <= nums[i] <= 10^7`\n", "solution": "## Approach\n\nLet the table hold the largest net advantage the player about to move can secure on each subarray. Single cells are worth their own value; wider intervals take the better of grabbing the left end or the right end and then subtracting the opponent's optimal reply on the remainder. A non-negative advantage on the full array means the opener ties or wins.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^2) for all intervals, with n <= 20.\n- **Space Complexity:** O(n^2) for the table.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def predictTheWinner(self, nums: List[int]) -> bool:\n n = len(nums)\n dp = [[0] * n for _ in range(n)]\n for i in range(n):\n dp[i][i] = nums[i]\n for length in range(2, n + 1):\n for i in range(n - length + 1):\n j = i + length - 1\n dp[i][j] = max(nums[i] - dp[i + 1][j], nums[j] - dp[i][j - 1])\n return dp[0][n - 1] >= 0\n```\n", "starter": {"go": "package main\n\nfunc PredictTheWinner(nums []int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def predictTheWinner(self, nums: List[int]) -> bool:\n return False\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n bool predictTheWinner(vector<int>& nums) {\n return false;\n }\n};"}, "fn": "predictTheWinner", "params": [{"name": "nums", "type": "int_array"}], "outputType": "boolean", "tests": [["[1,5,2]"], ["[1,5,233,7]"], ["[1]"], ["[1,2]"], ["[2,1]"], ["[0]"], ["[1,1]"], ["[5,3,4,5]"], ["[1,5,2,4,6]"], ["[10,1,1,1,1,1]"], ["[3,7,2,5]"], ["[0,0,0,0]"], ["[1000000,999999,1]"], ["[2,4,55,6,8]"], ["[1,2,3,4,5,6]"], ["[7,7,7,7,7]"], ["[1,100,1]"], ["[5,5,5]"], ["[8,15,3,7]"], ["[20,10,30,40]"], ["[1,2,3,4,5,6,7]"], ["[0,0]"], ["[5,4,3,2,1]"], ["[10,20,30]"], ["[7,8,9,10,11,12]"], ["[100,1,1,100]"], ["[3,3,3,3]"], ["[1,1000000,1,1000000]"]], "expected": [false, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, false, true, true, true, true, true, true, true, true, true, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "749", "slug": "prefix-and-suffix-search", "id": 749, "title": "Prefix and Suffix Search", "difficulty": "Hard", "category": "trie", "link": "https://leetcode.com/problems/prefix-and-suffix-search/", "examples": [{"input": "words = [\"apple\"], pref = \"a\", suff = \"e\"", "output": "0", "explanation": "Index 0 fits both ends."}, {"input": "words = [\"apple\",\"apply\",\"ape\"], pref = \"ap\", suff = \"e\"", "output": "2", "explanation": "Indices 0 and 2 fit; return the larger."}, {"input": "words = [\"hello\",\"world\"], pref = \"x\", suff = \"y\"", "output": "-1", "explanation": "No word fits."}], "hints": ["Scanning indices from the end downward lets you return the first fit, which is automatically the largest.", "A word fits when it starts with pref and ends with suff; both checks are linear in the word length.", "For many repeated queries a combined prefix-suffix map or trie pays off, but a single scan is enough for one query."], "statement": "You are given a dictionary `words` where each entry is a lowercase word. For one query you also receive a prefix string `pref` and a suffix string `suff`.\n\nFind the largest index `i` such that `words[i]` starts with `pref` and ends with `suff`. If no dictionary word satisfies both ends, return `-1`.\n\nAdaptation for this judge: the original task defines a `WordFilter` class whose constructor stores the dictionary and whose method `f(pref, suff)` answers each query. Here the whole job is condensed into a single function call `wordFilter(words, pref, suff)` that builds the structure and answers one query at once.\n\n**Constraints:**\n- `1 <= words.length <= 10^4`\n- `1 <= words[i].length <= 7`\n- `1 <= pref.length, suff.length <= 7`\n- `words[i]`, `pref` and `suff` hold lowercase English letters only.\n", "solution": "## Approach\n\nIterate the dictionary from the last index toward the first and test each word with a prefix check and a suffix check. The first word passing both is the largest valid index, so return it at once. If the loop ends, no word fits and the answer is -1.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m * L), where m is the number of words and L is the average word length for the two checks.\n- **Space Complexity:** O(1) besides the inputs.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def wordFilter(self, words: List[str], pref: str, suff: str) -> int:\n for i in range(len(words) - 1, -1, -1):\n if words[i].startswith(pref) and words[i].endswith(suff):\n return i\n return -1\n```\n", "starter": {"go": "package main\n\nfunc WordFilter(words []string, pref string, suff string) int {\n return -1\n}", "python": "from typing import List\nclass Solution:\n def wordFilter(self, words: List[str], pref: str, suff: str) -> int:\n pass", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n int wordFilter(vector<string>& words, string pref, string suff) {\n return -1;\n }\n};"}, "fn": "wordFilter", "params": [{"name": "words", "type": "string_array"}, {"name": "pref", "type": "string"}, {"name": "suff", "type": "string"}], "outputType": "int", "tests": [["['apple']", "a", "e"], ["['apple']", "b", "e"], ["['apple', 'apply', 'ape']", "ap", "e"], ["['apple', 'apricot', 'banana']", "a", "e"], ["['test', 'testing', 'tester']", "test", "er"], ["['abc', 'abcd', 'abcde']", "ab", "d"], ["['a', 'aa', 'aaa']", "a", "a"], ["['cat', 'car', 'cart']", "ca", "t"], ["['hello', 'world']", "h", "o"], ["['hello', 'world']", "w", "d"], ["['hello', 'world']", "x", "y"], ["['ab', 'ba', 'aba']", "a", "a"], ["['prefix', 'suffix', 'fix']", "fix", "fix"], ["['aaaa', 'aaab', 'aabb']", "aa", "bb"], ["['dog', 'cat', 'bird']", "d", "g"], ["['dog', 'cat', 'bird']", "c", "t"], ["['dog', 'cat', 'bird']", "b", "d"], ["['apple', 'apple']", "a", "e"], ["['x', 'y', 'z']", "x", "x"], ["['x', 'y', 'z']", "y", "y"], ["['x', 'y', 'z']", "a", "a"], ["['abcdefg', 'abcxyzg', 'abczzzg']", "abc", "g"], ["['one', 'two', 'three']", "t", "o"], ["['same', 'same', 'same']", "s", "e"], ["['a', 'b', 'c']", "a", "b"], ["['ababa', 'babab']", "aba", "aba"], ["['word', 'words', 'wordy']", "word", "s"], ["['alpha', 'beta', 'gamma']", "a", "a"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "791", "slug": "preimage-size-of-factorial-zeroes-function", "id": 791, "title": "Preimage Size of Factorial Zeroes Function", "difficulty": "Hard", "category": "math", "link": "https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function/", "examples": [{"input": "k = 0", "output": "5", "explanation": "Values 0 through 4 have zero trailing zeroes."}, {"input": "k = 5", "output": "0", "explanation": "The zero count skips from 4 to 6."}, {"input": "k = 3", "output": "5", "explanation": "Values 15 through 19 each give three zeroes."}], "hints": ["Trailing zeroes of x! equal floor(x/5) + floor(x/25) + floor(x/125) + ... .", "That count function is monotone, so binary-search the smallest x reaching at least k.", "If that x yields exactly k, a full block of five consecutive values shares it; otherwise the answer is 0."], "statement": "For a non-negative integer `x`, write `zeros(x)` for the count of trailing\nzeroes in the decimal form of `x!` (the factorial), with `zeros(0) = 0`\nsince `0! = 1`. The function climbs in flat stretches: several consecutive\n`x` values share the same zero count, and some counts never occur at all.\n\nGiven `k`, count how many `x` satisfy `zeros(x) == k`. The answer turns out\nto be either five (a full block between multiples of five) or zero (a count\nthat the factorial skips over).\n\n**Constraints:**\n- `0 <= k <= 10^9`\n", "solution": "## Approach\n\nThe zero count of `x!` is the sum of `floor(x/5^i)` over all powers of\nfive, which grows monotonically. Binary-search the smallest `x` whose count\nreaches at least `k`. When that position yields exactly `k`, the five values\nfrom the block start through the next multiple-of-five boundary all share\nit; otherwise `k` is skipped and the answer is zero.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log k) search steps, each evaluating the zero sum in O(log x).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def preimageSizeFZF(self, k: int) -> int:\n def zeros(x: int) -> int:\n total = 0\n while x:\n x //= 5\n total += x\n return total\n\n lo, hi = 0, 5 * (k + 1)\n while lo < hi:\n mid = (lo + hi) // 2\n if zeros(mid) < k:\n lo = mid + 1\n else:\n hi = mid\n return 5 if zeros(lo) == k else 0\n```\n", "starter": {"go": "package main\n\nfunc PreimageSizeFZF(k int) int {\n return 0\n}", "python": "class Solution:\n def preimageSizeFZF(self, k: int) -> int:\n return 0\n", "cpp": "class Solution {\npublic:\n int preimageSizeFZF(int k) {\n return 0;\n }\n};"}, "fn": "preimageSizeFZF", "params": [{"name": "k", "type": "int"}], "outputType": "int", "tests": [["0"], ["5"], ["3"], ["1"], ["2"], ["4"], ["6"], ["10"], ["11"], ["7"], ["13"], ["24"], ["25"], ["26"], ["29"], ["30"], ["31"], ["100"], ["124"], ["125"], ["1000"], ["1000000"], ["1000000000"], ["999999999"], ["42"], ["99"], ["101"], ["100000000"]], "expected": [5, 0, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "764", "slug": "prime-number-of-set-bits-in-binary-representation", "id": 764, "title": "Prime Number of Set Bits in Binary Representation", "difficulty": "Easy", "category": "math", "link": "https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/", "examples": [{"input": "left = 6, right = 10", "output": "4", "explanation": "6, 7, 9, 10 have 2, 3, 2, 2 one-bits (all prime); 8 has 1."}, {"input": "left = 10, right = 15", "output": "5", "explanation": "Only 15 (4 bits) misses a prime count."}, {"input": "left = 1, right = 1", "output": "0", "explanation": "A single one-bit is not prime."}], "hints": ["Count one-bits with a loop or a builtin popcount, then test membership in the small prime set.", "Values up to 10^6 need at most 20 bits, so only primes 2, 3, 5, 7, 11, 13, 17, 19 can occur."], "statement": "Given two integers `left` and `right` with `left <= right`, count how many integers `x` in the closed interval `[left, right]` have a prime number of `1` bits in their binary form.\n\nThe bit count of `x` is the number of ones when `x` is written in base two; for instance `21 = 10101` has three such bits.\n\n**Constraints:**\n- `1 <= left <= right <= 10^6`\n- `0 <= right - left <= 10^4`\n", "solution": "## Approach\n\nIterate over the closed interval and count the one-bits of each value with a popcount operation. Look up whether that count is prime (only 2, 3, 5, 7, 11, 13, 17, 19 are reachable below 10^6) and tally the hits.\n\n## Complexity Analysis\n\n- **Time Complexity:** O((right - left + 1) * log right) for scanning and bit counting.\n- **Space Complexity:** O(1) besides the answer.\n\n## Implementation\n\n```python\nclass Solution:\n def countPrimeSetBits(self, left: int, right: int) -> int:\n primes = {2, 3, 5, 7, 11, 13, 17, 19}\n ans = 0\n for x in range(left, right + 1):\n if bin(x).count(\"1\") in primes:\n ans += 1\n return ans\n```\n", "starter": {"go": "package main\n\nfunc CountPrimeSetBits(left int, right int) int {\n return 0\n}", "python": "class Solution:\n def countPrimeSetBits(self, left: int, right: int) -> int:\n pass\n", "cpp": "class Solution {\npublic:\n int countPrimeSetBits(int left, int right) {\n return 0;\n }\n};"}, "fn": "countPrimeSetBits", "params": [{"name": "left", "type": "int"}, {"name": "right", "type": "int"}], "outputType": "int", "tests": [["6", "10"], ["10", "15"], ["1", "1"], ["1", "2"], ["2", "2"], ["3", "3"], ["4", "4"], ["1", "10"], ["20", "30"], ["100", "110"], ["1", "100"], ["512", "512"], ["1023", "1023"], ["1024", "1024"], ["999983", "999993"], ["1000000", "1000000"], ["500000", "500010"], ["7", "7"], ["8", "8"], ["15", "15"], ["16", "16"], ["31", "31"], ["32", "32"], ["255", "255"], ["256", "256"], ["1", "1000"], ["990000", "1000000"], ["123456", "123466"]], "expected": [4, 5, 0, 0, 0, 1, 0, 6, 7, 6, 65, 0, 0, 0, 2, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 530, 3754, 4], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "861", "slug": "prime-palindrome", "id": 861, "title": "Prime Palindrome", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/prime-palindrome/", "examples": [{"input": "n = 6", "output": "7", "explanation": "7 is the next prime palindrome."}, {"input": "n = 8", "output": "11", "explanation": "11 is the first prime palindrome at or above 8."}, {"input": "n = 13", "output": "101", "explanation": "101 is the first prime palindrome at or above 13."}], "hints": ["Even-length palindromes beyond 11 are all multiples of 11, so only the number 11 matters among them.", "It is enough to build palindromes by mirroring the first half; generate odd-length candidates in increasing order plus the special 11.", "Test primality by trial division up to the square root, skipping even divisors after 2."], "statement": "You are given an integer `n`. A prime palindrome is a number that reads the same forward and backward (in decimal, without leading zeros) and is also prime.\n\nReturn the smallest prime palindrome that is greater than or equal to `n`.\n\nSingle-digit numbers that are prime (2, 3, 5, 7) already qualify, and two-digit 11 qualifies as well.\n\n**Constraints:**\n- `1 <= n <= 10^8`\n", "solution": "## Approach\n\nSmall inputs are answered directly, since 2, 3, 5, 7 and 11 cover everything up to 11. Longer even-length palindromes are divisible by 11, so only odd lengths can yield new prime palindromes. Build each odd-length palindrome by mirroring its first half in numeric order and return the first one that is at least `n` and passes a trial-division primality test.\n\n## Complexity Analysis\n\n- **Time Complexity:** Roughly proportional to the count of palindromes tried times the square root of the value for trial division; tiny in practice for the given limits.\n- **Space Complexity:** O(1) besides a few counters.\n\n## Implementation\n\n```python\nclass Solution:\n def primePalindrome(self, n: int) -> int:\n def is_prime(x: int) -> bool:\n if x < 2:\n return False\n if x % 2 == 0:\n return x == 2\n d = 3\n while d * d <= x:\n if x % d == 0:\n return False\n d += 2\n return True\n if n <= 2:\n return 2\n if n <= 3:\n return 3\n if n <= 5:\n return 5\n if n <= 7:\n return 7\n if n <= 11:\n return 11\n length = len(str(n))\n while True:\n if length % 2 == 1:\n start = 10 ** ((length - 1) // 2)\n end = 10 ** ((length + 1) // 2)\n for half in range(start, end):\n s = str(half)\n pal = int(s + s[-2::-1])\n if pal < n:\n continue\n if is_prime(pal):\n return pal\n length += 1\n```\n", "starter": {"go": "package main\n\nfunc PrimePalindrome(n int) int {\n return 0\n}", "python": "class Solution:\n def primePalindrome(self, n: int) -> int:\n pass", "cpp": "class Solution {\npublic:\n int primePalindrome(int n) {\n return 0;\n }\n};"}, "fn": "primePalindrome", "params": [{"name": "n", "type": "int"}], "outputType": "int", "tests": [["6"], ["8"], ["13"], ["1"], ["2"], ["3"], ["7"], ["10"], ["11"], ["12"], ["70"], ["100"], ["101"], ["131"], ["1000"], ["1968"], ["7654"], ["12345"], ["99999"], ["100000"], ["128000"], ["100005"], ["9989900"], ["9999999"], ["20"], ["30"], ["4"], ["5"]], "expected": [7, 11, 101, 2, 2, 3, 7, 11, 11, 101, 101, 101, 101, 131, 10301, 10301, 10301, 12421, 1003001, 1003001, 1003001, 1003001, 100030001, 100030001, 101, 101, 5, 5], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "675", "slug": "print-binary-tree", "id": 675, "title": "Print Binary Tree", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/print-binary-tree/", "examples": [{"input": "root = [1,2]", "output": "[[\"\",\"1\",\"\"],[\"2\",\"\",\"\"]]"}, {"input": "root = [1,2,3,null,4]", "output": "[[\"\",\"\",\"\",\"1\",\"\",\"\",\"\"],[\"\",\"2\",\"\",\"\",\"\",\"3\",\"\"],[\"\",\"\",\"4\",\"\",\"\",\"\",\"\"]]"}], "hints": ["The height h sets the canvas size: h rows and 2^h - 1 columns filled with empty strings.", "Put the root at the middle of the top row, then place each child at the middle of its own side region one row down.", "A depth-first fill that carries the left and right column bounds keeps every label centered."], "statement": "You are given the root of a binary tree. Lay the tree out on a text canvas as follows:\n\n- Let the height `h` be the number of levels. The canvas has `h` rows and `2^h - 1` columns, initially all empty strings.\n- Put the root label at the middle column of row 0.\n- For a node placed at row `r` and column `c` with left bound `L` and right bound `R`, put its left child at row `r+1` and the middle of `[L, c-1]`, and its right child at row `r+1` and the middle of `[c+1, R]`. Keep splitting until every node is placed.\n\nReturn the filled canvas.\n\n**Adaptation:** the canvas maps to a nested string list in this judge.\n\n**Constraints:**\n- `1 <= number of nodes <= 200`\n- `-100 <= node value <= 100`\n", "solution": "## Approach\n\nMeasure the height `h`, then create an `h` by `2^h - 1` grid of empty strings. Fill it depth-first: a node covering columns `[L, R]` sits at `(L + R) // 2` on its row, and its children cover the left and right halves on the next row. Node values become strings.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(h * 2^h) to create and fill the grid.\n- **Space Complexity:** O(h * 2^h) for the canvas.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def printTree(self, root) -> List[List[str]]:\n def height(n):\n if not n:\n return 0\n return 1 + max(height(n.left), height(n.right))\n h = height(root)\n w = (1 << h) - 1\n ans = [[\"\" for _ in range(w)] for _ in range(h)]\n def fill(n, r, l, rr):\n if not n:\n return\n c = (l + rr) // 2\n ans[r][c] = str(n.val)\n fill(n.left, r + 1, l, c - 1)\n fill(n.right, r + 1, c + 1, rr)\n fill(root, 0, 0, w - 1)\n return ans\n```\n", "starter": {"go": "// Definition for a binary tree node.\n// type TreeNode struct {\n// Val int\n// Left *TreeNode\n// Right *TreeNode\n// }\npackage main\n\nfunc PrintTree(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\n\nfrom typing import List\nclass Solution:\n def printTree(self, root) -> List[List[str]]:\n pass", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\n#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n vector<vector<string>> printTree(TreeNode* root) {\n return {};\n }\n};"}, "fn": "printTree", "params": [{"name": "root", "type": "tree_node"}], "outputType": "string_list_2d", "tests": [["[1,2]"], ["[1,2,3,null,4]"], ["[1]"], ["[1,2,3]"], ["[1,null,2]"], ["[1,2,null]"], ["[1,2,3,4,5,6,7]"], ["[1,2,3,4,null,null,5]"], ["[5,3,8,1,4,null,9]"], ["[1,2,null,3,null,4,null]"], ["[1,null,2,null,3,null,4]"], ["[2,1,3]"], ["[10,5,15,3,7,12,20]"], ["[1,2,3,null,5,null,7]"], ["[0,-1,2,-3,null,null,4]"], ["[1,2,2,3,null,null,3]"], ["[4,2,6,1,3,5,7,0,null,null,null,null,null,null,8]"], ["[1,null,2,null,3]"], ["[3,1,4,null,2]"], ["[7,3,9,1,5,null,10]"], ["[1,2,3,4,5,null,null,6,null,null,null]"], ["[100,50,150]"], ["[1,2,null,null,3]"], ["[2,null,3,null,4,null,5]"], ["[6,4,8,3,5,7,9,1,null,null,null,null,null,null,10]"], ["[1,2,3,null,null,4,5,6,null,null,7]"], ["[9,7,11,6,8,10,12]"], ["[1,2,3,4,null,6,7,null,5]"]], "expected": [[["", "1", ""], ["2", "", ""]], [["", "", "", "1", "", "", ""], ["", "2", "", "", "", "3", ""], ["", "", "4", "", "", "", ""]], [["1"]], [["", "1", ""], ["2", "", "3"]], [["", "1", ""], ["", "", "2"]], [["", "1", ""], ["2", "", ""]], [["", "", "", "1", "", "", ""], ["", "2", "", "", "", "3", ""], ["4", "", "5", "", "6", "", "7"]], [["", "", "", "1", "", "", ""], ["", "2", "", "", "", "3", ""], ["4", "", "", "", "", "", "5"]], [["", "", "", "5", "", "", ""], ["", "3", "", "", "", "8", ""], ["1", "", "4", "", "", "", "9"]], [["", "", "", "", "", "", "", "1", "", "", "", "", "", "", ""], ["", "", "", "2", "", "", "", "", "", "", "", "", "", "", ""], ["", "3", "", "", "", "", "", "", "", "", "", "", "", "", ""], ["4", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]], [["", "", "", "", "", "", "", "1", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", "", "", "", "", "2", "", "", ""], ["", "", "", "", "", "", "", "", "", "", "", "", "", "3", ""], ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "4"]], [["", "2", ""], ["1", "", "3"]], [["", "", "", "10", "", "", ""], ["", "5", "", "", "", "15", ""], ["3", "", "7", "", "12", "", "20"]], [["", "", "", "1", "", "", ""], ["", "2", "", "", "", "3", ""], ["", "", "5", "", "", "", "7"]], [["", "", "", "0", "", "", ""], ["", "-1", "", "", "", "2", ""], ["-3", "", "", "", "", "", "4"]], [["", "", "", "1", "", "", ""], ["", "2", "", "", "", "2", ""], ["3", "", "", "", "", "", "3"]], [["", "", "", "", "", "", "", "4", "", "", "", "", "", "", ""], ["", "", "", "2", "", "", "", "", "", "", "", "6", "", "", ""], ["", "1", "", "", "", "3", "", "", "", "5", "", "", "", "7", ""], ["0", "", "", "", "", "", "", "", "", "", "", "", "", "", "8"]], [["", "", "", "1", "", "", ""], ["", "", "", "", "", "2", ""], ["", "", "", "", "", "", "3"]], [["", "", "", "3", "", "", ""], ["", "1", "", "", "", "4", ""], ["", "", "2", "", "", "", ""]], [["", "", "", "7", "", "", ""], ["", "3", "", "", "", "9", ""], ["1", "", "5", "", "", "", "10"]], [["", "", "", "", "", "", "", "1", "", "", "", "", "", "", ""], ["", "", "", "2", "", "", "", "", "", "", "", "3", "", "", ""], ["", "4", "", "", "", "5", "", "", "", "", "", "", "", "", ""], ["6", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]], [["", "100", ""], ["50", "", "150"]], [["", "", "", "1", "", "", ""], ["", "2", "", "", "", "", ""], ["", "", "3", "", "", "", ""]], [["", "", "", "", "", "", "", "2", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", "", "", "", "", "3", "", "", ""], ["", "", "", "", "", "", "", "", "", "", "", "", "", "4", ""], ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "5"]], [["", "", "", "", "", "", "", "6", "", "", "", "", "", "", ""], ["", "", "", "4", "", "", "", "", "", "", "", "8", "", "", ""], ["", "3", "", "", "", "5", "", "", "", "7", "", "", "", "9", ""], ["1", "", "", "", "", "", "", "", "", "", "", "", "", "", "10"]], [["", "", "", "", "", "", "", "1", "", "", "", "", "", "", ""], ["", "", "", "2", "", "", "", "", "", "", "", "3", "", "", ""], ["", "", "", "", "", "", "", "", "", "4", "", "", "", "5", ""], ["", "", "", "", "", "", "", "", "6", "", "", "", "", "", "7"]], [["", "", "", "9", "", "", ""], ["", "7", "", "", "", "11", ""], ["6", "", "8", "", "10", "", "12"]], [["", "", "", "", "", "", "", "1", "", "", "", "", "", "", ""], ["", "", "", "2", "", "", "", "", "", "", "", "3", "", "", ""], ["", "4", "", "", "", "", "", "", "", "6", "", "", "", "7", ""], ["", "", "5", "", "", "", "", "", "", "", "", "", "", "", ""]]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "943", "slug": "prison-cells-after-n-days", "id": 943, "title": "Prison Cells After N Days", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/prison-cells-after-n-days/", "examples": [{"input": "cells = [0,1,0,1,1,0,0,1], N = 7", "output": "[0,0,1,1,0,0,0,0]", "explanation": "After seven daily updates the row settles into [0,0,1,1,0,0,0,0]."}, {"input": "cells = [1,0,0,1,0,0,1,0], N = 1", "output": "[0,0,0,1,0,0,1,0]", "explanation": "A single update turns each interior cell on exactly when its two neighbours match."}, {"input": "cells = [1,1,1,0,1,1,1,1], N = 2", "output": "[0,1,1,1,1,0,0,0]", "explanation": "Two updates in a row propagate the single gap across the row."}], "hints": ["Only 256 row layouts exist, so the evolution must eventually loop.", "Record the first day each layout appears; on a repeat, skip whole cycles at once.", "The two border cells always clear to 0 after day one."], "statement": "Eight holding cells sit in a row, each either occupied (`1`) or empty (`0`). Every day each cell is refreshed at the same time: a cell becomes occupied when its left and right neighbours currently hold the same value (both occupied or both empty), and becomes empty otherwise. The two end cells have only one neighbour, so they always become empty after the first day.\n\nGiven the starting layout `cells` and a day count `N`, return the layout of the row right after the `N`-th daily refresh.\n\n**Constraints:**\n- `cells.length == 8`\n- Each entry of `cells` is `0` or `1`\n- `1 <= N <= 10^9` (so a day-by-day simulation needs cycle skipping)\n", "solution": "## Approach\n\nSimulate the daily refresh, but memoize every layout seen so far. Because there are only finitely many rows, the layouts must eventually repeat, forming a cycle. Once a repeat is found, fast-forward over whole cycles in one jump and simulate only the leftover days. Each step compares the two neighbours of every interior cell while the ends always clear to zero.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1) \u2014 at most a few hundred simulated days regardless of N.\n- **Space Complexity:** O(1) for the memo table of past layouts.\n\n## Implementation\n\n```python\nclass Solution:\n def prisonAfterNDays(self, cells: list[int], N: int) -> list[int]:\n cur = list(cells)\n seen = {}\n day = 0\n while day < N:\n key = tuple(cur)\n if key in seen:\n period = day - seen[key]\n rem = N - day\n if period > 0 and rem >= period:\n day += (rem // period) * period\n continue\n else:\n seen[key] = day\n nxt = [0] * 8\n for i in range(1, 7):\n nxt[i] = 1 if cur[i - 1] == cur[i + 1] else 0\n cur = nxt\n day += 1\n return cur\n```\n", "starter": {"go": "package main\n\nfunc PrisonAfterNDays(cells []int, n int) []int {\n return nil\n}", "python": "from typing import List\nclass Solution:\n def prisonAfterNDays(self, cells: List[int], n: int) -> List[int]:\n return []", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<int> prisonAfterNDays(vector<int>& cells, int n) {\n return {};\n }\n};"}, "fn": "prisonAfterNDays", "params": [{"name": "cells", "type": "int_array"}, {"name": "n", "type": "int"}], "outputType": "int_array", "tests": [["[0,1,0,1,1,0,0,1]", "7"], ["[1,0,0,1,0,0,1,0]", "1"], ["[1,1,1,0,1,1,1,1]", "2"], ["[0,1,0,1,1,0,0,1]", "14"], ["[0,0,0,0,0,0,0,0]", "5"], ["[1,1,1,1,1,1,1,1]", "3"], ["[1,0,1,0,1,0,1,0]", "10"], ["[0,1,0,1,1,0,0,1]", "1000000000"], ["[1,0,0,1,0,0,0,1]", "14"], ["[1,0,0,1,0,0,0,1]", "15"], ["[1,0,0,1,0,0,0,1]", "16"], ["[0,0,1,1,1,0,1,0]", "20"], ["[1,1,0,0,1,0,1,1]", "100"], ["[0,1,1,0,0,1,0,1]", "1000000000"], ["[1,0,1,1,0,1,0,0]", "6"], ["[0,0,0,1,1,1,0,0]", "9"], ["[1,1,0,1,0,0,0,1]", "13"], ["[0,1,1,1,0,0,1,0]", "21"], ["[1,0,1,0,0,0,1,1]", "28"], ["[0,0,1,0,1,1,1,0]", "30"], ["[1,1,1,0,0,0,1,1]", "4"], ["[0,1,0,0,1,0,1,0]", "11"], ["[1,0,0,0,1,1,0,1]", "17"], ["[0,0,1,1,0,1,1,0]", "25"], ["[1,1,0,1,1,0,0,0]", "8"], ["[0,1,1,0,1,0,0,1]", "12"], ["[1,0,1,1,1,0,1,0]", "19"], ["[0,0,0,1,0,1,0,1]", "26"]], "expected": [[0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0], [0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 1, 0], [0, 1, 0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 1, 1, 0], [0, 1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 1, 1, 1, 1, 0]], "loose": false}