offcode 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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-7tyR3Zsa.js +147 -0
  1036. package/dist/web/assets/index-oer4U46K.css +1 -0
  1037. package/dist/web/index.html +13 -0
  1038. package/package.json +42 -3
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "335", "slug": "contains-duplicate-iii", "id": 335, "title": "Contains Duplicate III", "difficulty": "Hard", "category": "sliding-window", "link": "https://leetcode.com/problems/contains-duplicate-iii/", "examples": [{"explanation": "Positions 0 and 3 hold 1; |0-3| = 3 <= 3 and |1-1| = 0 <= 0.", "input": "nums = [1,2,3,1], indexDiff = 3, valueDiff = 0", "output": "true"}, {"explanation": "Equal values sit 3 apart (too far), and pairs within distance 2 differ by 4 or more.", "input": "nums = [1,5,9,1,5,9], indexDiff = 2, valueDiff = 3", "output": "false"}, {"explanation": "Positions 2 and 3 both hold 1 with |2-3| = 1 <= 1.", "input": "nums = [1,2,1,1], indexDiff = 1, valueDiff = 0", "output": "true"}], "hints": ["Keep a sliding window of the last indexDiff values in an ordered set so neighbours of each new value can be queried.", "For each value, check the smallest stored value >= it (ceiling) and the largest stored value <= it (floor); either within valueDiff is a hit.", "Evict the value that falls out of the window and use 64-bit arithmetic to avoid overflow on extreme inputs."], "statement": "You are given an integer array `nums` and two non-negative limits `indexDiff` and `valueDiff`. Decide whether there exist two different positions `i` and `j` such that the positions are close and the values are close at the same time:\n\n- `abs(i - j) <= indexDiff`, and\n- `abs(nums[i] - nums[j]) <= valueDiff`.\n\n**Constraints:**\n- `1 <= nums.length <= 10^5`\n- `-2^31 <= nums[i] <= 2^31 - 1`\n- `0 <= indexDiff <= 10^5`\n- `0 <= valueDiff <= 2^31 - 1`\n", "solution": "## Approach\n\nSweep the array while holding the last `indexDiff` values in a sorted container. For each new value, its only possible partners are the closest stored values above and below it, so checking the ceiling and the floor against `valueDiff` is sufficient. Then insert the value and evict the one sliding out of the window. Using 64-bit integers keeps extreme inputs from overflowing.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log k), where k is `indexDiff`, for the ordered window operations.\n- **Space Complexity:** O(k) for the window.\n\n## Implementation\n\n```python\nimport bisect\nfrom typing import List\n\nclass Solution:\n def containsNearbyAlmostDuplicate(self, nums: List[int], indexDiff: int, valueDiff: int) -> bool:\n if indexDiff < 0 or valueDiff < 0:\n return False\n window: List[int] = []\n for i, v in enumerate(nums):\n pos = bisect.bisect_left(window, v)\n if pos < len(window) and window[pos] - v <= valueDiff:\n return True\n if pos > 0 and v - window[pos - 1] <= valueDiff:\n return True\n bisect.insort(window, v)\n if len(window) > indexDiff:\n window.pop(bisect.bisect_left(window, nums[i - indexDiff]))\n return False\n```\n", "starter": {"go": "package main\n\nfunc ContainsNearbyAlmostDuplicate(nums []int, indexDiff int, valueDiff int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def containsNearbyAlmostDuplicate(self, nums: List[int], indexDiff: int, valueDiff: int) -> bool:\n return False\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool containsNearbyAlmostDuplicate(vector<int>& nums, int indexDiff, int valueDiff) {\n return false;\n }\n};"}, "fn": "containsNearbyAlmostDuplicate", "params": [{"name": "nums", "type": "int_array"}, {"name": "indexDiff", "type": "int"}, {"name": "valueDiff", "type": "int"}], "outputType": "boolean", "tests": [["[1,2,3,1]", "3", "0"], ["[1,5,9,1,5,9]", "2", "3"], ["[1,2,1,1]", "1", "0"], ["[1]", "1", "1"], ["[1,2]", "0", "1"], ["[1,2]", "1", "1"], ["[-1,-1]", "1", "0"], ["[2147483647,-2147483648]", "1", "2147483647"], ["[1,3,6,9,12]", "1", "2"], ["[1,3,6,9,12]", "2", "3"], ["[4,2]", "2", "1"], ["[2,0,-2,2]", "2", "1"], ["[1,2,3,4,5,6,7,8,9,10]", "9", "0"], ["[10,9,8,7,6,5,4,3,2,1]", "3", "1"], ["[0,0]", "0", "0"], ["[0,0]", "1", "0"], ["[7,7,7,7]", "1", "0"], ["[1,10,20,30,11]", "4", "1"], ["[1,10,20,30,11]", "1", "9"], ["[-3,3,-3,3]", "2", "4"], ["[-3,3,-3,3]", "2", "6"], ["[100,50,51,49,48]", "3", "1"], ["[1,5,2,8,3]", "2", "1"], ["[8,7,15,1,6,1,9,15]", "1", "3"], ["[0,2147483647]", "1", "2147483647"], ["[0,2147483647]", "1", "2147483646"], ["[3,6,0,4]", "2", "2"], ["[5,1,5,1,5]", "2", "0"]], "expected": [true, false, true, false, false, true, true, false, true, true, false, false, false, true, false, true, true, true, true, true, true, true, true, true, true, false, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "3", "slug": "contains-duplicate", "id": 3, "title": "Contains Duplicate", "difficulty": "Easy", "category": "array", "link": "https://leetcode.com/problems/contains-duplicate/", "examples": [{"input": "nums = [1,2,3,1]", "output": true, "explanation": "Value 1 appears at indices 0 and 3, so there is a duplicate."}, {"input": "nums = [1,2,3,4]", "output": false, "explanation": "All values are unique, no duplicates found."}, {"input": "nums = [1,1,1,3,3,4,3,2,4,2]", "output": true, "explanation": "Value 1 appears at indices 0 and 1, so there is a duplicate."}], "hints": ["A common solution runs in O(n) time using a hash set: iterate through the array and check whether the current element is already in the set. If so, return true; otherwise insert it. If no duplicates are found, return false."], "statement": "You receive an integer array `nums`. Decide whether some value occurs more than once in it: return `true` when any entry is repeated, and `false` when all entries are pairwise different.\n\n**Constraints:**\n- `1 <= nums.length <= 10^5`\n- `-10^9 <= nums[i] <= 10^9`\n", "solution": "## Approach\n\nUse a hash set to track seen elements; if any element is encountered twice, return true.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n)\n- **Space Complexity:** O(n)\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def containsDuplicate(self, nums: List[int]) -> bool:\n seen = set()\n for n in nums:\n if n in seen:\n return True\n seen.add(n)\n return False\n```\n", "starter": {"go": "package main\n\nfunc ContainsDuplicate(nums []int) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def containsDuplicate(self, nums: List[int]) -> bool:\n ", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n bool containsDuplicate(vector<int>& nums) {\n return false;\n }\n};"}, "fn": "containsDuplicate", "params": [{"name": "nums", "type": "int_array"}], "outputType": "boolean", "tests": [["[1,2,3,1]"], ["[1,2,3,4]"], ["[1,1,1,3,3,4,3,2,4,2]"], ["[1,2,3,4,5,6]"], ["[1,1,4,2]"], ["[1,1,2]"], ["[1,1]"], ["[1,1,2,3,4,5]"], ["@javascript: JSON.stringify([...Array(99998).fill(1).map((val, idx) => idx + 1), 0, 0])"], ["@javascript: JSON.stringify([...Array(100000).fill(1).map((val, idx) => idx)])"], ["[1]"], ["[0]"], ["[-1]"], ["[1,2]"], ["[2,2]"], ["[0,0]"], ["[-1,0,1]"], ["[3,1,3]"], ["[1,2,3,4,5,1]"], ["[5,4,3,2,1]"], ["[1,2,3,4,5,6,7,8,9,10]"], ["[10,9,8,7,6,5,4,3,2,1]"], ["[0,1,2,3,0]"], ["[-1,-1]"], ["[7,7,7]"], ["[2,5,5,2]"], ["[4,4,4,4]"], ["[9,1,2,3,9]"], ["[6,1,2,3,4,5,6]"], ["[1,5,-2,-4,0]"], ["[-1000000000,1000000000]"], ["[100,200,300,100]"]], "expected": [true, false, true, false, true, true, true, true, true, false, false, false, false, false, true, true, false, true, true, false, false, false, true, true, true, true, true, true, true, false, false, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "584", "slug": "contiguous-array", "id": 584, "title": "Contiguous Array", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/contiguous-array/", "examples": [{"input": "nums = [0,1]", "output": "2", "explanation": "The whole array has one 0 and one 1."}, {"input": "nums = [0,1,0]", "output": "2", "explanation": "Both [0,1] and [1,0] are balanced with length 2."}, {"input": "nums = [0,0,1,0,0,0,1,1]", "output": "6", "explanation": "The slice [1,0,0,0,1,1] has three 0s and three 1s."}], "hints": ["Replace each 0 with -1 so a balanced slice becomes a subarray summing to zero.", "Record the first index where each running total appears; a repeat marks a zero-sum slice.", "Seed the map with total 0 at index -1 so slices starting at the front are measured."], "statement": "You are given a binary array `nums` containing only `0`s and `1`s. Find the length of the longest contiguous subarray that holds an equal number of `0`s and `1`s. If no such subarray exists, return `0`.\n\n**Constraints:**\n- `1 <= nums.length <= 10^5`\n- `nums[i]` is either `0` or `1`.\n", "solution": "## Approach\n\nTreat every `0` as `-1` and every `1` as `+1`, turning a balanced slice into a subarray whose values sum to zero. A zero-sum subarray sits between two equal prefix totals, so scanning once while remembering the earliest index of each running total reveals the longest such slice. The map starts with total `0` at position `-1` so slices beginning at the front are covered.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the length of `nums`.\n- **Space Complexity:** O(n) for the first-occurrence map.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def findMaxLength(self, nums: List[int]) -> int:\n first = {0: -1}\n best = 0\n total = 0\n for i, v in enumerate(nums):\n total += 1 if v == 1 else -1\n if total in first:\n best = max(best, i - first[total])\n else:\n first[total] = i\n return best\n```\n", "starter": {"go": "package main\n\nfunc FindMaxLength(nums []int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def findMaxLength(self, nums: List[int]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int findMaxLength(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "findMaxLength", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[0,1]"], ["[0,1,0]"], ["[0,0,1,0,0,0,1,1]"], ["[0]"], ["[1]"], ["[0,0]"], ["[1,1]"], ["[0,0,0]"], ["[1,1,1]"], ["[0,1,1,0]"], ["[1,0,0,1]"], ["[0,0,1,1]"], ["[1,1,0,0]"], ["[0,1,0,1,0,1]"], ["[1,0,1,0,1,0,1,0]"], ["[0,0,0,1,1,1]"], ["[1,0,0,0,1,1,1,0]"], ["[0,1,0,0,1,1,0,1,0,1]"], ["[0,0,0,0]"], ["[1,1,1,1]"], ["[0,1,1,1,0,0,1,0]"], ["[1,0,1,1,0,0,0,1,1,0]"], ["[0,0,1,1,0,1,0,0,1,1,0,1]"], ["[1,1,0,1,0,0,1,0,1,1,0,0]"], ["[0,1,0,1,1,0,0,1]"], ["[1,0,0,1,1,1,0,0,1,0,0,1,1,0]"], ["[0,0,1,0,1,1,1,0,0,1]"], ["[1,1,1,0,0,0,1,1,1,0,0,0]"]], "expected": [2, 2, 6, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 6, 8, 6, 8, 10, 0, 0, 8, 10, 12, 12, 8, 14, 10, 12], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "582", "slug": "continuous-subarray-sum", "id": 582, "title": "Continuous Subarray Sum", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/continuous-subarray-sum/", "examples": [{"input": "nums = [23,2,4,6,7], k = 6", "output": "true", "explanation": "The slice [2,4] sums to 6, a multiple of 6."}, {"input": "nums = [23,2,6,4,7], k = 6", "output": "true", "explanation": "The whole array sums to 42, which is 7 times 6."}, {"input": "nums = [23,2,6,4,7], k = 13", "output": "false", "explanation": "No slice of length 2 or more sums to a multiple of 13."}], "hints": ["Track prefix sums modulo k: if the same remainder appears at two positions at least two apart, the slice between them is good.", "Remember the first index where each remainder occurs; a repeat with distance 2 or more is a success.", "When k is zero there is no modulo to take, so look for a repeated raw prefix sum instead."], "statement": "You are given an integer array `nums` and an integer `k`. A subarray is called *good* when it uses at least two consecutive positions and its elements add up to a multiple of `k` (that is, the sum divided by `k` leaves remainder zero; when `k` is zero this means the sum itself must be zero).\n\nReturn `true` if `nums` contains at least one good subarray, and `false` otherwise.\n\n**Constraints:**\n- `1 <= nums.length <= 10^5`\n- `0 <= nums[i] <= 10^9`\n- `0 <= k <= 2^31 - 1`\n", "solution": "## Approach\n\nWalk the array while maintaining the running total. For a nonzero `k`, only the remainder of the running total modulo `k` matters: whenever the same remainder has been seen at least two positions earlier, the slice in between sums to a multiple of `k`. Storing each remainder's earliest index in a hash map finds such a slice in one pass. When `k` is zero there is no remainder to compute, so the same idea is applied to the raw running totals (a repeat means a zero-sum slice).\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the length of `nums`. Each element is processed once.\n- **Space Complexity:** O(n) in the worst case for the remainder map.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def checkSubarraySum(self, nums: List[int], k: int) -> bool:\n first = {0: -1}\n total = 0\n for i, v in enumerate(nums):\n total += v\n key = total if k == 0 else total % k\n if key in first:\n if i - first[key] >= 2:\n return True\n else:\n first[key] = i\n return False\n```\n", "starter": {"go": "package main\n\nfunc CheckSubarraySum(nums []int, k int) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def checkSubarraySum(self, nums: List[int], k: int) -> bool:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool checkSubarraySum(vector<int>& nums, int k) {\n return false;\n }\n};"}, "fn": "checkSubarraySum", "params": [{"name": "nums", "type": "int_array"}, {"name": "k", "type": "int"}], "outputType": "boolean", "tests": [["[23,2,4,6,7]", "6"], ["[23,2,6,4,7]", "6"], ["[23,2,6,4,7]", "13"], ["[0,0]", "0"], ["[0,0]", "1"], ["[1,0]", "0"], ["[0]", "0"], ["[5]", "5"], ["[1,2,3]", "5"], ["[1,2,3]", "7"], ["[2,4,3]", "6"], ["[1,1,1,1]", "2"], ["[1,1,1]", "2"], ["[1]", "2"], ["[1000000000,1000000000]", "1000000000"], ["[7,7,7]", "7"], ["[1,2,12]", "6"], ["[5,0,0]", "5"], ["[0,1,0]", "0"], ["[0,0,1]", "0"], ["[3,1,4,2]", "6"], ["[3,1,4,2]", "7"], ["[3,1,4,2]", "11"], ["[1,2,3,4,5]", "3"], ["[4,1,2,1]", "3"], ["[9,8,7,6,5]", "100"], ["[2,2]", "4"], ["[2,2]", "3"]], "expected": [true, true, false, true, true, false, false, false, true, false, true, true, true, false, true, true, false, true, false, true, true, true, false, true, true, false, true, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "479", "slug": "convert-a-number-to-hexadecimal", "id": 479, "title": "Convert a Number to Hexadecimal", "difficulty": "Easy", "category": "math", "link": "https://leetcode.com/problems/convert-a-number-to-hexadecimal/", "examples": [{"input": "num = 26", "output": "\"1a\"", "explanation": "26 equals 1 sixteen plus 10, written 1a."}, {"input": "num = -1", "output": "\"ffffffff\"", "explanation": "Negative values use 32-bit two's complement, so -1 becomes eight f digits."}, {"input": "num = 0", "output": "\"0\"", "explanation": "Zero maps to a single zero digit."}], "hints": ["Handle zero as a special case returning a single zero character.", "Treat the value as an unsigned 32-bit pattern so negatives wrap via two's complement.", "Peel off 4-bit groups from the low end, mapping 0-15 to 0-9a-f, until nothing remains."], "statement": "Write the hexadecimal form of a signed 32-bit integer `num`, using lowercase letters.\n\nNon-negative values convert in the usual base-16 way with no leading zeros (except that zero itself becomes `\"0\"`). Negative values first wrap into their 32-bit two's complement bit pattern and then convert that unsigned pattern the same way. For instance, `-1` has all 32 bits set, giving eight `f` characters.\n\nDo not call a built-in base-conversion helper; build the digits directly.\n\n**Constraints:**\n- `-2^31 <= num <= 2^31 - 1`\n- Output uses only `0-9` and `a-f`, with no leading zeros unless the value is zero.\n", "solution": "## Approach\n\nZero returns immediately. Otherwise the signed value is masked into an unsigned 32-bit range, which automatically gives the two's complement pattern for negatives. Repeatedly taking the lowest four bits yields one hex digit at a time from least to most significant; reversing the collected digits drops all leading zeros.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1), at most eight hex digits.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def toHex(self, num: int) -> str:\n if num == 0:\n return \"0\"\n dig = \"0123456789abcdef\"\n v = num & 0xFFFFFFFF\n out = []\n while v != 0:\n out.append(dig[v & 0xF])\n v >>= 4\n return \"\".join(reversed(out))\n```\n", "starter": {"go": "package main\n\nfunc ToHex(num int) string {\n return \"\"\n}", "python": "class Solution:\n def toHex(self, num: int) -> str:\n return \"\"", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n string toHex(int num) {\n return \"\";\n }\n};"}, "fn": "toHex", "params": [{"name": "num", "type": "int"}], "outputType": "string", "tests": [["26"], ["-1"], ["0"], ["16"], ["1"], ["15"], ["17"], ["255"], ["256"], ["-16"], ["-255"], ["-2"], ["2147483647"], ["-2147483648"], ["4096"], ["-4096"], ["100"], ["-100"], ["1000"], ["-1000"], ["123456"], ["-123456"], ["10"], ["11"], ["31"], ["32"], ["25555"], ["-25555"], ["2"], ["7"]], "expected": ["1a", "ffffffff", "0", "10", "1", "f", "11", "ff", "100", "fffffff0", "ffffff01", "fffffffe", "7fffffff", "80000000", "1000", "fffff000", "64", "ffffff9c", "3e8", "fffffc18", "1e240", "fffe1dc0", "a", "b", "1f", "20", "63d3", "ffff9c2d", "2", "7"], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "496", "slug": "convert-binary-search-tree-to-sorted-doubly-linked-list", "id": 496, "title": "Convert Binary Search Tree to Sorted Doubly Linked List", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/", "examples": [{"input": "root = [4,2,5,1,3]", "output": "[1,null,2,null,3,null,4,null,5]", "explanation": "Inorder gives 1,2,3,4,5 chained through right pointers."}, {"input": "root = [2,1,3]", "output": "[1,null,2,null,3]", "explanation": "The sorted order is 1,2,3."}, {"input": "root = []", "output": "[]", "explanation": "An empty tree flattens to nothing."}], "hints": ["Collect values with an inorder walk; a BST yields them sorted.", "Rebuild a right-only chain from that order and clear every left pointer.", "Adaptation: the circular and previous links are omitted so output stays serializable."], "statement": "You are given the root of a binary search tree. Rearrange its nodes into ascending order linked through the `right` pointer, so that following `right` from the smallest node visits every value exactly once from low to high.\n\nReturn the head (the smallest node) of that chain. All `left` pointers in the returned structure must be `null` so the result remains a valid tree serialization.\n\n**Constraints:**\n- The tree holds between 0 and 1000 nodes.\n- Node values fit in a 32-bit signed integer.\n- The input is a valid binary search tree.\n\nAdaptation: the source produces a circular doubly linked list using left as previous and right as next. Because circular and backward links cannot be serialized as a tree without looping forever, this judge asks for the linear right-only chain (left pointers cleared, circular link omitted); only the ascending right order is checked.\n", "solution": "## Approach\n\nGather the BST values with an inorder traversal, which emits them in ascending order. Then stitch a fresh right-leaning chain from those values, leaving every left pointer empty. The head of that chain is the answer in this linearized adaptation.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the node count. One inorder pass plus one chaining pass.\n- **Space Complexity:** O(n) for the value list and the rebuilt chain.\n\n## Implementation\n\n```python\nclass Solution:\n def treeToDoublyList(self, root):\n vals = []\n def inorder(n):\n if not n:\n return\n inorder(n.left)\n vals.append(n.val)\n inorder(n.right)\n inorder(root)\n if not vals:\n return None\n head = TreeNode(vals[0])\n cur = head\n for v in vals[1:]:\n cur.right = TreeNode(v)\n cur = cur.right\n return head\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 TreeToDoublyList(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 treeToDoublyList(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* treeToDoublyList(TreeNode* root) {\n \n }\n};"}, "fn": "treeToDoublyList", "params": [{"name": "root", "type": "tree_node", "visualizeType": "tree_node"}], "outputType": "tree_node", "tests": [["[4,2,5,1,3]"], ["[2,1,3]"], ["[]"], ["[1]"], ["[5,3,7,2,4,6,8]"], ["[10,5,15,3,7,13,18]"], ["[1,null,2,null,3]"], ["[3,2,1]"], ["[2,null,3]"], ["[4,2,6,1,3,5,7]"], ["[8,4,12,2,6,10,14]"], ["[1,null,2]"], ["[50,30,70,20,40,60,80]"], ["[6,2,8,0,4,7,9,null,null,3,5]"], ["[3]"], ["[3,null,4]"], ["[3,1,null]"], ["[5,3,6,2,4]"], ["[7,3,10,1,5,null,12]"], ["[9,5,null,3,7]"], ["[15,10,20,8,12,17,25]"], ["[1,null,2,null,3,null,4]"], ["[4,3,null,2,null,1]"], ["[11,6,15,3,8,13,17]"], ["[100]"], ["[0]"], ["[-5,-10,0]"], ["[20,10,30,5,15,25,35]"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "596", "slug": "convert-bst-to-greater-tree", "id": 596, "title": "Convert BST to Greater Tree", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/convert-bst-to-greater-tree/", "examples": [{"input": "root = [4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]", "output": "[30,36,21,36,35,26,15,null,null,null,33,null,null,null,8]", "explanation": "Each node becomes its own value plus all larger values (e.g. 4 becomes 30)."}, {"input": "root = [0,null,1]", "output": "[1,null,1]", "explanation": "The node 1 keeps 1; the node 0 absorbs it and becomes 1."}, {"input": "root = [1,0,2]", "output": "[3,3,2]", "explanation": "Node 2 keeps 2, node 1 becomes 3, node 0 becomes 3."}], "hints": ["Walk the tree right-first so keys are visited from largest to smallest.", "Carry a running total: add each node's original value to it, then overwrite the node with the total.", "The shape never changes; only the stored values are rewritten."], "statement": "You are given the root of a binary search tree (BST). Rewrite the tree so that every node's value becomes the sum of its original value plus all values greater than it (keeping the same shape). In other words, each node accumulates the total of its own key and every larger key in the tree.\n\nReturn the root of the rewritten tree.\n\n**Constraints:**\n- The tree holds between 0 and 10^4 nodes.\n- `-10^4 <= Node.val <= 10^4`\n- The tree is a valid BST with distinct values.\n- The rewritten values fit in a 32-bit signed integer.\n", "solution": "## Approach\n\nA reversed inorder walk (right subtree, node, left subtree) visits BST keys from largest to smallest. A running accumulator adds each node's original value and then replaces the node's value with the accumulator, so every node ends up holding its own key plus all greater keys. The tree structure is left untouched.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the number of nodes. Each node is visited once.\n- **Space Complexity:** O(h) for the recursion stack, where h is the tree height.\n\n## Implementation\n\n```python\nclass Solution:\n def convertBST(self, root):\n self.acc = 0\n def walk(node):\n if not node:\n return\n walk(node.right)\n self.acc += node.val\n node.val = self.acc\n walk(node.left)\n walk(root)\n return root\n```\n", "starter": {"go": "package main\n\n/*\nDefinition for a binary tree node.\ntype TreeNode struct {\n Val int\n Left *TreeNode\n Right *TreeNode\n}\n*/\n\nfunc ConvertBST(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 convertBST(self, root):\n pass\n", "cpp": "/*\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n};\n*/\nclass Solution {\npublic:\n TreeNode* convertBST(TreeNode* root) {\n return nullptr;\n }\n};"}, "fn": "convertBST", "params": [{"name": "root", "type": "tree_node", "visualizeType": "tree_node"}], "outputType": "tree_node", "tests": [["[4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]"], ["[0,null,1]"], ["[1,0,2]"], ["[]"], ["[0]"], ["[2,1,3]"], ["[5,3,7,2,4,6,8]"], ["[1,null,2,null,3]"], ["[3,2,null,1]"], ["[10,5,15,2,7,12,20]"], ["[-5,-10,0,null,-7,null,3]"], ["[100,50,150,25,75,125,175]"], ["[7,3,9,1,5,null,10]"], ["[50,30,70,20,40,60,80]"], ["[8,3,10,1,6,null,14,null,null,4,7,13]"], ["[1,0,2]"], ["[3,1,4,null,2]"], ["[5,1,9,0,2,7,10]"], ["[20,10,30,5,15,25,35]"], ["[6,2,8,0,4,7,9,null,null,3,5]"], ["[2,0,4,-1,1,3,5]"], ["[15,6,20,3,9,17,25]"], ["[11,5,18,2,8,14,22]"], ["[9,4,14,2,6,12,16]"], ["[27,14,40,7,20,33,47]"], ["[60,30,90,15,45,75,105]"], ["[4,1,7,0,2,5,9]"], ["[13,6,19,3,9,16,23]"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "287", "slug": "convert-sorted-array-to-binary-search-tree", "id": 287, "title": "Convert Sorted Array to Binary Search Tree", "difficulty": "Easy", "category": "tree", "link": "https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/", "examples": [{"input": "nums = [-10,-3,0,5,9]", "output": "[0,-3,9,-10,null,5]", "explanation": "One balanced choice puts 0 at the root with [-10,-3] left and [5,9] right; any height-balanced search tree with these values is accepted."}, {"input": "nums = [1,3]", "output": "[3,1]", "explanation": "Either [3,1] or [1,null,3] is balanced; the checker accepts any valid one."}], "hints": ["Pick the middle entry as the root so both halves stay roughly equal in size.", "Recurse on the left slice and right slice to build balanced children.", "Any height-balanced search tree holding exactly these values passes; the checker validates ordering and balance, not exact shape."], "statement": "Turn an ascending integer list into a height-balanced binary search tree.\n\nA height-balanced tree requires that, for every node, the depths of its two subtrees differ by at most one. Combined with the search-tree ordering (left values smaller, right values larger), this keeps the tree shallow. Choose elements so both sides stay even, build each side the same way, and return the root.\n\nBecause several balanced shapes can be valid, any height-balanced search tree containing exactly the input values is accepted.\n\n**Constraints:**\n- `1 <= nums.length <= 10^4`\n- `-10^4 <= nums[i] <= 10^4`\n- `nums` is sorted in strictly increasing order.\n", "solution": "## Approach\n\nThe middle of a sorted slice is the ideal root: it leaves equal-sized halves for the children, which guarantees balance. Recurse on the left half and right half with the same rule. Each level halves the input, so the recursion depth stays logarithmic.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), every entry becomes one node.\n- **Space Complexity:** O(log n) recursion depth for balanced output, O(n) for the tree itself.\n\n## Implementation\n\n```python\nclass Solution:\n def sortedArrayToBST(self, nums):\n def build(l, r):\n if l > r:\n return None\n m = (l + r) // 2\n n = TreeNode(nums[m])\n n.left = build(l, m - 1)\n n.right = build(m + 1, r)\n return n\n return build(0, len(nums) - 1)\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 SortedArrayToBST(nums []int) *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\nfrom typing import List\nclass Solution:\n def sortedArrayToBST(self, nums: List[int]):\n pass\n", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\n#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n TreeNode* sortedArrayToBST(vector<int>& nums) {\n \n }\n};"}, "fn": "sortedArrayToBST", "params": [{"name": "nums", "type": "int_array"}], "outputType": "tree_node", "tests": [["[-10,-3,0,5,9]"], ["[1,3]"], ["[1]"], ["[1,2,3,4,5]"], ["[0,1,2,3,4,5,6,7]"], ["[-5,-4,-3,-2,-1]"], ["[1,2]"], ["[1,2,3]"], ["[1,2,3,4]"], ["[1,2,3,4,5,6]"], ["[1,2,3,4,5,6,7]"], ["[-10,-3,0,5,9,12]"], ["[0]"], ["[-1,0]"], ["[0,1]"], ["[-100,0,100]"], ["[1,3,5,7,9,11,13]"], ["[-7,-5,-3,-1,1,3,5]"], ["[2,4,6,8,10,12,14,16,18]"], ["[1,2,3,4,5,6,7,8,9]"], ["[-9,-7,-5,-3,-1,0,2,4]"], ["[10,20,30,40,50]"], ["[-2,-1,0,1,2]"], ["[5]"], ["[1,2,3,4,5,6,7,8,9,10,11]"], ["[-10000,0,10000]"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "288", "slug": "convert-sorted-list-to-binary-search-tree", "id": 288, "title": "Convert Sorted List to Binary Search Tree", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/", "examples": [{"input": "head = [-10,-3,0,5,9]", "output": "[0,-3,9,-10,null,5]", "explanation": "The ordered values become a balanced search tree; any balanced arrangement with the same inorder sequence is accepted."}, {"input": "head = []", "output": "[]", "explanation": "An empty list yields an empty tree."}, {"input": "head = [1]", "output": "[1]", "explanation": "One value becomes one node."}], "hints": ["Copy the list values into an array first; then the task matches building a balanced tree from a sorted array.", "Alternatively use slow/fast pointers to find each subtree midpoint without extra storage.", "The checker validates search ordering, balance, and exact value multiset \u2014 not one fixed shape."], "statement": "Build a height-balanced binary search tree from the values of an ascending singly linked list.\n\nWalk the list to gather its values in order, then convert that ordered sequence into a balanced tree: the middle value becomes the root and each half recursively becomes a subtree. Every node's two subtree heights may differ by at most one.\n\nReturn the tree root. An empty list produces an empty tree, and any balanced search tree holding exactly the list values is accepted.\n\n**Constraints:**\n- `0 <= number of list nodes <= 2 * 10^4`\n- `-10^5 <= Node.val <= 10^5`\n- Values appear in non-decreasing order.\n", "solution": "## Approach\n\nDrain the linked list into an array to get random access to the sorted values. Then apply the classic middle-as-root construction: the center entry becomes the root, the left slice builds the left subtree, and the right slice builds the right subtree. Recursion depth stays logarithmic because each step halves the range.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), one pass over the list plus one node creation per value.\n- **Space Complexity:** O(n) for the value array plus O(log n) recursion depth.\n\n## Implementation\n\n```python\nclass Solution:\n def sortedListToBST(self, head):\n vals = []\n p = head\n while p:\n vals.append(p.val)\n p = p.next\n def build(l, r):\n if l > r:\n return None\n m = (l + r) // 2\n n = TreeNode(vals[m])\n n.left = build(l, m - 1)\n n.right = build(m + 1, r)\n return n\n return build(0, len(vals) - 1)\n```\n", "starter": {"go": "// Definition for singly-linked list.\n// type ListNode struct {\n// Val int\n// Next *ListNode\n// }\n// Definition for a binary tree node.\n// type TreeNode struct {\n// Val int\n// Left *TreeNode\n// Right *TreeNode\n// }\npackage main\n\nfunc SortedListToBST(head *ListNode) *TreeNode {\n \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\n# 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 sortedListToBST(self, head):\n pass\n", "cpp": "/*\nDefinition for singly-linked list.\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*/\n/*\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* sortedListToBST(ListNode* head) {\n \n }\n};"}, "fn": "sortedListToBST", "params": [{"name": "head", "type": "list_node"}], "outputType": "tree_node", "tests": [["[-10,-3,0,5,9]"], ["[]"], ["[1]"], ["[1,2,3,4,5]"], ["[1,2]"], ["[1,2,3]"], ["[1,2,3,4]"], ["[1,2,3,4,5,6]"], ["[1,2,3,4,5,6,7]"], ["[-5,-4,-3,-2,-1]"], ["[0,1,2,3,4,5,6,7]"], ["[-10,-3,0,5,9,12]"], ["[1,3]"], ["[1,3,5,7,9]"], ["[2,4,6,8,10]"], ["[0]"], ["[-1,0]"], ["[0,1]"], ["[5]"], ["[1,2,3,4,5,6,7,8,9]"], ["[-9,-7,-5,-3,-1,1,3]"], ["[10,20,30,40,50]"], ["[-2,-1,0,1,2]"], ["[1,2,3,4,5,6,7,8]"], ["[100,200,300]"], ["[-100,0,100]"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "534", "slug": "convex-polygon", "id": 534, "title": "Convex Polygon", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/convex-polygon/", "examples": [{"input": "polygon = [[0,0],[0,1],[1,1],[1,0]]", "output": "true", "explanation": "A unit square: every consecutive turn bends the same way."}, {"input": "polygon = [[0,0],[0,10],[10,10],[10,0],[5,5]]", "output": "false", "explanation": "The last vertex dents inward, so one turn bends the opposite way from the rest."}], "hints": ["The sign of the cross product of each pair of consecutive edges tells you which way the boundary turns.", "Straight (collinear) joints carry no turn information and can be skipped; everything else must agree in sign."], "statement": "You are given the vertices of a polygon in order (either clockwise or counter-clockwise), where `polygon[i] = [x, y]` is the `i`-th vertex and the last vertex connects back to the first.\n\nA polygon is convex when its boundary always turns the same way: walking along the vertices, every turn is either always left or always right. Joints where three consecutive vertices lie on a straight line are allowed and do not break convexity.\n\nReturn `true` if the polygon is convex, and `false` otherwise.\n\n**Constraints:**\n- `3 <= polygon.length <= 10^4`\n- `-10^4 <= polygon[i][0], polygon[i][1] <= 10^4`\n", "solution": "## Approach\n\nFor each triple of consecutive vertices (wrapping around), compute the cross product of the two edge vectors: its sign reports a left or right turn. Collinear triples give zero and are ignored. If all non-zero turns share one sign, the polygon is convex; the first sign disagreement proves a dent.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) for the single pass over the vertices.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def isConvex(self, polygon: List[List[int]]) -> bool:\n n = len(polygon)\n sign = 0\n for i in range(n):\n ax, ay = polygon[i]\n bx, by = polygon[(i + 1) % n]\n cx, cy = polygon[(i + 2) % n]\n cross = (bx - ax) * (cy - by) - (by - ay) * (cx - bx)\n if cross != 0:\n s = 1 if cross > 0 else -1\n if sign == 0:\n sign = s\n elif sign != s:\n return False\n return True\n```\n", "starter": {"go": "package main\n\nfunc IsConvex(polygon [][]int) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def isConvex(self, polygon: List[List[int]]) -> bool:\n pass", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n bool isConvex(vector<vector<int>>& polygon) {\n return false;\n }\n};"}, "fn": "isConvex", "params": [{"name": "polygon", "type": "int_array_2d"}], "outputType": "boolean", "tests": [["[[0,0],[0,1],[1,1],[1,0]]"], ["[[0,0],[0,10],[10,10],[10,0],[5,5]]"], ["[[0,0],[1,0],[0,1]]"], ["[[0,0],[0,1],[0,2],[1,2],[1,0]]"], ["[[1,0],[2,1],[1,2],[0,1]]"], ["[[0,0],[2,0],[2,2],[1,1],[0,2]]"], ["[[0,0],[3,0],[3,3],[0,3]]"], ["[[0,0],[4,0],[4,4],[2,1],[0,4]]"], ["[[0,0],[2,1],[3,3],[1,4],[-1,2]]"], ["[[0,0],[1,0],[1,1],[0,1]]"], ["[[0,0],[2,0],[1,1]]"], ["[[0,0],[5,0],[5,5],[0,5]]"], ["[[0,0],[1,0],[2,0],[2,1],[0,1]]"], ["[[0,0],[4,0],[4,4],[2,2],[0,4]]"], ["[[0,0],[1,1],[2,0],[1,-1]]"], ["[[0,0],[2,0],[3,1],[2,2],[0,2],[-1,1]]"], ["[[0,0],[10,0],[10,10],[5,5],[0,10]]"], ["[[0,0],[0,5],[5,5],[5,0]]"], ["[[-5,-5],[5,-5],[5,5],[-5,5]]"], ["[[0,0],[4,0],[0,4]]"], ["[[0,0],[6,0],[6,1],[0,1]]"], ["[[1,1],[3,1],[2,3]]"], ["[[0,0],[2,0],[2,1],[1,1],[1,2],[0,2]]"], ["[[0,0],[3,1],[2,4],[-1,3],[-2,1]]"], ["[[0,0],[1,0],[1,2],[0,2]]"], ["[[5,0],[10,5],[5,10],[0,5]]"], ["[[0,0],[2,0],[2,2],[0,2],[1,1]]"], ["[[0,0],[5,0],[5,1],[0,1]]"]], "expected": [true, false, true, true, true, false, true, false, true, true, true, true, true, false, true, true, false, true, true, true, true, true, false, true, true, true, false, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "92", "slug": "copy-list-with-random-pointer", "id": 92, "title": "Copy List with Random Pointer", "difficulty": "Medium", "category": "linked-list", "link": "https://leetcode.com/problems/copy-list-with-random-pointer/", "examples": [{"input": "nodes = [[7,-1],[13,0],[11,4],[10,2],[1,0]]", "output": "[[7,-1],[13,0],[11,4],[10,2],[1,0]]", "explanation": "Each returned row preserves the node value and the index targeted by its random pointer."}, {"input": "nodes = [[1,1],[2,1]]", "output": "[[1,1],[2,1]]", "explanation": "A deep copy of the linked list preserves all node values and random pointer targets: [[1,1],[2,1]]."}, {"input": "nodes = []", "output": "[]", "explanation": "A deep copy of the empty list is also empty: []."}], "hints": ["Create one copied row or conceptual copied node for every original position before resolving random targets.", "The random index already identifies the target position, so preserve `-1` and every valid index exactly.", "Do not return or reuse mutable input rows; construct an independent result."], "statement": "You are given a linked list in a portable serialized form. Each row of `nodes` is\n`[value, randomIndex]` for one node:\n\n- Node `i` has value `value`.\n- Its `next` pointer targets node `i + 1`, or `null` for the final node.\n- Its `random` pointer targets node `randomIndex`, or is `null` when\n `randomIndex` is `-1`.\n\nReturn the same structural encoding for a **deep copy** of the list. Conceptually,\nevery returned node must be newly allocated, and both `next` and `random` pointers\nmust refer only to copied nodes.\n\nThis `int[][]` interface is a portable serialization adaptation of the usual\nnode-based random-pointer-list API. Because object identity cannot be represented\nin the returned JSON value, the judge compares the copied list's serialized\nstructure.\n\n**Constraints:**\n\n- `0 <= nodes.length <= 1000`\n- `nodes[i].length == 2`\n- `-10^4 <= nodes[i][0] <= 10^4`\n- `nodes[i][1] == -1` or `0 <= nodes[i][1] < nodes.length`\n", "solution": "## Approach\n\nThe portable input already describes every node by its value and random target index. Build a new outer list and copy each row so the result has the same structure without sharing mutable rows with the input.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where `n` is the number of serialized nodes.\n- **Space Complexity:** O(n) for the copied output.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def copyRandomList(self, nodes: List[List[int]]) -> List[List[int]]:\n return [row[:] for row in nodes]\n```\n", "starter": {"go": "package main\n\nfunc CopyRandomList(nodes [][]int) [][]int {\n return nil\n}", "python": "from typing import List\n\nclass Solution:\n def copyRandomList(self, nodes: List[List[int]]) -> List[List[int]]:\n pass\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<vector<int>> copyRandomList(vector<vector<int>>& nodes) {\n return {};\n }\n};"}, "fn": "copyRandomList", "params": [{"name": "nodes", "type": "int_array_2d"}], "outputType": "int_array_2d", "tests": [["[]"], ["[[7,-1]]"], ["[[7,0]]"], ["[[1,-1],[2,-1]]"], ["[[1,1],[2,0]]"], ["[[1,0],[2,1]]"], ["[[1,1],[2,1]]"], ["[[7,-1],[13,0],[11,4],[10,2],[1,0]]"], ["[[3,2],[3,-1],[3,0]]"], ["[[0,-1],[0,-1],[0,-1]]"], ["[[-1,2],[-2,0],[-3,1]]"], ["[[10000,1],[-10000,0]]"], ["[[5,3],[6,2],[7,1],[8,0]]"], ["[[5,0],[6,0],[7,0],[8,0]]"], ["[[5,3],[6,3],[7,3],[8,3]]"], ["[[1,-1],[2,0],[3,1],[4,2],[5,3]]"], ["[[1,1],[2,2],[3,3],[4,4],[5,-1]]"], ["[[1,4],[2,3],[3,2],[4,1],[5,0]]"], ["[[9,2],[8,2],[7,2],[6,2],[5,2]]"], ["[[9,-1],[8,4],[7,-1],[6,1],[5,3]]"], ["[[10,5],[20,4],[30,3],[40,2],[50,1],[60,0]]"], ["[[10,1],[20,2],[30,3],[40,4],[50,5],[60,0]]"], ["[[10,-1],[20,-1],[30,-1],[40,-1],[50,-1],[60,-1]]"], ["[[4,6],[8,5],[15,4],[16,3],[23,2],[42,1],[108,0]]"], ["[[4,0],[8,1],[15,2],[16,3],[23,4],[42,5],[108,6]]"], ["[[2,1],[4,0],[6,3],[8,2],[10,5],[12,4],[14,-1]]"], ["[[-7,-1],[-6,0],[-5,0],[-4,1],[-3,1],[-2,2],[-1,2]]"], ["[[0,7],[1,6],[2,5],[3,4],[4,3],[5,2],[6,1],[7,0]]"], ["[[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,0]]"], ["[[0,-1],[1,0],[2,-1],[3,2],[4,-1],[5,4],[6,-1],[7,6]]"], ["[[11,8],[22,7],[33,6],[44,5],[55,4],[66,3],[77,2],[88,1],[99,0]]"], ["[[11,0],[22,0],[33,0],[44,0],[55,0],[66,0],[77,0],[88,0],[99,0]]"], ["[[11,8],[22,8],[33,8],[44,8],[55,8],[66,8],[77,8],[88,8],[99,8]]"], ["[[1,2],[1,3],[2,4],[3,5],[5,6],[8,7],[13,8],[21,9],[34,0],[55,1]]"], ["[[1,9],[2,8],[3,7],[4,6],[5,5],[6,4],[7,3],[8,2],[9,1],[10,0]]"], ["[[-10,1],[-9,2],[-8,3],[-7,4],[-6,5],[-5,6],[-4,7],[-3,8],[-2,9],[-1,-1]]"], ["[[100,-1],[200,0],[300,0],[400,0],[500,0],[600,0],[700,0],[800,0],[900,0],[1000,0]]"], ["[[100,9],[200,9],[300,9],[400,9],[500,9],[600,9],[700,9],[800,9],[900,9],[1000,-1]]"], ["[[6,3],[2,0],[6,7],[4,4],[3,1],[3,5],[8,-1],[1,2],[9,8],[7,6]]"], ["[[42,5],[42,4],[42,3],[42,2],[42,1],[42,0]]"], ["[[-10000,10],[-8000,9],[-6000,8],[-4000,7],[-2000,6],[0,5],[2000,4],[4000,3],[6000,2],[8000,1],[10000,0]]"], ["[[0,0],[1,-1],[2,2],[3,-1],[4,4],[5,-1],[6,6],[7,-1],[8,8],[9,-1],[10,10]]"], ["[[12,11],[11,10],[10,9],[9,8],[8,7],[7,6],[6,5],[5,4],[4,3],[3,2],[2,1],[1,0]]"], ["[[12,1],[11,2],[10,3],[9,4],[8,5],[7,6],[6,7],[5,8],[4,9],[3,10],[2,11],[1,0]]"], ["[[5,-1],[-5,0],[5,1],[-5,2],[5,3],[-5,4],[5,5],[-5,6],[5,7],[-5,8],[5,9],[-5,10]]"], ["[[13,4],[21,6],[34,8],[55,10],[89,0],[144,2],[233,4],[377,6],[610,8],[987,10],[1597,-1]]"], ["[[1,12],[2,11],[3,10],[4,9],[5,8],[6,7],[7,6],[8,5],[9,4],[10,3],[11,2],[12,1],[13,0]]"], ["[[1,-1],[2,0],[3,0],[4,1],[5,1],[6,2],[7,2],[8,3],[9,3],[10,4],[11,4],[12,5],[13,5]]"], ["[[99,7],[98,0],[97,12],[96,2],[95,9],[94,-1],[93,3],[92,11],[91,5],[90,1],[89,10],[88,4],[87,8]]"], ["[[0,14],[1,13],[2,12],[3,11],[4,10],[5,9],[6,8],[7,7],[8,6],[9,5],[10,4],[11,3],[12,2],[13,1],[14,0]]"], ["[[15,1],[14,2],[13,3],[12,4],[11,5],[10,6],[9,7],[8,8],[7,9],[6,10],[5,11],[4,12],[3,13],[2,14],[1,-1]]"], ["[[3,5],[1,8],[4,13],[1,0],[5,2],[9,4],[2,6],[6,10],[5,12],[3,14],[5,7],[8,9],[9,11],[7,3],[9,-1]]"], ["@javascript:JSON.stringify(Array.from({length:999},(_,i)=>[i%2===0?-10000:10000,(i*37)%999]))"], ["@javascript:JSON.stringify(Array.from({length:1000},(_,i)=>[(i%20001)-10000,999-i]))"]], "expected": [[], [[7, -1]], [[7, 0]], [[1, -1], [2, -1]], [[1, 1], [2, 0]], [[1, 0], [2, 1]], [[1, 1], [2, 1]], [[7, -1], [13, 0], [11, 4], [10, 2], [1, 0]], [[3, 2], [3, -1], [3, 0]], [[0, -1], [0, -1], [0, -1]], [[-1, 2], [-2, 0], [-3, 1]], [[10000, 1], [-10000, 0]], [[5, 3], [6, 2], [7, 1], [8, 0]], [[5, 0], [6, 0], [7, 0], [8, 0]], [[5, 3], [6, 3], [7, 3], [8, 3]], [[1, -1], [2, 0], [3, 1], [4, 2], [5, 3]], [[1, 1], [2, 2], [3, 3], [4, 4], [5, -1]], [[1, 4], [2, 3], [3, 2], [4, 1], [5, 0]], [[9, 2], [8, 2], [7, 2], [6, 2], [5, 2]], [[9, -1], [8, 4], [7, -1], [6, 1], [5, 3]], [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1], [60, 0]], [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 0]], [[10, -1], [20, -1], [30, -1], [40, -1], [50, -1], [60, -1]], [[4, 6], [8, 5], [15, 4], [16, 3], [23, 2], [42, 1], [108, 0]], [[4, 0], [8, 1], [15, 2], [16, 3], [23, 4], [42, 5], [108, 6]], [[2, 1], [4, 0], [6, 3], [8, 2], [10, 5], [12, 4], [14, -1]], [[-7, -1], [-6, 0], [-5, 0], [-4, 1], [-3, 1], [-2, 2], [-1, 2]], [[0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [7, 0]], [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]], [[0, -1], [1, 0], [2, -1], [3, 2], [4, -1], [5, 4], [6, -1], [7, 6]], [[11, 8], [22, 7], [33, 6], [44, 5], [55, 4], [66, 3], [77, 2], [88, 1], [99, 0]], [[11, 0], [22, 0], [33, 0], [44, 0], [55, 0], [66, 0], [77, 0], [88, 0], [99, 0]], [[11, 8], [22, 8], [33, 8], [44, 8], [55, 8], [66, 8], [77, 8], [88, 8], [99, 8]], [[1, 2], [1, 3], [2, 4], [3, 5], [5, 6], [8, 7], [13, 8], [21, 9], [34, 0], [55, 1]], [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0]], [[-10, 1], [-9, 2], [-8, 3], [-7, 4], [-6, 5], [-5, 6], [-4, 7], [-3, 8], [-2, 9], [-1, -1]], [[100, -1], [200, 0], [300, 0], [400, 0], [500, 0], [600, 0], [700, 0], [800, 0], [900, 0], [1000, 0]], [[100, 9], [200, 9], [300, 9], [400, 9], [500, 9], [600, 9], [700, 9], [800, 9], [900, 9], [1000, -1]], [[6, 3], [2, 0], [6, 7], [4, 4], [3, 1], [3, 5], [8, -1], [1, 2], [9, 8], [7, 6]], [[42, 5], [42, 4], [42, 3], [42, 2], [42, 1], [42, 0]], [[-10000, 10], [-8000, 9], [-6000, 8], [-4000, 7], [-2000, 6], [0, 5], [2000, 4], [4000, 3], [6000, 2], [8000, 1], [10000, 0]], [[0, 0], [1, -1], [2, 2], [3, -1], [4, 4], [5, -1], [6, 6], [7, -1], [8, 8], [9, -1], [10, 10]], [[12, 11], [11, 10], [10, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]], [[12, 1], [11, 2], [10, 3], [9, 4], [8, 5], [7, 6], [6, 7], [5, 8], [4, 9], [3, 10], [2, 11], [1, 0]], [[5, -1], [-5, 0], [5, 1], [-5, 2], [5, 3], [-5, 4], [5, 5], [-5, 6], [5, 7], [-5, 8], [5, 9], [-5, 10]], [[13, 4], [21, 6], [34, 8], [55, 10], [89, 0], [144, 2], [233, 4], [377, 6], [610, 8], [987, 10], [1597, -1]], [[1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7], [7, 6], [8, 5], [9, 4], [10, 3], [11, 2], [12, 1], [13, 0]], [[1, -1], [2, 0], [3, 0], [4, 1], [5, 1], [6, 2], [7, 2], [8, 3], [9, 3], [10, 4], [11, 4], [12, 5], [13, 5]], [[99, 7], [98, 0], [97, 12], [96, 2], [95, 9], [94, -1], [93, 3], [92, 11], [91, 5], [90, 1], [89, 10], [88, 4], [87, 8]], [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [8, 6], [9, 5], [10, 4], [11, 3], [12, 2], [13, 1], [14, 0]], [[15, 1], [14, 2], [13, 3], [12, 4], [11, 5], [10, 6], [9, 7], [8, 8], [7, 9], [6, 10], [5, 11], [4, 12], [3, 13], [2, 14], [1, -1]], [[3, 5], [1, 8], [4, 13], [1, 0], [5, 2], [9, 4], [2, 6], [6, 10], [5, 12], [3, 14], [5, 7], [8, 9], [9, 11], [7, 3], [9, -1]], [[-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962], [10000, 0], [-10000, 37], [10000, 74], [-10000, 111], [10000, 148], [-10000, 185], [10000, 222], [-10000, 259], [10000, 296], [-10000, 333], [10000, 370], [-10000, 407], [10000, 444], [-10000, 481], [10000, 518], [-10000, 555], [10000, 592], [-10000, 629], [10000, 666], [-10000, 703], [10000, 740], [-10000, 777], [10000, 814], [-10000, 851], [10000, 888], [-10000, 925], [10000, 962], [-10000, 0], [10000, 37], [-10000, 74], [10000, 111], [-10000, 148], [10000, 185], [-10000, 222], [10000, 259], [-10000, 296], [10000, 333], [-10000, 370], [10000, 407], [-10000, 444], [10000, 481], [-10000, 518], [10000, 555], [-10000, 592], [10000, 629], [-10000, 666], [10000, 703], [-10000, 740], [10000, 777], [-10000, 814], [10000, 851], [-10000, 888], [10000, 925], [-10000, 962]], [[-10000, 999], [-9999, 998], [-9998, 997], [-9997, 996], [-9996, 995], [-9995, 994], [-9994, 993], [-9993, 992], [-9992, 991], [-9991, 990], [-9990, 989], [-9989, 988], [-9988, 987], [-9987, 986], [-9986, 985], [-9985, 984], [-9984, 983], [-9983, 982], [-9982, 981], [-9981, 980], [-9980, 979], [-9979, 978], [-9978, 977], [-9977, 976], [-9976, 975], [-9975, 974], [-9974, 973], [-9973, 972], [-9972, 971], [-9971, 970], [-9970, 969], [-9969, 968], [-9968, 967], [-9967, 966], [-9966, 965], [-9965, 964], [-9964, 963], [-9963, 962], [-9962, 961], [-9961, 960], [-9960, 959], [-9959, 958], [-9958, 957], [-9957, 956], [-9956, 955], [-9955, 954], [-9954, 953], [-9953, 952], [-9952, 951], [-9951, 950], [-9950, 949], [-9949, 948], [-9948, 947], [-9947, 946], [-9946, 945], [-9945, 944], [-9944, 943], [-9943, 942], [-9942, 941], [-9941, 940], [-9940, 939], [-9939, 938], [-9938, 937], [-9937, 936], [-9936, 935], [-9935, 934], [-9934, 933], [-9933, 932], [-9932, 931], [-9931, 930], [-9930, 929], [-9929, 928], [-9928, 927], [-9927, 926], [-9926, 925], [-9925, 924], [-9924, 923], [-9923, 922], [-9922, 921], [-9921, 920], [-9920, 919], [-9919, 918], [-9918, 917], [-9917, 916], [-9916, 915], [-9915, 914], [-9914, 913], [-9913, 912], [-9912, 911], [-9911, 910], [-9910, 909], [-9909, 908], [-9908, 907], [-9907, 906], [-9906, 905], [-9905, 904], [-9904, 903], [-9903, 902], [-9902, 901], [-9901, 900], [-9900, 899], [-9899, 898], [-9898, 897], [-9897, 896], [-9896, 895], [-9895, 894], [-9894, 893], [-9893, 892], [-9892, 891], [-9891, 890], [-9890, 889], [-9889, 888], [-9888, 887], [-9887, 886], [-9886, 885], [-9885, 884], [-9884, 883], [-9883, 882], [-9882, 881], [-9881, 880], [-9880, 879], [-9879, 878], [-9878, 877], [-9877, 876], [-9876, 875], [-9875, 874], [-9874, 873], [-9873, 872], [-9872, 871], [-9871, 870], [-9870, 869], [-9869, 868], [-9868, 867], [-9867, 866], [-9866, 865], [-9865, 864], [-9864, 863], [-9863, 862], [-9862, 861], [-9861, 860], [-9860, 859], [-9859, 858], [-9858, 857], [-9857, 856], [-9856, 855], [-9855, 854], [-9854, 853], [-9853, 852], [-9852, 851], [-9851, 850], [-9850, 849], [-9849, 848], [-9848, 847], [-9847, 846], [-9846, 845], [-9845, 844], [-9844, 843], [-9843, 842], [-9842, 841], [-9841, 840], [-9840, 839], [-9839, 838], [-9838, 837], [-9837, 836], [-9836, 835], [-9835, 834], [-9834, 833], [-9833, 832], [-9832, 831], [-9831, 830], [-9830, 829], [-9829, 828], [-9828, 827], [-9827, 826], [-9826, 825], [-9825, 824], [-9824, 823], [-9823, 822], [-9822, 821], [-9821, 820], [-9820, 819], [-9819, 818], [-9818, 817], [-9817, 816], [-9816, 815], [-9815, 814], [-9814, 813], [-9813, 812], [-9812, 811], [-9811, 810], [-9810, 809], [-9809, 808], [-9808, 807], [-9807, 806], [-9806, 805], [-9805, 804], [-9804, 803], [-9803, 802], [-9802, 801], [-9801, 800], [-9800, 799], [-9799, 798], [-9798, 797], [-9797, 796], [-9796, 795], [-9795, 794], [-9794, 793], [-9793, 792], [-9792, 791], [-9791, 790], [-9790, 789], [-9789, 788], [-9788, 787], [-9787, 786], [-9786, 785], [-9785, 784], [-9784, 783], [-9783, 782], [-9782, 781], [-9781, 780], [-9780, 779], [-9779, 778], [-9778, 777], [-9777, 776], [-9776, 775], [-9775, 774], [-9774, 773], [-9773, 772], [-9772, 771], [-9771, 770], [-9770, 769], [-9769, 768], [-9768, 767], [-9767, 766], [-9766, 765], [-9765, 764], [-9764, 763], [-9763, 762], [-9762, 761], [-9761, 760], [-9760, 759], [-9759, 758], [-9758, 757], [-9757, 756], [-9756, 755], [-9755, 754], [-9754, 753], [-9753, 752], [-9752, 751], [-9751, 750], [-9750, 749], [-9749, 748], [-9748, 747], [-9747, 746], [-9746, 745], [-9745, 744], [-9744, 743], [-9743, 742], [-9742, 741], [-9741, 740], [-9740, 739], [-9739, 738], [-9738, 737], [-9737, 736], [-9736, 735], [-9735, 734], [-9734, 733], [-9733, 732], [-9732, 731], [-9731, 730], [-9730, 729], [-9729, 728], [-9728, 727], [-9727, 726], [-9726, 725], [-9725, 724], [-9724, 723], [-9723, 722], [-9722, 721], [-9721, 720], [-9720, 719], [-9719, 718], [-9718, 717], [-9717, 716], [-9716, 715], [-9715, 714], [-9714, 713], [-9713, 712], [-9712, 711], [-9711, 710], [-9710, 709], [-9709, 708], [-9708, 707], [-9707, 706], [-9706, 705], [-9705, 704], [-9704, 703], [-9703, 702], [-9702, 701], [-9701, 700], [-9700, 699], [-9699, 698], [-9698, 697], [-9697, 696], [-9696, 695], [-9695, 694], [-9694, 693], [-9693, 692], [-9692, 691], [-9691, 690], [-9690, 689], [-9689, 688], [-9688, 687], [-9687, 686], [-9686, 685], [-9685, 684], [-9684, 683], [-9683, 682], [-9682, 681], [-9681, 680], [-9680, 679], [-9679, 678], [-9678, 677], [-9677, 676], [-9676, 675], [-9675, 674], [-9674, 673], [-9673, 672], [-9672, 671], [-9671, 670], [-9670, 669], [-9669, 668], [-9668, 667], [-9667, 666], [-9666, 665], [-9665, 664], [-9664, 663], [-9663, 662], [-9662, 661], [-9661, 660], [-9660, 659], [-9659, 658], [-9658, 657], [-9657, 656], [-9656, 655], [-9655, 654], [-9654, 653], [-9653, 652], [-9652, 651], [-9651, 650], [-9650, 649], [-9649, 648], [-9648, 647], [-9647, 646], [-9646, 645], [-9645, 644], [-9644, 643], [-9643, 642], [-9642, 641], [-9641, 640], [-9640, 639], [-9639, 638], [-9638, 637], [-9637, 636], [-9636, 635], [-9635, 634], [-9634, 633], [-9633, 632], [-9632, 631], [-9631, 630], [-9630, 629], [-9629, 628], [-9628, 627], [-9627, 626], [-9626, 625], [-9625, 624], [-9624, 623], [-9623, 622], [-9622, 621], [-9621, 620], [-9620, 619], [-9619, 618], [-9618, 617], [-9617, 616], [-9616, 615], [-9615, 614], [-9614, 613], [-9613, 612], [-9612, 611], [-9611, 610], [-9610, 609], [-9609, 608], [-9608, 607], [-9607, 606], [-9606, 605], [-9605, 604], [-9604, 603], [-9603, 602], [-9602, 601], [-9601, 600], [-9600, 599], [-9599, 598], [-9598, 597], [-9597, 596], [-9596, 595], [-9595, 594], [-9594, 593], [-9593, 592], [-9592, 591], [-9591, 590], [-9590, 589], [-9589, 588], [-9588, 587], [-9587, 586], [-9586, 585], [-9585, 584], [-9584, 583], [-9583, 582], [-9582, 581], [-9581, 580], [-9580, 579], [-9579, 578], [-9578, 577], [-9577, 576], [-9576, 575], [-9575, 574], [-9574, 573], [-9573, 572], [-9572, 571], [-9571, 570], [-9570, 569], [-9569, 568], [-9568, 567], [-9567, 566], [-9566, 565], [-9565, 564], [-9564, 563], [-9563, 562], [-9562, 561], [-9561, 560], [-9560, 559], [-9559, 558], [-9558, 557], [-9557, 556], [-9556, 555], [-9555, 554], [-9554, 553], [-9553, 552], [-9552, 551], [-9551, 550], [-9550, 549], [-9549, 548], [-9548, 547], [-9547, 546], [-9546, 545], [-9545, 544], [-9544, 543], [-9543, 542], [-9542, 541], [-9541, 540], [-9540, 539], [-9539, 538], [-9538, 537], [-9537, 536], [-9536, 535], [-9535, 534], [-9534, 533], [-9533, 532], [-9532, 531], [-9531, 530], [-9530, 529], [-9529, 528], [-9528, 527], [-9527, 526], [-9526, 525], [-9525, 524], [-9524, 523], [-9523, 522], [-9522, 521], [-9521, 520], [-9520, 519], [-9519, 518], [-9518, 517], [-9517, 516], [-9516, 515], [-9515, 514], [-9514, 513], [-9513, 512], [-9512, 511], [-9511, 510], [-9510, 509], [-9509, 508], [-9508, 507], [-9507, 506], [-9506, 505], [-9505, 504], [-9504, 503], [-9503, 502], [-9502, 501], [-9501, 500], [-9500, 499], [-9499, 498], [-9498, 497], [-9497, 496], [-9496, 495], [-9495, 494], [-9494, 493], [-9493, 492], [-9492, 491], [-9491, 490], [-9490, 489], [-9489, 488], [-9488, 487], [-9487, 486], [-9486, 485], [-9485, 484], [-9484, 483], [-9483, 482], [-9482, 481], [-9481, 480], [-9480, 479], [-9479, 478], [-9478, 477], [-9477, 476], [-9476, 475], [-9475, 474], [-9474, 473], [-9473, 472], [-9472, 471], [-9471, 470], [-9470, 469], [-9469, 468], [-9468, 467], [-9467, 466], [-9466, 465], [-9465, 464], [-9464, 463], [-9463, 462], [-9462, 461], [-9461, 460], [-9460, 459], [-9459, 458], [-9458, 457], [-9457, 456], [-9456, 455], [-9455, 454], [-9454, 453], [-9453, 452], [-9452, 451], [-9451, 450], [-9450, 449], [-9449, 448], [-9448, 447], [-9447, 446], [-9446, 445], [-9445, 444], [-9444, 443], [-9443, 442], [-9442, 441], [-9441, 440], [-9440, 439], [-9439, 438], [-9438, 437], [-9437, 436], [-9436, 435], [-9435, 434], [-9434, 433], [-9433, 432], [-9432, 431], [-9431, 430], [-9430, 429], [-9429, 428], [-9428, 427], [-9427, 426], [-9426, 425], [-9425, 424], [-9424, 423], [-9423, 422], [-9422, 421], [-9421, 420], [-9420, 419], [-9419, 418], [-9418, 417], [-9417, 416], [-9416, 415], [-9415, 414], [-9414, 413], [-9413, 412], [-9412, 411], [-9411, 410], [-9410, 409], [-9409, 408], [-9408, 407], [-9407, 406], [-9406, 405], [-9405, 404], [-9404, 403], [-9403, 402], [-9402, 401], [-9401, 400], [-9400, 399], [-9399, 398], [-9398, 397], [-9397, 396], [-9396, 395], [-9395, 394], [-9394, 393], [-9393, 392], [-9392, 391], [-9391, 390], [-9390, 389], [-9389, 388], [-9388, 387], [-9387, 386], [-9386, 385], [-9385, 384], [-9384, 383], [-9383, 382], [-9382, 381], [-9381, 380], [-9380, 379], [-9379, 378], [-9378, 377], [-9377, 376], [-9376, 375], [-9375, 374], [-9374, 373], [-9373, 372], [-9372, 371], [-9371, 370], [-9370, 369], [-9369, 368], [-9368, 367], [-9367, 366], [-9366, 365], [-9365, 364], [-9364, 363], [-9363, 362], [-9362, 361], [-9361, 360], [-9360, 359], [-9359, 358], [-9358, 357], [-9357, 356], [-9356, 355], [-9355, 354], [-9354, 353], [-9353, 352], [-9352, 351], [-9351, 350], [-9350, 349], [-9349, 348], [-9348, 347], [-9347, 346], [-9346, 345], [-9345, 344], [-9344, 343], [-9343, 342], [-9342, 341], [-9341, 340], [-9340, 339], [-9339, 338], [-9338, 337], [-9337, 336], [-9336, 335], [-9335, 334], [-9334, 333], [-9333, 332], [-9332, 331], [-9331, 330], [-9330, 329], [-9329, 328], [-9328, 327], [-9327, 326], [-9326, 325], [-9325, 324], [-9324, 323], [-9323, 322], [-9322, 321], [-9321, 320], [-9320, 319], [-9319, 318], [-9318, 317], [-9317, 316], [-9316, 315], [-9315, 314], [-9314, 313], [-9313, 312], [-9312, 311], [-9311, 310], [-9310, 309], [-9309, 308], [-9308, 307], [-9307, 306], [-9306, 305], [-9305, 304], [-9304, 303], [-9303, 302], [-9302, 301], [-9301, 300], [-9300, 299], [-9299, 298], [-9298, 297], [-9297, 296], [-9296, 295], [-9295, 294], [-9294, 293], [-9293, 292], [-9292, 291], [-9291, 290], [-9290, 289], [-9289, 288], [-9288, 287], [-9287, 286], [-9286, 285], [-9285, 284], [-9284, 283], [-9283, 282], [-9282, 281], [-9281, 280], [-9280, 279], [-9279, 278], [-9278, 277], [-9277, 276], [-9276, 275], [-9275, 274], [-9274, 273], [-9273, 272], [-9272, 271], [-9271, 270], [-9270, 269], [-9269, 268], [-9268, 267], [-9267, 266], [-9266, 265], [-9265, 264], [-9264, 263], [-9263, 262], [-9262, 261], [-9261, 260], [-9260, 259], [-9259, 258], [-9258, 257], [-9257, 256], [-9256, 255], [-9255, 254], [-9254, 253], [-9253, 252], [-9252, 251], [-9251, 250], [-9250, 249], [-9249, 248], [-9248, 247], [-9247, 246], [-9246, 245], [-9245, 244], [-9244, 243], [-9243, 242], [-9242, 241], [-9241, 240], [-9240, 239], [-9239, 238], [-9238, 237], [-9237, 236], [-9236, 235], [-9235, 234], [-9234, 233], [-9233, 232], [-9232, 231], [-9231, 230], [-9230, 229], [-9229, 228], [-9228, 227], [-9227, 226], [-9226, 225], [-9225, 224], [-9224, 223], [-9223, 222], [-9222, 221], [-9221, 220], [-9220, 219], [-9219, 218], [-9218, 217], [-9217, 216], [-9216, 215], [-9215, 214], [-9214, 213], [-9213, 212], [-9212, 211], [-9211, 210], [-9210, 209], [-9209, 208], [-9208, 207], [-9207, 206], [-9206, 205], [-9205, 204], [-9204, 203], [-9203, 202], [-9202, 201], [-9201, 200], [-9200, 199], [-9199, 198], [-9198, 197], [-9197, 196], [-9196, 195], [-9195, 194], [-9194, 193], [-9193, 192], [-9192, 191], [-9191, 190], [-9190, 189], [-9189, 188], [-9188, 187], [-9187, 186], [-9186, 185], [-9185, 184], [-9184, 183], [-9183, 182], [-9182, 181], [-9181, 180], [-9180, 179], [-9179, 178], [-9178, 177], [-9177, 176], [-9176, 175], [-9175, 174], [-9174, 173], [-9173, 172], [-9172, 171], [-9171, 170], [-9170, 169], [-9169, 168], [-9168, 167], [-9167, 166], [-9166, 165], [-9165, 164], [-9164, 163], [-9163, 162], [-9162, 161], [-9161, 160], [-9160, 159], [-9159, 158], [-9158, 157], [-9157, 156], [-9156, 155], [-9155, 154], [-9154, 153], [-9153, 152], [-9152, 151], [-9151, 150], [-9150, 149], [-9149, 148], [-9148, 147], [-9147, 146], [-9146, 145], [-9145, 144], [-9144, 143], [-9143, 142], [-9142, 141], [-9141, 140], [-9140, 139], [-9139, 138], [-9138, 137], [-9137, 136], [-9136, 135], [-9135, 134], [-9134, 133], [-9133, 132], [-9132, 131], [-9131, 130], [-9130, 129], [-9129, 128], [-9128, 127], [-9127, 126], [-9126, 125], [-9125, 124], [-9124, 123], [-9123, 122], [-9122, 121], [-9121, 120], [-9120, 119], [-9119, 118], [-9118, 117], [-9117, 116], [-9116, 115], [-9115, 114], [-9114, 113], [-9113, 112], [-9112, 111], [-9111, 110], [-9110, 109], [-9109, 108], [-9108, 107], [-9107, 106], [-9106, 105], [-9105, 104], [-9104, 103], [-9103, 102], [-9102, 101], [-9101, 100], [-9100, 99], [-9099, 98], [-9098, 97], [-9097, 96], [-9096, 95], [-9095, 94], [-9094, 93], [-9093, 92], [-9092, 91], [-9091, 90], [-9090, 89], [-9089, 88], [-9088, 87], [-9087, 86], [-9086, 85], [-9085, 84], [-9084, 83], [-9083, 82], [-9082, 81], [-9081, 80], [-9080, 79], [-9079, 78], [-9078, 77], [-9077, 76], [-9076, 75], [-9075, 74], [-9074, 73], [-9073, 72], [-9072, 71], [-9071, 70], [-9070, 69], [-9069, 68], [-9068, 67], [-9067, 66], [-9066, 65], [-9065, 64], [-9064, 63], [-9063, 62], [-9062, 61], [-9061, 60], [-9060, 59], [-9059, 58], [-9058, 57], [-9057, 56], [-9056, 55], [-9055, 54], [-9054, 53], [-9053, 52], [-9052, 51], [-9051, 50], [-9050, 49], [-9049, 48], [-9048, 47], [-9047, 46], [-9046, 45], [-9045, 44], [-9044, 43], [-9043, 42], [-9042, 41], [-9041, 40], [-9040, 39], [-9039, 38], [-9038, 37], [-9037, 36], [-9036, 35], [-9035, 34], [-9034, 33], [-9033, 32], [-9032, 31], [-9031, 30], [-9030, 29], [-9029, 28], [-9028, 27], [-9027, 26], [-9026, 25], [-9025, 24], [-9024, 23], [-9023, 22], [-9022, 21], [-9021, 20], [-9020, 19], [-9019, 18], [-9018, 17], [-9017, 16], [-9016, 15], [-9015, 14], [-9014, 13], [-9013, 12], [-9012, 11], [-9011, 10], [-9010, 9], [-9009, 8], [-9008, 7], [-9007, 6], [-9006, 5], [-9005, 4], [-9004, 3], [-9003, 2], [-9002, 1], [-9001, 0]]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "264", "slug": "count-and-say", "id": 264, "title": "Count and Say", "difficulty": "Medium", "category": "string", "link": "https://leetcode.com/problems/count-and-say/", "examples": [{"input": "n = 4", "output": "\"1211\"", "explanation": "The chain runs \"1\" -> \"11\" -> \"21\" -> \"1211\"."}, {"input": "n = 1", "output": "\"1\"", "explanation": "The sequence starts with \"1\"."}, {"input": "n = 5", "output": "\"111221\"", "explanation": "Reading \"1211\" aloud gives one 1, one 2, then two 1s."}], "hints": ["Build term k+1 from term k by scanning it once and counting each maximal run of equal characters.", "Append the count (as decimal text) and then the digit for every run; repeat n-1 times starting from \"1\"."], "statement": "The count-and-say sequence builds each term by reading aloud the previous one: start with `\"1\"`, and obtain every later term by replacing each maximal run of equal digits with the run's length followed by the digit itself. For instance, `\"3322251\"` is read as two `3`s, three `2`s, one `5`, and one `1`, giving `\"23321511\"`.\n\nFormally, `countAndSay(1) = \"1\"`, and `countAndSay(n)` is the run-length encoding of `countAndSay(n - 1)`.\n\nGiven `n`, return the nth term.\n\n**Constraints:**\n- `1 <= n <= 30`\n", "solution": "## Approach\n\nStart from `\"1\"` and iterate: each step walks the current term once, measures every maximal block of identical digits, and writes the block length followed by the digit. Repeating this transformation `n - 1` times produces exactly the nth term.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(3^n) in the worst case, since term lengths grow by roughly 30% per step (the 30th term has 4462 characters).\n- **Space Complexity:** O(L) for the current term of length L.\n\n## Implementation\n\n```python\nclass Solution:\n def countAndSay(self, n: int) -> str:\n cur = \"1\"\n for _ in range(1, n):\n nxt = []\n count = 1\n for j in range(1, len(cur) + 1):\n if j < len(cur) and cur[j] == cur[j - 1]:\n count += 1\n else:\n nxt.append(str(count) + cur[j - 1])\n count = 1\n cur = \"\".join(nxt)\n return cur\n```\n", "starter": {"go": "package main\n\nfunc CountAndSay(n int) string {\n \n}", "python": "class Solution:\n def countAndSay(self, n: int) -> str:\n pass", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n string countAndSay(int n) {\n return \"\";\n }\n};"}, "fn": "countAndSay", "params": [{"name": "n", "type": "int"}], "outputType": "string", "tests": [["1"], ["2"], ["3"], ["4"], ["5"], ["6"], ["7"], ["8"], ["9"], ["10"], ["11"], ["12"], ["13"], ["14"], ["15"], ["16"], ["17"], ["18"], ["19"], ["20"], ["21"], ["22"], ["23"], ["24"], ["25"], ["26"], ["27"], ["28"], ["29"], ["30"]], "expected": ["1", "11", "21", "1211", "111221", "312211", "13112221", "1113213211", "31131211131221", "13211311123113112211", "11131221133112132113212221", "3113112221232112111312211312113211", "1321132132111213122112311311222113111221131221", "11131221131211131231121113112221121321132132211331222113112211", "311311222113111231131112132112311321322112111312211312111322212311322113212221", "132113213221133112132113311211131221121321131211132221123113112221131112311332111213211322211312113211", "11131221131211132221232112111312212321123113112221121113122113111231133221121321132132211331121321231231121113122113322113111221131221", "31131122211311123113321112131221123113112211121312211213211321322112311311222113311213212322211211131221131211132221232112111312111213111213211231131122212322211331222113112211", "1321132132211331121321231231121113112221121321132122311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112311332111213122112311311123112111331121113122112132113213211121332212311322113212221", "11131221131211132221232112111312111213111213211231132132211211131221131211221321123113213221123113112221131112311332211211131221131211132211121312211231131112311211232221121321132132211331121321231231121113112221121321133112132112312321123113112221121113122113121113123112112322111213211322211312113211", "311311222113111231133211121312211231131112311211133112111312211213211312111322211231131122211311122122111312211213211312111322211213211321322113311213212322211231131122211311123113223112111311222112132113311213211221121332211211131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221131112311311121321122112132231121113122113322113111221131221", "132113213221133112132123123112111311222112132113311213211231232112311311222112111312211311123113322112132113213221133122112231131122211211131221131112311332211211131221131211132221232112111312111213322112132113213221133112132113221321123113213221121113122123211211131221222112112322211231131122211311123113321112131221123113111231121113311211131221121321131211132221123113112211121312211231131122211211133112111311222112111312211312111322211213211321322113311213211331121113122122211211132213211231131122212322211331222113112211", "111312211312111322212321121113121112131112132112311321322112111312212321121113122112131112131221121321132132211231131122211331121321232221121113122113121113222123112221221321132132211231131122211331121321232221123113112221131112311332111213122112311311123112112322211211131221131211132221232112111312211322111312211213211312111322211231131122111213122112311311221132211221121332211213211321322113311213212312311211131122211213211331121321123123211231131122211211131221131112311332211213211321223112111311222112132113213221123123211231132132211231131122211311123113322112111312211312111322212321121113122123211231131122113221123113221113122112132113213211121332212311322113212221", "3113112221131112311332111213122112311311123112111331121113122112132113121113222112311311221112131221123113112221121113311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112311332111213213211221113122113121113222112132113213221232112111312111213322112132113213221133112132123123112111311222112132113311213211221121332211231131122211311123113321112131221123113112221132231131122211211131221131112311332211213211321223112111311222112132113212221132221222112112322211211131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221133112132123222112111312211312112213211231132132211211131221131211132221121311121312211213211312111322211213211321322113311213212322211231131122211311123113321112131221123113112211121312211213211321222113222112132113223113112221121113122113121113123112112322111213211322211312113211", "132113213221133112132123123112111311222112132113311213211231232112311311222112111312211311123113322112132113212231121113112221121321132132211231232112311321322112311311222113111231133221121113122113121113221112131221123113111231121123222112132113213221133112132123123112111312111312212231131122211311123113322112111312211312111322111213122112311311123112112322211211131221131211132221232112111312111213111213211231132132211211131221232112111312212221121123222112132113213221133112132123123112111311222112132113213221132213211321322112311311222113311213212322211211131221131211221321123113213221121113122113121132211332113221122112133221123113112221131112311332111213122112311311123112111331121113122112132113121113222112311311221112131221123113112221121113311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112212211131221121321131211132221123113112221131112311332211211133112111311222112111312211311123113322112111312211312111322212321121113121112133221121321132132211331121321231231121113112221121321132122311211131122211211131221131211322113322112111312211322132113213221123113112221131112311311121321122112132231121113122113322113111221131221", "1113122113121113222123211211131211121311121321123113213221121113122123211211131221121311121312211213211321322112311311222113311213212322211211131221131211221321123113213221121113122113121113222112131112131221121321131211132221121321132132211331121321232221123113112221131112311322311211131122211213211331121321122112133221121113122113121113222123211211131211121311121321123113111231131122112213211321322113311213212322211231131122211311123113223112111311222112132113311213211221121332211231131122211311123113321112131221123113111231121113311211131221121321131211132221123113112211121312211231131122113221122112133221121113122113121113222123211211131211121311121321123113213221121113122113121113222113221113122113121113222112132113213221232112111312111213322112311311222113111221221113122112132113121113222112311311222113111221132221231221132221222112112322211213211321322113311213212312311211131122211213211331121321123123211231131122211211131221131112311332211213211321223112111311222112132113213221123123211231132132211231131122211311123113322112111312211312111322111213122112311311123112112322211213211321322113312211223113112221121113122113111231133221121321132132211331121321232221123123211231132132211231131122211331121321232221123113112221131112311332111213122112311311123112112322211211131221131211132221232112111312111213111213211231132132211211131221131211221321123113213221123113112221131112211322212322211231131122211322111312211312111322211213211321322113311213211331121113122122211211132213211231131122212322211331222113112211", "31131122211311123113321112131221123113111231121113311211131221121321131211132221123113112211121312211231131122211211133112111311222112111312211312111322211213211321322123211211131211121332211231131122211311122122111312211213211312111322211231131122211311123113322112111331121113112221121113122113111231133221121113122113121113222123211211131211121332211213211321322113311213211322132112311321322112111312212321121113122122211211232221123113112221131112311332111213122112311311123112111331121113122112132113311213211321222122111312211312111322212321121113121112133221121321132132211331121321132213211231132132211211131221232112111312212221121123222112132113213221133112132123123112111311222112132113311213211231232112311311222112111312211311123113322112132113212231121113112221121321132122211322212221121123222112311311222113111231133211121312211231131112311211133112111312211213211312111322211231131122211311123113322113223113112221131112311332211211131221131211132211121312211231131112311211232221121321132132211331221122311311222112111312211311123113322112132113213221133122211332111213112221133211322112211213322112111312211312111322212321121113121112131112132112311321322112111312212321121113122112131112131221121321132132211231131122211331121321232221121113122113121122132112311321322112111312211312111322211213111213122112132113121113222112132113213221133112132123222112311311222113111231132231121113112221121321133112132112211213322112111312211312111322212311222122132113213221123113112221133112132123222112111312211312111322212321121113121112133221121311121312211213211312111322211213211321322123211211131211121332211213211321322113311213212312311211131122211213211331121321122112133221123113112221131112311332111213122112311311123112111331121113122112132113121113222112311311222113111221221113122112132113121113222112132113213221133122211332111213322112132113213221132231131122211311123113322112111312211312111322212321121113122123211231131122113221123113221113122112132113213211121332212311322113212221", "13211321322113311213212312311211131122211213211331121321123123211231131122211211131221131112311332211213211321223112111311222112132113213221123123211231132132211231131122211311123113322112111312211312111322111213122112311311123112112322211213211321322113312211223113112221121113122113111231133221121321132132211331121321232221123123211231132132211231131122211331121321232221123113112221131112311332111213122112311311123112112322211211131221131211132221232112111312211322111312211213211312111322211231131122111213122112311311221132211221121332211213211321322113311213212312311211131122211213211331121321123123211231131122211211131221232112111312211312113211223113112221131112311332111213122112311311123112112322211211131221131211132221232112111312211322111312211213211312111322211231131122111213122112311311221132211221121332211211131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221133112132123222112111312211312112213211231132132211211131221131211322113321132211221121332211213211321322113311213212312311211131122211213211331121321123123211231131122211211131221131112311332211213211321322113311213212322211322132113213221133112132123222112311311222113111231132231121113112221121321133112132112211213322112111312211312111322212311222122132113213221123113112221133112132123222112111312211312111322212311322123123112111321322123122113222122211211232221123113112221131112311332111213122112311311123112111331121113122112132113121113222112311311221112131221123113112221121113311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112212211131221121321131211132221123113112221131112311332211211133112111311222112111312211311123113322112111312211312111322212321121113121112133221121321132132211331121321132213211231132132211211131221232112111312212221121123222112311311222113111231133211121321321122111312211312111322211213211321322123211211131211121332211231131122211311123113321112131221123113111231121123222112111331121113112221121113122113111231133221121113122113121113221112131221123113111231121123222112111312211312111322212321121113121112131112132112311321322112111312212321121113122122211211232221121321132132211331121321231231121113112221121321133112132112312321123113112221121113122113111231133221121321132132211331221122311311222112111312211311123113322112111312211312111322212311322123123112112322211211131221131211132221132213211321322113311213212322211231131122211311123113321112131221123113112211121312211213211321222113222112132113223113112221121113122113121113123112112322111213211322211312113211", "11131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221133112132123222112111312211312112213211231132132211211131221131211132221121311121312211213211312111322211213211321322113311213212322211231131122211311123113223112111311222112132113311213211221121332211211131221131211132221231122212213211321322112311311222113311213212322211211131221131211132221232112111312111213322112131112131221121321131211132221121321132132212321121113121112133221121321132132211331121321231231121113112221121321133112132112211213322112311311222113111231133211121312211231131122211322311311222112111312211311123113322112132113212231121113112221121321132122211322212221121123222112111312211312111322212321121113121112131112132112311321322112111312212321121113122112131112131221121321132132211231131122111213122112311311222113111221131221221321132132211331121321231231121113112221121321133112132112211213322112311311222113111231133211121312211231131122211322311311222112111312211311123113322112132113212231121113112221121321132122211322212221121123222112311311222113111231133211121312211231131112311211133112111312211213211312111322211231131122111213122112311311222112111331121113112221121113122113121113222112132113213221232112111312111213322112311311222113111221221113122112132113121113222112311311222113111221132221231221132221222112112322211211131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221133112132123222112111312211312111322212321121113121112133221132211131221131211132221232112111312111213322112132113213221133112132113221321123113213221121113122123211211131221222112112322211231131122211311123113321112132132112211131221131211132221121321132132212321121113121112133221123113112221131112311332111213211322111213111213211231131211132211121311222113321132211221121332211213211321322113311213212312311211131122211213211331121321123123211231131122211211131221131112311332211213211321223112111311222112132113213221123123211231132132211231131122211311123113322112111312211312111322111213122112311311123112112322211213211321322113312211223113112221121113122113111231133221121321132132211331121321232221123123211231132132211231131122211331121321232221123113112221131112311332111213122112311311123112112322211211131221131211132221232112111312211322111312211213211312111322211231131122111213122112311311221132211221121332211213211321322113311213212312311211131211131221223113112221131112311332211211131221131211132211121312211231131112311211232221121321132132211331121321231231121113112221121321133112132112211213322112312321123113213221123113112221133112132123222112311311222113111231132231121113112221121321133112132112211213322112311311222113111231133211121312211231131112311211133112111312211213211312111322211231131122111213122112311311221132211221121332211211131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221133112132123222112111312211312111322212311222122132113213221123113112221133112132123222112311311222113111231133211121321132211121311121321122112133221123113112221131112311332211322111312211312111322212321121113121112133221121321132132211331121321231231121113112221121321132122311211131122211211131221131211322113322112111312211322132113213221123113112221131112311311121321122112132231121113122113322113111221131221", "3113112221131112311332111213122112311311123112111331121113122112132113121113222112311311221112131221123113112221121113311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112212211131221121321131211132221123113112221131112311332211211133112111311222112111312211311123113322112111312211312111322212321121113121112133221121321132132211331121321132213211231132132211211131221232112111312212221121123222112311311222113111231133211121321321122111312211312111322211213211321322123211211131211121332211231131122211311123113321112131221123113111231121123222112111331121113112221121113122113111231133221121113122113121113221112131221123113111231121123222112111312211312111322212321121113121112131112132112311321322112111312212321121113122122211211232221121321132132211331121321231231121113112221121321132132211322132113213221123113112221133112132123222112111312211312112213211231132132211211131221131211322113321132211221121332211231131122211311123113321112131221123113111231121113311211131221121321131211132221123113112211121312211231131122211211133112111311222112111312211312111322211213211321223112111311222112132113213221133122211311221122111312211312111322212321121113121112131112132112311321322112111312212321121113122122211211232221121321132132211331121321231231121113112221121321132132211322132113213221123113112221133112132123222112111312211312112213211231132132211211131221131211322113321132211221121332211213211321322113311213212312311211131122211213211331121321123123211231131122211211131221131112311332211213211321223112111311222112132113213221123123211231132132211231131122211311123113322112111312211312111322111213122112311311123112112322211213211321322113312211223113112221121113122113111231133221121321132132211331222113321112131122211332113221122112133221123113112221131112311332111213122112311311123112111331121113122112132113121113222112311311221112131221123113112221121113311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112311332111213122112311311123112112322211322311311222113111231133211121312211231131112311211232221121113122113121113222123211211131221132211131221121321131211132221123113112211121312211231131122113221122112133221121321132132211331121321231231121113121113122122311311222113111231133221121113122113121113221112131221123113111231121123222112132113213221133112132123123112111312211322311211133112111312211213211311123113223112111321322123122113222122211211232221121113122113121113222123211211131211121311121321123113213221121113122123211211131221121311121312211213211321322112311311222113311213212322211211131221131211221321123113213221121113122113121113222112131112131221121321131211132221121321132132211331121321232221123113112221131112311322311211131122211213211331121321122112133221121113122113121113222123112221221321132132211231131122211331121321232221121113122113121113222123211211131211121332211213111213122112132113121113222112132113213221232112111312111213322112132113213221133112132123123112111311222112132113311213211221121332211231131122211311123113321112131221123113112221132231131122211211131221131112311332211213211321223112111311222112132113212221132221222112112322211211131221131211132221232112111312111213111213211231131112311311221122132113213221133112132123222112311311222113111231132231121113112221121321133112132112211213322112111312211312111322212321121113121112131112132112311321322112111312212321121113122122211211232221121311121312211213211312111322211213211321322123211211131211121332211213211321322113311213211322132112311321322112111312212321121113122122211211232221121321132132211331121321231231121113112221121321133112132112312321123113112221121113122113111231133221121321132122311211131122211213211321222113222122211211232221123113112221131112311332111213122112311311123112111331121113122112132113121113222112311311221112131221123113112221121113311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112311332111213213211221113122113121113222112132113213221232112111312111213322112132113213221133112132123123112111312211322311211133112111312212221121123222112132113213221133112132123222113223113112221131112311332111213122112311311123112112322211211131221131211132221232112111312111213111213211231132132211211131221131211221321123113213221123113112221131112211322212322211231131122211322111312211312111322211213211321322113311213211331121113122122211211132213211231131122212322211331222113112211"], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "710", "slug": "count-binary-substrings", "id": 710, "title": "Count Binary Substrings", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/count-binary-substrings/", "examples": [{"input": "s = \"00110011\"", "output": "6", "explanation": "Six overlapping balanced runs."}, {"input": "s = \"10101\"", "output": "4", "explanation": "Four adjacent pairs."}, {"input": "s = \"000111\"", "output": "3", "explanation": "Runs of 3 and 3 give 3."}], "hints": ["Compress the string into run lengths (for example 00110011 becomes 2,2,2,2).", "Each neighbouring pair of runs contributes the smaller of the two lengths.", "Sum those minima in one linear pass."], "statement": "A binary string uses only `0` and `1`. Count its non-empty pieces that contain equal numbers of zeros and ones, with all zeros bunched together and all ones bunched together (so each valid piece looks like some zeros followed by some ones, or vice versa, with matching run lengths). Pieces occurring at different positions count separately even when their text matches.\n\n**Constraints:**\n- `1 <= s.length <= 10^5`\n- `s` contains only `0` and `1`.\n", "solution": "## Approach\n\nCollapse the string into consecutive run lengths. Any valid piece must straddle one boundary between two runs and take equally many characters from each side, so the boundary contributes exactly the minimum of the two neighbouring run lengths. Adding that minimum over every boundary counts everything once.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), a single left-to-right scan.\n- **Space Complexity:** O(1) besides the input.\n\n## Implementation\n\n```python\nclass Solution:\n def countBinarySubstrings(self, s: str) -> int:\n prev, cur, ans = 0, 1, 0\n for i in range(1, len(s)):\n if s[i] == s[i-1]:\n cur += 1\n else:\n ans += min(prev, cur)\n prev, cur = cur, 1\n ans += min(prev, cur)\n return ans\n```\n", "starter": {"go": "package main\n\nfunc CountBinarySubstrings(s string) int {\n return 0\n}", "python": "class Solution:\n def countBinarySubstrings(self, s: str) -> int:\n return 0\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n int countBinarySubstrings(string s) {\n return 0;\n }\n};"}, "fn": "countBinarySubstrings", "params": [{"name": "s", "type": "string"}], "outputType": "int", "tests": [["00110011"], ["10101"], ["000111"], ["0"], ["1"], ["01"], ["10"], ["00"], ["11"], ["0011"], ["1100"], ["000111000"], ["111000111"], ["01010101"], ["0000"], ["1111"], ["00001111"], ["11110000"], ["0100"], ["0010"], ["10100101"], ["00011011"], ["01100011"], ["1010101010"], ["000111000111"], ["110011001100"], ["0101010101010101"], ["0000011111"]], "expected": [6, 4, 3, 0, 0, 1, 1, 0, 0, 2, 2, 6, 6, 7, 0, 0, 4, 4, 2, 2, 6, 4, 5, 9, 9, 10, 15, 5], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "337", "slug": "count-complete-tree-nodes", "id": 337, "title": "Count Complete Tree Nodes", "difficulty": "Easy", "category": "tree", "link": "https://leetcode.com/problems/count-complete-tree-nodes/", "examples": [{"explanation": "The tree holds six nodes.", "input": "root = [1,2,3,4,5,6]", "output": "6"}, {"explanation": "There is no tree.", "input": "root = []", "output": "0"}, {"explanation": "Only the root exists.", "input": "root = [1]", "output": "1"}], "hints": ["Compare the depth of the leftmost and rightmost paths: equal depths mean the subtree is perfect, holding 2^h - 1 nodes.", "When the depths differ, the last level is partial, so count the root plus both sides recursively.", "Each recursion descends only one side fully, giving O(log^2 n) time."], "statement": "You are given the root of a complete binary tree: every level except possibly the last is fully filled, and the last level's nodes sit as far left as possible. Count the nodes in the tree.\n\nThe tree is supplied in level-order form such as `[1,2,3,4,5,6]`, where `null` marks a missing child, and an empty list means there is no tree.\n\n**Constraints:**\n- The tree holds between 0 and `5 * 10^4` nodes.\n- `0 <= node value <= 10^5`\n", "solution": "## Approach\n\nMeasure the leftmost depth and the rightmost depth of each subtree. When they agree, the subtree is a perfect tree with `2^h - 1` nodes and needs no further visits. Otherwise the last level is only partly filled, so count the root plus both sides recursively. Completeness guarantees one side becomes perfect at every step, keeping the walk short.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log^2 n), one height walk per level of recursion.\n- **Space Complexity:** O(log n) for the recursion stack.\n\n## Implementation\n\n```python\nclass Solution:\n def countNodes(self, root) -> int:\n if root is None:\n return 0\n\n def height(node, go_left: bool) -> int:\n h = 0\n while node is not None:\n h += 1\n node = node.left if go_left else node.right\n return h\n\n left_h = height(root, True)\n right_h = height(root, False)\n if left_h == right_h:\n return (1 << left_h) - 1\n return 1 + self.countNodes(root.left) + self.countNodes(root.right)\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 CountNodes(root *TreeNode) int {\n \n}", "python": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, val=0, left=None, right=None):\n# self.val = val\n# self.left = left\n# self.right = right\n\nclass Solution:\n def countNodes(self, root):\n # TODO: return the number of nodes in the complete tree\n pass\n", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\nclass Solution {\npublic:\n int countNodes(TreeNode* root) {\n \n }\n};"}, "fn": "countNodes", "params": [{"name": "root", "type": "tree_node"}], "outputType": "int", "tests": [["[1,2,3,4,5,6]"], ["[]"], ["[1]"], ["[1,2,3]"], ["[1,2,3,4]"], ["[1,2,3,4,5]"], ["[1,2,3,4,5,6,7]"], ["[1,2,3,4,5,6,7,8]"], ["[1,2,3,4,5,6,7,8,9,10]"], ["[1,null,2]"], ["[5,4,8,11,null,13,4]"], ["[1,2]"], ["[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]"], ["[1,2,3,4,5,6,7,8,9,10,11,12,13,14]"], ["[3,9,20,null,null,15,7]"], ["[1,null,2,null,3]"], ["[1,2,null,3]"], ["[10,5,15,3,7,null,18]"], ["[1,2,3,4,5,6,7,8,9,10,11]"], ["[1,2,3,4,5,6,7,8,9]"], ["[2,1]"], ["[1,2,3,4,null,null,5]"], ["[100,50,150,25,75,125,175]"], ["[1,2,3,4,5,null,6]"], ["[1,2,3,4,5,6,7,8,9,10,11,12]"], ["[9,8,7,6,5,4,3]"], ["[1,2,3,null,4,null,5]"], ["[6,4,8,3,5,7,9,1]"]], "expected": [6, 0, 1, 3, 4, 5, 7, 8, 10, 2, 7, 2, 15, 14, 5, 3, 3, 7, 11, 9, 2, 7, 7, 7, 12, 7, 5, 8], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "737", "slug": "count-different-palindromic-subsequences", "id": 737, "title": "Count Different Palindromic Subsequences", "difficulty": "Hard", "category": "dp", "link": "https://leetcode.com/problems/count-different-palindromic-subsequences/", "examples": [{"input": "s = \"bccb\"", "output": "6", "explanation": "Six distinct palindromes: b, c, bb, cc, bcb, bccb."}, {"input": "s = \"abcdabcdabcdabcd\"", "output": "244", "explanation": "Four repeats of abcd yield 244 distinct palindromic letter sequences."}, {"input": "s = \"a\"", "output": "1"}], "hints": ["Let dp[l][r] be the answer for the slice s[l..r]; grow the slice from short to long.", "When the ends match, the inner answer doubles, then adjust using the next matching positions inside to avoid double counting.", "When the ends differ, combine dp[l+1][r] and dp[l][r-1] and subtract dp[l+1][r-1]; keep everything modulo 1000000007."], "statement": "A subsequence keeps some of the characters of a string in their original order while dropping the rest. Two subsequences count as the same whenever their letter sequences match, even if they were formed from different positions.\n\nGiven a string `s` built only from the letters `a`, `b`, `c` and `d`, count how many distinct non-empty subsequences of `s` read the same forwards and backwards. Because the total can be huge, return it modulo `1,000,000,007`.\n\n**Constraints:**\n- `1 <= s.length <= 1000`\n- `s` holds only `a`, `b`, `c`, `d`.\n", "solution": "## Approach\n\nCount distinct palindromic subsequences per interval with dynamic programming. For a slice, equal ends extend every inner palindrome on both sides, contributing the two single letters plus the wrapped forms; the nearest matching letters inside decide how much was already counted and must be removed. Unequal ends merge the two one-shorter slices minus their overlap. All steps use modulo 1,000,000,007.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^2), where n is the string length \u2014 one state per interval.\n- **Space Complexity:** O(n^2) for the table.\n\n## Implementation\n\n```python\nclass Solution:\n def countPalindromicSubsequences(self, s: str) -> int:\n MOD = 1000000007\n n = len(s)\n dp = [[0] * n for _ in range(n)]\n for i in range(n):\n dp[i][i] = 1\n for length in range(2, n + 1):\n for l in range(n - length + 1):\n r = l + length - 1\n if s[l] == s[r]:\n low, high = l + 1, r - 1\n while low <= high and s[low] != s[l]:\n low += 1\n while low <= high and s[high] != s[l]:\n high -= 1\n if low > high:\n dp[l][r] = dp[l + 1][r - 1] * 2 + 2\n elif low == high:\n dp[l][r] = dp[l + 1][r - 1] * 2 + 1\n else:\n dp[l][r] = dp[l + 1][r - 1] * 2 - dp[low + 1][high - 1]\n else:\n dp[l][r] = dp[l + 1][r] + dp[l][r - 1] - dp[l + 1][r - 1]\n dp[l][r] %= MOD\n return dp[0][n - 1] % MOD\n```\n", "starter": {"go": "package main\n\nfunc CountPalindromicSubsequences(s string) int {\n return 0\n}", "python": "class Solution:\n def countPalindromicSubsequences(self, s: str) -> int:\n return 0\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n int countPalindromicSubsequences(string s) {\n return 0;\n }\n};"}, "fn": "countPalindromicSubsequences", "params": [{"name": "s", "type": "string"}], "outputType": "int", "tests": [["bccb"], ["abcdabcdabcdabcd"], ["a"], ["aa"], ["aaa"], ["aba"], ["abca"], ["abcd"], ["aab"], ["abb"], ["aabb"], ["abcba"], ["aaccaa"], ["b"], ["ab"], ["ba"], ["bb"], ["abc"], ["cba"], ["abccba"], ["abcdcba"], ["aaaa"], ["abab"], ["baba"], ["dcba"], ["ddccbbaa"], ["abcdabcd"], ["dcbadcbad"]], "expected": [6, 244, 1, 2, 3, 4, 6, 4, 3, 3, 4, 10, 10, 1, 2, 2, 2, 3, 3, 14, 22, 4, 6, 6, 4, 8, 20, 33], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "100", "slug": "count-good-nodes-in-binary-tree", "id": 100, "title": "Count Good Nodes in Binary Tree", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/count-good-nodes-in-binary-tree/", "examples": [{"input": "root = [3,1,4,3,null,1,5]", "output": "4", "explanation": "The root 3, the left grandchild 3, node 4, and node 5 are good."}, {"input": "root = [3,3,null,4,2]", "output": "3", "explanation": "There are 3 good nodes (nodes where all ancestors have <= node.val)."}, {"input": "root = [1]", "output": "1", "explanation": "There are 1 good nodes (nodes where all ancestors have <= node.val)."}], "hints": ["Carry the maximum value seen on the path from the root during a DFS or BFS.", "A node is good exactly when its value is at least that path maximum.", "Pass `max(pathMaximum, node.val)` to each child."], "statement": "You are given the root of a binary tree. Regard a node as **good** when its value reaches or exceeds every value encountered along the route from the root down to it.\n\nCount how many such good nodes the tree holds. The route examined for each node contains both endpoints, the root and the node itself.\n\n**Constraints:**\n- The number of nodes lies in the range `1` to `100000`.\n- `-10^4 <= node.val <= 10^4`\n", "solution": "## Approach\n\nPerform an iterative depth-first traversal while carrying the maximum value seen on each root-to-node path. A node is good when its value is at least that maximum. Push each child together with the updated maximum.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n).\n- **Space Complexity:** O(h), where `h` is the tree height, for the DFS stack.\n\n## Implementation\n\n```python\nclass Solution:\n def goodNodes(self, root) -> int:\n if root is None:\n return 0\n\n stack = [(root, root.val)]\n count = 0\n while stack:\n node, path_maximum = stack.pop()\n if node.val >= path_maximum:\n count += 1\n next_maximum = max(path_maximum, node.val)\n if node.left is not None:\n stack.append((node.left, next_maximum))\n if node.right is not None:\n stack.append((node.right, next_maximum))\n return count\n```\n", "starter": {"go": "package main\n\nfunc GoodNodes(root *TreeNode) int {\n return 0\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 goodNodes(self, root) -> int:\n pass\n", "cpp": "/*\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n};\n*/\nclass Solution {\npublic:\n int goodNodes(TreeNode* root) {\n return 0;\n }\n};"}, "fn": "goodNodes", "params": [{"name": "root", "type": "tree_node", "visualizeType": "tree_node"}], "outputType": "int", "tests": [["[1]"], ["[3,1,4,3,null,1,5]"], ["[3,3,null,4,2]"], ["[1,2]"], ["[2,1]"], ["[1,null,2]"], ["[2,null,1]"], ["[1,2,3]"], ["[3,2,1]"], ["[0,0,0]"], ["[-1,-2,-3]"], ["[-3,-2,-1]"], ["[1,2,null,3,null,4,null,5]"], ["[5,4,null,3,null,2,null,1]"], ["[1,null,2,null,3,null,4,null,5]"], ["[5,null,4,null,3,null,2,null,1]"], ["[1,2,null,null,3,4,null,null,5]"], ["[5,4,null,null,3,2,null,null,1]"], ["[1,2,3,4,5,6,7]"], ["[7,6,5,4,3,2,1]"], ["[0,-1,1,-2,null,null,2]"], ["[0,1,-1,2,null,null,-2]"], ["[1,1,1,1,1,1,1]"], ["[-1,-1,-1,-1,-1,-1,-1]"], ["[10,5,15,3,7,12,18,1,4,6,8,11,13,17,20]"], ["[20,17,18,13,11,12,15,8,6,4,1,7,3,5,10]"], ["[10,5,15,3,7,null,18,1,null,6,8,17,20]"], ["[10,15,5,18,12,null,3,20,null,8,6,1,4]"], ["[8,4,12,2,6,10,14,1,3,5,7,9,11,13,15]"], ["[8,12,4,14,10,6,2,15,13,11,9,7,5,3,1]"], ["[10000,-10000,9999]"], ["[-10000,10000,-9999]"], ["[5,1,4,3,null,6,2]"], ["[5,5,5,5,null,null,5]"], ["[5,6,4,7,null,null,3]"], ["[5,4,6,3,null,null,7,2,null,null,8]"], ["[5,6,4,7,null,null,3,8,null,null,2]"], ["[1,3,2,5,4,4,3,7,6,6,5,6,5,5,4]"], ["[9,8,7,6,5,4,3,2,1,0,-1,-2,-3,-4,-5]"], ["[-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5]"], ["[50,25,75,12,37,62,87,6,18,31,43,56,68,81,93]"], ["[50,75,25,87,62,37,12,93,81,68,56,43,31,18,6]"], ["[3,1,4,null,2,null,5,null,null,null,6]"], ["[6,5,null,4,null,3,null,2,null,1]"], ["[0,-1,1,null,-2,2,null,null,-3,null,3]"], ["[0,1,-1,null,2,-2,null,null,3,null,-3]"], ["[4,2,6,1,3,5,7,null,null,null,null,null,null,null,8]"], ["[8,7,6,5,null,null,4,3,null,null,2,1]"], ["[1,2,3,4,null,null,5,6,7,8,9]"], ["[9,8,7,6,null,null,5,4,3,2,1]"], ["[2,2,2,3,1,2,4,4,0,3,1,3,2,5,4]"], ["[5,3,5,3,4,5,6,2,null,null,4,null,null,null,7]"], ["[3,1,5,0,2,4,6,-1,null,null,null,null,null,null,7]"], ["[-3,-5,-1,-6,-4,-2,0,-7,null,null,null,null,null,null,1]"], ["[1,2,null,3,null,4,null,5,null,6,null,7,null,8,null,9,null,10]"], ["@javascript:(()=>{const n=9999,a=[10000];let made=1,active=1;while(made<n){active--;if(active<63&&made+1<n){a.push(10000-(made%20001),10000-((made+1)%20001));made+=2;active+=2}else{a.push(10000-(made%20001),null);made++;active++}}while(a[a.length-1]===null)a.pop();return JSON.stringify(a)})()"], ["@javascript:(()=>{const n=10000,a=[-10000];let made=1,active=1;while(made<n){active--;if(active<63&&made+1<n){a.push((made%20001)-10000,((made+1)%20001)-10000);made+=2;active+=2}else{a.push((made%20001)-10000,null);made++;active++}}while(a[a.length-1]===null)a.pop();return JSON.stringify(a)})()"]], "expected": [1, 4, 3, 2, 1, 2, 1, 3, 1, 3, 1, 3, 5, 1, 5, 1, 5, 1, 7, 1, 3, 3, 7, 7, 4, 1, 4, 4, 4, 4, 1, 3, 2, 5, 3, 4, 4, 15, 1, 15, 4, 4, 4, 1, 4, 4, 4, 1, 9, 1, 12, 5, 4, 4, 10, 1, 10000], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "436", "slug": "count-numbers-with-unique-digits", "id": 436, "title": "Count Numbers with Unique Digits", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/count-numbers-with-unique-digits/", "examples": [{"input": "n = 2", "output": "91", "explanation": "All numbers from 0 to 99 except 11, 22, 33, 44, 55, 66, 77, 88 and 99 have distinct digits."}, {"input": "n = 0", "output": "1"}, {"input": "n = 1", "output": "10"}], "hints": ["Count numbers by exact length: the first digit has 9 choices (no leading zero) and each later digit has one fewer choice.", "Add the length-1 counts for all lengths from 1 up to n, plus 1 for zero itself.", "Lengths beyond 10 cannot have unique digits, but n is at most 8 here."], "statement": "Count all integers `x` with `0 <= x < 10^n` whose decimal digits are pairwise\ndifferent. Note that `0` itself counts as a one-digit number with unique\ndigits.\n\nFor `n = 2` the range is `0..99`, and only the nine doubles `11, 22, ..., 99`\nare excluded, giving `91`. For `n = 0` the range holds just `0`, giving `1`.\n\n**Constraints:**\n- `0 <= n <= 8`\n", "solution": "## Approach\n\nFix the number of digits k. The leading digit offers 9 options and each later\nposition offers one fewer remaining digit, giving `9 * 9 * 8 * ...` for that\nlength. Summing these counts for lengths 1 through n, plus one for zero,\nyields the answer.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) with n at most 8.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def countNumbersWithUniqueDigits(self, n: int) -> int:\n if n == 0:\n return 1\n if n == 1:\n return 10\n total = 10\n prod = 9\n for i in range(2, min(n, 10) + 1):\n prod *= 11 - i\n total += prod\n return total\n```\n", "starter": {"go": "package main\n\nfunc CountNumbersWithUniqueDigits(n int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def countNumbersWithUniqueDigits(self, n: int) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int countNumbersWithUniqueDigits(int n) {\n return 0;\n }\n};"}, "fn": "countNumbersWithUniqueDigits", "params": [{"name": "n", "type": "int"}], "outputType": "int", "tests": [["2"], ["0"], ["1"], ["3"], ["4"], ["5"], ["6"], ["7"], ["8"], ["2"], ["3"], ["4"], ["0"], ["1"], ["8"], ["7"], ["6"], ["5"], ["4"], ["3"], ["2"], ["1"], ["0"], ["8"], ["7"], ["6"], ["5"]], "expected": [91, 1, 10, 739, 5275, 32491, 168571, 712891, 2345851, 91, 739, 5275, 1, 10, 2345851, 712891, 168571, 32491, 5275, 739, 91, 10, 1, 2345851, 712891, 168571, 32491], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "414", "slug": "count-of-range-sum", "id": 414, "title": "Count of Range Sum", "difficulty": "Hard", "category": "array", "link": "https://leetcode.com/problems/count-of-range-sum/", "examples": [{"explanation": "The qualifying blocks are [0,0] with sum -2, [2,2] with sum -1, and [0,2] with sum 2.", "input": "nums = [-2,5,-1], lower = -2, upper = 2", "output": "3"}, {"explanation": "The single block [0,0] sums to 0, which lies in range.", "input": "nums = [0], lower = 0, upper = 0", "output": "1"}, {"explanation": "The blocks [0,1], [1,2] and [2,2] sum to 3, 5 and 3 respectively.", "input": "nums = [1,2,3], lower = 3, upper = 5", "output": "3"}], "hints": ["Rewrite each range sum as a difference of two prefix sums and count ordered pairs in bounds.", "Sort prefix sums with merge sort; while merging, count cross pairs whose difference lies in [lower, upper] with two sliding pointers.", "Use 64-bit prefix sums since totals can overflow 32 bits."], "statement": "You are given an integer array `nums` and two integers `lower` and `upper`. A *range sum* is the sum of a contiguous, non-empty block of the array. Count how many range sums fall inside the closed interval `[lower, upper]` and return that count.\n\n**Constraints:**\n- `1 <= nums.length <= 10^5`\n- `-2^31 <= nums[i] <= 2^31 - 1`\n- `-10^5 <= lower <= upper <= 10^5`\n- The answer fits in a 32-bit signed integer.\n", "solution": "## Approach\n\nExpress every range sum as a difference of two prefix sums, turning the task into counting ordered prefix pairs whose difference lies in `[lower, upper]`. A merge sort over the prefix array counts the cross pairs spanning the midpoint with two sliding pointers before merging the halves back into order.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log n), where n is the length of `nums`.\n- **Space Complexity:** O(n) for the prefix array and merge buffer.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def countRangeSum(self, nums: List[int], lower: int, upper: int) -> int:\n prefix = [0]\n for v in nums:\n prefix.append(prefix[-1] + v)\n\n def sort_count(lo: int, hi: int) -> int:\n if hi - lo <= 1:\n return 0\n mid = (lo + hi) // 2\n count = sort_count(lo, mid) + sort_count(mid, hi)\n j = k = mid\n for i in range(lo, mid):\n while k < hi and prefix[k] - prefix[i] < lower:\n k += 1\n while j < hi and prefix[j] - prefix[i] <= upper:\n j += 1\n count += j - k\n prefix[lo:hi] = sorted(prefix[lo:hi])\n return count\n\n return sort_count(0, len(prefix))\n```\n", "starter": {"go": "package main\n\nfunc CountRangeSum(nums []int, lower int, upper int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def countRangeSum(self, nums: List[int], lower: int, upper: int) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int countRangeSum(vector<int>& nums, int lower, int upper) {\n return 0;\n }\n};"}, "fn": "countRangeSum", "params": [{"name": "nums", "type": "int_array"}, {"name": "lower", "type": "int"}, {"name": "upper", "type": "int"}], "outputType": "int", "tests": [["[-2,5,-1]", "-2", "2"], ["[0]", "0", "0"], ["[1,2,3]", "3", "5"], ["[1]", "1", "1"], ["[1]", "2", "3"], ["[-1,-2,-3]", "-6", "-1"], ["[0,0,0]", "0", "0"], ["[1,2,3,4]", "0", "10"], ["[1,2,3,4]", "100", "200"], ["[5,-3,2,-1,4]", "1", "5"], ["[2147483647,-2147483648,1]", "-1", "1"], ["[-5,5,-5,5,-5,5]", "-5", "5"], ["[1,1,1,1,1]", "2", "3"], ["[10,-5,3,-2,8,-1]", "0", "8"], ["[100,-100,100,-100]", "-50", "50"], ["[3]", "-3", "3"], ["[-2,5,-1]", "2", "2"], ["[1,3,-2,4,-1,2,1,-5,4]", "-2", "2"], ["[2,-1,2,-1,2,-1]", "1", "2"], ["[7,7,7]", "7", "14"], ["[0,0,0,0,0]", "1", "2"], ["[5,4,3,2,1]", "3", "9"], ["[-1,2,-3,4,-5]", "-3", "3"], ["@javascript:JSON.stringify(Array(2000).fill(1))", "500", "1500"], ["@javascript:JSON.stringify(Array.from({length:2000}, (_, i) => (i % 2 === 0 ? 1 : -1)))", "0", "1"], ["[1,-1,1,-1,1,-1,1]", "0", "1"], ["[100000,-100000]", "-100000", "100000"], ["[4,-2,4,-2,4]", "2", "6"], ["[9,-9,9,-9,9]", "0", "9"], ["[2,2,2,2]", "4", "4"]], "expected": [3, 1, 3, 1, 0, 6, 6, 10, 0, 10, 3, 21, 7, 12, 4, 1, 1, 19, 12, 5, 0, 9, 12, 1002001, 1500500, 22, 3, 11, 12, 3], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "404", "slug": "count-of-smaller-numbers-after-self", "id": 404, "title": "Count of Smaller Numbers After Self", "difficulty": "Hard", "category": "array", "link": "https://leetcode.com/problems/count-of-smaller-numbers-after-self/", "examples": [{"explanation": "Right of 5 sit the smaller values 2 and 1; right of 2 sits 1; right of 6 sits 1; right of 1 sits nothing.", "input": "nums = [5,2,6,1]", "output": "[2,1,1,0]"}, {"explanation": "A lone element has nothing to its right.", "input": "nums = [-1]", "output": "[0]"}, {"explanation": "Neither entry is strictly smaller than the other.", "input": "nums = [-1,-1]", "output": "[0,0]"}], "hints": ["Scanning from right to left turns the task into counting previously seen values below a threshold.", "Compress the values to ranks and keep a Fenwick tree of seen frequencies for O(log n) queries and updates.", "A merge-sort variant that counts right-side takeovers while merging works too."], "statement": "You are given an integer array `nums`. For every position `i`, count how many elements strictly smaller than `nums[i]` appear to its right (at indices greater than `i`). Collect these counts into an array of the same length and return it.\n\n*Adaptation note:* the original statement returns a list of integers; here the result is returned as a plain integer array with identical contents and order.\n\n**Constraints:**\n- `1 <= nums.length <= 10^5`\n- `-10^4 <= nums[i] <= 10^4`\n", "solution": "## Approach\n\nWalk the array from right to left while remembering which values have been seen. Coordinate-compress the values to ranks and store their frequencies in a Fenwick tree, which reports how many seen values fall below the current one in logarithmic time and then records the current value.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log n), where n is the length of `nums`.\n- **Space Complexity:** O(n) for the compressed ranks and the tree.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def countSmaller(self, nums: List[int]) -> List[int]:\n vals = sorted(set(nums))\n rank = {v: i + 1 for i, v in enumerate(vals)}\n bit = [0] * (len(vals) + 2)\n\n def query(k):\n s = 0\n while k > 0:\n s += bit[k]\n k -= k & -k\n return s\n\n def update(k):\n while k < len(bit):\n bit[k] += 1\n k += k & -k\n\n ans = [0] * len(nums)\n for i in range(len(nums) - 1, -1, -1):\n ans[i] = query(rank[nums[i]] - 1)\n update(rank[nums[i]])\n return ans\n```\n", "starter": {"go": "package main\n\nfunc CountSmaller(nums []int) []int {\n \n}", "python": "from typing import List\nclass Solution:\n def countSmaller(self, nums: List[int]) -> List[int]:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<int> countSmaller(vector<int>& nums) {\n return {};\n }\n};"}, "fn": "countSmaller", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int_array", "tests": [["[5,2,6,1]"], ["[-1]"], ["[-1,-1]"], ["[1,2,3,4]"], ["[4,3,2,1]"], ["[1,1,1,1]"], ["[2,0,1]"], ["[5,2,6,1,9,3]"], ["[26,78,27,100,33,67,90,23,66,5,38,7,35,23,52,22,83,51,98,69,81,32,78,28,94,13,2,97,3,76,99,51,9,21,84,66,65,36,100,41]"], ["[0]"], ["[10000,-10000]"], ["[-10000,10000]"], ["[3,2,2,6,1]"], ["[1,0,2]"], ["[5,4,3,2,1,0,-1,-2]"], ["[1,2,1,2,1,2]"], ["[7,7,7,1,7]"], ["[-5,-2,-6,-1,0]"], ["[10,9,8,7,6,5,4,3,2,1,0]"], ["[0,1,2,3,4,5,6,7,8,9,10]"], ["[2,1]"], ["[1,2]"], ["[9,4,9,4,9,4]"], ["[100,50,100,50,100,50]"], ["[5,5,5,5,5,1]"], ["@javascript:JSON.stringify(Array.from({length:2000}, (_, i) => 2000 - i))"], ["@javascript:JSON.stringify(Array.from({length:2000}, (_, i) => i))"], ["[3,7,1,9,2,8,4,6,5]"], ["[-3,-1,-2,-5,-4]"], ["[0,0,1,1,0]"]], "expected": [[2, 1, 1, 0], [0], [0, 0], [0, 0, 0, 0], [3, 2, 1, 0], [0, 0, 0, 0], [2, 0, 0], [3, 1, 2, 0, 1, 0], [10, 27, 10, 35, 12, 22, 28, 8, 19, 2, 12, 2, 9, 6, 12, 5, 17, 9, 19, 12, 14, 6, 12, 5, 12, 3, 0, 10, 0, 7, 8, 4, 0, 0, 4, 3, 2, 0, 1, 0], [0], [1, 0], [0, 0], [3, 1, 1, 1, 0], [1, 0, 0], [7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 0, 1, 0, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0], [0, 0], [3, 0, 2, 0, 1, 0], [3, 0, 2, 0, 1, 0], [1, 1, 1, 1, 1, 0], [1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984, 1983, 1982, 1981, 1980, 1979, 1978, 1977, 1976, 1975, 1974, 1973, 1972, 1971, 1970, 1969, 1968, 1967, 1966, 1965, 1964, 1963, 1962, 1961, 1960, 1959, 1958, 1957, 1956, 1955, 1954, 1953, 1952, 1951, 1950, 1949, 1948, 1947, 1946, 1945, 1944, 1943, 1942, 1941, 1940, 1939, 1938, 1937, 1936, 1935, 1934, 1933, 1932, 1931, 1930, 1929, 1928, 1927, 1926, 1925, 1924, 1923, 1922, 1921, 1920, 1919, 1918, 1917, 1916, 1915, 1914, 1913, 1912, 1911, 1910, 1909, 1908, 1907, 1906, 1905, 1904, 1903, 1902, 1901, 1900, 1899, 1898, 1897, 1896, 1895, 1894, 1893, 1892, 1891, 1890, 1889, 1888, 1887, 1886, 1885, 1884, 1883, 1882, 1881, 1880, 1879, 1878, 1877, 1876, 1875, 1874, 1873, 1872, 1871, 1870, 1869, 1868, 1867, 1866, 1865, 1864, 1863, 1862, 1861, 1860, 1859, 1858, 1857, 1856, 1855, 1854, 1853, 1852, 1851, 1850, 1849, 1848, 1847, 1846, 1845, 1844, 1843, 1842, 1841, 1840, 1839, 1838, 1837, 1836, 1835, 1834, 1833, 1832, 1831, 1830, 1829, 1828, 1827, 1826, 1825, 1824, 1823, 1822, 1821, 1820, 1819, 1818, 1817, 1816, 1815, 1814, 1813, 1812, 1811, 1810, 1809, 1808, 1807, 1806, 1805, 1804, 1803, 1802, 1801, 1800, 1799, 1798, 1797, 1796, 1795, 1794, 1793, 1792, 1791, 1790, 1789, 1788, 1787, 1786, 1785, 1784, 1783, 1782, 1781, 1780, 1779, 1778, 1777, 1776, 1775, 1774, 1773, 1772, 1771, 1770, 1769, 1768, 1767, 1766, 1765, 1764, 1763, 1762, 1761, 1760, 1759, 1758, 1757, 1756, 1755, 1754, 1753, 1752, 1751, 1750, 1749, 1748, 1747, 1746, 1745, 1744, 1743, 1742, 1741, 1740, 1739, 1738, 1737, 1736, 1735, 1734, 1733, 1732, 1731, 1730, 1729, 1728, 1727, 1726, 1725, 1724, 1723, 1722, 1721, 1720, 1719, 1718, 1717, 1716, 1715, 1714, 1713, 1712, 1711, 1710, 1709, 1708, 1707, 1706, 1705, 1704, 1703, 1702, 1701, 1700, 1699, 1698, 1697, 1696, 1695, 1694, 1693, 1692, 1691, 1690, 1689, 1688, 1687, 1686, 1685, 1684, 1683, 1682, 1681, 1680, 1679, 1678, 1677, 1676, 1675, 1674, 1673, 1672, 1671, 1670, 1669, 1668, 1667, 1666, 1665, 1664, 1663, 1662, 1661, 1660, 1659, 1658, 1657, 1656, 1655, 1654, 1653, 1652, 1651, 1650, 1649, 1648, 1647, 1646, 1645, 1644, 1643, 1642, 1641, 1640, 1639, 1638, 1637, 1636, 1635, 1634, 1633, 1632, 1631, 1630, 1629, 1628, 1627, 1626, 1625, 1624, 1623, 1622, 1621, 1620, 1619, 1618, 1617, 1616, 1615, 1614, 1613, 1612, 1611, 1610, 1609, 1608, 1607, 1606, 1605, 1604, 1603, 1602, 1601, 1600, 1599, 1598, 1597, 1596, 1595, 1594, 1593, 1592, 1591, 1590, 1589, 1588, 1587, 1586, 1585, 1584, 1583, 1582, 1581, 1580, 1579, 1578, 1577, 1576, 1575, 1574, 1573, 1572, 1571, 1570, 1569, 1568, 1567, 1566, 1565, 1564, 1563, 1562, 1561, 1560, 1559, 1558, 1557, 1556, 1555, 1554, 1553, 1552, 1551, 1550, 1549, 1548, 1547, 1546, 1545, 1544, 1543, 1542, 1541, 1540, 1539, 1538, 1537, 1536, 1535, 1534, 1533, 1532, 1531, 1530, 1529, 1528, 1527, 1526, 1525, 1524, 1523, 1522, 1521, 1520, 1519, 1518, 1517, 1516, 1515, 1514, 1513, 1512, 1511, 1510, 1509, 1508, 1507, 1506, 1505, 1504, 1503, 1502, 1501, 1500, 1499, 1498, 1497, 1496, 1495, 1494, 1493, 1492, 1491, 1490, 1489, 1488, 1487, 1486, 1485, 1484, 1483, 1482, 1481, 1480, 1479, 1478, 1477, 1476, 1475, 1474, 1473, 1472, 1471, 1470, 1469, 1468, 1467, 1466, 1465, 1464, 1463, 1462, 1461, 1460, 1459, 1458, 1457, 1456, 1455, 1454, 1453, 1452, 1451, 1450, 1449, 1448, 1447, 1446, 1445, 1444, 1443, 1442, 1441, 1440, 1439, 1438, 1437, 1436, 1435, 1434, 1433, 1432, 1431, 1430, 1429, 1428, 1427, 1426, 1425, 1424, 1423, 1422, 1421, 1420, 1419, 1418, 1417, 1416, 1415, 1414, 1413, 1412, 1411, 1410, 1409, 1408, 1407, 1406, 1405, 1404, 1403, 1402, 1401, 1400, 1399, 1398, 1397, 1396, 1395, 1394, 1393, 1392, 1391, 1390, 1389, 1388, 1387, 1386, 1385, 1384, 1383, 1382, 1381, 1380, 1379, 1378, 1377, 1376, 1375, 1374, 1373, 1372, 1371, 1370, 1369, 1368, 1367, 1366, 1365, 1364, 1363, 1362, 1361, 1360, 1359, 1358, 1357, 1356, 1355, 1354, 1353, 1352, 1351, 1350, 1349, 1348, 1347, 1346, 1345, 1344, 1343, 1342, 1341, 1340, 1339, 1338, 1337, 1336, 1335, 1334, 1333, 1332, 1331, 1330, 1329, 1328, 1327, 1326, 1325, 1324, 1323, 1322, 1321, 1320, 1319, 1318, 1317, 1316, 1315, 1314, 1313, 1312, 1311, 1310, 1309, 1308, 1307, 1306, 1305, 1304, 1303, 1302, 1301, 1300, 1299, 1298, 1297, 1296, 1295, 1294, 1293, 1292, 1291, 1290, 1289, 1288, 1287, 1286, 1285, 1284, 1283, 1282, 1281, 1280, 1279, 1278, 1277, 1276, 1275, 1274, 1273, 1272, 1271, 1270, 1269, 1268, 1267, 1266, 1265, 1264, 1263, 1262, 1261, 1260, 1259, 1258, 1257, 1256, 1255, 1254, 1253, 1252, 1251, 1250, 1249, 1248, 1247, 1246, 1245, 1244, 1243, 1242, 1241, 1240, 1239, 1238, 1237, 1236, 1235, 1234, 1233, 1232, 1231, 1230, 1229, 1228, 1227, 1226, 1225, 1224, 1223, 1222, 1221, 1220, 1219, 1218, 1217, 1216, 1215, 1214, 1213, 1212, 1211, 1210, 1209, 1208, 1207, 1206, 1205, 1204, 1203, 1202, 1201, 1200, 1199, 1198, 1197, 1196, 1195, 1194, 1193, 1192, 1191, 1190, 1189, 1188, 1187, 1186, 1185, 1184, 1183, 1182, 1181, 1180, 1179, 1178, 1177, 1176, 1175, 1174, 1173, 1172, 1171, 1170, 1169, 1168, 1167, 1166, 1165, 1164, 1163, 1162, 1161, 1160, 1159, 1158, 1157, 1156, 1155, 1154, 1153, 1152, 1151, 1150, 1149, 1148, 1147, 1146, 1145, 1144, 1143, 1142, 1141, 1140, 1139, 1138, 1137, 1136, 1135, 1134, 1133, 1132, 1131, 1130, 1129, 1128, 1127, 1126, 1125, 1124, 1123, 1122, 1121, 1120, 1119, 1118, 1117, 1116, 1115, 1114, 1113, 1112, 1111, 1110, 1109, 1108, 1107, 1106, 1105, 1104, 1103, 1102, 1101, 1100, 1099, 1098, 1097, 1096, 1095, 1094, 1093, 1092, 1091, 1090, 1089, 1088, 1087, 1086, 1085, 1084, 1083, 1082, 1081, 1080, 1079, 1078, 1077, 1076, 1075, 1074, 1073, 1072, 1071, 1070, 1069, 1068, 1067, 1066, 1065, 1064, 1063, 1062, 1061, 1060, 1059, 1058, 1057, 1056, 1055, 1054, 1053, 1052, 1051, 1050, 1049, 1048, 1047, 1046, 1045, 1044, 1043, 1042, 1041, 1040, 1039, 1038, 1037, 1036, 1035, 1034, 1033, 1032, 1031, 1030, 1029, 1028, 1027, 1026, 1025, 1024, 1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014, 1013, 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1005, 1004, 1003, 1002, 1001, 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950, 949, 948, 947, 946, 945, 944, 943, 942, 941, 940, 939, 938, 937, 936, 935, 934, 933, 932, 931, 930, 929, 928, 927, 926, 925, 924, 923, 922, 921, 920, 919, 918, 917, 916, 915, 914, 913, 912, 911, 910, 909, 908, 907, 906, 905, 904, 903, 902, 901, 900, 899, 898, 897, 896, 895, 894, 893, 892, 891, 890, 889, 888, 887, 886, 885, 884, 883, 882, 881, 880, 879, 878, 877, 876, 875, 874, 873, 872, 871, 870, 869, 868, 867, 866, 865, 864, 863, 862, 861, 860, 859, 858, 857, 856, 855, 854, 853, 852, 851, 850, 849, 848, 847, 846, 845, 844, 843, 842, 841, 840, 839, 838, 837, 836, 835, 834, 833, 832, 831, 830, 829, 828, 827, 826, 825, 824, 823, 822, 821, 820, 819, 818, 817, 816, 815, 814, 813, 812, 811, 810, 809, 808, 807, 806, 805, 804, 803, 802, 801, 800, 799, 798, 797, 796, 795, 794, 793, 792, 791, 790, 789, 788, 787, 786, 785, 784, 783, 782, 781, 780, 779, 778, 777, 776, 775, 774, 773, 772, 771, 770, 769, 768, 767, 766, 765, 764, 763, 762, 761, 760, 759, 758, 757, 756, 755, 754, 753, 752, 751, 750, 749, 748, 747, 746, 745, 744, 743, 742, 741, 740, 739, 738, 737, 736, 735, 734, 733, 732, 731, 730, 729, 728, 727, 726, 725, 724, 723, 722, 721, 720, 719, 718, 717, 716, 715, 714, 713, 712, 711, 710, 709, 708, 707, 706, 705, 704, 703, 702, 701, 700, 699, 698, 697, 696, 695, 694, 693, 692, 691, 690, 689, 688, 687, 686, 685, 684, 683, 682, 681, 680, 679, 678, 677, 676, 675, 674, 673, 672, 671, 670, 669, 668, 667, 666, 665, 664, 663, 662, 661, 660, 659, 658, 657, 656, 655, 654, 653, 652, 651, 650, 649, 648, 647, 646, 645, 644, 643, 642, 641, 640, 639, 638, 637, 636, 635, 634, 633, 632, 631, 630, 629, 628, 627, 626, 625, 624, 623, 622, 621, 620, 619, 618, 617, 616, 615, 614, 613, 612, 611, 610, 609, 608, 607, 606, 605, 604, 603, 602, 601, 600, 599, 598, 597, 596, 595, 594, 593, 592, 591, 590, 589, 588, 587, 586, 585, 584, 583, 582, 581, 580, 579, 578, 577, 576, 575, 574, 573, 572, 571, 570, 569, 568, 567, 566, 565, 564, 563, 562, 561, 560, 559, 558, 557, 556, 555, 554, 553, 552, 551, 550, 549, 548, 547, 546, 545, 544, 543, 542, 541, 540, 539, 538, 537, 536, 535, 534, 533, 532, 531, 530, 529, 528, 527, 526, 525, 524, 523, 522, 521, 520, 519, 518, 517, 516, 515, 514, 513, 512, 511, 510, 509, 508, 507, 506, 505, 504, 503, 502, 501, 500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 483, 482, 481, 480, 479, 478, 477, 476, 475, 474, 473, 472, 471, 470, 469, 468, 467, 466, 465, 464, 463, 462, 461, 460, 459, 458, 457, 456, 455, 454, 453, 452, 451, 450, 449, 448, 447, 446, 445, 444, 443, 442, 441, 440, 439, 438, 437, 436, 435, 434, 433, 432, 431, 430, 429, 428, 427, 426, 425, 424, 423, 422, 421, 420, 419, 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, 399, 398, 397, 396, 395, 394, 393, 392, 391, 390, 389, 388, 387, 386, 385, 384, 383, 382, 381, 380, 379, 378, 377, 376, 375, 374, 373, 372, 371, 370, 369, 368, 367, 366, 365, 364, 363, 362, 361, 360, 359, 358, 357, 356, 355, 354, 353, 352, 351, 350, 349, 348, 347, 346, 345, 344, 343, 342, 341, 340, 339, 338, 337, 336, 335, 334, 333, 332, 331, 330, 329, 328, 327, 326, 325, 324, 323, 322, 321, 320, 319, 318, 317, 316, 315, 314, 313, 312, 311, 310, 309, 308, 307, 306, 305, 304, 303, 302, 301, 300, 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 5, 0, 5, 0, 3, 0, 1, 0], [2, 3, 2, 0, 0], [0, 0, 1, 1, 0]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "330", "slug": "count-primes", "id": 330, "title": "Count Primes", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/count-primes/", "examples": [{"explanation": "The primes below 10 are 2, 3, 5 and 7.", "input": "n = 10", "output": "4"}, {"explanation": "There is nothing below 0.", "input": "n = 0", "output": "0"}, {"explanation": "0 is not prime, so the count is 0.", "input": "n = 1", "output": "0"}], "hints": ["Cross out multiples with the Sieve of Eratosthenes instead of testing each number separately.", "Start crossing out at i*i and only sieve odd candidates after handling 2.", "Count the survivors below n; 0 and 1 are never counted."], "statement": "Given a non-negative integer `n`, count how many prime numbers are strictly smaller than `n`. Recall that 0 and 1 are not prime, and a prime has no divisors other than 1 and itself.\n\n**Constraints:**\n- `0 <= n <= 5 * 10^6`\n", "solution": "## Approach\n\nRun the Sieve of Eratosthenes: keep a boolean table where an entry records whether the index is composite. Scan from 2 upward; each unmarked number is prime and marks its multiples starting from its square. The primes below `n` are exactly the unmarked entries, so count them.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log log n) for the sieve.\n- **Space Complexity:** O(n) for the composite table.\n\n## Implementation\n\n```python\nclass Solution:\n def countPrimes(self, n: int) -> int:\n if n <= 2:\n return 0\n composite = bytearray(n)\n count = 0\n for i in range(2, n):\n if not composite[i]:\n count += 1\n if i * i < n:\n step = i\n start = i * i\n composite[start:n:step] = b\"\\x01\" * ((n - 1 - start) // step + 1)\n return count\n```\n", "starter": {"go": "package main\n\nfunc CountPrimes(n int) int {\n return 0\n}", "python": "class Solution:\n def countPrimes(self, n: int) -> int:\n return 0\n", "cpp": "class Solution {\npublic:\n int countPrimes(int n) {\n return 0;\n }\n};"}, "fn": "countPrimes", "params": [{"name": "n", "type": "int"}], "outputType": "int", "tests": [["10"], ["0"], ["1"], ["2"], ["3"], ["4"], ["5"], ["11"], ["20"], ["25"], ["50"], ["100"], ["101"], ["200"], ["1000"], ["10000"], ["50000"], ["100000"], ["17"], ["18"], ["30"], ["49"], ["121"], ["1000"], ["25000"], ["200000"], ["499979"], ["500000"]], "expected": [4, 0, 0, 0, 1, 2, 2, 4, 8, 9, 15, 25, 25, 46, 168, 1229, 5133, 9592, 6, 7, 10, 15, 30, 168, 2762, 17984, 41537, 41538], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "531", "slug": "count-the-repetitions", "id": 531, "title": "Count The Repetitions", "difficulty": "Hard", "category": "string", "link": "https://leetcode.com/problems/count-the-repetitions/", "examples": [{"input": "s1 = \"acb\", n1 = 4, s2 = \"ab\", n2 = 2", "output": "2", "explanation": "Repeating s1 four times gives \"acbacbacbacb\", which contains \"ab\" four times as a subsequence; 4 / 2 = 2."}, {"input": "s1 = \"aaa\", n1 = 3, s2 = \"aa\", n2 = 1", "output": "4", "explanation": "Nine a's contain \"aa\" four times as a subsequence; 4 / 1 = 4."}], "hints": ["Scanning all n1 copies is too slow; the position inside s2 after each copy must eventually repeat, forming a cycle.", "Record the completed-copy count the first time each s2-offset appears, then fast-forward whole cycles with arithmetic."], "statement": "Write `[S, n]` for the string formed by repeating `S` exactly `n` times. Given strings `s1`, `s2` and counts `n1`, `n2`, consider `S1 = [s1, n1]`.\n\nCount how many copies of `s2` appear in `S1` as a subsequence (characters in order, not necessarily adjacent), then divide that count by `n2` using integer division. In other words, find the largest `M` such that `[s2, M]` divided into groups of `n2` still fits, i.e. `M = (number of subsequence copies of s2 in S1) / n2` rounded down.\n\nReturn that value `M`.\n\n**Constraints:**\n- `1 <= s1.length, s2.length <= 100`\n- `1 <= n1, n2 <= 10^6`\n- `s1` and `s2` consist of lowercase English letters.\n", "solution": "## Approach\n\nSimulate matching `s2` cyclically against repeated copies of `s1`, tracking how many full `s2` copies complete and where inside `s2` each copy of `s1` ends. The end offset has only `len(s2)` possible values, so it must repeat: once an offset recurs, the segment between the two occurrences is a cycle. Measure the cycle's length and yield, skip all whole cycles with arithmetic, handle the leftover copies directly, and finally divide by `n2`.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(|s1| * |s2|), since a repeat is forced within `|s2| + 1` copies of `s1`.\n- **Space Complexity:** O(|s2| + n1) for the offset table and per-copy counts.\n\n## Implementation\n\n```python\nclass Solution:\n def getMaxRepetitions(self, s1: str, n1: int, s2: str, n2: int) -> int:\n if n1 == 0:\n return 0\n reps = [0] * (n1 + 1)\n seen = {}\n j = 0\n cnt = 0\n for k in range(1, n1 + 1):\n for ch in s1:\n if ch == s2[j]:\n j += 1\n if j == len(s2):\n j = 0\n cnt += 1\n reps[k] = cnt\n if j in seen:\n pk, pcnt = seen[j]\n cycle_len = k - pk\n cycle_cnt = cnt - pcnt\n remaining = n1 - pk\n total = pcnt + (remaining // cycle_len) * cycle_cnt\n total += reps[pk + (remaining % cycle_len)] - pcnt\n return total // n2\n seen[j] = (k, cnt)\n return reps[n1] // n2\n```\n", "starter": {"go": "package main\n\nfunc GetMaxRepetitions(s1 string, n1 int, s2 string, n2 int) int {\n \n}", "python": "class Solution:\n def getMaxRepetitions(self, s1: str, n1: int, s2: str, n2: int) -> int:\n pass", "cpp": "#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n int getMaxRepetitions(string s1, int n1, string s2, int n2) {\n return 0;\n }\n};"}, "fn": "getMaxRepetitions", "params": [{"name": "s1", "type": "string"}, {"name": "n1", "type": "int"}, {"name": "s2", "type": "string"}, {"name": "n2", "type": "int"}], "outputType": "int", "tests": [["acb", "4", "ab", "2"], ["aaa", "3", "aa", "1"], ["abc", "4", "ab", "2"], ["a", "1000", "a", "1"], ["abc", "1", "abcd", "1"], ["aaa", "2", "aaaa", "1"], ["ababa", "3", "aba", "2"], ["abcab", "2", "abcab", "2"], ["baba", "2", "ba", "3"], ["abcd", "100", "abcdabcd", "1"], ["aab", "3", "ab", "1"], ["a", "1000000", "a", "1"], ["abc", "3", "abc", "1"], ["ab", "5", "ab", "2"], ["aab", "4", "ab", "2"], ["xyz", "10", "xy", "5"], ["hello", "3", "hello", "1"], ["abcd", "2", "ab", "1"], ["aaaab", "2", "aaab", "1"], ["abcabc", "3", "abc", "2"], ["a", "5", "aa", "1"], ["ababa", "4", "ab", "3"], ["test", "7", "te", "2"], ["bbb", "6", "bb", "3"], ["abcde", "2", "ace", "1"], ["zzzz", "8", "zz", "2"], ["ababab", "2", "abab", "1"], ["qwerty", "3", "qwe", "1"]], "expected": [2, 4, 2, 1000, 0, 1, 1, 1, 1, 50, 3, 1000000, 3, 2, 2, 2, 3, 2, 2, 3, 2, 2, 3, 3, 2, 8, 3, 3], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "826", "slug": "count-unique-characters-of-all-substrings-of-a-given-string", "id": 826, "title": "Count Unique Characters of All Substrings of a Given String", "difficulty": "Hard", "category": "string", "link": "https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string/", "examples": [{"input": "s = \"ABC\"", "output": "10", "explanation": "Single letters give 3, pairs give 4, the triple gives 3."}, {"input": "s = \"ABA\"", "output": "8", "explanation": "The full string scores only 1 because A repeats."}, {"input": "s = \"LEETCODE\"", "output": "92"}], "hints": ["Think per character occurrence: an occurrence at position i with neighbours prev and next is the unique one exactly for starts in (prev, i] and ends in [i, next).", "Keep the last two seen positions for each of the 26 letters and add (i - last1) * (last1 - last2) as you scan.", "After the scan, flush each letter once more using the string length as the virtual next occurrence, taking the total modulo 1e9+7."], "statement": "Given a string `s` of uppercase English letters, look at every contiguous substring (including the whole string and each single character). For one substring, its score is the number of characters that occur exactly once inside it. Add up the scores of all substrings and return the total modulo `10^9 + 7`.\n\n**Constraints:**\n- `1 <= s.length <= 10^5`\n- `s` consists of uppercase English letters only\n", "solution": "## Approach\n\nEach occurrence of a letter is the unique representative of its substrings whose start falls after its previous occurrence and whose end falls before its next occurrence, giving (i - prev) * (next - i) substrings per occurrence. Scanning left to right while remembering the last two positions of every letter lets us add each occurrence's share the moment its successor is known. A final flush treats the string end as every letter's next occurrence, with the running total kept modulo 1e9+7.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) where n is the string length; each character is processed once.\n- **Space Complexity:** O(1) besides the input, using two fixed arrays of size 26.\n\n## Implementation\n\n```python\nclass Solution:\n def uniqueLetterString(self, s: str) -> int:\n mod = 10 ** 9 + 7\n last2 = [-1] * 26\n last1 = [-1] * 26\n ans = 0\n for i, ch in enumerate(s):\n c = ord(ch) - ord(\"A\")\n ans += (i - last1[c]) * (last1[c] - last2[c])\n last2[c] = last1[c]\n last1[c] = i\n n = len(s)\n for c in range(26):\n ans += (n - last1[c]) * (last1[c] - last2[c])\n return ans % mod\n```\n", "starter": {"go": "package main\n\nfunc UniqueLetterString(s string) int {\n return 0\n}", "python": "class Solution:\n def uniqueLetterString(self, s: str) -> int:\n pass", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n int uniqueLetterString(string s) {\n return 0;\n }\n};"}, "fn": "uniqueLetterString", "params": [{"name": "s", "type": "string"}], "outputType": "int", "tests": [["ABC"], ["ABA"], ["LEETCODE"], ["A"], ["AA"], ["AB"], ["ABAABA"], ["ABCABC"], ["AAAA"], ["ABCD"], ["DCBA"], ["ABCA"], ["Z"], ["AZAZAZ"], ["HELLO"], ["WORLD"], ["MISSISSIPPI"], ["ABCDEFGHIJ"], ["AAAAAAAAAA"], ["ABABABAB"], ["QWERTY"], ["AAB"], ["ABB"], ["ABCDEEDCBA"], ["XYZZYX"], ["UNIQUE"], ["BANANA"], ["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]], "expected": [10, 8, 92, 1, 2, 4, 20, 36, 4, 20, 20, 18, 1, 20, 23, 35, 61, 220, 10, 28, 56, 6, 6, 110, 28, 52, 26, 3276], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "356", "slug": "count-univalue-subtrees", "id": 356, "title": "Count Univalue Subtrees", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/count-univalue-subtrees/", "examples": [{"input": "root = [5,1,5,5,5,null,5]", "output": "4", "explanation": "The univalue subtrees are the leaves 5, 5, 5 and the single node 1."}, {"input": "root = []", "output": "0", "explanation": "An empty tree has no subtrees."}, {"input": "root = [5,5,5,5,5,null,5]", "output": "4", "explanation": "Four single nodes plus larger matching groups combine into 4 univalue subtrees."}], "hints": ["Post-order traversal lets each node learn whether its children are univalue before deciding.", "A node is univalue when both children are univalue (or absent) and match its value.", "Count the node itself whenever that check passes."], "statement": "Given the root of a binary tree, count the subtrees in which every node holds the same value. A single node (including each leaf) qualifies, and an empty tree contributes zero.\n\nA subtree rooted at some node is univalue when that node's value matches the values of its left and right subtrees and both of those subtrees are themselves univalue. Empty children count as univalue.\n\nReturn the total number of such subtrees.\n\n**Constraints:**\n- The number of nodes is in the range `[0, 1000]`.\n- `-1000 <= Node.val <= 1000`\n", "solution": "## Approach\n\nUse a post-order walk that reports whether each subtree is univalue. A null child is trivially univalue. A node qualifies when both children qualify and any present child matches its value; each qualifying node increments the total. The walk returns the qualification flag upward so parents can decide.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the number of nodes. Each node is visited once.\n- **Space Complexity:** O(h) for the recursion stack, where h is the tree height.\n\n## Implementation\n\n```python\nclass Solution:\n def countUnivalSubtrees(self, root) -> int:\n self.count = 0\n\n def is_unival(node):\n if node is None:\n return True\n left = is_unival(node.left)\n right = is_unival(node.right)\n if not left or not right:\n return False\n if node.left and node.left.val != node.val:\n return False\n if node.right and node.right.val != node.val:\n return False\n self.count += 1\n return True\n\n is_unival(root)\n return self.count\n```\n", "starter": {"go": "package main\n\nfunc CountUnivalSubtrees(root *TreeNode) int {\n return 0\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 countUnivalSubtrees(self, root) -> int:\n pass", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n};\n*/\nclass Solution {\npublic:\n int countUnivalSubtrees(TreeNode* root) {\n return 0;\n }\n};"}, "fn": "countUnivalSubtrees", "params": [{"name": "root", "type": "tree_node", "visualizeType": "tree_node"}], "outputType": "int", "tests": [["[5,1,5,5,5,null,5]"], ["[]"], ["[5,5,5,5,5,null,5]"], ["[1]"], ["[1,1,1]"], ["[1,2,3]"], ["[5,4,5,4,4,null,5]"], ["[1,1,null,1,1,null,null,1]"], ["[0,0,0,null,0]"], ["[2,2,2,2,2,2,2]"], ["[1,2,2,3,3,3,3]"], ["[-1,-1,-1]"], ["[1,1,1,1,1,1,1]"], ["[1,2,null,3,null,4,null]"], ["[5,null,5,null,5]"], ["[5,null,4,null,5]"], ["[1,1,1,2,2,2,2]"], ["[10,20,10,20,20,null,10]"], ["[0]"], ["[1,1,null,1,null,1]"], ["[3,3,3,null,3,null,3]"], ["[1000,-1000,1000]"], ["[7,7,null,7,7]"], ["[1,null,2,null,3]"], ["[2,1,1,null,null,1,1]"], ["[9,9,9,9,null,null,9]"], ["[4,4,4,4,4,null,null]"], ["[6,null,6,6,null,6,6]"]], "expected": [4, 0, 6, 1, 3, 2, 5, 5, 4, 7, 4, 3, 7, 1, 3, 1, 4, 5, 1, 4, 5, 2, 4, 1, 4, 5, 5, 5], "loose": false}