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": "116", "slug": "walls-and-gates", "id": 116, "title": "Walls and Gates", "difficulty": "Medium", "category": "graph", "link": "https://leetcode.com/problems/walls-and-gates/", "examples": [{"input": "rooms = [[2147483647,-1,0,2147483647],[2147483647,2147483647,2147483647,-1],[2147483647,-1,2147483647,-1],[0,-1,2147483647,2147483647]]", "output": "[[3,-1,0,1],[2,2,1,-1],[1,-1,2,-1],[0,-1,3,4]]", "explanation": "The distances to the nearest gate are: [[3,-1,0,1],[2,2,1,-1],[1,-1,2,-1],[0,-1,3,4]]."}, {"input": "rooms = [[-1,2147483647],[0,2147483647]]", "output": "[[-1,2],[0,1]]", "explanation": "The distances to the nearest gate are: [[-1,2],[0,1]]."}], "hints": ["Start a breadth-first search from all gates at the same time.", "The first time an empty room is reached is through its nearest gate."], "statement": "You are given a nonempty rectangular matrix `rooms` containing three kinds of cells:\n\n- `-1` is a wall.\n- `0` is a gate.\n- `2147483647` is an empty room.\n\nFor every empty room, fill it with the distance to its nearest gate using horizontal and vertical moves. Walls cannot be crossed. If no gate is reachable, leave the room as `2147483647`.\n\nThis version adapts the usual in-place operation: return the completed matrix.\n\n**Constraints:**\n- `1 <= rooms.length <= 250`\n- `1 <= rooms[r].length <= 250`\n- Every row has the same length.\n- Every cell is `-1`, `0`, or `2147483647`.\n", "solution": "## Approach\n\nCopy the matrix for the return-value adaptation, then put every gate into one breadth-first-search queue. Expanding all gates together visits each empty room first from its nearest gate. Assign a distance only when the cell still has the empty-room sentinel, which also prevents repeated work and leaves unreachable rooms unchanged.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m * n), because every room enters the queue at most once.\n- **Space Complexity:** O(m * n) for the returned copy and the breadth-first-search queue.\n\n## Implementation\n\n```python\nfrom collections import deque\nfrom typing import List\n\n\nclass Solution:\n def wallsAndGates(self, rooms: List[List[int]]) -> List[List[int]]:\n result = [row.copy() for row in rooms]\n rows, cols = len(result), len(result[0])\n queue = deque(\n (row, col)\n for row in range(rows)\n for col in range(cols)\n if result[row][col] == 0\n )\n while queue:\n row, col = queue.popleft()\n for row_step, col_step in ((1, 0), (-1, 0), (0, 1), (0, -1)):\n next_row = row + row_step\n next_col = col + col_step\n if not (0 <= next_row < rows and 0 <= next_col < cols):\n continue\n if result[next_row][next_col] != 2147483647:\n continue\n result[next_row][next_col] = result[row][col] + 1\n queue.append((next_row, next_col))\n return result\n```\n", "starter": {"go": "package main\n\nfunc WallsAndGates(rooms [][]int) [][]int {\n return [][]int{}\n}\n", "python": "from typing import List\n\nclass Solution:\n def wallsAndGates(self, rooms: List[List[int]]) -> List[List[int]]:\n return []\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<vector<int>> wallsAndGates(vector<vector<int>>& rooms) {\n return {};\n }\n};"}, "fn": "wallsAndGates", "params": [{"name": "rooms", "type": "int_array_2d", "visualizeType": "matrix"}], "outputType": "int_array_2d", "tests": [["[[2147483647]]"], ["[[0]]"], ["[[-1]]"], ["[[2147483647,0]]"], ["[[0,2147483647]]"], ["[[2147483647,-1]]"], ["[[-1,2147483647]]"], ["[[2147483647,2147483647,0]]"], ["[[0,2147483647,2147483647]]"], ["[[2147483647,-1,0]]"], ["[[2147483647],[0]]"], ["[[0],[2147483647]]"], ["[[2147483647],[-1],[0]]"], ["[[2147483647,2147483647],[2147483647,0]]"], ["[[0,2147483647],[2147483647,2147483647]]"], ["[[-1,2147483647],[0,2147483647]]"], ["[[2147483647,-1],[2147483647,0]]"], ["[[0,-1],[-1,2147483647]]"], ["[[0,0],[0,0]]"], ["[[2147483647,2147483647],[2147483647,2147483647]]"], ["[[2147483647,0,2147483647],[2147483647,2147483647,2147483647]]"], ["[[2147483647,2147483647,2147483647],[0,-1,0]]"], ["[[0,-1,2147483647],[2147483647,-1,2147483647],[2147483647,2147483647,2147483647]]"], ["[[2147483647,-1,0],[2147483647,-1,2147483647],[2147483647,2147483647,2147483647]]"], ["[[2147483647,2147483647,2147483647],[2147483647,-1,2147483647],[0,2147483647,0]]"], ["[[0,2147483647,0],[2147483647,2147483647,2147483647],[0,2147483647,0]]"], ["[[-1,-1,-1],[-1,2147483647,-1],[-1,-1,0]]"], ["[[2147483647,-1,2147483647],[0,-1,0],[2147483647,-1,2147483647]]"], ["[[0,2147483647,2147483647,2147483647]]"], ["[[2147483647,2147483647,2147483647,0]]"], ["[[0,-1,2147483647,2147483647,0]]"], ["[[2147483647],[2147483647],[2147483647],[0]]"], ["[[0],[2147483647],[-1],[2147483647],[0]]"], ["[[2147483647,2147483647,-1,0],[2147483647,-1,2147483647,2147483647]]"], ["[[0,2147483647,-1,2147483647],[-1,2147483647,2147483647,2147483647]]"], ["[[2147483647,-1,0,2147483647],[2147483647,2147483647,2147483647,-1],[2147483647,-1,2147483647,-1],[0,-1,2147483647,2147483647]]"], ["[[0,2147483647,2147483647,2147483647],[2147483647,-1,-1,2147483647],[2147483647,2147483647,2147483647,2147483647]]"], ["[[2147483647,2147483647,2147483647,0],[-1,-1,2147483647,-1],[0,2147483647,2147483647,2147483647]]"], ["[[2147483647,-1,2147483647,0],[2147483647,-1,2147483647,-1],[2147483647,2147483647,2147483647,2147483647]]"], ["[[0,-1,2147483647,2147483647],[2147483647,-1,2147483647,-1],[2147483647,2147483647,2147483647,0]]"], ["[[2147483647,2147483647,0,2147483647,2147483647],[2147483647,-1,-1,-1,2147483647],[2147483647,2147483647,2147483647,2147483647,2147483647]]"], ["[[0,2147483647,2147483647,-1,2147483647],[2147483647,-1,2147483647,-1,2147483647],[2147483647,-1,2147483647,2147483647,0]]"], ["[[2147483647,-1,0,-1,2147483647],[2147483647,-1,2147483647,-1,2147483647],[2147483647,2147483647,2147483647,2147483647,2147483647]]"], ["[[2147483647,2147483647,2147483647],[2147483647,0,2147483647],[2147483647,2147483647,2147483647],[2147483647,-1,2147483647]]"], ["[[0,-1,2147483647],[2147483647,-1,2147483647],[2147483647,-1,2147483647],[2147483647,2147483647,2147483647]]"], ["[[2147483647,2147483647,2147483647,2147483647],[2147483647,-1,-1,2147483647],[0,2147483647,2147483647,0],[2147483647,-1,2147483647,2147483647]]"], ["[[2147483647,-1,2147483647,-1,0],[2147483647,-1,2147483647,2147483647,2147483647],[0,2147483647,2147483647,-1,2147483647]]"], ["[[0,2147483647,-1,2147483647,0],[2147483647,2147483647,-1,2147483647,2147483647],[-1,2147483647,2147483647,2147483647,-1]]"], ["[[2147483647,2147483647,2147483647,2147483647,2147483647],[2147483647,-1,-1,-1,2147483647],[2147483647,-1,0,-1,2147483647],[2147483647,-1,2147483647,-1,2147483647],[2147483647,2147483647,2147483647,2147483647,2147483647]]"], ["[[0,-1,2147483647,2147483647,2147483647],[2147483647,-1,2147483647,-1,2147483647],[2147483647,-1,2147483647,-1,2147483647],[2147483647,2147483647,2147483647,-1,0]]"], ["[[2147483647,0,2147483647,2147483647],[2147483647,-1,2147483647,-1],[2147483647,2147483647,2147483647,2147483647],[0,-1,2147483647,2147483647]]"], ["[[2147483647,-1,2147483647,0,2147483647,2147483647],[2147483647,-1,2147483647,-1,-1,2147483647],[0,2147483647,2147483647,2147483647,2147483647,2147483647]]"], ["@javascript:JSON.stringify(Array.from({length:40},(_,r)=>Array.from({length:250},(_,c)=>r===0&&c===0?0:2147483647)))"]], "expected": [[[2147483647]], [[0]], [[-1]], [[1, 0]], [[0, 1]], [[2147483647, -1]], [[-1, 2147483647]], [[2, 1, 0]], [[0, 1, 2]], [[2147483647, -1, 0]], [[1], [0]], [[0], [1]], [[2147483647], [-1], [0]], [[2, 1], [1, 0]], [[0, 1], [1, 2]], [[-1, 2], [0, 1]], [[2, -1], [1, 0]], [[0, -1], [-1, 2147483647]], [[0, 0], [0, 0]], [[2147483647, 2147483647], [2147483647, 2147483647]], [[1, 0, 1], [2, 1, 2]], [[1, 2, 1], [0, -1, 0]], [[0, -1, 6], [1, -1, 5], [2, 3, 4]], [[6, -1, 0], [5, -1, 1], [4, 3, 2]], [[2, 3, 2], [1, -1, 1], [0, 1, 0]], [[0, 1, 0], [1, 2, 1], [0, 1, 0]], [[-1, -1, -1], [-1, 2147483647, -1], [-1, -1, 0]], [[1, -1, 1], [0, -1, 0], [1, -1, 1]], [[0, 1, 2, 3]], [[3, 2, 1, 0]], [[0, -1, 2, 1, 0]], [[3], [2], [1], [0]], [[0], [1], [-1], [1], [0]], [[2147483647, 2147483647, -1, 0], [2147483647, -1, 2, 1]], [[0, 1, -1, 5], [-1, 2, 3, 4]], [[3, -1, 0, 1], [2, 2, 1, -1], [1, -1, 2, -1], [0, -1, 3, 4]], [[0, 1, 2, 3], [1, -1, -1, 4], [2, 3, 4, 5]], [[3, 2, 1, 0], [-1, -1, 2, -1], [0, 1, 2, 3]], [[7, -1, 1, 0], [6, -1, 2, -1], [5, 4, 3, 4]], [[0, -1, 3, 4], [1, -1, 2, -1], [2, 2, 1, 0]], [[2, 1, 0, 1, 2], [3, -1, -1, -1, 3], [4, 5, 6, 5, 4]], [[0, 1, 2, -1, 2], [1, -1, 3, -1, 1], [2, -1, 2, 1, 0]], [[6, -1, 0, -1, 6], [5, -1, 1, -1, 5], [4, 3, 2, 3, 4]], [[2, 1, 2], [1, 0, 1], [2, 1, 2], [3, -1, 3]], [[0, -1, 8], [1, -1, 7], [2, -1, 6], [3, 4, 5]], [[2, 3, 3, 2], [1, -1, -1, 1], [0, 1, 1, 0], [1, -1, 2, 1]], [[2, -1, 4, -1, 0], [1, -1, 3, 2, 1], [0, 1, 2, -1, 2]], [[0, 1, -1, 1, 0], [1, 2, -1, 2, 1], [-1, 3, 4, 3, -1]], [[8, 9, 10, 9, 8], [7, -1, -1, -1, 7], [6, -1, 0, -1, 6], [5, -1, 1, -1, 5], [4, 3, 2, 3, 4]], [[0, -1, 5, 4, 3], [1, -1, 6, -1, 2], [2, -1, 6, -1, 1], [3, 4, 5, -1, 0]], [[1, 0, 1, 2], [2, -1, 2, -1], [1, 2, 3, 4], [0, -1, 4, 5]], [[2, -1, 1, 0, 1, 2], [1, -1, 2, -1, -1, 3], [0, 1, 2, 3, 4, 4]], [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261], [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262], [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263], [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265], [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266], [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267], [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270], [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271], [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272], [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273], [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274], [26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275], [27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276], [28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277], [29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278], [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280], [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281], [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282], [34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283], [35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284], [36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285], [37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286], [38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287], [39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288]]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "444", "slug": "water-and-jug-problem", "id": 444, "title": "Water and Jug Problem", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/water-and-jug-problem/", "examples": [{"input": "x = 3, y = 5, target = 4", "output": "true", "explanation": "A fill-pour-empty cycle can isolate exactly 4 litres."}, {"input": "x = 2, y = 6, target = 5", "output": "false", "explanation": "Every reachable total is even, so 5 can never appear."}, {"input": "x = 1, y = 2, target = 3", "output": "true", "explanation": "Fill both jugs."}], "hints": ["Model reachable totals with the greatest common divisor of x and y.", "The target must not exceed x + y, and zero is always reachable.", "Otherwise the target works exactly when it is a multiple of gcd(x, y)."], "statement": "You hold two jugs holding exactly `x` and `y` litres, plus an unlimited water\nsupply. In any step you may fill a jug completely, empty a jug completely, or\npour from one jug into the other until either the source is empty or the\ndestination is full.\n\nDecide whether these moves can leave exactly `target` litres combined across\nboth jugs.\n\nA useful insight: every reachable total is a multiple of the greatest common\ndivisor of the two capacities, and any such multiple up to `x + y` is\nreachable. A target of zero is always reachable (both jugs empty).\n\n**Constraints:**\n- `0 <= x, y, target <= 10^3`\n", "solution": "## Approach\n\nPouring preserves multiples of `gcd(x, y)`: every reachable combined total is\nsuch a multiple, and every multiple between 0 and `x + y` is reachable. The\nanswer is therefore true exactly when the target fits in both jugs and passes\nthe divisibility test, with zero always reachable.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log(min(x, y))) for the GCD.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nimport math\n\nclass Solution:\n def canMeasureWater(self, x: int, y: int, target: int) -> bool:\n if target < 0:\n return False\n if target == 0:\n return True\n if x + y < target:\n return False\n if x == 0:\n return y == target\n if y == 0:\n return x == target\n return target % math.gcd(x, y) == 0\n```\n", "starter": {"go": "package main\n\nfunc CanMeasureWater(x int, y int, target int) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def canMeasureWater(self, x: int, y: int, target: int) -> bool:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool canMeasureWater(int x, int y, int target) {\n return false;\n }\n};"}, "fn": "canMeasureWater", "params": [{"name": "x", "type": "int"}, {"name": "y", "type": "int"}, {"name": "target", "type": "int"}], "outputType": "boolean", "tests": [["3", "5", "4"], ["2", "6", "5"], ["1", "2", "3"], ["0", "0", "0"], ["0", "5", "5"], ["0", "5", "3"], ["5", "0", "5"], ["5", "0", "4"], ["1", "1", "1"], ["1", "1", "2"], ["1", "1", "0"], ["4", "6", "8"], ["4", "6", "7"], ["3", "6", "9"], ["3", "6", "10"], ["6", "9", "3"], ["6", "9", "12"], ["6", "9", "15"], ["6", "9", "16"], ["11", "13", "1"], ["11", "13", "24"], ["11", "13", "25"], ["7", "7", "7"], ["7", "7", "14"], ["7", "7", "15"], ["1000", "1000", "1000"], ["1000", "999", "1"], ["34", "68", "34"]], "expected": [true, false, true, true, true, false, true, false, true, true, true, true, false, true, false, true, true, true, false, true, true, false, true, true, false, true, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "411", "slug": "wiggle-sort-ii", "id": 411, "title": "Wiggle Sort II", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/wiggle-sort-ii/", "examples": [{"explanation": "1 < 6 > 1 < 5 > 1 < 4 holds; other valid orders such as [1,4,1,5,1,6] are also accepted.", "input": "nums = [1,5,1,1,6,4]", "output": "[1,6,1,5,1,4]"}, {"explanation": "2 < 3 > 1 < 3 > 1 < 2 is a valid strict wiggle.", "input": "nums = [1,3,2,2,3,1]", "output": "[2,3,1,3,1,2]"}, {"explanation": "With one peak in the middle, 1 < 2 > 1 works.", "input": "nums = [1,1,2]", "output": "[1,2,1]"}], "hints": ["Adaptation: the original asks for in-place void; here return the reordered array.", "Sort a copy, split it into a smaller half and a larger half, reverse both, then interleave small, large, small, large.", "Any permutation with the strict wiggle property and the same multiset is accepted."], "statement": "You are given an integer array `nums` and must reorder it so that strict ups and downs alternate: `nums[0] < nums[1] > nums[2] < nums[3] ...`. Every input given here admits at least one such ordering. Return any reordered array meeting the condition (it must reuse exactly the same elements).\n\n*Adaptation note:* the original statement rearranges the array in place without returning anything; here you return the reordered array instead, holding the same values.\n\n**Constraints:**\n- `1 <= nums.length <= 5 * 10^4`\n- `0 <= nums[i] <= 5000`\n- A valid answer always exists for the given input.\n", "solution": "## Approach\n\nSort a copy of the array and cut it into a smaller half and a larger half. Reverse both halves and interleave them (small, large, small, large, ...). Reversing keeps equal values apart so that every even position is strictly below its right neighbor and every odd position strictly above, whenever a valid ordering exists.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log n), where n is the length of `nums`, dominated by sorting.\n- **Space Complexity:** O(n) for the sorted copy and the result.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def wiggleSort(self, nums: List[int]) -> List[int]:\n s = sorted(nums)\n n = len(nums)\n mid = (n + 1) // 2\n left = s[:mid][::-1]\n right = s[mid:][::-1]\n res = []\n for i in range(len(right)):\n res.append(left[i])\n res.append(right[i])\n if len(left) > len(right):\n res.append(left[-1])\n return res\n```\n", "starter": {"go": "package main\n\nfunc WiggleSort(nums []int) []int {\n \n}", "python": "from typing import List\nclass Solution:\n def wiggleSort(self, nums: List[int]) -> List[int]:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<int> wiggleSort(vector<int>& nums) {\n return {};\n }\n};"}, "fn": "wiggleSort", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int_array", "tests": [["[1,5,1,1,6,4]"], ["[1,3,2,2,3,1]"], ["[1,1,2]"], ["[1]"], ["[1,2]"], ["[2,1]"], ["[1,2,3,4,5]"], ["[5,4,3,2,1]"], ["[1,1,2,2,3,3]"], ["[1,1,1,2,2,3]"], ["[4,5,5,6]"], ["[3,5,2,1,6,4]"], ["[6,6,5,6,3,8]"], ["[1,2,1]"], ["[2,3,2]"], ["[1,2,2,3,3]"], ["[2,1,3]"], ["[3,2,1]"], ["[1,3,2]"], ["[2,3,1]"], ["[1,1,2,3,4]"], ["[5,3,1,2,4,6]"], ["[1,2,1,2,1,2,3]"], ["[4,1,3,2,5]"], ["[1,4,2,5,3]"], ["[7,9,4,3,2,8,6]"], ["[1,2,3,4,4,5]"], ["[3,1,2,2,1,3]"], ["[2,4,1,5,3,6,7]"], ["[5,1,4,2,3,6]"], ["[1,1,2,2,2,3]"], ["[5,5,4,4,3]"]], "expected": [[1, 6, 1, 5, 1, 4], [2, 3, 1, 3, 1, 2], [1, 2, 1], [1], [1, 2], [1, 2], [3, 5, 2, 4, 1], [3, 5, 2, 4, 1], [2, 3, 1, 3, 1, 2], [1, 3, 1, 2, 1, 2], [5, 6, 4, 5], [3, 6, 2, 5, 1, 4], [6, 8, 5, 6, 3, 6], [1, 2, 1], [2, 3, 2], [2, 3, 2, 3, 1], [2, 3, 1], [2, 3, 1], [2, 3, 1], [2, 3, 1], [2, 4, 1, 3, 1], [3, 6, 2, 5, 1, 4], [2, 3, 1, 2, 1, 2, 1], [3, 5, 2, 4, 1], [3, 5, 2, 4, 1], [6, 9, 4, 8, 3, 7, 2], [3, 5, 2, 4, 1, 4], [2, 3, 1, 3, 1, 2], [4, 7, 3, 6, 2, 5, 1], [3, 6, 2, 5, 1, 4], [2, 3, 1, 2, 1, 2], [4, 5, 4, 5, 3]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "378", "slug": "wiggle-sort", "id": 378, "title": "Wiggle Sort", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/wiggle-sort/", "examples": [{"input": "nums = [3,5,2,1,6,4]", "output": "[3,5,1,6,2,4]", "explanation": "One valid wiggle is [3,5,1,6,2,4] with 3<=5>=1<=6>=2<=4."}, {"input": "nums = [6,6,5,6,3,8]", "output": "[6,6,3,6,5,8]", "explanation": "[6,6,3,6,5,8] satisfies the wiggle inequalities."}, {"input": "nums = [1]", "output": "[1]", "explanation": "A single element already wiggles."}], "hints": ["Adaptation: the original asks for in-place void; here return the reordered array.", "Scan once: for even i require nums[i] <= nums[i+1], for odd i require nums[i] >= nums[i+1]; swap when violated.", "Any permutation with the wiggle property is accepted."], "statement": "Reorder the array into wiggle order: `nums[0] <= nums[1] >= nums[2] <= nums[3] ...`.\n\n**Adaptation:** the original requires an in-place void update; here implement\n`wiggleSort(nums)` returning a reordered copy. Any ordering with the wiggle\nproperty and the same multiset of values is accepted.\n\n**Constraints:**\n- `1 <= nums.length <= 10^4`\n- `0 <= nums[i] <= 10^4`\n", "solution": "## Approach\n\nWalk the array once and fix each adjacent pair locally: swap positions i and i+1 whenever an even index violates <= or an odd index violates >=. One pass suffices because each swap only affects the current pair's relation.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n)\n- **Space Complexity:** O(1) extra besides the returned copy.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def wiggleSort(self, nums: List[int]) -> List[int]:\n a = list(nums)\n for i in range(len(a) - 1):\n if (i % 2 == 0 and a[i] > a[i + 1]) or (i % 2 == 1 and a[i] < a[i + 1]):\n a[i], a[i + 1] = a[i + 1], a[i]\n return a\n```\n", "starter": {"go": "package main\n\nfunc WiggleSort(nums []int) []int {\n \n}", "python": "from typing import List\nclass Solution:\n def wiggleSort(self, nums: List[int]) -> List[int]:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<int> wiggleSort(vector<int>& nums) {\n return {};\n }\n};"}, "fn": "wiggleSort", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int_array", "tests": [["[3,5,2,1,6,4]"], ["[6,6,5,6,3,8]"], ["[1]"], ["[1,2]"], ["[2,1]"], ["[3,3,3]"], ["[1,2,3,4,5]"], ["[5,4,3,2,1]"], ["[1,3,2,2,3,1]"], ["[0,0,0,0]"], ["[4,5,5,6]"], ["[9,6,8,3,7]"], ["[1,1,2]"], ["[2,2,1]"], ["[1,0]"], ["[3,1,2]"], ["[7,7,7,8,7]"], ["[10,9,8,7,6,5,4]"], ["[1,2,2,3]"], ["[5,3,1,2,3]"], ["[2,1,3]"], ["[4,4,4,4]"], ["[1,2,3]"], ["[3,2,1]"], ["[0]"], ["[0,1]"], ["[5,5,4,4,3,3]"], ["[8,7,6,5,4,3,2,1]"], ["[1,3,2,4,3,5]"], ["[9,1,9,1,9]"]], "expected": [[3, 5, 1, 6, 2, 4], [6, 6, 5, 6, 3, 8], [1], [1, 2], [1, 2], [3, 3, 3], [1, 3, 2, 5, 4], [4, 5, 2, 3, 1], [1, 3, 2, 3, 1, 2], [0, 0, 0, 0], [4, 5, 5, 6], [6, 9, 3, 8, 7], [1, 2, 1], [2, 2, 1], [0, 1], [1, 3, 2], [7, 7, 7, 8, 7], [9, 10, 7, 8, 5, 6, 4], [1, 2, 2, 3], [3, 5, 1, 3, 2], [1, 3, 2], [4, 4, 4, 4], [1, 3, 2], [2, 3, 1], [0], [0, 1], [5, 5, 4, 4, 3, 3], [7, 8, 5, 6, 3, 4, 1, 2], [1, 3, 2, 4, 3, 5], [1, 9, 1, 9, 9]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "453", "slug": "wiggle-subsequence", "id": 453, "title": "Wiggle Subsequence", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/wiggle-subsequence/", "examples": [{"input": "nums = [1,7,4,9,2,5]", "output": "6", "explanation": "All five steps alternate."}, {"input": "nums = [1,17,5,10,13,15,10,5,16,8]", "output": "7", "explanation": "A seven-entry subsequence alternates."}, {"input": "nums = [1,2,3,4,5,6,7,8,9]", "output": "2", "explanation": "Monotone climbs allow only length 2."}], "hints": ["Track the lengths of the best subsequences ending with an upward step and with a downward step.", "A rise extends the best downward run; a fall extends the best upward run.", "Equal neighbors extend nothing and are skipped."], "statement": "Measure the longest subsequence whose steps zigzag up and down.\n\nA wiggle run requires neighboring differences to strictly alternate in sign: positive, negative, positive, and so on. The opening step may point either way. A single value always qualifies with length 1, and any two different values qualify with length 2, while equal neighbors can never sit next to each other in the subsequence. From `nums`, keep a subsequence (deleting entries freely but preserving order) that wiggles and is as long as possible, then return its length.\n\n**Constraints:**\n- `1 <= nums.length <= 1000`\n- `0 <= nums[i] <= 1000`\n", "solution": "## Approach\n\nKeep two counters: the best wiggle ending with a rise and the best ending with a fall. A higher neighbor extends the falling best by one, a lower neighbor extends the rising best by one, and equal neighbors change nothing. The answer is the larger counter.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), a single scan of `nums`.\n- **Space Complexity:** O(1) extra.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def wiggleMaxLength(self, nums: List[int]) -> int:\n if len(nums) < 2:\n return len(nums)\n up = down = 1\n for i in range(1, len(nums)):\n if nums[i] > nums[i - 1]:\n up = down + 1\n elif nums[i] < nums[i - 1]:\n down = up + 1\n return max(up, down)\n```\n", "starter": {"go": "package main\n\nfunc WiggleMaxLength(nums []int) int {\n return 0\n}", "python": "from typing import List\n\nclass Solution:\n def wiggleMaxLength(self, nums: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int wiggleMaxLength(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "wiggleMaxLength", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[1,7,4,9,2,5]"], ["[1,17,5,10,13,15,10,5,16,8]"], ["[1,2,3,4,5,6,7,8,9]"], ["[1]"], ["[1,1]"], ["[1,2]"], ["[2,1]"], ["[1,1,1]"], ["[3,3,3,2,5]"], ["[1,7,4,5,5]"], ["[9,8,7,6,5]"], ["[1,3,2,4,3,5,4]"], ["[0,0,1,0]"], ["[1,2,2,3,4]"], ["[5,5,5,5,6]"], ["[1,2,1,2,1,2]"], ["[2,2,2,2,2,1]"], ["[1,100,1,100,1]"], ["[33,53,12,64,50,41,45,21,97,35,47,92,39,0,93,55,40,46,69,42,51,49,30,4,43,41,48,19,57,83,20,79,73,23,27,71,64,10,74,17]"], ["[0]"], ["[1000,0,1000,0,1000]"], ["[1,2,3,2,1,2,3,2,1]"], ["[5,1,5,1,5,1,5]"], ["[1,2,3,4,3,2,1]"], ["[8,8,9,9,8,8,9]"], ["[1,0,1,0,1,0,1]"], ["[10,9,8,7,8,9,10]"], ["[4,4,4,4]"], ["[1,2,3,4,5,4,3,2,1,2,3]"], ["[22,11,22,11,22]"]], "expected": [6, 7, 2, 1, 1, 2, 2, 1, 3, 4, 2, 7, 3, 2, 2, 6, 2, 5, 29, 1, 5, 5, 7, 3, 4, 7, 3, 1, 4, 5], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "265", "slug": "wildcard-matching", "id": 265, "title": "Wildcard Matching", "difficulty": "Hard", "category": "string", "link": "https://leetcode.com/problems/wildcard-matching/", "examples": [{"input": "s = \"aa\", p = \"a\"", "output": "false", "explanation": "One literal \"a\" cannot cover the two-character text."}, {"input": "s = \"aa\", p = \"*\"", "output": "true", "explanation": "A single star absorbs any text, including all of \"aa\"."}, {"input": "s = \"cb\", p = \"?a\"", "output": "false", "explanation": "\"?\" matches \"c\", but then \"a\" disagrees with \"b\"."}], "hints": ["Walk both strings with two pointers; when a '*' is seen, remember it and the text position so a later mismatch can stretch the star by one more character.", "Only the most recent star needs remembering, because an earlier star can always absorb whatever the later one gives up."], "statement": "You are given a text `s` and a pattern `p` that may contain two special symbols: `'?'`, which stands for exactly one arbitrary character, and `'*'`, which stands for any (possibly empty) run of characters.\n\nDecide whether the *entire* text matches the *entire* pattern under these rules \u2014 a partial overlap is not enough.\n\n**Constraints:**\n- `0 <= s.length, p.length <= 2000`\n- `s` holds only lowercase English letters.\n- `p` holds only lowercase English letters, `'?'`, and `'*'`.\n", "solution": "## Approach\n\nScan the text and pattern together with two pointers. Matching characters (or `?`) advance both; a `*` is recorded along with the current text position while the pattern moves on. On a mismatch, fall back to the last star and let it swallow one more character. Trailing stars are skipped at the end, and success means the whole pattern was consumed.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n * m) worst case, where n and m are the text and pattern lengths; typically near-linear.\n- **Space Complexity:** O(1) extra space.\n\n## Implementation\n\n```python\nclass Solution:\n def isMatch(self, s: str, p: str) -> bool:\n i = j = 0\n star, mark = -1, 0\n while i < len(s):\n if j < len(p) and (p[j] == '?' or p[j] == s[i]):\n i += 1\n j += 1\n elif j < len(p) and p[j] == '*':\n star = j\n mark = i\n j += 1\n elif star != -1:\n j = star + 1\n mark += 1\n i = mark\n else:\n return False\n while j < len(p) and p[j] == '*':\n j += 1\n return j == len(p)\n```\n", "starter": {"go": "package main\n\nfunc IsMatch(s string, p string) bool {\n \n}", "python": "class Solution:\n def isMatch(self, s: str, p: str) -> bool:\n pass", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool isMatch(string s, string p) {\n return false;\n }\n};"}, "fn": "isMatch", "params": [{"name": "s", "type": "string"}, {"name": "p", "type": "string"}], "outputType": "boolean", "tests": [["aa", "a"], ["aa", "*"], ["cb", "?a"], ["adceb", "*a*b"], ["acdcb", "a*c?b"], ["ab", "?*"], ["aab", "c*a*b"], ["abc", "abc"], ["abc", "a?c"], ["abc", "a*d"], ["", ""], ["a", ""], ["", "a"], ["", "*"], ["", "?"], ["ho", "ho**"], ["ho", "**ho"], ["abcdef", "a*f"], ["abcdef", "a*e"], ["aaaa", "***a"], ["aaabbbaab", "a*******b"], ["abefcdgiescdfimde", "ab*cd*ef*"], ["abcabczzzde", "*abc???def*"], ["mississippi", "m??*ss*?i*pi"], ["abcccd", "*ccd"], ["abcccd", "*c?d"], ["abcd", "****"], ["abcd", "a***d"], ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*"], ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "a*b*a*b"]], "expected": [false, true, false, true, false, true, false, true, true, false, true, false, false, true, false, true, true, true, false, true, true, false, false, false, true, true, true, true, true, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "586", "slug": "word-abbreviation", "id": 586, "title": "Word Abbreviation", "difficulty": "Hard", "category": "string", "link": "https://leetcode.com/problems/word-abbreviation/", "examples": [{"input": "words = [\"like\",\"god\",\"internal\",\"me\",\"internet\",\"interval\",\"intension\",\"face\",\"intrusion\"]", "output": "[\"l2e\",\"god\",\"internal\",\"me\",\"i6t\",\"interval\",\"inte4n\",\"f2e\",\"intr4n\"]", "explanation": "\"internal\" and \"interval\" collide until the full word is needed; \"intension\" and \"intrusion\" separate with longer prefixes."}, {"input": "words = [\"abcdef\",\"abcdeg\"]", "output": "[\"a4f\",\"a4g\"]", "explanation": "One-letter prefixes already separate the two words."}, {"input": "words = [\"word\",\"world\",\"would\"]", "output": "[\"w2d\",\"world\",\"would\"]", "explanation": "Further prefixes would not shorten \"world\"/\"would\", so both keep full forms that are already unique."}], "hints": ["Start every word with a one-letter prefix abbreviation, keeping the original when it is not shorter.", "Group words by their current abbreviation; any group with more than one member needs longer prefixes.", "Repeat the growth step until every group holds exactly one word."], "statement": "You are given a list of distinct lowercase words. For each word, build its *abbreviation* as follows: keep a prefix of the word, then write the count of skipped middle characters, then keep the last character. For example, with a one-letter prefix, `word` becomes `w2d` (keep `w`, skip 2 letters, keep `d`).\n\nTwo rules apply:\n- If the abbreviation is not strictly shorter than the original word, keep the original word instead.\n- Abbreviations in the final answer must be pairwise unique, so no two words may share one. Resolve clashes with the *shared-prefix growth rule*: while any abbreviation is used by more than one word, extend the kept prefix by one character for every word in each clashing group and rebuild those abbreviations (keeping the original whenever it is not shorter).\n\nReturn the abbreviations in the same order as the input words.\n\n**Constraints:**\n- `1 <= words.length <= 400`\n- `1 <= words[i].length <= 400`\n- All words are distinct and contain only lowercase English letters.\n", "solution": "## Approach\n\nGive every word a one-letter-prefix abbreviation, falling back to the full word whenever shortening saves nothing. Then repeatedly collect words by their current abbreviation: in any group of two or more, lengthen each member's prefix by one letter and rebuild. Because prefixes only grow and full words are always distinct, the process must settle with all unique results.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n * L^2) in the worst case, where n is the word count and L the maximum length, since each word's prefix can grow up to its full length.\n- **Space Complexity:** O(n * L) for the answers and grouping map.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def wordsAbbreviation(self, words: List[str]) -> List[str]:\n def abbr(w, pref):\n if pref + 2 >= len(w):\n return w\n return w[:pref] + str(len(w) - pref - 1) + w[-1]\n n = len(words)\n pref = [1] * n\n ans = [abbr(w, 1) for w in words]\n while True:\n groups = {}\n for i, a in enumerate(ans):\n groups.setdefault(a, []).append(i)\n dup = [g for g in groups.values() if len(g) > 1]\n if not dup:\n break\n for g in dup:\n for i in g:\n pref[i] += 1\n ans[i] = abbr(words[i], pref[i])\n return ans\n```\n", "starter": {"go": "package main\n\nfunc WordsAbbreviation(words []string) []string {\n return []string{}\n}", "python": "from typing import List\nclass Solution:\n def wordsAbbreviation(self, words: List[str]) -> List[str]:\n return []\n", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<string> wordsAbbreviation(vector<string>& words) {\n return {};\n }\n};"}, "fn": "wordsAbbreviation", "params": [{"name": "words", "type": "string_array"}], "outputType": "string_list", "tests": [["[\"like\",\"god\",\"internal\",\"me\",\"internet\",\"interval\",\"intension\",\"face\",\"intrusion\"]"], ["[\"abcdef\",\"abcdeg\"]"], ["[\"word\",\"world\",\"would\"]"], ["[\"a\"]"], ["[\"ab\",\"ac\"]"], ["[\"abc\",\"abd\",\"abe\"]"], ["[\"hello\"]"], ["[\"apple\",\"apply\",\"aptly\"]"], ["[\"test\",\"tent\",\"text\"]"], ["[\"abcdefg\",\"abcdeff\",\"abcdeef\"]"], ["[\"aa\",\"aaa\",\"aaaa\"]"], ["[\"x\",\"xy\",\"xyz\"]"], ["[\"same\",\"samey\",\"samer\"]"], ["[\"abcdef\",\"abcxef\",\"abcyef\"]"], ["[\"qwerty\",\"qwertz\",\"qwertt\"]"], ["[\"aaaaab\",\"aaaaac\",\"aaaaad\"]"], ["[\"ab\",\"abc\",\"abcd\",\"abcde\"]"], ["[\"zz\",\"zzz\",\"zzzz\",\"zzzzz\"]"], ["[\"cat\",\"car\",\"cart\",\"care\"]"], ["[\"dog\",\"dot\",\"dote\",\"dodge\"]"], ["[\"internationalization\",\"localization\"]"], ["[\"accessibility\",\"accessibilities\"]"], ["[\"kite\",\"kit\",\"kits\",\"kiteboarding\"]"], ["[\"book\",\"books\",\"booking\",\"booked\"]"], ["[\"aaaa\",\"aaab\",\"aaba\",\"abaa\"]"], ["[\"m\",\"mm\",\"mmm\",\"mmmm\",\"mmmmm\"]"], ["[\"abcd\",\"abce\",\"abde\",\"acde\"]"], ["[\"abcdefghi\",\"abcdefgjk\",\"abcdefgkl\"]"]], "expected": [["l2e", "god", "internal", "me", "i6t", "interval", "inte4n", "f2e", "intr4n"], ["a4f", "a4g"], ["w2d", "world", "would"], ["a"], ["ab", "ac"], ["abc", "abd", "abe"], ["h3o"], ["a3e", "apply", "aptly"], ["test", "tent", "text"], ["a5g", "abcdeff", "abcdeef"], ["aa", "aaa", "a2a"], ["x", "xy", "xyz"], ["s2e", "s3y", "s3r"], ["abcdef", "abcxef", "abcyef"], ["q4y", "q4z", "q4t"], ["a4b", "a4c", "a4d"], ["ab", "abc", "a2d", "a3e"], ["zz", "zzz", "z2z", "z3z"], ["cat", "car", "c2t", "c2e"], ["dog", "dot", "d2e", "d3e"], ["i18n", "l10n"], ["a11y", "a13s"], ["k2e", "kit", "k2s", "k10g"], ["b2k", "b3s", "b5g", "b4d"], ["aaaa", "a2b", "aaba", "abaa"], ["m", "mm", "mmm", "m2m", "m3m"], ["a2d", "abce", "abde", "acde"], ["a7i", "a7k", "a7l"]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "213", "slug": "word-break-ii", "id": 213, "title": "Word Break II", "difficulty": "Hard", "category": "dp", "link": "https://leetcode.com/problems/word-break-ii/", "examples": [{"input": "s = \"catsanddog\", wordDict = [\"cat\",\"cats\",\"and\",\"sand\",\"dog\"]", "output": "[\"cats and dog\",\"cat sand dog\"]", "explanation": "Add spaces in \"catsanddog\" so that each word is a valid dictionary word."}, {"input": "s = \"pineapplepenapple\", wordDict = [\"apple\",\"pen\",\"applepen\",\"pine\",\"pineapple\"]", "output": "[\"pine apple pen apple\",\"pineapple pen apple\",\"pine applepen apple\"]", "explanation": "Note that you are allowed to reuse a dictionary word."}, {"input": "s = \"catsandog\", wordDict = [\"cats\",\"dog\",\"sand\",\"and\",\"cat\"]", "output": "[]", "explanation": "The string cannot be segmented into dictionary words, so the result is empty."}], "hints": ["Think of the string positions as cut points: every valid sentence is a sequence of dictionary words that tile `s` from position 0 to the end.", "Use recursion with memoization keyed by the start position to avoid re-computing all suffix segmentations.", "Build each sentence by concatenating a matched word with the space-separated segmentations of the remaining suffix."], "statement": "You are given a string `s` plus a list of strings `wordDict`. Place blanks into `s` so that it becomes a blank-separated sentence in which every token shows up in `wordDict`, and gather every distinct sentence obtainable this way. Return the whole collection in any sequence.\n\nA single dictionary entry may be drawn on repeatedly inside one sentence.\n\n**Constraints:**\n\n- `1 <= s.length <= 20`\n- `1 <= wordDict.length <= 1000`\n- `1 <= wordDict[i].length <= 10`\n- `s` and `wordDict[i]` consist of only lowercase English letters.\n- All the strings of `wordDict` are **unique**.\n- Input is generated in a way that the length of the answer doesn't exceed 10^5.\n", "solution": "## Approach\n\nRecursion with memoization over start positions. At each position `start`, every dictionary word that matches the substring beginning at `start` is a candidate; for each match we append the word to every sentence produced by segmenting the remaining suffix starting at `start + len(word)`. Because the suffix work depends only on the start index, memoizing by position avoids recomputing the same suffix multiple times. The empty sentence at the end of the string serves as the base case.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n * L * R) where n is `s.length`, L is the maximum length of a dictionary word (checked at each position), and R is the number of results produced for a suffix. Since results are memoized per position, each position contributes its combinations only once.\n- **Space Complexity:** O(n * R) for the memoized lists plus the recursion stack depth of O(n).\n\n## Implementation\n\n```python\nfrom typing import List\n\n\nclass Solution:\n def wordBreak(self, s: str, wordDict: List[str]) -> List[str]:\n words = set(wordDict)\n n = len(s)\n memo: dict[int, List[str]] = {}\n\n def break_at(start: int) -> List[str]:\n if start == n:\n return [\"\"]\n if start in memo:\n return memo[start]\n result: List[str] = []\n for word in words:\n if s.startswith(word, start):\n for tail in break_at(start + len(word)):\n result.append(word if not tail else word + \" \" + tail)\n memo[start] = result\n return result\n\n return break_at(0)\n```", "starter": {"go": "package main\n\nfunc WordBreak(s string, wordDict []string) []string {\n \n}", "python": "from typing import List\nclass Solution:\n def wordBreak(self, s: str, wordDict: List[str]) -> List[str]:\n ", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<string> wordBreak(string s, vector<string>& wordDict) {\n \n }\n};"}, "fn": "wordBreak", "params": [{"name": "s", "type": "string"}, {"name": "wordDict", "type": "string_array"}], "outputType": "string_list", "tests": [["a", "[\"a\"]"], ["a", "[\"b\"]"], ["ab", "[\"a\",\"b\",\"ab\"]"], ["catsanddog", "[\"cat\",\"cats\",\"and\",\"sand\",\"dog\"]"], ["catsandog", "[\"cats\",\"dog\",\"sand\",\"and\",\"cat\"]"], ["pineapplepenapple", "[\"apple\",\"pen\",\"applepen\",\"pine\",\"pineapple\"]"], ["aaaa", "[\"a\",\"aa\",\"aaa\"]"], ["aaaaaaa", "[\"aaaa\",\"aa\",\"a\"]"], ["leetcode", "[\"leet\",\"code\",\"lee\",\"tcode\"]"], ["aaaa", "[\"aaaaa\"]"], ["aaaaaaaaaa", "[\"a\",\"aa\"]"], ["abcdef", "[\"abc\",\"def\",\"abcdef\",\"bc\",\"a\",\"d\",\"ef\"]"], ["b", "['a']"], ["ab", "['ab']"], ["aa", "['a']"], ["aaa", "['a', 'aa']"], ["abc", "['a', 'b', 'c']"], ["abcd", "['ab', 'cd']"], ["dogcat", "['dog', 'cat']"], ["catdogcat", "['cat', 'dog']"], ["aaaaa", "['a', 'aa']"], ["abab", "['a', 'b', 'ab']"], ["xyz", "['xy', 'z']"], ["helloworld", "['hello', 'world']"], ["aaaaaaaa", "['a', 'aa', 'aaa']"], ["abcde", "['ab', 'cde']"], ["qq", "['q']"], ["pqr", "['p', 'qr']"], ["aab", "['a', 'ab']"], ["bac", "['b', 'a', 'c']"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "20", "slug": "word-break", "id": 20, "title": "Word Break", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/word-break/", "examples": [{"input": "s=\"leetcode\", wordDict=[\"leet\",\"code\"]", "output": "true", "explanation": "\"leetcode\" can be segmented into \"leet\" and \"code\", both in the dictionary."}, {"input": "s=\"applepenapple\", wordDict=[\"apple\",\"pen\"]", "output": "true", "explanation": "\"applepenapple\" can be segmented into \"apple\", \"pen\", and \"apple\", all in the dictionary."}], "hints": ["DP over prefixes: dp[i]=true if there exists j<i such that dp[j] and s[j..i) in dict. Optimize by max word length."], "statement": "You receive a string `s` together with a list of strings `wordDict`. Decide whether `s` can be tiled end to end by a chain of one or more pieces such that every piece appears in `wordDict`. Entries from the list may be drawn on any number of times. Return `true` when at least one such tiling exists, and `false` otherwise.\n\n**Constraints:**\n\n- 1 \u2264 s.length \u2264 300\n- 1 \u2264 wordDict.length \u2264 1000\n- 1 \u2264 wordDict[i].length \u2264 20\n- s and wordDict[i] consist of only lowercase English letters.\n- All the strings of wordDict are unique.\n", "solution": "## Approach\n\nUse dynamic programming where dp[i] indicates whether the prefix s[:i] can be segmented into dictionary words. For each position, check all substrings ending at i against the word set.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n\u00b2)\n- **Space Complexity:** O(n)\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def wordBreak(self, s: str, wordDict: List[str]) -> bool:\n words = set(wordDict)\n max_len = max(len(w) for w in wordDict) if wordDict else 0\n dp = [False] * (len(s) + 1)\n dp[0] = True\n for i in range(1, len(s) + 1):\n for j in range(max(0, i - max_len), i):\n if dp[j] and s[j:i] in words:\n dp[i] = True\n break\n return dp[len(s)]\n```\n", "starter": {"go": "package main\n\nfunc WordBreak(s string, wordDict []string) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def wordBreak(self, s: str, wordDict: List[str]) -> bool:\n pass\n", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool wordBreak(string s, vector<string>& wordDict) {\n return false;\n }\n};"}, "fn": "wordBreak", "params": [{"name": "s", "type": "string"}, {"name": "wordDict", "type": "string_array"}], "outputType": "boolean", "tests": [["leetcode", "['leet', 'code']"], ["applepenapple", "['apple', 'pen']"], ["catsandog", "['cats', 'dog', 'sand', 'and', 'cat']"], ["@javascript: 'a'.repeat(300)", "['a', 'aa', 'aaa', 'aaaa', 'aaaaa']"], ["a", "['a']"], ["b", "['a']"], ["ab", "['a', 'b']"], ["aa", "['a']"], ["abc", "['ab', 'c']"], ["aaaa", "['a', 'aa']"], ["abcd", "['a', 'b', 'c', 'd']"], ["catsanddog", "['cat', 'cats', 'and', 'sand', 'dog']"], ["cars", "['car', 'ca', 'rs']"], ["helloworld", "['hello', 'world']"], ["helloworldx", "['hello', 'world']"], ["aaaaaaaab", "['a', 'aa', 'aaa']"], ["bb", "['b', 'bb']"], ["abcabc", "['abc']"], ["abbc", "['ab', 'bc']"], ["pineapple", "['pine', 'apple']"], ["pineapplepie", "['pine', 'apple', 'pie']"], ["qqqqq", "['qq', 'qqq']"], ["abcdabcd", "['ab', 'cd']"], ["zzzzzzzzzz", "['z', 'zz', 'zzz']"], ["abcdefghij", "['ab', 'cd', 'ef', 'gh', 'ij']"], ["abcdefghijk", "['ab', 'cd', 'ef', 'gh', 'ij']"], ["aaaaaaaaaaaaaaaaaaaa", "['a', 'aa', 'aaa', 'aaaa']"], ["aaaaaaaaaaaaaaaaaaaab", "['a', 'aa', 'aaa', 'aaaa']"], ["dogcatdog", "['dog', 'cat']"], ["onetwothree", "['one', 'two', 'three']"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "299", "slug": "word-ladder-ii", "id": 299, "title": "Word Ladder II", "difficulty": "Hard", "category": "graph", "link": "https://leetcode.com/problems/word-ladder-ii/", "examples": [{"input": "beginWord = \"hit\", endWord = \"cog\", wordList = [\"hot\",\"dot\",\"dog\",\"lot\",\"log\",\"cog\"]", "output": "[[\"hit\",\"hot\",\"dot\",\"dog\",\"cog\"],[\"hit\",\"hot\",\"lot\",\"log\",\"cog\"]]", "explanation": "Both ladders use 5 words, which is minimal here."}, {"input": "beginWord = \"hit\", endWord = \"cog\", wordList = [\"hot\",\"dot\",\"dog\",\"lot\",\"log\"]", "output": "[]", "explanation": "Without \"cog\" in the dictionary the target is unreachable."}], "hints": ["BFS from the start records the shortest distance to each reachable word.", "Revisit words level by level so every shortest predecessor is captured.", "DFS backwards from the target through predecessors to enumerate all shortest ladders."], "statement": "A ladder from `beginWord` to `endWord` is a chain where neighboring words differ by exactly one letter, every middle word belongs to `wordList`, and the final word equals `endWord`. The starting word itself does not need to appear in `wordList`.\n\nReturn every shortest possible ladder as a list of words from start to finish. If no ladder exists, return an empty list. The order of the ladders does not matter.\n\n**Constraints:**\n- `1 <= beginWord.length <= 5`\n- `endWord.length == beginWord.length`\n- `1 <= wordList.length <= 500`\n- `wordList[i].length == beginWord.length`\n- All strings use lowercase English letters.\n- `beginWord != endWord`\n- All `wordList` entries are unique.\n\n**Adaptation note:** The original return type is `List<List<String>>`. Here it is `string_list_2d`, with order-insensitive grading: any permutation of the ladder set is accepted.\n", "solution": "## Approach\n\nRun BFS from the start word, recording the shortest distance to every reachable dictionary word and all predecessors that achieve that distance. Words are discovered level by level so that each word's predecessor list contains exactly the neighbors one step closer to the start. Then DFS from the target back through predecessors enumerates every shortest ladder.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(N * L * 26), where N is the dictionary size and L is the word length, plus output size for enumeration.\n- **Space Complexity:** O(N * L) for distances, predecessors, and the queue.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import deque, defaultdict\nclass Solution:\n def findLadders(self, beginWord: str, endWord: str, wordList: List[str]) -> List[List[str]]:\n words = set(wordList)\n if endWord not in words:\n return []\n words.add(beginWord)\n dist = {beginWord: 0}\n pred = defaultdict(list)\n q = deque([beginWord])\n level = 0\n found = False\n while q and not found:\n level += 1\n for _ in range(len(q)):\n word = q.popleft()\n arr = list(word)\n for i in range(len(arr)):\n orig = arr[i]\n for c in \"abcdefghijklmnopqrstuvwxyz\":\n if c == orig:\n continue\n arr[i] = c\n nb = \"\".join(arr)\n if nb not in words:\n continue\n if nb not in dist:\n dist[nb] = level\n pred[nb].append(word)\n q.append(nb)\n if nb == endWord:\n found = True\n elif dist[nb] == level:\n pred[nb].append(word)\n arr[i] = orig\n if endWord not in dist:\n return []\n ans = []\n path = [endWord]\n def dfs(cur):\n if cur == beginWord:\n ans.append(list(reversed(path)))\n return\n for p in pred[cur]:\n path.append(p)\n dfs(p)\n path.pop()\n dfs(endWord)\n return ans\n```\n", "starter": {"go": "package main\n\nfunc FindLadders(beginWord string, endWord string, wordList []string) [][]string {\n return [][]string{}\n}", "python": "from typing import List\nclass Solution:\n def findLadders(self, beginWord: str, endWord: str, wordList: List[str]) -> List[List[str]]:\n return []", "cpp": "#include <string>\n#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<vector<string>> findLadders(string beginWord, string endWord, vector<string>& wordList) {\n return {};\n }\n};"}, "fn": "findLadders", "params": [{"name": "beginWord", "type": "string"}, {"name": "endWord", "type": "string"}, {"name": "wordList", "type": "string_array"}], "outputType": "string_list_2d", "tests": [["hit", "cog", "['hot', 'dot', 'dog', 'lot', 'log', 'cog']"], ["hit", "cog", "['hot', 'dot', 'dog', 'lot', 'log']"], ["a", "c", "['a', 'b', 'c']"], ["hot", "dog", "['hot', 'dog', 'dot']"], ["red", "tax", "['ted', 'tex', 'red', 'tax', 'tad', 'den', 'rex', 'pee']"], ["hit", "cog", "['hot', 'dot', 'dog', 'lot', 'log', 'cog', 'hog', 'hig']"], ["aa", "bb", "['ab', 'ba', 'aa', 'bb']"], ["ab", "ba", "['ab', 'ba', 'aa', 'bb']"], ["a", "b", "['a', 'b']"], ["a", "b", "['c', 'd']"], ["lost", "cost", "['most', 'mist', 'miss', 'lost', 'cost']"], ["cat", "dog", "['cat', 'bat', 'bot', 'bog', 'dog', 'cog', 'cot']"], ["kiss", "tusk", "['miss', 'disk', 'kiss', 'dusk', 'tusk', 'risk', 'musk']"], ["qa", "qb", "['qa', 'qb', 'qc']"], ["hot", "dot", "['hot', 'dot', 'lot', 'hit']"], ["talk", "tail", "['talk', 'tall', 'tail']"], ["cold", "warm", "['cold', 'cord', 'card', 'ward', 'warm', 'corm']"], ["game", "thee", "['game', 'gane', 'tane', 'thane', 'thee', 'gave']"], ["cet", "ism", "['cet', 'cat', 'bat', 'bit', 'bim', 'ism', 'sim']"], ["hit", "hot", "['hot', 'hit', 'hit']"], ["ab", "cd", "['ab', 'ac', 'ad', 'cd', 'bd']"], ["dog", "cat", "['dog', 'dot', 'cot', 'cat']"], ["sand", "acne", "['sand', 'acne']"], ["code", "coke", "['code', 'coke', 'cake', 'coke']"], ["b", "c", "['b', 'c', 'a']"], ["nanny", "aloud", "['nanny', 'aloud', 'nancy']"], ["zz", "aa", "['za', 'az', 'aa', 'zz']"], ["teach", "place", "['teach', 'peach', 'place']"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "121", "slug": "word-ladder", "id": 121, "title": "Word Ladder", "difficulty": "Hard", "category": "graph", "link": "https://leetcode.com/problems/word-ladder/", "examples": [{"input": "beginWord = \"hit\", endWord = \"cog\", wordList = [\"hot\",\"dot\",\"dog\",\"lot\",\"log\",\"cog\"]", "output": "5", "explanation": "One shortest sequence is hit -> hot -> dot -> dog -> cog."}, {"input": "beginWord = \"hit\", endWord = \"cog\", wordList = [\"hot\",\"dot\",\"dog\",\"lot\",\"log\"]", "output": "0", "explanation": "The end word is not in the list."}], "hints": ["Words are graph nodes; two words share an edge when they differ in exactly one position.", "Generate neighbors by replacing each character with every lowercase letter instead of comparing every pair of words.", "Bidirectional BFS from beginWord and endWord can substantially reduce the explored search space."], "statement": "You are given a starting string `beginWord`, a destination string `endWord`, and a pool of strings `wordList`. Consider chains that open with `beginWord` and finish at `endWord`, alter precisely one letter between consecutive links, and draw every link after the first from `wordList`.\n\nAmong all such chains, return how many strings the briefest one holds, counting both the opening and the closing string. When the two ends cannot be connected this way, return `0`.\n\n**Constraints:**\n\n- `1 <= beginWord.length <= 10`\n- `endWord.length == beginWord.length`\n- `1 <= wordList.length <= 5000`\n- Every word contains only lowercase English letters and has the same length as `beginWord`.\n- All words in `wordList` are unique.\n- `beginWord != endWord`\n", "solution": "## Approach\n\nStore unused dictionary words in a set and run bidirectional breadth-first search from `beginWord` and `endWord`. Always expand the smaller frontier, generating neighbors by replacing one character with each lowercase letter. The first generated word in the opposite frontier completes a shortest transformation sequence.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(N * L^2) for a fixed 26-letter alphabet, where N is the number of words and L is their length; constructing each generated Python string costs O(L).\n- **Space Complexity:** O(N * L) for the dictionary and BFS frontiers.\n\n## Implementation\n\n```python\nfrom typing import List\n\n\nclass Solution:\n def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int:\n unused = set(wordList)\n if endWord not in unused:\n return 0\n\n front = {beginWord}\n back = {endWord}\n unused.discard(beginWord)\n unused.discard(endWord)\n length = 1\n\n while front and back:\n if len(front) > len(back):\n front, back = back, front\n\n next_front = set()\n for word in front:\n chars = list(word)\n for i, original in enumerate(chars):\n for code in range(ord(\"a\"), ord(\"z\") + 1):\n replacement = chr(code)\n if replacement == original:\n continue\n chars[i] = replacement\n candidate = \"\".join(chars)\n if candidate in back:\n return length + 1\n if candidate in unused:\n unused.remove(candidate)\n next_front.add(candidate)\n chars[i] = original\n\n front = next_front\n length += 1\n\n return 0\n```\n", "starter": {"go": "package main\n\nfunc LadderLength(beginWord string, endWord string, wordList []string) int {\n return 0\n}\n", "python": "from typing import List\n\nclass Solution:\n def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int:\n return 0\n", "cpp": "#include <string>\n#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int ladderLength(string beginWord, string endWord, vector<string>& wordList) {\n return 0;\n }\n};"}, "fn": "ladderLength", "params": [{"name": "beginWord", "type": "string"}, {"name": "endWord", "type": "string"}, {"name": "wordList", "type": "string_array"}], "outputType": "int", "tests": [["hit", "cog", "[\"hot\",\"dot\",\"dog\",\"lot\",\"log\",\"cog\"]"], ["hit", "cog", "[\"hot\",\"dot\",\"dog\",\"lot\",\"log\"]"], ["a", "c", "[\"a\",\"b\",\"c\"]"], ["a", "z", "[\"z\"]"], ["a", "b", "[\"c\",\"d\"]"], ["aa", "bb", "[\"ab\",\"bb\"]"], ["aa", "bb", "[\"ba\",\"bb\"]"], ["aa", "bb", "[\"ab\",\"ba\",\"bb\"]"], ["aa", "zz", "[\"az\",\"za\",\"aa\"]"], ["ab", "cd", "[\"ad\",\"cd\",\"cb\"]"], ["ab", "cd", "[\"ac\",\"cc\",\"cd\"]"], ["ab", "cd", "[\"cb\",\"cd\",\"ad\",\"bd\"]"], ["az", "za", "[\"aa\",\"za\"]"], ["az", "za", "[\"zz\",\"za\"]"], ["go", "me", "[\"ge\",\"me\",\"mo\"]"], ["cat", "dog", "[\"cot\",\"cog\",\"dog\"]"], ["cat", "dog", "[\"dat\",\"dot\",\"dog\"]"], ["cat", "dog", "[\"cot\",\"dot\",\"dog\",\"cog\"]"], ["cat", "dog", "[\"cot\",\"cog\",\"dig\",\"fig\"]"], ["red", "tax", "[\"ted\",\"tex\",\"red\",\"tax\",\"tad\",\"den\",\"rex\",\"pee\"]"], ["hot", "dog", "[\"hot\",\"dog\",\"dot\"]"], ["hot", "dog", "[\"dog\"]"], ["lost", "cost", "[\"cost\"]"], ["lost", "miss", "[\"most\",\"mist\",\"miss\"]"], ["lost", "miss", "[\"list\",\"mist\",\"miss\"]"], ["lost", "miss", "[\"most\",\"mist\",\"miss\",\"moss\",\"mass\"]"], ["cold", "warm", "[\"cord\",\"card\",\"ward\",\"warm\"]"], ["cold", "warm", "[\"cord\",\"word\",\"worm\",\"warm\"]"], ["cold", "warm", "[\"bold\",\"bald\",\"bard\",\"ward\",\"warm\"]"], ["cold", "warm", "[\"cord\",\"card\",\"ward\",\"warn\"]"], ["same", "diff", "[\"dame\",\"dime\",\"dire\",\"dirt\",\"dirf\",\"diff\"]"], ["same", "diff", "[\"some\",\"dome\",\"dime\",\"dire\",\"diff\"]"], ["same", "diff", "[\"sime\",\"dime\",\"dife\",\"diff\"]"], ["same", "diff", "[\"dame\",\"dime\",\"dire\",\"dirt\"]"], ["stone", "money", "[\"stony\",\"atony\",\"money\"]"], ["stone", "money", "[\"stony\",\"story\",\"store\",\"money\"]"], ["stone", "money", "[\"stony\",\"stoey\",\"mopey\",\"money\"]"], ["stone", "money", "[\"atone\",\"alone\",\"clone\",\"clove\",\"glove\",\"glory\",\"money\"]"], ["aaaa", "bbbb", "[\"baaa\",\"bbaa\",\"bbba\",\"bbbb\"]"], ["aaaa", "bbbb", "[\"aaab\",\"aabb\",\"abbb\",\"bbbb\"]"], ["aaaa", "bbbb", "[\"baaa\",\"abaa\",\"aaba\",\"aaab\",\"bbbb\"]"], ["aaaa", "bbbb", "[\"baaa\",\"bbaa\",\"bbba\",\"bbbb\",\"aaab\",\"aabb\",\"abbb\"]"], ["lead", "gold", "[\"load\",\"goad\",\"gold\"]"], ["lead", "gold", "[\"lend\",\"land\",\"load\",\"goad\",\"gold\"]"], ["lead", "gold", "[\"load\",\"goad\",\"goat\",\"goal\"]"], ["talk", "tail", "[\"tall\",\"tail\"]"], ["talk", "tail", "[\"task\",\"tusk\",\"tuil\",\"tail\"]"], ["talk", "tail", "[\"tall\",\"tell\",\"teal\",\"tail\"]"], ["code", "data", "[\"cade\",\"cate\",\"date\",\"data\"]"], ["code", "data", "[\"coda\",\"doda\",\"data\"]"], ["code", "data", "[\"cade\",\"cate\",\"date\",\"data\",\"coda\",\"doda\"]"], ["code", "data", "[\"cade\",\"cate\",\"date\",\"dote\",\"done\"]"], ["aaaaaaaaaa", "zzzzzzzzzz", "@javascript:(()=>{const words=[];for(let value=0;value<2490;value++){let number=value,suffix='';for(let i=0;i<9;i++){suffix=String.fromCharCode(97+number%26)+suffix;number=Math.floor(number/26);}words.push('m'+suffix);}for(let length=1;length<=10;length++){words.push('z'.repeat(length)+'a'.repeat(10-length));}return JSON.stringify(words);})()"]], "expected": [5, 0, 2, 2, 0, 3, 3, 3, 0, 3, 4, 3, 3, 3, 3, 4, 4, 4, 0, 4, 3, 0, 2, 4, 4, 4, 5, 5, 6, 0, 6, 0, 5, 0, 0, 0, 0, 0, 5, 5, 0, 5, 4, 4, 0, 3, 0, 3, 5, 0, 5, 0, 11], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "387", "slug": "word-pattern-ii", "id": 387, "title": "Word Pattern II", "difficulty": "Medium", "category": "string", "link": "https://leetcode.com/problems/word-pattern-ii/", "examples": [{"input": "pattern = \"abab\", s = \"redblueredblue\"", "output": "true", "explanation": "'a' maps to \"red\" and 'b' maps to \"blue\"."}, {"input": "pattern = \"aaaa\", s = \"asdasdasdasd\"", "output": "true", "explanation": "Each 'a' maps to \"asd\"."}, {"input": "pattern = \"aabb\", s = \"xyzabcxzyabc\"", "output": "false", "explanation": "No bijective block mapping rebuilds the text."}], "hints": ["Try assigning the next pattern letter to every possible non-empty block starting at the current text position, then solve the rest recursively.", "Keep both directions of the mapping: letter -> block and used blocks, so two letters never share one block.", "When a letter already has a block, simply check the text continues with that block instead of guessing again."], "statement": "You are given a `pattern` string made of lowercase English letters and a text string `s`.\nDecide whether `s` follows the pattern: every pattern letter must stand for one non-empty\nblock of characters, the same letter always stands for the same block, and two different\nletters must stand for two different blocks. Concatenating the blocks in pattern order must\nreproduce `s` exactly.\n\n**Constraints:**\n- `1 <= pattern.length <= 20`\n- `1 <= s.length <= 20`\n- `pattern` and `s` contain only lowercase English letters.\n", "solution": "## Approach\n\nBacktrack over the pattern: bind each new letter to every feasible next block and recurse, enforcing a two-way (bijective) mapping.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^m) worst case\n- **Space Complexity:** O(m + n)\n\n## Implementation\n\n```python\nclass Solution:\n def wordPatternMatch(self, pattern: str, s: str) -> bool:\n mapping, used = {}, set()\n def dfs(i: int, j: int) -> bool:\n if i == len(pattern):\n return j == len(s)\n c = pattern[i]\n if c in mapping:\n w = mapping[c]\n return s.startswith(w, j) and dfs(i + 1, j + len(w))\n for k in range(j + 1, len(s) + 1):\n w = s[j:k]\n if w in used:\n continue\n mapping[c] = w\n used.add(w)\n if dfs(i + 1, k):\n return True\n del mapping[c]\n used.remove(w)\n return False\n return dfs(0, 0)\n```\n", "starter": {"go": "package main\n\nfunc WordPatternMatch(pattern string, s string) bool {\n return false\n}", "python": "class Solution:\n def wordPatternMatch(self, pattern: str, s: str) -> bool:\n ", "cpp": "#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n bool wordPatternMatch(string pattern, string s) {\n return false;\n }\n};"}, "fn": "wordPatternMatch", "params": [{"name": "pattern", "type": "string"}, {"name": "s", "type": "string"}], "outputType": "boolean", "tests": [["abab", "redblueredblue"], ["aaaa", "asdasdasdasd"], ["aabb", "xyzabcxzyabc"], ["a", "x"], ["a", ""], ["ab", "aa"], ["aa", "ab"], ["ab", "ab"], ["abc", "xyz"], ["abc", "xxyyzz"], ["aba", "catcatcat"], ["abba", "redbluebluered"], ["abba", "redblueredblue"], ["aaaa", "abcd"], ["abcabc", "abccbaabccba"], ["abcd", "abcd"], ["abca", "redblueredred"], ["abca", "redbluegreenred"], ["aab", "xxxy"], ["aab", "xxyy"], ["abbb", "xyyy"], ["abbb", "xyyx"], ["abcba", "mnomnom"], ["abcba", "redblueredblue"], ["ab", "qwertyqwerty"], ["ba", "qwertyqwerty"], ["aaab", "aaab"], ["abbbba", "xyyyyyx"]], "expected": [true, true, false, true, false, false, false, true, true, true, false, true, false, false, true, true, true, true, true, true, true, false, false, false, true, true, true, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "386", "slug": "word-pattern", "id": 386, "title": "Word Pattern", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/word-pattern/", "examples": [{"input": "pattern = \"abba\", s = \"dog cat cat dog\"", "output": "true", "explanation": "a maps to dog and b maps to cat bijectively."}, {"input": "pattern = \"abba\", s = \"dog cat cat fish\"", "output": "false", "explanation": "The last fish breaks the a-dog pairing."}, {"input": "pattern = \"aaaa\", s = \"dog cat cat dog\"", "output": "false", "explanation": "One letter cannot map to two different words."}], "hints": ["Split s on single spaces; lengths of pattern and word list must match.", "Enforce a bijection with two maps (letter->word and word->letter).", "Reject when one side would map to two different partners."], "statement": "Check whether the sentence `s` follows the letter pattern.\n\nEach letter in `pattern` must map to exactly one distinct word in `s` and\neach word to exactly one letter (a bijection). Words in `s` are separated by\nsingle spaces with no leading or trailing gaps. Implement\n`wordPattern(pattern, s)` returning true on a full match.\n\n**Constraints:**\n- `1 <= pattern.length <= 300`, lowercase letters.\n- `1 <= s.length <= 3000`, lowercase letters and single spaces.\n", "solution": "## Approach\n\nSplit the sentence into words and require equal length to the pattern. Maintain forward and reverse maps while scanning pairs; any conflict means no bijection.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) over pattern plus words.\n- **Space Complexity:** O(k) for distinct symbols.\n\n## Implementation\n\n```python\nclass Solution:\n def wordPattern(self, pattern: str, s: str) -> bool:\n words = s.split(\" \")\n if len(words) != len(pattern):\n return False\n c2w: dict[str, str] = {}\n w2c: dict[str, str] = {}\n for c, w in zip(pattern, words):\n if c in c2w and c2w[c] != w:\n return False\n if w in w2c and w2c[w] != c:\n return False\n c2w[c] = w\n w2c[w] = c\n return True\n```\n", "starter": {"go": "package main\n\nfunc WordPattern(pattern string, s string) bool {\n \n}", "python": "class Solution:\n def wordPattern(self, pattern: str, s: str) -> bool:\n pass", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool wordPattern(string pattern, string s) {\n return false;\n }\n};"}, "fn": "wordPattern", "params": [{"name": "pattern", "type": "string"}, {"name": "s", "type": "string"}], "outputType": "boolean", "tests": [["abba", "dog cat cat dog"], ["abba", "dog cat cat fish"], ["aaaa", "dog cat cat dog"], ["abba", "dog dog dog dog"], ["a", "x"], ["ab", "dog cat"], ["abc", "dog cat fish"], ["abc", "dog cat dog"], ["abba", "dog cat cat dog extra"], ["a", "a a a a"], ["abca", "dog cat fish dog"], ["abcd", "one two three four"], ["aaaa", "dog dog dog dog"], ["ab", "dog dog"], ["aa", "dog cat"], ["abc", "b c a"], ["aba", "dog cat dog"], ["aba", "dog cat cat"], ["a", "a"], ["abba", "cat dog dog cat"], ["ab", "dog fish"], ["aa", "dog dog"], ["ab", "dog cat cat"], ["abcba", "a b c b a"], ["abc", "a a a"], ["abbc", "dog cat cat dog"], ["abcd", "a b c d"], ["aaaa", "a a a"], ["xyz", "foo bar baz"], ["abab", "dog cat dog cat"]], "expected": [true, false, false, false, true, true, true, false, false, false, true, true, true, false, false, true, true, false, true, true, true, true, false, true, false, false, true, false, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "73", "slug": "word-search-ii", "id": 73, "title": "Word Search II", "difficulty": "Hard", "category": "tree", "link": "https://leetcode.com/problems/word-search-ii/", "examples": [{"input": "board = [[a,b,c,e],[s,f,c,s],[a,d,e,e]], words = [see,abcced,abcb]", "output": "[see,abcced]", "explanation": "\"see\" is found via s(1,3)->e(2,3)->e(2,2). \"abcced\" is found via a(0,0)->b(0,1)->c(0,2)->c(1,2)->e(2,2)->d(2,1). \"abcb\" has no valid path."}], "hints": ["Build a trie of words and backtrack from each cell, pruning via the trie; mark visited cells and collect matches once per word."], "statement": "You receive a character grid `board` with `m` rows and `n` columns, together with a list of strings `words`. Collect every entry of `words` that can be traced on the grid by walking from cell to orthogonally touching cell (upward, downward, leftward, or rightward) in letter order, never stepping onto one cell twice while tracing a single entry. Return the subset of entries for which at least one such walk exists.\n\n**Constraints:**\n\n- m == board.length\n- n == board[i].length\n- 1 \u2264 m, n \u2264 12\n- board[i][j] is a lowercase English letter.\n- 1 \u2264 words.length \u2264 3 * 10^4\n- 1 \u2264 words[i].length \u2264 10\n- words[i] consists of lowercase English letters.\n- All the strings of words are unique.\n", "solution": "## Approach\n\nBuild a trie of all target words, then perform DFS from each cell on the board, pruning the search when the current path no longer matches any prefix in the trie.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m\u00d7n\u00d74^L)\n- **Space Complexity:** O(total characters in words)\n\n## Implementation\n\n```python\nfrom typing import List\nclass TrieNode:\n def __init__(self):\n self.children = {}\n self.word = None\nclass Solution:\n def findWords(self, board: List[List[str]], words: List[str]) -> List[str]:\n root = TrieNode()\n for w in words:\n node = root\n for c in w:\n if c not in node.children:\n node.children[c] = TrieNode()\n node = node.children[c]\n node.word = w\n m, n = len(board), len(board[0])\n res = set()\n def dfs(i, j, node):\n if i < 0 or i >= m or j < 0 or j >= n:\n return\n c = board[i][j]\n if c not in node.children:\n return\n node = node.children[c]\n if node.word:\n res.add(node.word)\n board[i][j] = '#'\n for di, dj in ((1,0),(-1,0),(0,1),(0,-1)):\n dfs(i + di, j + dj, node)\n board[i][j] = c\n for i in range(m):\n for j in range(n):\n dfs(i, j, root)\n return list(res)\n```\n", "starter": {"go": "package main\n\nfunc FindWords(board [][]byte, words []string) []string {\n \n}", "python": "from typing import List\nclass Solution:\n def findWords(self, board: List[List[str]], words: List[str]) -> List[str]:\n return []\n", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n vector<string> findWords(vector<vector<char>>& board, vector<string>& words) {\n return {};\n }\n};"}, "fn": "findWords", "params": [{"name": "board", "type": "char_array_2d", "visualizeType": "matrix"}, {"name": "words", "type": "string_array"}], "outputType": "string_list", "tests": [["[['o', 'a', 'a', 'n'], ['e', 't', 'a', 'e'], ['i', 'h', 'k', 'r'], ['i', 'f', 'l', 'v']]", "['oath', 'pea', 'eat', 'rain']"], ["[['a', 'b'], ['c', 'd']]", "['ab', 'cb', 'ad', 'bd', 'ac', 'ca', 'da', 'bc', 'db', 'adcb', 'dabc', 'abb', 'acb']"], ["[['a', 'a']]", "['aaa']"], ["[['a']]", "['a']"], ["[['a']]", "['b']"], ["[['a', 'b']]", "['ab', 'ba']"], ["[['a'], ['b']]", "['ab', 'ba']"], ["[['c', 'a', 't'], ['d', 'o', 'g']]", "['cat', 'dog', 'cog', 'tag']"], ["[['a', 'b'], ['c', 'd'], ['e', 'f']]", "['ab', 'cd', 'ef', 'abcdef']"], ["[['x']]", "['x', 'xx', 'y']"], ["[['a', 'a'], ['a', 'a']]", "['aa', 'aaa', 'aaaa']"], ["[['s', 'e', 'e'], ['a', 'b', 'c']]", "['see', 'sea', 'abc']"], ["[['h', 'e', 'l', 'l', 'o']]", "['hello', 'hell', 'ole']"], ["[['m']]", "['m', 'n', 'mm']"], ["[['a', 'b', 'c'], ['d', 'e', 'f']]", "['abcdef', 'fedcba', 'ace']"], ["[['z', 'z'], ['z', 'z']]", "['z', 'zz', 'zzz', 'zzzz']"], ["[['p', 'y']]", "['py', 'yp', 'ppy']"], ["[['q', 'w', 'e']]", "['qwe', 'ewq', 'qw']"], ["[['a', 'b', 'c', 'd']]", "['abcd', 'dcba', 'ac']"], ["[['t', 'a', 'p']]", "['tap', 'pat', 'apt']"], ["[['a', 'b'], ['b', 'a']]", "['ab', 'ba', 'aba']"], ["[['l', 'e', 'e', 't']]", "['leet', 'leetco', 'teel']"], ["[['c', 'o', 'd', 'e']]", "['code', 'decode', 'ecod']"], ["[['a', 'c'], ['e', 'g']]", "['aceg', 'geca', 'ac']"], ["[['r', 'a', 'i', 'n']]", "['rain', 'niar', 'ran']"], ["[['a', 'b', 'c'], ['c', 'b', 'a']]", "['abc', 'cba', 'abccba']"], ["[['d', 'o', 'g']]", "['dog', 'god', 'do']"], ["[['k', 'i', 't', 'e']]", "['kite', 'etik', 'kit']"], ["[['b', 'a', 'd']]", "['bad', 'dab', 'adb']"], ["[['f', 'o', 'o']]", "['foo', 'oof', 'of']"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "49", "slug": "word-search", "id": 49, "title": "Word Search", "difficulty": "Medium", "category": "matrix", "link": "https://leetcode.com/problems/word-search/", "examples": [{"input": "board = [[\"A\",\"B\",\"C\",\"E\"],[\"S\",\"F\",\"C\",\"S\"],[\"A\",\"D\",\"E\",\"E\"]], word = \"ABCCED\"", "output": "true", "explanation": "The word \"ABCCED\" can be found in the board via adjacent cells."}, {"input": "board = [[\"A\",\"B\",\"C\",\"E\"],[\"S\",\"F\",\"C\",\"S\"],[\"A\",\"D\",\"E\",\"E\"]], word = \"SEE\"", "output": "true", "explanation": "The word \"SEE\" can be found in the board via adjacent cells."}, {"input": "board = [[\"A\",\"B\",\"C\",\"E\"],[\"S\",\"F\",\"C\",\"S\"],[\"A\",\"D\",\"E\",\"E\"]], word = \"ABCB\"", "output": "false", "explanation": "The word \"ABCB\" does not exist in the board."}], "hints": ["Backtracking/DFS from each starting cell, marking visited cells, exploring four directions, and backtracking on mismatch."], "statement": "You are handed a rectangular arrangement `board` of `m` rows by `n` columns holding single characters, plus a target string `word`. Decide whether `word` can be traced across the arrangement by stepping from cell to orthogonally touching cell \u2014 upward, downward, leftward, or rightward \u2014 matching its letters in order, without stepping onto any single cell twice within the same trace. Return `true` when such a trace exists, and `false` otherwise.\n\n**Constraints:**\n\n- m == board.length\n- n = board[i].length\n- 1 \u2264 m, n \u2264 6\n- 1 \u2264 word.length \u2264 15\n- board and word consists of only lowercase and uppercase English letters.\n", "solution": "## Approach\n\nUse DFS with backtracking from each cell, marking visited cells with a temporary placeholder to avoid reuse, and exploring all four directions.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m\u00d7n\u00d74^L)\n- **Space Complexity:** O(L)\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def exist(self, board: List[List[str]], word: str) -> bool:\n m, n = len(board), len(board[0])\n def dfs(i, j, k):\n if k == len(word):\n return True\n if i < 0 or i >= m or j < 0 or j >= n or board[i][j] != word[k]:\n return False\n tmp = board[i][j]\n board[i][j] = '#'\n if dfs(i+1,j,k+1) or dfs(i-1,j,k+1) or dfs(i,j+1,k+1) or dfs(i,j-1,k+1):\n return True\n board[i][j] = tmp\n return False\n for i in range(m):\n for j in range(n):\n if dfs(i, j, 0):\n return True\n return False\n```\n", "starter": {"go": "package main\n\nfunc Exist(board [][]byte, word string) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def exist(self, board: List[List[str]], word: str) -> bool:\n pass\n", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool exist(vector<vector<char>>& board, string word) {\n return false;\n }\n};"}, "fn": "exist", "params": [{"name": "board", "type": "char_array_2d", "visualizeType": "matrix"}, {"name": "word", "type": "string"}], "outputType": "boolean", "tests": [["[[\"A\",\"B\",\"C\",\"E\"],[\"S\",\"F\",\"C\",\"S\"],[\"A\",\"D\",\"E\",\"E\"]]", "ABCCED"], ["[[\"A\",\"B\",\"C\",\"E\"],[\"S\",\"F\",\"C\",\"S\"],[\"A\",\"D\",\"E\",\"E\"]]", "SEE"], ["[[\"A\",\"B\"],[\"C\",\"D\"]]", "ABCD"], ["[[\"A\"]]", "A"], ["[[\"A\"]]", "B"], ["[[\"A\",\"B\"],[\"C\",\"D\"]]", "ACDB"], ["[[\"A\",\"B\"],[\"C\",\"D\"]]", "ACBD"], ["[[\"a\"]]", "aa"], ["[[\"a\",\"b\",\"c\"]]", "abc"], ["[[\"a\",\"b\",\"c\"]]", "acb"], ["[[\"x\",\"y\"],[\"z\",\"w\"]]", "xywz"], ["[[\"p\",\"q\",\"r\"],[\"s\",\"t\",\"u\"]]", "pqrstu"], ["[[\"A\",\"a\"],[\"b\",\"B\"]]", "AaBb"], ["[[\"Z\"]]", "ZZZZZZZZZZZZZZZ"], ["[[\"m\",\"n\"],[\"o\",\"p\"]]", "mnpo"], ["[[\"a\",\"a\",\"a\"],[\"a\",\"a\",\"a\"]]", "aaaaaaa"], ["[[\"a\",\"a\",\"a\"],[\"a\",\"a\",\"a\"]]", "aaaaaaaaaaa"], ["[[\"A\",\"B\",\"C\"]]", "ABC"], ["[[\"A\",\"B\",\"C\"]]", "CBA"], ["[[\"k\"]]", "k"], ["[[\"H\",\"e\",\"l\",\"l\",\"o\"]]", "Hello"], ["[[\"a\",\"b\"],[\"d\",\"c\"]]", "abcd"], ["[[\"T\",\"E\",\"S\",\"T\"]]", "TESTEST"], ["[[\"q\",\"w\"],[\"e\",\"r\"],[\"t\",\"y\"]]", "qwerty"], ["[[\"a\",\"B\",\"c\",\"D\",\"e\"]]", "aBcDe"], ["[[\"M\"]]", "N"], ["[[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"]]", "ABCDEF"], ["[[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"]]", "FEDCBA"], ["[[\"g\",\"o\",\"o\",\"d\"]]", "good"], ["[[\"U\",\"V\"],[\"W\",\"X\"],[\"Y\",\"Z\"]]", "VWXYZU"]], "expected": [true, true, false, true, false, true, false, false, true, false, true, false, true, false, true, false, false, true, true, true, true, true, false, false, true, false, true, true, true, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "495", "slug": "word-squares", "id": 495, "title": "Word Squares", "difficulty": "Hard", "category": "string", "link": "https://leetcode.com/problems/word-squares/", "examples": [{"input": "words=[\"area\",\"lead\",\"wall\",\"lady\",\"ball\"]", "output": "[[\"wall\",\"area\",\"lead\",\"lady\"],[\"ball\",\"area\",\"lead\",\"lady\"]]", "explanation": "Both arrangements read the same across rows and down columns."}, {"input": "words=[\"abat\",\"baba\",\"atan\",\"atal\"]", "output": "[[\"baba\",\"abat\",\"baba\",\"atan\"],[\"baba\",\"abat\",\"baba\",\"atal\"]]", "explanation": "Each arrangement mirrors along the diagonal."}], "hints": ["Index every word by each of its prefixes so the required next-row prefix is a fast lookup.", "Grow squares row by row: the next needed prefix is spelled by the latest column characters.", "Backtrack and record a copy once the square reaches full size."], "statement": "You receive a dictionary `words` holding distinct lowercase strings, all sharing one length. A word square is a sequence of that same length where row `k` and column `k` spell the same word for every `k`. In other words, if the sequence is `r0, r1, ..., r_{n-1}`, then the `j`-th letter of `ri` must equal the `j`-th letter of `rj` pattern: the prefix formed by the first `t` rows constrains which word may sit in row `t`.\n\nList every word square you can assemble from `words`. Words may be reused. The order of the returned squares does not matter.\n\n**Constraints:**\n- `1 <= words.length <= 1000`\n- `1 <= words[i].length <= 5`\n- All words share the same length and are pairwise distinct.\n- All words use lowercase English letters.\n\nAdaptation: the source returns a nested list of strings; here it maps to `string_list_2d`.\n", "solution": "## Approach\n\nPrecompute a map from every prefix to the words carrying it. Then extend a partial square one row at a time: the letters already placed in column `r` spell the prefix the next word must have. Look up candidates with that prefix and recurse. A full-size arrangement is a valid square by construction.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(candidates explored). Prefix lookups are O(1) and each complete square costs O(n^2) to copy.\n- **Space Complexity:** O(total prefix entries + recursion depth n).\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def wordSquares(self, words: List[str]) -> List[List[str]]:\n if not words:\n return []\n n = len(words[0])\n pref = {}\n for w in words:\n for i in range(n + 1):\n pref.setdefault(w[:i], []).append(w)\n ans = []\n def backtrack(cur):\n if len(cur) == n:\n ans.append(list(cur))\n return\n r = len(cur)\n need = ''.join(row[r] for row in cur)\n for w in pref.get(need, []):\n cur.append(w)\n backtrack(cur)\n cur.pop()\n backtrack([])\n return ans\n```\n", "starter": {"go": "package main\n\nfunc WordSquares(words []string) [][]string {\n \n}", "python": "from typing import List\nclass Solution:\n def wordSquares(self, words: List[str]) -> List[List[str]]:\n pass\n", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n vector<vector<string>> wordSquares(vector<string>& words) {\n return {};\n }\n};"}, "fn": "wordSquares", "params": [{"name": "words", "type": "string_array"}], "outputType": "string_list_2d", "tests": [["[\"area\",\"lead\",\"wall\",\"lady\",\"ball\"]"], ["[\"abat\",\"baba\",\"atan\",\"atal\"]"], ["[\"a\"]"], ["[\"ab\",\"ba\"]"], ["[\"aa\",\"bb\"]"], ["[\"abc\",\"bca\",\"cab\"]"], ["[\"a\",\"b\"]"], ["[\"ball\",\"area\",\"read\",\"lady\"]"], ["[\"abcd\",\"bnrt\",\"crmy\",\"dtye\"]"], ["[\"aa\",\"aa\"]"], ["[\"ab\",\"aa\",\"ba\"]"], ["[\"o\"]"], ["[\"aa\",\"ab\"]"], ["[\"ab\",\"bb\"]"], ["[\"ba\",\"aa\"]"], ["[\"abc\",\"def\"]"], ["[\"aaa\",\"aab\"]"], ["[\"aba\",\"bab\"]"], ["[\"abcd\",\"abce\"]"], ["[\"a\",\"b\",\"c\"]"], ["[\"o\",\"a\"]"], ["[\"ab\",\"cd\"]"], ["[\"aa\",\"bb\",\"cc\"]"], ["[\"ab\",\"bc\",\"ca\"]"], ["[\"at\",\"ta\"]"], ["[\"no\",\"on\"]"], ["[\"abc\",\"bca\"]"], ["[\"aaa\",\"bbb\"]"], ["[\"aba\",\"aca\"]"], ["[\"abcd\",\"bcda\"]"]], "expected": [[["wall", "area", "lead", "lady"], ["ball", "area", "lead", "lady"]], [["baba", "abat", "baba", "atan"], ["baba", "abat", "baba", "atal"]], [["a"]], [["ab", "ba"], ["ba", "ab"]], [["aa", "aa"], ["bb", "bb"]], [["abc", "bca", "cab"], ["bca", "cab", "abc"], ["cab", "abc", "bca"]], [["a"], ["b"]], [], [["abcd", "bnrt", "crmy", "dtye"]], [["aa", "aa"], ["aa", "aa"], ["aa", "aa"], ["aa", "aa"]], [["ab", "ba"], ["aa", "ab"], ["aa", "aa"], ["ba", "ab"], ["ba", "aa"]], [["o"]], [["aa", "aa"], ["aa", "ab"]], [["ab", "bb"], ["bb", "bb"]], [["ba", "aa"], ["aa", "aa"]], [], [["aaa", "aaa", "aaa"], ["aaa", "aaa", "aab"]], [["aba", "bab", "aba"], ["bab", "aba", "bab"]], [], [["a"], ["b"], ["c"]], [["o"], ["a"]], [], [["aa", "aa"], ["bb", "bb"], ["cc", "cc"]], [["ab", "bc"], ["bc", "ca"], ["ca", "ab"]], [["at", "ta"], ["ta", "at"]], [["no", "on"], ["on", "no"]], [], [["aaa", "aaa", "aaa"], ["bbb", "bbb", "bbb"]], [], []], "loose": true}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "904", "slug": "word-subsets", "id": 904, "title": "Word Subsets", "difficulty": "Medium", "category": "string", "link": "https://leetcode.com/problems/word-subsets/", "examples": [{"input": "words1 = [\"amazon\",\"apple\",\"facebook\",\"google\",\"leetcode\"], words2 = [\"e\",\"o\"]", "output": "[\"facebook\",\"google\",\"leetcode\"]", "explanation": "These are the words containing at least one e and at least one o."}, {"input": "words1 = [\"amazon\",\"apple\",\"facebook\",\"google\",\"leetcode\"], words2 = [\"lo\",\"eo\"]", "output": "[\"google\",\"leetcode\"]", "explanation": "Only these words cover the letter demands of both \"lo\" and \"eo\"."}, {"input": "words1 = [\"amazon\",\"apple\",\"facebook\",\"google\",\"leetcode\"], words2 = [\"ec\",\"oc\",\"ceo\"]", "output": "[\"facebook\",\"leetcode\"]", "explanation": "Each of these words contains every letter pattern required by all of words2."}], "hints": ["A words1 entry is universal when, for every letter, its count there reaches the largest count demanded by any single words2 entry.", "Collapse all of words2 into one demand table holding per-letter maxima, then test each words1 entry against it.", "The order of the returned words does not matter for judging; sorted comparison is used."], "statement": "You are given two string arrays `words1` and `words2`. A word from `words1` is called universal when, for every word `b` in `words2`, each letter appears in it at least as many times as it appears in `b`.\n\nReturn the list of all universal words from `words1`. The order of the returned list does not matter.\n\n**Constraints:**\n- `1 <= words1.length, words2.length <= 10^4`\n- `1 <= words1[i].length, words2[i].length <= 30`\n- All words consist of lowercase English letters\n", "solution": "## Approach\n\nFor each letter, only the strongest demand across all of `words2` matters: a candidate must contain every letter at least that many times. Build this per-letter demand table once, then keep the `words1` entries whose letter counts dominate it everywhere.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(total characters in words1 plus total characters in words2).\n- **Space Complexity:** O(1) extra besides the output (two fixed 26-counters).\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def wordSubsets(self, words1: List[str], words2: List[str]) -> List[str]:\n need = [0] * 26\n for w in words2:\n c = [0] * 26\n for ch in w:\n c[ord(ch) - 97] += 1\n for i in range(26):\n if c[i] > need[i]:\n need[i] = c[i]\n ans = []\n for w in words1:\n c = [0] * 26\n for ch in w:\n c[ord(ch) - 97] += 1\n if all(c[i] >= need[i] for i in range(26)):\n ans.append(w)\n return ans\n```\n", "starter": {"go": "package main\n\nfunc WordSubsets(words1 []string, words2 []string) []string {\n \n}", "python": "from typing import List\nclass Solution:\n def wordSubsets(self, words1: List[str], words2: List[str]) -> List[str]:\n ", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<string> wordSubsets(vector<string>& words1, vector<string>& words2) {\n \n }\n};"}, "fn": "wordSubsets", "params": [{"name": "words1", "type": "string_array"}, {"name": "words2", "type": "string_array"}], "outputType": "string_list", "tests": [["[\"amazon\", \"apple\", \"facebook\", \"google\", \"leetcode\"]", "[\"e\", \"o\"]"], ["[\"amazon\", \"apple\", \"facebook\", \"google\", \"leetcode\"]", "[\"l\", \"e\"]"], ["[\"amazon\", \"apple\", \"facebook\", \"google\", \"leetcode\"]", "[\"e\", \"oo\"]"], ["[\"amazon\", \"apple\", \"facebook\", \"google\", \"leetcode\"]", "[\"lo\", \"eo\"]"], ["[\"amazon\", \"apple\", \"facebook\", \"google\", \"leetcode\"]", "[\"ec\", \"oc\", \"ceo\"]"], ["[\"eaee\", \"beccd\", \"c\", \"dcbeabeb\", \"cae\", \"dbbeddd\"]", "[\"eabc\", \"daad\"]"], ["[\"bb\", \"ba\", \"baeabee\", \"cdce\", \"eecdae\"]", "[\"d\", \"e\", \"ab\"]"], ["[\"dbecaeb\", \"bcedb\", \"dbabaec\", \"abee\", \"eede\", \"dcdebab\"]", "[\"ddbd\"]"], ["[\"bbbba\", \"e\", \"ebbb\", \"bbd\", \"e\", \"bbcdadc\"]", "[\"eaba\", \"b\", \"ad\"]"], ["[\"aec\"]", "[\"ab\", \"aeb\", \"db\"]"], ["[\"cbcbacbd\", \"cdca\", \"b\", \"eb\", \"eacadadc\", \"ebec\"]", "[\"ad\"]"], ["[\"ddebb\", \"dbe\", \"eec\", \"bba\", \"ebcacc\"]", "[\"cead\"]"], ["[\"b\", \"adabddba\", \"cddea\", \"cbecab\", \"debeda\"]", "[\"d\", \"daa\", \"d\"]"], ["[\"c\", \"dbcd\", \"cedabdb\", \"bcdabcbb\", \"cdcddc\"]", "[\"bda\"]"], ["[\"cebeb\", \"eadbc\"]", "[\"db\", \"edbc\", \"abcc\"]"], ["[\"eda\", \"ddeaddcb\", \"eb\"]", "[\"a\", \"ded\", \"a\"]"], ["[\"cabce\", \"ec\", \"a\", \"cecba\"]", "[\"dced\"]"], ["[\"aebceec\", \"cba\", \"caacb\", \"aeece\", \"e\"]", "[\"ed\", \"ddca\"]"], ["[\"b\", \"aaadc\", \"dee\", \"cbeebd\", \"bdcacddc\"]", "[\"cd\", \"ed\", \"eee\"]"], ["[\"eecbc\", \"ddaadd\", \"a\"]", "[\"ed\"]"], ["[\"bdccaa\", \"ceadbb\", \"dccaabce\", \"ac\", \"bdd\", \"ebeb\"]", "[\"a\"]"], ["[\"da\"]", "[\"ebb\", \"d\", \"abce\"]"], ["[\"cde\", \"b\", \"cabcbccb\", \"dceabae\", \"ddbeedb\", \"a\"]", "[\"cc\", \"dedc\"]"], ["[\"ebeeecb\", \"b\", \"cdddcd\", \"bbaeed\"]", "[\"dd\"]"], ["[\"daecec\"]", "[\"ecca\", \"acbe\", \"ccb\"]"], ["[\"cbedadae\", \"ca\"]", "[\"ceb\", \"acd\", \"dc\"]"], ["[\"ee\", \"eaecc\"]", "[\"ecb\", \"be\"]"], ["[\"deadbea\", \"eecdd\", \"cbebe\", \"dadd\", \"bbac\", \"ccaecaee\"]", "[\"caba\", \"d\"]"]], "expected": [["facebook", "google", "leetcode"], ["apple", "google", "leetcode"], ["facebook", "google"], ["google", "leetcode"], ["facebook", "leetcode"], [], [], [], [], [], ["cbcbacbd", "cdca", "eacadadc"], [], ["adabddba"], ["cedabdb", "bcdabcbb"], [], ["ddeaddcb"], [], [], [], [], ["bdccaa", "ceadbb", "dccaabce", "ac"], [], [], ["cdddcd"], [], ["cbedadae"], [], []], "loose": true}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "902", "slug": "x-of-a-kind-in-a-deck-of-cards", "id": 902, "title": "X of a Kind in a Deck of Cards", "difficulty": "Easy", "category": "array", "link": "https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/", "examples": [{"input": "deck = [1,2,3,4,4,3,2,1]", "output": "true", "explanation": "Split into four pairs: [1,1], [2,2], [3,3], [4,4]."}, {"input": "deck = [1,1,1,2,2,2,3,3]", "output": "false", "explanation": "No group size X >= 2 divides every value count (3, 3, 2)."}, {"input": "deck = [1,1,2,2,2,2]", "output": "true", "explanation": "Use X = 2: [1,1], [2,2], [2,2]."}, {"input": "deck = [1]", "output": "false", "explanation": "A single card cannot form a group of size at least 2."}], "hints": ["Count how many times each distinct value appears; every count must be a multiple of the shared group size X.", "That is possible exactly when the greatest common divisor of all counts is at least 2.", "A deck with fewer than 2 cards, or with a count of 1 anywhere while others disagree, fails."], "statement": "You are given an integer array `deck` where each entry is the value written on one card. Decide whether the whole deck can be split into groups satisfying all of these rules:\n\n- Every group contains the same number of cards `X`, with `X >= 2`.\n- All cards inside a single group show the same value.\n\nReturn `true` if such a split exists, otherwise `false`.\n\n**Constraints:**\n- `1 <= deck.length <= 10^4`\n- `0 <= deck[i] < 10^4`\n", "solution": "## Approach\n\nTally the occurrences of each distinct card. A common group size `X` works exactly when it divides every tally, so the best candidate is the greatest common divisor of all tallies. The deck splits evenly precisely when that divisor is at least 2.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n + m log m) for counting plus gcd steps over the tallies.\n- **Space Complexity:** O(m) for the frequency table of m distinct values.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import Counter\nimport math\nclass Solution:\n def hasGroupsSizeX(self, deck: List[int]) -> bool:\n counts = Counter(deck).values()\n g = 0\n for c in counts:\n g = math.gcd(g, c)\n return g >= 2\n```\n", "starter": {"go": "package main\n\nfunc HasGroupsSizeX(deck []int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def hasGroupsSizeX(self, deck: List[int]) -> bool:\n return False\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool hasGroupsSizeX(vector<int>& deck) {\n return false;\n }\n};"}, "fn": "hasGroupsSizeX", "params": [{"name": "deck", "type": "int_array"}], "outputType": "boolean", "tests": [["[1,2,3,4,4,3,2,1]"], ["[1,1,1,2,2,2,3,3]"], ["[1]"], ["[1,1]"], ["[1,1,2,2,2,2]"], ["[1,1,1,2,2,2]"], ["[1,1,1,2,2,2,3,3,3]"], ["[2,2,2,3,3,3,3,3,3]"], ["[0,0,0,0]"], ["[5,5,5,5,5]"], ["[1,2,3,4]"], ["[1,1,2,2]"], ["[1,1,1,1,2,2,2,2,3,3,3,3]"], ["[7,7,7]"], ["[4,4,4,4,4,4]"], ["[1,1,1,1,1,1,2,2,2,2,2,2]"], ["[9,9,8,8,8,9,9,8]"], ["[3,3,3,3,3,3,3,3,3]"], ["[1,1,1,1,2,2,2,3,3]"], ["[6,6,6,6,6,6,6,6,6,6,6,6]"], ["[1,2]"], ["[0,0,1,1,1,1]"], ["[2]"], ["[1,1,1,1]"], ["[1,2,2,3,3,3]"], ["[4,4,4,4,4,4,4,4]"], ["[1,3,1,3,1,3]"], ["[10,10,10,20,20,20,20,20,20,30,30,30]"]], "expected": [true, false, false, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, false, true, false, true, false, true, false, true, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "251", "slug": "zigzag-conversion", "id": 251, "title": "Zigzag Conversion", "difficulty": "Medium", "category": "string", "link": "https://leetcode.com/problems/zigzag-conversion/", "examples": [{"input": "s = \"PAYPALISHIRING\", numRows = 3", "output": "\"PAHNAPLSIIGYIR\"", "explanation": "Rows are \"PAHN\", \"APLSIIG\", \"YIR\"."}, {"input": "s = \"PAYPALISHIRING\", numRows = 4", "output": "\"PINALSIGYAHRPI\""}, {"input": "s = \"A\", numRows = 1", "output": "\"A\""}], "hints": ["Simulate the row index moving down then up, appending each character to its row.", "If numRows is 1, the answer is the original string."], "statement": "Given a string `s` and a positive integer `numRows`, arrange the characters of `s` in a zigzag across `numRows` rows, then read the rows from top to bottom, left to right.\n\nTo picture the ordering, write the characters diagonally down and then diagonally up, repeating: move down one row at a time until the bottom row, then move up one row at a time until the top row, and repeat. Characters that land in the same row keep their original left-to-right order.\n\nReturn the string obtained by concatenating the rows in order.\n\n**Constraints:**\n- `1 <= s.length <= 1000`\n- `s` consists of English letters, `,` and `.`\n- `1 <= numRows <= 1000`\n", "solution": "## Approach\n\nSimulate walking through the rows in a down-then-up cycle. Keep one string builder per row and append each character to the current row. Reverse direction at the top row and the bottom row. When there is only one row, the walk never moves, so the input is returned unchanged. Finally concatenate the rows.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the length of `s`. Each character is visited once.\n- **Space Complexity:** O(n) for the row buffers and the output.\n\n## Implementation\n\n```python\nclass Solution:\n def convert(self, s: str, numRows: int) -> str:\n if numRows == 1 or len(s) <= numRows:\n return s\n rows = [\"\" for _ in range(numRows)]\n cur = 0\n down = True\n for c in s:\n rows[cur] += c\n if cur == 0:\n down = True\n elif cur == numRows - 1:\n down = False\n cur += 1 if down else -1\n return \"\".join(rows)\n```\n", "starter": {"go": "package main\n\nfunc Convert(s string, numRows int) string {\n \n}", "python": "class Solution:\n def convert(self, s: str, numRows: int) -> str:\n pass", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n string convert(string s, int numRows) {\n return \"\";\n }\n};"}, "fn": "convert", "params": [{"name": "s", "type": "string"}, {"name": "numRows", "type": "int"}], "outputType": "string", "tests": [["PAYPALISHIRING", "3"], ["PAYPALISHIRING", "4"], ["A", "1"], ["AB", "1"], ["ABC", "2"], ["ABCD", "2"], ["ABCDE", "4"], ["HELLO,WORLD.", "3"], ["ABCDEFGHIJKLMN", "5"], ["A", "1000"], ["AB", "2"], ["PAYPALISHIRING", "5"], ["ZZZ", "2"], ["ABCDEF", "3"], ["ABCDEFG", "3"], ["A.B,C", "2"], ["XYZ", "5"], ["HELLOWORLD", "1"], ["ABCDEFGHIJ", "4"], ["AAABBBCCC", "2"], ["QWERTYUIOPASDFGHJKL", "3"], ["A,B.C", "3"], ["SHORT", "10"], ["REPEATEDREPEATED", "6"], [".,.,.,", "2"], ["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", "7"]], "expected": ["PAHNAPLSIIGYIR", "PINALSIGYAHRPI", "A", "AB", "ACB", "ACBD", "ABCED", "HOREL,OL.LWD", "AIBHJCGKDFLNEM", "A", "AB", "PHASIYIRPLIGAN", "ZZZ", "AEBDFC", "AEBDFCG", "ABC.,", "XYZ", "HELLOWORLD", "AGBFHCEIDJ", "AABCCABBC", "QTODJWRYIPSFHKEUAGL", "AC,.B", "SHORT", "RPEEEPRAEDTAEETD", "...,,,", "AMYkwBLNXZjlvxCKOWaimuyDJPVbhntzEIQUcgosFHRTdfprGSeq"], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "379", "slug": "zigzag-iterator", "id": 379, "title": "Zigzag Iterator", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/zigzag-iterator/", "examples": [{"input": "v1 = [1,2], v2 = [3,4,5,6]", "output": "[1,3,2,4,5,6]", "explanation": "Alternate starting with v1; append the tail of the longer list."}, {"input": "v1 = [1], v2 = []", "output": "[1]", "explanation": "Only v1 has values."}, {"input": "v1 = [], v2 = [1]", "output": "[1]", "explanation": "Only v2 has values."}], "hints": ["Adaptation: the original iterator class with next/hasNext is replaced by a function returning the full zigzag order.", "Alternate taking from v1 then v2; when one list is exhausted, drain the other.", "Start with v1."], "statement": "Given two integer lists, produce their zigzag interleaving.\n\n**Adaptation:** the original design asks for an iterator class with `next`\nand `hasNext`; here implement `zigzagIterate(v1, v2)` returning the whole\ntraversal: take one element from `v1`, then one from `v2`, alternating, and\ndrain whichever list remains when the other runs out.\n\n**Constraints:**\n- `0 <= v1.length, v2.length <= 1000`\n- `1 <= v1[i], v2[i] <= 1000` when present.\n", "solution": "## Approach\n\nWalk both lists with two indices and a toggle. On each step take from the toggled list when it still has items, otherwise take from the other list, then flip the toggle until both lists are drained.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n + m)\n- **Space Complexity:** O(n + m) for the output.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def zigzagIterate(self, v1: List[int], v2: List[int]) -> List[int]:\n res, i, j, take_first = [], 0, 0, True\n while i < len(v1) or j < len(v2):\n if take_first:\n if i < len(v1):\n res.append(v1[i]); i += 1\n else:\n res.append(v2[j]); j += 1\n else:\n if j < len(v2):\n res.append(v2[j]); j += 1\n else:\n res.append(v1[i]); i += 1\n take_first = not take_first\n return res\n```\n", "starter": {"go": "package main\n\nfunc ZigzagIterate(v1 []int, v2 []int) []int {\n return []int{}\n}", "python": "from typing import List\nclass Solution:\n def zigzagIterate(self, v1: List[int], v2: List[int]) -> List[int]:\n return []", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<int> zigzagIterate(vector<int>& v1, vector<int>& v2) {\n return {};\n }\n};"}, "fn": "zigzagIterate", "params": [{"name": "v1", "type": "int_array"}, {"name": "v2", "type": "int_array"}], "outputType": "int_array", "tests": [["[1,2]", "[3,4,5,6]"], ["[1]", "[]"], ["[]", "[1]"], ["[]", "[]"], ["[1,3,5]", "[2,4,6]"], ["[1,2,3,4,5]", "[6]"], ["[1]", "[2,3,4,5]"], ["[1,2]", "[3]"], ["[5]", "[5]"], ["[0,0,0]", "[1,1,1]"], ["[1,2,3]", "[]"], ["[]", "[4,5,6]"], ["[7,8]", "[9,10,11,12,13]"], ["[1,1,1,1]", "[2,2]"], ["[3]", "[1,2]"], ["[1,2,3]", "[4,5,6]"], ["[10]", "[20]"], ["[1,2,3,4]", "[]"], ["[]", "[5,6,7,8]"], ["[1]", "[2]"], ["[9,8,7]", "[1,2,3,4,5]"], ["[100]", "[200,300]"], ["[5,5,5]", "[5,5,5]"], ["[1,3,5,7]", "[2,4]"], ["[42]", "[42,42]"], ["[2,4,6,8,10]", "[1,3,5,7,9]"], ["[7,7,7]", "[8]"], ["[1000]", "[1]"], ["[3,1]", "[2]"], ["[6,5,4]", "[3,2,1]"]], "expected": [[1, 3, 2, 4, 5, 6], [1], [1], [], [1, 2, 3, 4, 5, 6], [1, 6, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 3, 2], [5, 5], [0, 1, 0, 1, 0, 1], [1, 2, 3], [4, 5, 6], [7, 9, 8, 10, 11, 12, 13], [1, 2, 1, 2, 1, 1], [3, 1, 2], [1, 4, 2, 5, 3, 6], [10, 20], [1, 2, 3, 4], [5, 6, 7, 8], [1, 2], [9, 1, 8, 2, 7, 3, 4, 5], [100, 200, 300], [5, 5, 5, 5, 5, 5], [1, 2, 3, 4, 5, 7], [42, 42, 42], [2, 1, 4, 3, 6, 5, 8, 7, 10, 9], [7, 8, 7, 7], [1000, 1], [3, 2, 1], [6, 3, 5, 2, 4, 1]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "552", "slug": "zuma-game", "id": 552, "title": "Zuma Game", "difficulty": "Hard", "category": "string", "link": "https://leetcode.com/problems/zuma-game/", "examples": [{"input": "board = \"WRRBBW\", hand = \"RB\"", "output": "-1", "explanation": "No insertion order empties the row with these two hand balls."}, {"input": "board = \"WWRRBBWW\", hand = \"WRBRW\"", "output": "2", "explanation": "Two well placed insertions trigger cascading deletions that clear the row."}, {"input": "board = \"G\", hand = \"GGGGG\"", "output": "2", "explanation": "Adding two more G balls makes three in a row, which are then removed."}], "hints": ["Search over game states with breadth-first or depth-first search plus memoization; the state is the current row together with remaining hand counts.", "Only insertions next to an equal-colored ball can be useful, and identical resulting rows from different gaps need be tried once.", "Write a helper that repeatedly deletes every run of length three or more until the row is stable."], "statement": "A row of colored balls sits on a board. Each ball shows one of five colors, written as single letters `R`, `Y`, `B`, `G` or `W`. You also hold a small collection of extra balls described by a second short string.\n\nOn each move you may take one ball from your hand and slide it into the row at any gap, including both ends. After the insertion, look for runs of three or more equal neighbors. Remove every such run. The removal can join previously separated equal balls, so keep deleting newly formed runs until none remain. If the row becomes empty you have cleared the board.\n\nYour task is to use as few hand balls as possible to empty the row. Return that minimum count, or `-1` when the hand cannot finish the job.\n\n**Constraints:**\n- `1 <= board.length <= 16`\n- `1 <= hand.length <= 5`\n- Both strings use only `R`, `Y`, `B`, `G` and `W`\n- The starting row never already contains three equal neighbors in a row\n", "solution": "## Approach\n\nTreat each distinct pair of current row plus remaining hand counts as a search state. Depth-first search tries every useful insertion: a hand ball placed directly beside an equal-colored row ball. After each insertion a helper repeatedly strips runs of three or more until stable, then recursion continues. Memoization on the state keeps the branching tiny because the hand holds at most five balls. If no branch empties the row the answer is `-1`.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(S * B * H) where S is the number of reachable states, B the row length and H the hand size. With the given limits this easily fits.\n- **Space Complexity:** O(S) for the memo table and recursion stack.\n\n## Implementation\n\n```python\nfrom typing import Dict, Tuple\n\nclass Solution:\n def findMinStep(self, board: str, hand: str) -> int:\n colors = ['R', 'Y', 'B', 'G', 'W']\n cnt = [hand.count(c) for c in colors]\n memo: Dict[Tuple[str, Tuple[int, ...]], int] = {}\n\n def collapse(s: str) -> str:\n cur = s\n while True:\n nxt = []\n i = 0\n changed = False\n while i < len(cur):\n j = i\n while j < len(cur) and cur[j] == cur[i]:\n j += 1\n if j - i >= 3:\n changed = True\n else:\n nxt.append(cur[i:j])\n i = j\n cur = \"\".join(nxt)\n if not changed:\n return cur\n\n def dfs(b: str, h: Tuple[int, ...]) -> int:\n if not b:\n return 0\n key = (b, h)\n if key in memo:\n return memo[key]\n best = 100\n hlist = list(h)\n for ci, c in enumerate(colors):\n if hlist[ci] == 0:\n continue\n seen = set()\n for i in range(len(b) + 1):\n adj = (i > 0 and b[i - 1] == c) or (i < len(b) and b[i] == c)\n if not adj:\n continue\n nb = collapse(b[:i] + c + b[i:])\n if nb in seen:\n continue\n seen.add(nb)\n hlist[ci] -= 1\n sub = dfs(nb, tuple(hlist))\n hlist[ci] += 1\n if sub < 100:\n best = min(best, 1 + sub)\n memo[key] = best\n return best\n\n ans = dfs(board, tuple(cnt))\n return -1 if ans >= 100 else ans\n```\n", "starter": {"go": "package main\n\nfunc FindMinStep(board string, hand string) int {\n \n}", "python": "class Solution:\n def findMinStep(self, board: str, hand: str) -> int:\n pass\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n int findMinStep(string board, string hand) {\n return 0;\n }\n};"}, "fn": "findMinStep", "params": [{"name": "board", "type": "string"}, {"name": "hand", "type": "string"}], "outputType": "int", "tests": [["WRRBBW", "RB"], ["WWRRBBWW", "WRBRW"], ["G", "GGGGG"], ["RR", "RR"], ["R", "R"], ["R", "RR"], ["Y", "YY"], ["RB", "RB"], ["RRYBB", "RYB"], ["WW", "WW"], ["RRWW", "RW"], ["YWWY", "YW"], ["BB", "BBB"], ["RYYR", "RY"], ["WBRY", "WBRY"], ["GG", "GGG"], ["RRBB", "RB"], ["YBBR", "YBR"], ["W", "W"], ["W", "WW"], ["RW", "RRW"], ["YYRR", "YR"], ["BBRY", "BRY"], ["RBRBR", "RBB"], ["WWYWW", "YW"], ["RGBW", "RGBW"], ["RRY", "RY"], ["BWWB", "WB"]], "expected": [-1, 2, 2, 1, -1, 2, 2, -1, -1, 1, 2, 2, 1, 2, -1, 1, 2, -1, -1, 2, -1, 2, -1, -1, -1, -1, -1, 2], "loose": false}