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": "281", "slug": "unique-binary-search-trees", "id": 281, "title": "Unique Binary Search Trees", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/unique-binary-search-trees/", "examples": [{"input": "n = 3", "output": "5", "explanation": "Five distinct BST shapes exist over three ordered values."}, {"input": "n = 1", "output": "1", "explanation": "A single node forms exactly one tree."}, {"input": "n = 4", "output": "14", "explanation": "The Catalan number C4 is 14."}], "hints": ["Let dp[i] be the count for i nodes; dp[0] = dp[1] = 1.", "For i >= 2, dp[i] = sum over roots r of dp[r-1] * dp[i-r].", "Fill dp bottom-up from 2 to n."], "statement": "Count how many structurally unique binary search trees can be formed using the values `1` through `n` in order. Only the shape and the placement of values matter; two trees that differ in structure count separately even if they hold the same keys.\n\nThe total follows the Catalan recurrence: with `r` as root, the left side contributes `count(r-1)` shapes and the right side contributes `count(n-r)` shapes. Summing the product over every choice of `r` gives the answer, with `count(0) = count(1) = 1`.\n\n**Constraints:**\n- `1 <= n <= 19`\n", "solution": "## Approach\n\nCount trees with dynamic programming over the Catalan recurrence. With one node fixed as root, left and right subtree counts multiply; summing over every root choice builds larger answers from smaller ones, starting from dp[0] = dp[1] = 1.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^2) for the nested root loop.\n- **Space Complexity:** O(n) for the dp table.\n\n## Implementation\n\n```python\nclass Solution:\n def numTrees(self, n: int) -> int:\n dp = [0] * (n + 1)\n dp[0] = 1\n if n >= 1:\n dp[1] = 1\n for i in range(2, n + 1):\n total = 0\n for r in range(1, i + 1):\n total += dp[r - 1] * dp[i - r]\n dp[i] = total\n return dp[n]\n```\n", "starter": {"go": "package main\n\nfunc NumTrees(n int) int {\n return 0\n}", "python": "class Solution:\n def numTrees(self, n: int) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int numTrees(int n) {\n return 0;\n }\n};"}, "fn": "numTrees", "params": [{"name": "n", "type": "int"}], "outputType": "int", "tests": [["3"], ["1"], ["4"], ["2"], ["5"], ["6"], ["7"], ["8"], ["9"], ["10"], ["11"], ["12"], ["13"], ["14"], ["15"], ["16"], ["17"], ["18"], ["19"], ["1"], ["2"], ["3"], ["4"], ["5"], ["10"], ["15"], ["19"], ["6"], ["7"], ["8"]], "expected": [5, 1, 14, 2, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190, 1, 2, 5, 14, 42, 16796, 9694845, 1767263190, 132, 429, 1430], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "916", "slug": "unique-email-addresses", "id": 916, "title": "Unique Email Addresses", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/unique-email-addresses/", "examples": [{"input": "emails = [\"test.email+alex@leetcode.com\",\"test.e.mail+bob.cathy@leetcode.com\",\"testemail+david@lee.tcode.com\"]", "output": "2", "explanation": "The first two both become \"testemail@leetcode.com\"."}, {"input": "emails = [\"a@leetcode.com\",\"b@leetcode.com\",\"c@leetcode.com\"]", "output": "3"}, {"input": "emails = [\"test.email+alex@leetcode.com\",\"test.email.leet+alex@code.com\"]", "output": "2", "explanation": "Different domains keep them distinct."}], "hints": ["Split each address once at '@' to separate local and domain handling.", "In the local part, keep characters before '+' and drop every '.'; the domain never changes.", "Collect normalized strings in a set and return its size."], "statement": "Each email address has the form `local@domain`. The domain part is used exactly as written. The local part follows two rules: dots `'.'` are skipped entirely, and anything after the first `'+'` is discarded.\n\nTwo addresses that normalize to the same string count as one. Given a list `emails`, return how many distinct normalized addresses appear.\n\n**Constraints:**\n- `1 <= emails.length <= 100`\n- Each address contains exactly one `'@'`, lowercase letters, `'.'`, `'+'`, and digits in the local part.\n", "solution": "## Approach\n\nNormalize each address separately. Split at `'@'`, cut the local part at the first `'+'`, delete every `'.'`, then reattach the domain. Insert each normalized form into a hash set and return its size.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m), where m is the total number of characters across all emails. Each address is scanned once.\n- **Space Complexity:** O(m) for the normalized strings in the set.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def numUniqueEmails(self, emails: List[str]) -> int:\n seen = set()\n for e in emails:\n local, domain = e.split('@', 1)\n local = local.split('+', 1)[0].replace('.', '')\n seen.add(local + '@' + domain)\n return len(seen)\n```\n", "starter": {"go": "package main\n\nfunc NumUniqueEmails(emails []string) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def numUniqueEmails(self, emails: List[str]) -> int:\n pass", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n int numUniqueEmails(vector<string>& emails) {\n return 0;\n }\n};"}, "fn": "numUniqueEmails", "params": [{"name": "emails", "type": "string_array"}], "outputType": "int", "tests": [["['test.email+alex@leetcode.com', 'test.e.mail+bob.cathy@leetcode.com', 'testemail+david@lee.tcode.com']"], ["['a@leetcode.com', 'b@leetcode.com', 'c@leetcode.com']"], ["['test.email+alex@leetcode.com', 'test.email.leet+alex@code.com']"], ["['a@b.com']"], ["['a+b@b.com', 'a@b.com']"], ["['a.b@b.com', 'ab@b.com']"], ["['a.b+c@b.com', 'ab@b.com']"], ["['x@y.com', 'x@y.com']"], ["['ab.cd+ef@xy.com', 'abcd@xy.com', 'ab.cd@xy.com']"], ["['foo.bar+baz@qux.com', 'foobar@qux.com']"], ["['a.a.a@x.com', 'aaa@x.com']"], ["['a+a+a@x.com', 'a@x.com']"], ["['m.y+name@email.com', 'my@email.com', 'my+spam@email.com']"], ["['test@leetcode.com', 'test@lee.tcode.com']"], ["['a@b.com', 'a+b@b.com', 'a.b@b.com', 'a.b+c@b.com']"], ["['z@z.com', 'z.+1@z.com']"], ["['123+456@789.com', '123@789.com']"], ["['a.b.c.d@x.com', 'abcd@x.com']"], ["['q+w.e+r@w.com', 'qw@w.com']"], ["['u@v.com', 'u+@v.com']"], ["['dot.dot@dom.com', 'dotdot@dom.com']"], ["['plus+plus@dom.com', 'plus@dom.com']"], ["['A@b.com']"], ["['a@b.com', 'A@b.com']"], ["['first.last@x.com', 'firstlast@x.com', 'first+last@x.com']"], ["['aa@bb.com', 'aa+bb@bb.com', 'a.a@bb.com']"], ["['k.k.k+k@e.com', 'kkk@e.com']"], ["['solo@mail.com', 'solo+1@mail.com', 's.o.l.o@mail.com']"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "802", "slug": "unique-morse-code-words", "id": 802, "title": "Unique Morse Code Words", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/unique-morse-code-words/", "examples": [{"input": "words = [\"gin\",\"zen\",\"gig\",\"msg\"]", "output": "2", "explanation": "Two distinct Morse strings occur."}, {"input": "words = [\"a\"]", "output": "1", "explanation": "One word gives one encoding."}, {"input": "words = [\"abc\",\"def\",\"ghi\"]", "output": "3", "explanation": "All encodings differ."}], "hints": ["Store the 26 letter codes in an array indexed by character offset from 'a'.", "Build each word encoding with a string builder and insert it into a hash set.", "The set size is the answer."], "statement": "International Morse code maps each lowercase letter to a sequence of dots and dashes. The table begins `a -> .-`, `b -> -...`, `c -> -.-.`, and continues through `z -> --..` in the usual order.\n\nThe encoding of a whole word is formed by replacing every letter with its code and joining the pieces without separators. Given a list of words, determine how many distinct encodings appear.\n\n**Constraints:**\n- `1 <= words.length <= 100`\n- `1 <= words[i].length <= 12`\n- Each word contains only lowercase English letters\n", "solution": "## Approach\n\nLook up each letter in the fixed 26-entry Morse table and concatenate the codes for a word. Insert every word encoding into a hash set; distinct dot-dash strings collapse automatically and the set size is the required count.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(S), where S is the total number of characters across all words.\n- **Space Complexity:** O(S) for the encoded strings in the set.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def uniqueMorseRepresentations(self, words: List[str]) -> int:\n morse = [\".-\",\"-...\",\"-.-.\",\"-..\",\".\",\"..-.\",\"--.\",\"....\",\"..\",\".---\",\"-.-\",\".-..\",\"--\",\"-.\",\"---\",\".--.\",\"--.-\",\".-.\",\"...\",\"-\",\"..-\",\"...-\",\".--\",\"-..-\",\"-.--\",\"--..\"]\n return len({''.join(morse[ord(c) - 97] for c in w) for w in words})\n```\n", "starter": {"go": "package main\n\nfunc UniqueMorseRepresentations(words []string) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def uniqueMorseRepresentations(self, words: List[str]) -> int:\n return 0", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n int uniqueMorseRepresentations(vector<string>& words) {\n return 0;\n }\n};"}, "fn": "uniqueMorseRepresentations", "params": [{"name": "words", "type": "string_array"}], "outputType": "int", "tests": [["[\"gin\", \"zen\", \"gig\", \"msg\"]"], ["[\"a\"]"], ["[\"abc\", \"def\", \"ghi\"]"], ["[\"a\", \"b\", \"c\"]"], ["[\"aa\", \"bb\", \"aa\"]"], ["[\"hello\", \"world\"]"], ["[\"a\", \"a\", \"a\"]"], ["[\"gin\", \"gin\", \"gin\"]"], ["[\"zen\", \"zen\", \"gig\"]"], ["[\"abc\", \"abc\", \"def\"]"], ["[\"sos\", \"sos\", \"sos\"]"], ["[\"a\", \"b\"]"], ["[\"z\"]"], ["[\"abcdefghijklmnopqrstuvwxyz\"]"], ["[\"a\", \"aa\", \"aaa\"]"], ["[\"et\", \"ae\"]"], ["[\"rwj\", \"rwj\", \"rwj\", \"rwj\"]"], ["[\"hello\", \"hello\", \"world\", \"world\"]"], ["[\"abc\", \"cba\"]"], ["[\"qwerty\", \"asdf\", \"zxcv\"]"], ["[\"a\", \"e\", \"i\", \"o\", \"u\"]"], ["[\"gin\", \"zen\"]"], ["[\"gig\", \"msg\"]"], ["[\"test\", \"test\", \"test\", \"best\"]"], ["[\"abcdefghijkl\", \"bcdefghijklm\"]"], ["[\"morse\", \"code\", \"words\"]"], ["[\"a\", \"am\", \"ami\"]"], ["[\"zz\", \"yy\", \"xx\"]"]], "expected": [2, 1, 3, 3, 2, 2, 1, 1, 2, 2, 1, 2, 1, 1, 3, 2, 1, 2, 2, 3, 5, 1, 1, 2, 2, 3, 3, 3], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "231", "slug": "unique-paths-ii", "id": 231, "title": "Unique Paths II", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/unique-paths-ii/", "examples": [{"input": "obstacleGrid = [[0,0,0],[0,1,0],[0,0,0]]", "output": "2", "explanation": "There is one obstacle in the middle of the 3x3 grid above. There are two ways to reach the bottom-right corner: Right -> Right -> Down -> Down and Down -> Down -> Right -> Right."}, {"input": "obstacleGrid = [[0,1],[0,0]]", "output": "1", "explanation": ""}], "hints": ["Use dynamic programming since, from each cell, you can move to the right or down.", "Assume dp[i][j] is the number of unique paths to reach (i, j). dp[i][j] = dp[i][j - 1] + dp[i - 1][j]. Be careful when you encounter an obstacle; set its value in dp to 0."], "statement": "An `m x n` integer board named `grid` holds an automaton that begins in the upper-left cell (`grid[0][0]`) and aims for the lower-right cell (`grid[m - 1][n - 1]`). At each step the automaton may advance only downward or rightward.\n\nCells of `grid` hold `1` for a blocked cell and `0` for a free cell. No traveled route may pass through a blocked cell.\n\nCount how many distinct admissible routes reach the destination.\n\nThe test data is constructed so the count never exceeds `2 * 10^9`.\n\n**Constraints:**\n- m == obstacleGrid.length\n- n == obstacleGrid[i].length\n- 1 \u2264 m, n \u2264 100\n- obstacleGrid[i][j] is 0 or 1.\n", "solution": "## Approach\n\nUse 2D dynamic programming. Let `dp[i][j]` be the number of unique paths to reach cell `(i, j)`. Since the robot can only move down or right, `dp[i][j] = dp[i][j - 1] + dp[i - 1][j]`. If a cell is an obstacle (`obstacleGrid[i][j] == 1`), set `dp[i][j] = 0`. If the start cell itself is an obstacle, the answer is 0.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m * n), visiting each cell once.\n- **Space Complexity:** O(m * n) for the dp table (can be reduced to O(n) with a single row).\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def uniquePathsWithObstacles(self, obstacleGrid: List[List[int]]) -> int:\n m, n = len(obstacleGrid), len(obstacleGrid[0])\n if obstacleGrid[0][0] == 1:\n return 0\n dp = [[0] * n for _ in range(m)]\n dp[0][0] = 1\n for i in range(m):\n for j in range(n):\n if i == 0 and j == 0:\n continue\n if obstacleGrid[i][j] == 1:\n dp[i][j] = 0\n else:\n dp[i][j] = (dp[i - 1][j] if i > 0 else 0) + (dp[i][j - 1] if j > 0 else 0)\n return dp[m - 1][n - 1]\n```", "starter": {"go": "package main\n\nfunc UniquePathsWithObstacles(obstacleGrid [][]int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def uniquePathsWithObstacles(self, obstacleGrid: List[List[int]]) -> int:\n ", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {\n \n }\n};"}, "fn": "uniquePathsWithObstacles", "params": [{"name": "obstacleGrid", "type": "int_array_2d"}], "outputType": "int", "tests": [["[[0,0,0],[0,1,0],[0,0,0]]"], ["[[0,1],[0,0]]"], ["[[0,0]]"], ["[[1]]"], ["[[0]]"], ["[[1,0]]"], ["[[0],[0]]"], ["[[0,0],[0,0]]"], ["[[0,1,0],[0,0,1]]"], ["[[1,0,0],[0,1,0],[0,0,0]]"], ["[[0,0,1],[1,0,0],[0,0,0]]"], ["[[0,0,0,0],[0,0,0,0],[0,0,0,0]]"], ["[[0,0],[1,1],[0,0]]"], ["[[0,0,1,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0]]"], ["[[0,0,0],[0,0,0],[0,0,0]]"], ["[[0,0,0,0]]"], ["[[0],[0],[0]]"], ["[[1,1],[1,1]]"], ["[[0,0],[0,1]]"], ["[[1,1,1],[1,1,1]]"], ["[[0,0,0],[0,0,1]]"], ["[[0,0,0],[1,0,0],[0,0,0]]"], ["[[0,1,0,0],[0,0,0,1],[0,0,0,0]]"], ["[[0,0],[0,0],[0,0],[0,0]]"], ["[[0,1],[1,0]]"], ["[[1,0,0,0],[0,0,0,0]]"], ["[[0,0,1,1],[0,0,0,0]]"], ["[[0],[1]]"], ["[[1],[0]]"], ["[[0,1,0],[0,0,0],[0,0,0]]"]], "expected": [2, 1, 1, 0, 1, 0, 1, 2, 0, 0, 2, 10, 0, 11, 6, 1, 1, 0, 0, 0, 0, 3, 3, 4, 0, 0, 2, 0, 0, 3], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "964", "slug": "unique-paths-iii", "id": 964, "title": "Unique Paths III", "difficulty": "Hard", "category": "matrix", "link": "https://leetcode.com/problems/unique-paths-iii/", "examples": [{"input": "grid = [[1,0,0,0],[0,0,0,0],[0,0,2,-1]]", "output": "2", "explanation": "Two walks start at 1, step on every open cell exactly once, and finish at 2."}, {"input": "grid = [[1,0,0,0],[0,0,0,0],[0,0,0,2]]", "output": "4", "explanation": "Four covering walks exist on this obstacle-free board."}, {"input": "grid = [[0,1],[1,0]]", "output": "0", "explanation": "No walk can both cover every open cell and end at the target."}], "hints": ["Count how many non-obstacle cells must be visited; a valid walk visits exactly that many cells including start and end.", "Depth-first search with backtracking from the start cell, marking cells visited and unmarking on return.", "When the search reaches the end cell, count it only if every open cell has been stepped on."], "statement": "A grid contains `1` (start), `2` (finish), `0` (open), and `-1` (blocked). From the start cell, move up, down, left, or right one step at a time without leaving the grid or entering blocked cells.\n\nA valid walk must step on every non-blocked cell exactly once and finish on the `2` cell. Count such walks.\n\n**Constraints:**\n- `1 <= grid.length, grid[0].length <= 20`\n- Values are only `-1`, `0`, `1`, or `2`.\n- Exactly one `1` and one `2` appear.\n", "solution": "## Approach\n\nCount all non-blocked cells to know the required walk length. Then run depth-first search with backtracking from the start: temporarily mark each entered open cell as blocked, explore the four neighbors, and restore the mark on return. Reaching the finish cell counts one valid walk only when the visited count equals the total open-cell count, which enforces the exactly-once covering rule.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(3^k), where k is the number of open cells. Each step has at most three fresh neighbors.\n- **Space Complexity:** O(k) for recursion depth and the grid copy.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def uniquePathsIII(self, grid: List[List[int]]) -> int:\n R, C = len(grid), len(grid[0])\n total = sum(1 for i in range(R) for j in range(C) if grid[i][j] != -1)\n sx = sy = -1\n for i in range(R):\n for j in range(C):\n if grid[i][j] == 1:\n sx, sy = i, j\n self.ans = 0\n def dfs(x, y, vis):\n if not (0 <= x < R and 0 <= y < C) or grid[x][y] == -1:\n return\n if grid[x][y] == 2:\n if vis == total:\n self.ans += 1\n return\n saved = grid[x][y]\n grid[x][y] = -1\n dfs(x + 1, y, vis + 1)\n dfs(x - 1, y, vis + 1)\n dfs(x, y + 1, vis + 1)\n dfs(x, y - 1, vis + 1)\n grid[x][y] = saved\n dfs(sx, sy, 1)\n return self.ans\n```\n", "starter": {"go": "package main\n\nfunc UniquePathsIII(grid [][]int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def uniquePathsIII(self, grid: List[List[int]]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int uniquePathsIII(vector<vector<int>>& grid) {\n return 0;\n }\n};"}, "fn": "uniquePathsIII", "params": [{"name": "grid", "type": "int_array_2d"}], "outputType": "int", "tests": [["[[1,0,0,0],[0,0,0,0],[0,0,2,-1]]"], ["[[1,0,0,0],[0,0,0,0],[0,0,0,2]]"], ["[[0,1],[1,0]]"], ["[[1,2]]"], ["[[1,0,2]]"], ["[[1,-1,2]]"], ["[[1,0],[0,2]]"], ["[[1,0,0],[0,0,2]]"], ["[[1,0,0],[0,-1,2]]"], ["[[1,0,2],[0,0,0]]"], ["[[1,-1],[2,0]]"], ["[[1,0,0,2]]"], ["[[1,0],[2,0]]"], ["[[2,0],[0,1]]"], ["[[1,0,0,0,2]]"], ["[[1],[0],[2]]"], ["[[1],[-1],[2]]"], ["[[1,0,-1],[0,0,2]]"], ["[[0,0,0],[0,1,0],[0,0,2]]"], ["[[1,0,0],[0,0,0],[0,0,2]]"], ["[[1,-1,0],[0,0,2]]"], ["[[1,0],[0,0],[0,2]]"], ["[[1,2],[0,0]]"], ["[[1,0,0],[2,0,0]]"], ["[[1,0,-1,2]]"], ["[[1,0,0],[0,2,-1]]"], ["[[1,0],[0,-1],[0,2]]"], ["[[1,0,0,0],[0,-1,0,2]]"]], "expected": [2, 4, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 2, 2, 0, 1, 1, 1, 0, 0, 0, 0], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "25", "slug": "unique-paths", "id": 25, "title": "Unique Paths", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/unique-paths/", "examples": [{"input": "m=3, n=7", "output": "28", "explanation": "There are 28 unique paths on a 3x7 grid."}], "hints": ["Combinatorics: C(m+n-2, m-1)."], "statement": "Imagine an automaton placed on an m by n board that may advance solely toward the right or downward. Determine how many distinct routes carry it from the upper-left cell to the lower-right cell.\n\n**Constraints:**\n- `1 <= m, n <= 100`\n- The test cases are generated so that the answer will be less than or equal to `2 * 10^9`.\n", "solution": "## Approach\n\nUse 1D dynamic programming where dp[j] represents the number of paths to cell (i, j). Each cell is reachable from the top and left, so dp[j] = dp[j] + dp[j-1].\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m\u00d7n)\n- **Space Complexity:** O(n)\n\n## Implementation\n\n```python\nclass Solution:\n def uniquePaths(self, m: int, n: int) -> int:\n k = min(m - 1, n - 1)\n a = m + n - 2\n MASK64 = 0xFFFFFFFFFFFFFFFF\n res = 1\n for i in range(1, k + 1):\n res = (res * (a - k + i)) & MASK64\n if res >= 0x8000000000000000:\n res -= 0x10000000000000000\n res = res // i if res >= 0 else -(-res // i)\n res &= 0xFFFFFFFF\n return res if res < 0x80000000 else res - 0x100000000\n```\n", "starter": {"go": "package main\n\nfunc UniquePaths(m int, n int) int {\n \n}", "python": "class Solution:\n def uniquePaths(self, m: int, n: int) -> int:\n pass\n", "cpp": "class Solution {\npublic:\n int uniquePaths(int m, int n) {\n return 0;\n }\n};"}, "fn": "uniquePaths", "params": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}], "outputType": "int", "tests": [["3", "7"], ["3", "2"], ["7", "3"], ["3", "3"], ["100", "7"], ["1", "1"], ["1", "2"], ["2", "1"], ["1", "100"], ["100", "1"], ["2", "2"], ["2", "3"], ["3", "4"], ["4", "4"], ["5", "5"], ["10", "10"], ["3", "5"], ["5", "3"], ["4", "7"], ["7", "4"], ["2", "100"], ["15", "15"], ["10", "20"], ["10", "5"], ["5", "10"], ["23", "12"], ["12", "23"], ["18", "18"], ["19", "13"], ["13", "19"]], "expected": [28, 3, 28, 6, 1609344100, 1, 1, 1, 1, 1, 2, 3, 10, 20, 70, 48620, 15, 15, 84, 84, 100, 40116600, 6906900, 715, 715, 193536720, 193536720, -1961361076, 86493225, 86493225], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "532", "slug": "unique-substrings-in-wraparound-string", "id": 532, "title": "Unique Substrings in Wraparound String", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/unique-substrings-in-wraparound-string/", "examples": [{"input": "s = \"a\"", "output": "1", "explanation": "The only substring \"a\" appears in the wraparound string."}, {"input": "s = \"cac\"", "output": "2", "explanation": "The distinct substrings present are \"a\" and \"c\"; \"ca\", \"ac\" and \"cac\" never occur consecutively in the wrap."}, {"input": "s = \"zab\"", "output": "6", "explanation": "Every substring of \"zab\" occurs in the wrap: \"z\", \"a\", \"b\", \"za\", \"ab\", \"zab\"."}], "hints": ["For each letter, only the longest valid run ending with that letter matters: it contributes exactly that many new distinct substrings.", "Extend the current consecutive run when each new character follows the previous one in the alphabet (wrapping from z to a)."], "statement": "Consider the endless wraparound string `\"...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc...\"` formed by repeating the alphabet forever.\n\nYou are given a string `s`. Count how many distinct non-empty substrings of `s` also appear somewhere in that endless wraparound string. A substring is a block of consecutive characters of `s`.\n\n**Constraints:**\n- `1 <= s.length <= 10^5`\n- `s` consists of lowercase English letters.\n", "solution": "## Approach\n\nSweep through `s` while tracking the length of the current alphabet-consecutive run (where each character follows the previous one, wrapping from `z` to `a`). For every position, all run suffixes ending there are valid wraparound substrings, but to avoid double counting keep, per letter, only the longest run ever seen ending with it: a run of length `L` ending in some letter contributes exactly `L` distinct substrings for that letter. Summing the 26 best values gives the answer.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), one pass over the string.\n- **Space Complexity:** O(1), just the 26 counters.\n\n## Implementation\n\n```python\nclass Solution:\n def findSubstringInWraproundString(self, s: str) -> int:\n best = [0] * 26\n run = 0\n for i, ch in enumerate(s):\n if i > 0 and (ord(ch) - ord(s[i - 1])) % 26 == 1:\n run += 1\n else:\n run = 1\n c = ord(ch) - ord(\"a\")\n if run > best[c]:\n best[c] = run\n return sum(best)\n```\n", "starter": {"go": "package main\n\nfunc FindSubstringInWraproundString(s string) int {\n \n}", "python": "class Solution:\n def findSubstringInWraproundString(self, s: str) -> int:\n pass", "cpp": "#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n int findSubstringInWraproundString(string s) {\n return 0;\n }\n};"}, "fn": "findSubstringInWraproundString", "params": [{"name": "s", "type": "string"}], "outputType": "int", "tests": [["a"], ["cac"], ["zab"], ["abcd"], ["aaaa"], ["abab"], ["cdefg"], ["xyzab"], ["abczab"], ["abcdefghijklmnopqrstuvwxyz"], ["aab"], ["zabzab"], ["@javascript:\"ab\".repeat(50000)"], ["b"], ["z"], ["abc"], ["xyz"], ["ababa"], ["cde"], ["vwxyz"], ["abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"], ["aaaaab"], ["zyx"], ["zabcde"], ["qrstuv"], ["mnopqr"], ["abcdefz"], ["bcdabc"], ["xyzxyz"], ["c"]], "expected": [1, 2, 6, 10, 1, 3, 15, 15, 9, 351, 3, 6, 3, 1, 1, 6, 6, 3, 6, 15, 1027, 3, 3, 21, 21, 21, 22, 9, 6, 1], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "384", "slug": "unique-word-abbreviation", "id": 384, "title": "Unique Word Abbreviation", "difficulty": "Medium", "category": "string", "link": "https://leetcode.com/problems/unique-word-abbreviation/", "examples": [{"input": "dictionary = [\"deer\",\"door\",\"cake\",\"card\"], words = [\"dear\",\"cart\",\"cane\"]", "output": "[0,1,0]", "explanation": "dear shares d2r with deer/door (0); cart has fresh c2t (1); cane shares c2e with cake (0)."}, {"input": "dictionary = [\"hello\"], words = [\"hello\",\"hallo\"]", "output": "[1,0]", "explanation": "hello alone keeps h3o unique; hallo collides with it."}, {"input": "dictionary = [\"it\",\"bit\"], words = [\"hit\"]", "output": "[1]", "explanation": "h1t appears in no dictionary word."}], "hints": ["Adaptation: the ValidWordAbbr class is replaced by checkAbbr(dictionary, words) answering many queries at once (1 unique, 0 otherwise).", "Abbreviate as first letter + (length-2) + last letter; words of length <= 2 map to themselves.", "A query is unique when its abbreviation is absent, or the only dictionary word with it equals the query."], "statement": "Decide whether query words have unique abbreviations against a dictionary.\n\nAbbreviate a word as its first letter, then the count of middle letters,\nthen its last letter (for example `deer` becomes `d2r`); words of length 2\nor less abbreviate to themselves. A query is unique when no dictionary word\nshares its abbreviation, or every dictionary word sharing it equals the\nquery itself.\n\n**Adaptation:** instead of a `ValidWordAbbr` class with `isUnique`, implement\n`checkAbbr(dictionary, words)` returning an array with `1` for unique and\n`0` otherwise, one entry per query.\n\n**Constraints:**\n- `1 <= dictionary.length, words.length <= 100`\n- Words are lowercase letters.\n", "solution": "## Approach\n\nGroup dictionary words by abbreviation. For each query compute its abbreviation: if the group is missing, answer 1; if the group holds exactly the query word, answer 1; otherwise answer 0.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(D * L + Q * L) for dictionary and query lengths.\n- **Space Complexity:** O(D * L) for the map.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def checkAbbr(self, dictionary: List[str], words: List[str]) -> List[int]:\n def abbr(w: str) -> str:\n if len(w) <= 2:\n return w\n return f\"{w[0]}{len(w) - 2}{w[-1]}\"\n groups: dict[str, set[str]] = {}\n for w in dictionary:\n groups.setdefault(abbr(w), set()).add(w)\n ans = []\n for q in words:\n a = abbr(q)\n if a not in groups:\n ans.append(1)\n else:\n s = groups[a]\n ans.append(1 if len(s) == 1 and q in s else 0)\n return ans\n```\n", "starter": {"go": "package main\n\nfunc CheckAbbr(dictionary []string, words []string) []int {\n return []int{}\n}", "python": "from typing import List\nclass Solution:\n def checkAbbr(self, dictionary: List[str], words: List[str]) -> List[int]:\n return []", "cpp": "#include <string>\n#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<int> checkAbbr(vector<string>& dictionary, vector<string>& words) {\n return {};\n }\n};"}, "fn": "checkAbbr", "params": [{"name": "dictionary", "type": "string_array"}, {"name": "words", "type": "string_array"}], "outputType": "int_array", "tests": [["[\"deer\",\"door\",\"cake\",\"card\"]", "[\"dear\",\"cart\",\"cane\",\"make\",\"cake\"]"], ["[\"hello\"]", "[\"hello\",\"hallo\"]"], ["[\"it\",\"bit\"]", "[\"hit\",\"it\",\"bit\"]"], ["[\"a\",\"b\"]", "[\"a\",\"c\"]"], ["[\"dog\"]", "[\"dog\",\"dig\",\"dpg\"]"], ["[\"deer\",\"door\"]", "[\"dear\",\"deer\",\"door\"]"], ["[\"abc\",\"abb\"]", "[\"abc\",\"acc\"]"], ["[\"it\"]", "[\"it\"]"], ["[]", "[\"hello\"]"], ["[\"hello\",\"hallo\"]", "[\"hello\",\"hallo\"]"], ["[\"word\",\"ward\",\"world\"]", "[\"word\",\"would\"]"], ["[\"aa\",\"aaa\"]", "[\"aa\",\"aaa\",\"aaaa\"]"], ["[\"ab\",\"ba\"]", "[\"ab\",\"ac\"]"], ["[\"a\"]", "[\"b\"]"], ["[\" Hall\",\"hall\"]", "[\"hall\"]"], ["[\"cat\",\"car\"]", "[\"cat\",\"can\"]"], ["[\"collide\"]", "[\"collide\",\"connect\"]"], ["[\"a\",\"ab\",\"abc\"]", "[\"a\",\"ab\",\"abcd\"]"], ["[\"test\",\"text\"]", "[\"test\",\"best\"]"], ["[\"foo\"]", "[\"bar\",\"foo\",\"fox\"]"], ["[\"apple\",\"apply\"]", "[\"apple\",\"apply\",\"ample\"]"], ["[\"it\",\"is\"]", "[\"it\",\"as\",\"us\"]"], ["[\"word\"]", "[\"word\",\"world\"]"], ["[\"abcd\",\"abce\"]", "[\"abce\",\"abcf\"]"], ["[\"same\",\"same\"]", "[\"same\",\"some\"]"], ["[\"hello\",\"world\"]", "[\"helloworld\",\"hello\"]"], ["[\"ab\",\"ac\",\"ad\"]", "[\"ab\",\"ae\"]"], ["[\"foo\",\"bar\",\"baz\"]", "[\"fox\",\"box\",\"bar\"]"], ["[\"kite\",\"kit\"]", "[\"kite\",\"kat\"]"], ["[\"dog\",\"cat\"]", "[\"dag\",\"cot\",\"cog\"]"]], "expected": [[0, 1, 0, 1, 1], [1, 0], [1, 1, 1], [1, 1], [1, 0, 0], [0, 0, 0], [1, 0], [1], [1], [0, 0], [0, 0], [1, 1, 1], [1, 1], [1], [1], [1, 1], [1, 1], [1, 1, 1], [0, 1], [1, 1, 1], [1, 1, 0], [1, 1, 1], [1, 1], [1, 1], [1, 0], [1, 1], [1, 1], [1, 1, 1], [1, 0], [0, 0, 1]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "951", "slug": "univalued-binary-tree", "id": 951, "title": "Univalued Binary Tree", "difficulty": "Easy", "category": "tree", "link": "https://leetcode.com/problems/univalued-binary-tree/", "examples": [{"input": "root = [1,1,1,1,1,null,1]", "output": "true", "explanation": "Every node present in the tree carries the value 1."}, {"input": "root = [1,1,1,1,1,null,2]", "output": "false", "explanation": "The rightmost leaf holds a 2 while the rest hold 1, so the tree is not univalued."}, {"input": "root = [1]", "output": "true", "explanation": "A single node is trivially uniform."}], "hints": ["Compare every node's value against the root's value.", "Either a recursive walk or an explicit stack works; stop at the first mismatch."], "statement": "A binary tree is univalued when every node in it stores the same value. Given the level-order serialization `root`, return whether the described tree is univalued. An empty tree counts as univalued.\n\n**Constraints:**\n- The tree holds between 0 and 100 nodes.\n- Node values are integers fitting in a 32-bit signed range.\n", "solution": "## Approach\n\nRemember the root's value, then visit every node (depth-first with an explicit stack) and compare. The first mismatch disqualifies the tree; surviving the whole walk proves uniformity. Empty trees pass at once.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) for n nodes.\n- **Space Complexity:** O(h) stack space for height h.\n\n## Implementation\n\n```python\nclass Solution:\n def isUnivalTree(self, root) -> bool:\n if root is None:\n return True\n stack = [root]\n while stack:\n cur = stack.pop()\n if cur.val != root.val:\n return False\n if cur.left is not None:\n stack.append(cur.left)\n if cur.right is not None:\n stack.append(cur.right)\n return True\n```\n", "starter": {"go": "// Definition for a binary tree node.\n// type TreeNode struct {\n// Val int\n// Left *TreeNode\n// Right *TreeNode\n// }\npackage main\n\nfunc IsUnivalTree(root *TreeNode) bool {\n return false\n}", "python": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, val=0, left=None, right=None):\n# self.val = val\n# self.left = left\n# self.right = right\nclass Solution:\n def isUnivalTree(self, root) -> bool:\n return False", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\n#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n bool isUnivalTree(TreeNode* root) {\n return false;\n }\n};"}, "fn": "isUnivalTree", "params": [{"name": "root", "type": "tree_node"}], "outputType": "boolean", "tests": [["[1,1,1,1,1,null,1]"], ["[1,1,1,1,1,null,2]"], ["[1]"], ["[]"], ["[5,5,5,5,5,5,5]"], ["[5,5,5,5,4,5,5]"], ["[0]"], ["[2,2,2,5,2]"], ["[9,9,9,9,9,9,9,9,9]"], ["[1,1,2]"], ["[3,3,3,null,3]"], ["[4,4,null,4]"], ["[7,7,7,7,null,null,7]"], ["[1,2,1]"], ["[6,6,6,6,6,6,null]"], ["[8,8,8,8,8]"], ["[0,0,0,0,0,0,0,1]"], ["[100,100,100]"], ["[1,1,1,null,null,1,1]"], ["[2,2,null,2,2]"], ["[5,1,5,5,5]"], ["[9,9,null,9,9,9,9]"], ["[3,3,3,3,3,null,3,3]"], ["[1,1,1,1,1,1,1,1,1,1]"], ["[4,4,4,4,5]"], ["[6,null,6]"], ["[7,null,8]"], ["[10,10,10,10,10,10,10,10,10,10,10]"]], "expected": [true, false, true, true, true, false, true, false, true, false, true, true, true, false, true, true, false, true, true, true, false, true, true, true, false, true, false, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "469", "slug": "utf-8-validation", "id": 469, "title": "UTF-8 Validation", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/utf-8-validation/", "examples": [{"explanation": "11000101 10000010 00000001: a two-byte symbol plus a one-byte symbol.", "input": "data = [197,130,1]", "output": "true"}, {"explanation": "The third byte 00000100 does not start with 10, breaking the symbol.", "input": "data = [235,140,4]", "output": "false"}, {"explanation": "11111111 has eight leading ones, which starts no valid symbol.", "input": "data = [255]", "output": "false"}], "hints": ["Examine only the low 8 bits of each integer.", "Count leading ones of a symbol start to learn how many trailing bytes to demand.", "Each trailing byte must have the form 10xxxxxx; a lone 10xxxxxx or a 11111xxx start fails."], "statement": "An integer array `data` claims to hold a UTF-8 byte stream, one byte per entry (only the lowest eight bits of each integer matter). Multi-byte symbols follow a fixed prefix scheme:\n\n- a single-byte symbol starts with bit `0`;\n- a symbol using `k` bytes (`2 <= k <= 4`) starts with `k` one-bits followed by a zero bit, and each of its `k - 1` trailing bytes starts with bits `10`;\n- the patterns `10xxxxxx` never start a symbol, and a leading run of five or more ones never starts one.\n\nCheck the whole array from left to right and return `true` exactly when it splits into valid symbols with no bytes left over.\n\n**Constraints:**\n- `1 <= data.length <= 2 * 10^4`\n- `0 <= data[i] <= 255`\n", "solution": "## Approach\n\nWalk the bytes left to right, counting how many continuation bytes the current symbol still needs. A zero expectation means a new symbol starts: count its leading ones to learn the total length, rejecting a lone continuation prefix or a run longer than four. Otherwise the byte must carry the `10` prefix and decrement the debt. The stream is valid when no debt remains at the end.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the number of entries.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def validUtf8(self, data: List[int]) -> bool:\n need = 0\n for v in data:\n b = v & 0xFF\n if need == 0:\n if b >> 7 == 0:\n continue\n ones = 0\n bit = 7\n while bit >= 0 and (b >> bit) & 1:\n ones += 1\n bit -= 1\n if ones == 1 or ones > 4:\n return False\n need = ones - 1\n else:\n if b >> 6 != 0b10:\n return False\n need -= 1\n return need == 0\n```\n", "starter": {"go": "package main\n\nfunc ValidUtf8(data []int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def validUtf8(self, data: List[int]) -> bool:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool validUtf8(vector<int>& data) {\n return false;\n }\n};"}, "fn": "validUtf8", "params": [{"name": "data", "type": "int_array"}], "outputType": "boolean", "tests": [["[197,130,1]"], ["[235,140,4]"], ["[255]"], ["[0]"], ["[127]"], ["[128]"], ["[192,128]"], ["[194,128]"], ["[224,160,128]"], ["[240,144,128,128]"], ["[255,255,255,255]"], ["[145]"], ["[230,136,145]"], ["[39,191,50]"], ["[197,130,1,197,130,1]"], ["[240,162,138,147]"], ["[248,130,130,130]"], ["[238,130]"], ["[224,160]"], ["[240,144,128]"], ["[0,0,0]"], ["[127,127,127]"], ["[226,130,172]"], ["[237,160,128]"], ["[237,191,191]"], ["[244,144,128,128]"], ["[245,144,128,128]"], ["[192,191]"], ["[224,191,191]"], ["[240,191,191,191]"]], "expected": [true, false, false, true, true, false, true, true, true, true, false, false, true, false, true, true, false, false, false, false, true, true, true, true, true, true, true, true, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "53", "slug": "valid-anagram", "id": 53, "title": "Valid Anagram", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/valid-anagram/", "examples": [{"input": "s=\"anagram\", t=\"nagaram\"", "output": "true", "explanation": "Both \"anagram\" and \"nagaram\" contain the same characters with identical frequencies, so they are anagrams."}, {"input": "s=\"rat\", t=\"car\"", "output": "false", "explanation": "Character frequency counts differ between \"rat\" and \"car\", so they are not anagrams."}], "hints": ["Count character frequencies and compare, or sort both strings and compare equality."], "statement": "Take two strings, `s` and `t`. Report `true` when `t` rearranges the letters of `s`, and `false` otherwise.\n\n**Constraints:**\n\n- 1 \u2264 s.length, t.length \u2264 5 * 10^4\n- s and t consist of lowercase English letters.\n", "solution": "## Approach\n\nCompare character frequency counts of both strings \u2014 anagrams must have identical counts.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n)\n- **Space Complexity:** O(1)\n\n## Implementation\n\n```python\nfrom collections import Counter\nclass Solution:\n def isAnagram(self, s: str, t: str) -> bool:\n return Counter(s) == Counter(t)\n```\n", "starter": {"go": "package main\n\nfunc IsAnagram(s string, t string) bool {\n \n}", "python": "class Solution:\n def isAnagram(self, s: str, t: str) -> bool:\n pass\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool isAnagram(string s, string t) {\n return false;\n }\n};"}, "fn": "isAnagram", "params": [{"name": "s", "type": "string"}, {"name": "t", "type": "string"}], "outputType": "boolean", "tests": [["anagram", "nagaram"], ["rat", "car"], ["ab", "aa"], ["a", "a"], ["ab", "ba"], ["a", "b"], ["aa", "aa"], ["abc", "cba"], ["aab", "aba"], ["abcd", "abce"], ["listen", "silent"], ["triangle", "integral"], ["aacc", "ccaa"], ["abcde", "edcba"], ["xyz", "zyx"], ["hello", "holle"], ["qwerty", "ytrewq"], ["zzzzzzzzzz", "zzzzzzzzzy"], ["abcdefghij", "jihgfedcba"], ["aabbcc", "abcabc"], ["abc", "ab"], ["ab", "abc"], ["a", "aa"], ["aa", "a"], ["abcdefghijklmnopqrstuvwxyz", "zyxwvutsrqponmlkjihgfedcba"]], "expected": [true, false, false, true, true, false, true, true, true, false, true, true, true, true, true, true, true, false, true, true, false, false, false, false, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "928", "slug": "valid-mountain-array", "id": 928, "title": "Valid Mountain Array", "difficulty": "Easy", "category": "array", "link": "https://leetcode.com/problems/valid-mountain-array/", "examples": [{"input": "arr = [2,1]", "output": "false", "explanation": "Too short for a climb plus a descent."}, {"input": "arr = [3,5,5]", "output": "false", "explanation": "Equal neighbours break strictness."}, {"input": "arr = [0,3,2,1]", "output": "true", "explanation": "Strict rise to 3 then strict fall."}], "hints": ["Walk uphill while neighbours strictly increase, then walk downhill while they strictly decrease; a single index should carry you to the end.", "Reject arrays whose climb never starts (peak at index 0) or never ends (peak at the last index)."], "statement": "Decide whether an array climbs strictly and then descends strictly, forming a single peak.\n\nA valid mountain has at least three numbers. Reading left to right, values must rise by strict steps up to one summit, then fall by strict steps after it. The summit cannot sit at either end, and flat neighbours anywhere disqualify the array.\n\nGiven an integer array `arr`, return `true` when it is a mountain and `false` otherwise.\n\n**Constraints:**\n- `1 <= arr.length <= 10^4`\n- `0 <= arr[i] <= 10^4`\n", "solution": "## Approach\n\nClimb from the left while each step goes strictly up. The stopping point is the only candidate summit: it must not be the first or the last slot. From there walk down while each step goes strictly down. The array is a mountain exactly when this downhill walk reaches the final index.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), each element is visited at most twice.\n- **Space Complexity:** O(1), only an index is stored.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def validMountainArray(self, arr: List[int]) -> bool:\n n = len(arr)\n if n < 3:\n return False\n i = 0\n while i + 1 < n and arr[i] < arr[i + 1]:\n i += 1\n if i == 0 or i == n - 1:\n return False\n while i + 1 < n and arr[i] > arr[i + 1]:\n i += 1\n return i == n - 1\n```\n", "starter": {"go": "package main\n\nfunc ValidMountainArray(arr []int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def validMountainArray(self, arr: List[int]) -> bool:\n pass", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n bool validMountainArray(vector<int>& arr) {\n return 0;\n }\n};"}, "fn": "validMountainArray", "params": [{"name": "arr", "type": "int_array"}], "outputType": "boolean", "tests": [["[2, 1]"], ["[3, 5, 5]"], ["[0, 3, 2, 1]"], ["[0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]"], ["[1, 2, 3]"], ["[3, 2, 1]"], ["[1, 3, 2]"], ["[0, 1, 2, 3, 2, 1, 0]"], ["[1, 2, 2, 1]"], ["[0, 1, 0]"], ["[1, 2, 3, 4, 5]"], ["[5, 4, 3, 2, 1]"], ["[0, 2, 0]"], ["[1, 2, 3, 2]"], ["[2, 0, 2]"], ["[0, 1, 2, 1, 2]"], ["[1, 2, 3, 4, 3, 2, 1, 0]"], ["[9, 8, 7, 6, 5, 6, 7]"], ["[0]"], ["[0, 0, 0]"], ["[1, 2, 1, 2, 1]"], ["[0, 1, 2, 3, 4, 3, 2]"], ["[4, 5, 6, 5, 4, 3, 2, 1]"], ["[1, 2, 3, 5, 4]"], ["[1, 3, 5, 4, 2]"], ["[2, 3, 4, 5, 4, 3, 2, 1, 0]"], ["[1, 2, 3, 4, 4, 3, 2, 1]"], ["[0, 1, 2, 3, 2, 1]"]], "expected": [false, false, true, true, false, false, true, true, false, true, false, false, true, true, false, false, true, false, false, false, false, true, true, true, true, true, false, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "270", "slug": "valid-number", "id": 270, "title": "Valid Number", "difficulty": "Hard", "category": "string", "link": "https://leetcode.com/problems/valid-number/", "examples": [{"input": "s = \"0\"", "output": "true", "explanation": "A single digit is a valid integer."}, {"input": "s = \"e\"", "output": "false", "explanation": "An exponent marker alone has no base digits and no exponent digits."}, {"input": "s = \"2e10\"", "output": "true", "explanation": "Base 2 followed by exponent 10 is well formed."}], "hints": ["Trim surrounding spaces first; spaces anywhere else make the string invalid.", "Split on e/E: the exponent must be a signed integer and the base must be a signed decimal with at least one digit.", "The base allows at most one dot and requires a digit on at least one side of it."], "statement": "Decide whether a string represents a valid decimal number. A valid value may include leading and trailing blanks, an optional `+`/`-` sign, digits with at most one decimal point, and an optional exponent part.\n\nThe exponent, when present, starts with `e` or `E`, optionally followed by a sign, and must end with at least one digit. The base before the exponent must contain at least one digit, either before or after the point. Blanks are allowed only at the very start or end.\n\n**Constraints:**\n- `1 <= s.length <= 20`\n- `s` consists of digits, signs, points, exponents, and spaces.\n", "solution": "## Approach\n\nStrip outer blanks, then split the remainder at most once on `e`/`E`. The tail must be a signed integer with at least one digit, while the head must be either a signed integer or a signed decimal containing exactly one dot and at least one digit somewhere. Any other character or misplaced blank fails validation.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), a few linear scans of the string.\n- **Space Complexity:** O(n) for the trimmed copy and split parts.\n\n## Implementation\n\n```python\nclass Solution:\n def isNumber(self, s: str) -> bool:\n t = s.strip()\n if not t:\n return False\n epos = -1\n for i, c in enumerate(t):\n if c in \"eE\":\n if epos != -1:\n return False\n epos = i\n def is_int(part: str) -> bool:\n if not part:\n return False\n i = 0\n if part[0] in \"+-\":\n if len(part) == 1:\n return False\n i = 1\n return all(ch.isdigit() for ch in part[i:]) and i < len(part)\n def is_dec(part: str) -> bool:\n if not part:\n return False\n i = 0\n if part[0] in \"+-\":\n if len(part) == 1:\n return False\n i = 1\n has_digit = False\n has_dot = False\n for ch in part[i:]:\n if ch == \".\":\n if has_dot:\n return False\n has_dot = True\n elif ch.isdigit():\n has_digit = True\n else:\n return False\n return has_digit and has_dot\n if epos == -1:\n return is_int(t) or is_dec(t)\n base, exp = t[:epos], t[epos + 1:]\n if not base or not exp:\n return False\n return (is_int(base) or is_dec(base)) and is_int(exp)\n```\n", "starter": {"go": "package main\n\nfunc IsNumber(s string) bool {\n return false\n}", "python": "class Solution:\n def isNumber(self, s: str) -> bool:\n return False\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool isNumber(string s) {\n return false;\n }\n};"}, "fn": "isNumber", "params": [{"name": "s", "type": "string"}], "outputType": "boolean", "tests": [["0"], ["e"], ["2e10"], [" 0.1 "], ["abc"], ["1 a"], ["2e10"], [" -90e3 "], [" 1e"], ["e3"], [" 6e-1"], [" 99e2.5 "], ["53.5e93"], [" --6 "], ["-+3"], ["95a54e53"], [".1"], ["3."], ["."], [".e1"], ["+.8"], ["-.7e+2"], ["46.e3"], [". 1"], ["0e"], ["0e0"], ["+0e-0"], ["005047e+6"], ["4e+"], [" -."], ["+E3"], ["6+1"], ["1e."], [" 005 "], ["12e+5.4"]], "expected": [true, false, true, true, false, false, true, true, false, false, true, false, true, false, false, false, true, true, false, false, true, true, true, false, false, true, true, true, false, false, false, false, false, true, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "166", "slug": "valid-palindrome-ii", "id": 166, "title": "Valid Palindrome II", "difficulty": "Easy", "category": "two-pointer", "link": "https://leetcode.com/problems/valid-palindrome-ii/", "examples": [{"input": "s = \"aba\"", "output": "true", "explanation": "\"aba\" is already a palindrome."}, {"input": "s = \"abca\"", "output": "true", "explanation": "Delete the character 'c' to get \"aba\", which is a palindrome."}, {"input": "s = \"abc\"", "output": "false", "explanation": "No single deletion makes \"abc\" a palindrome."}], "hints": ["Use two pointers from both ends; on the first mismatch try skipping either the left or the right character.", "Check whether the remaining substring is a palindrome after one skip."], "statement": "You are handed a string `s`. Decide whether removing at most one character \u2014 either none at all or exactly one at any position \u2014 can leave behind a string that reads identically forward and backward. Return `true` when the input is already mirror-symmetric or becomes so after a single deletion, and `false` otherwise.\n\n**Constraints:**\n\n- 1 \u2264 s.length \u2264 10^5\n- s consists of lowercase English letters.\n", "solution": "## Approach\n\nUse two pointers `i` at the start and `j` at the end. While the characters match, move both inward. On the first mismatch, try skipping either the left character or the right character and check whether the remaining substring is a palindrome. If either skip yields a palindrome, return true; otherwise return false.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the length of the string. Each position is visited at most twice.\n- **Space Complexity:** O(1). Only two pointers and constant extra state are used.\n\n## Implementation\n\n```python\nclass Solution:\n def validPalindrome(self, s: str) -> bool:\n def is_pal(i: int, j: int) -> bool:\n while i < j:\n if s[i] != s[j]:\n return False\n i += 1\n j -= 1\n return True\n i, j = 0, len(s) - 1\n while i < j:\n if s[i] != s[j]:\n return is_pal(i + 1, j) or is_pal(i, j - 1)\n i += 1\n j -= 1\n return True\n```\n", "starter": {"go": "package main\n\nfunc ValidPalindrome(s string) bool {\n return false\n}", "python": "class Solution:\n def validPalindrome(self, s: str) -> bool:\n return False\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool validPalindrome(string s) {\n return false;\n }\n};"}, "fn": "validPalindrome", "params": [{"name": "s", "type": "string"}], "outputType": "boolean", "tests": [["aba"], ["abca"], ["abc"], ["a"], ["ab"], ["aa"], ["deeee"], ["cbbcc"], ["eedede"], ["abccaa"], ["aguokepatgbnvfqmgmlcupuufxoohdfpgjdmysgvhmvffcnqxjjxqncffvmhvgsymdjgpfdhooxfuupuculmgmqfvnbgtapekouga"], ["abcdefdba"], ["abccbxa"], ["acxcbab"], ["abcb"], ["abccb"], ["axbcb"], ["aaab"], ["baa"], ["racecar"], ["raceacar"], ["abcdefgfedcba"], ["abcdefgfedcbza"], ["z"], ["zz"], ["zaz"], ["abccbxaa"], ["abcaab"], ["abcddcba"], ["qwqwq"]], "expected": [true, true, false, true, true, true, true, true, true, false, true, false, true, false, true, true, false, true, true, true, true, true, true, true, true, true, false, false, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "56", "slug": "valid-palindrome", "id": 56, "title": "Valid Palindrome", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/valid-palindrome/", "examples": [{"input": "s=\"A man, a plan, a canal: Panama\"", "output": "true", "explanation": "\"A man, a plan, a canal: Panama\" reads the same forwards and backwards when only alphanumeric characters are compared case-insensitively."}, {"input": "s=\"race a car\"", "output": "false", "explanation": "\"race a car\" reads \"raceacar\" forwards but \"racaecar\" backwards when only alphanumeric characters are considered, so it is not a palindrome."}], "hints": ["Use two pointers from both ends, skipping non-alphanumeric characters and comparing case-insensitively."], "statement": "You receive a string `s`. Disregard every character that is not a letter or a digit, and treat uppercase and lowercase forms of the same letter as identical. After this filtering, decide whether the characters that remain read the same forward and backward. Return `true` when the filtered sequence is mirror-symmetric, and `false` otherwise.\n\n**Constraints:**\n\n- 1 \u2264 s.length \u2264 2 * 10^5\n- s consists only of printable ASCII characters.\n", "solution": "## Approach\n\nUse two pointers moving inward from both ends, skipping non-alphanumeric characters and comparing characters case-insensitively.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n)\n- **Space Complexity:** O(1)\n\n## Implementation\n\n```python\nclass Solution:\n def isPalindrome(self, s: str) -> bool:\n l, r = 0, len(s) - 1\n while l < r:\n while l < r and not s[l].isalnum():\n l += 1\n while l < r and not s[r].isalnum():\n r -= 1\n if s[l].lower() != s[r].lower():\n return False\n l += 1\n r -= 1\n return True\n```\n", "starter": {"go": "package main\n\nfunc IsPalindrome(s string) bool {\n \n}", "python": "class Solution:\n def isPalindrome(self, s: str) -> bool:\n pass\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool isPalindrome(string s) {\n return false;\n }\n};"}, "fn": "isPalindrome", "params": [{"name": "s", "type": "string"}], "outputType": "boolean", "tests": [["A man, a plan, a canal: Panama"], ["race a car"], ["a"], [" "], ["0P"], ["ab"], ["aa"], ["aba"], ["abcba"], ["abccaa"], ["Madam"], ["No 'x' in Nixon"], ["Was it a car or a cat I saw?"], [".,;:"], ["aA"], ["abBA"], ["12321"], ["12345"], ["Able was I ere I saw Elba"], ["a b a"], ["a b a"], ["!!aa!!"], ["xaY"], ["0a0"], ["a0a"]], "expected": [true, false, true, true, false, false, true, true, true, false, true, true, true, true, true, true, true, false, true, true, true, true, false, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "55", "slug": "valid-parentheses", "id": 55, "title": "Valid Parentheses", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/valid-parentheses/", "examples": [{"input": "s=\"()\"", "output": "true", "explanation": "Every opening bracket in \"()\" has a correctly matched closing bracket of the same type in the correct order."}, {"input": "s=\"()[]{}\"", "output": "true", "explanation": "Every opening bracket in \"()[]{}\" has a correctly matched closing bracket of the same type in the correct order."}, {"input": "s=\"(]\"", "output": "false", "explanation": "\"(\" is matched with \"]\", but \"]\" does not match the opening bracket type."}], "hints": ["Use a stack to match opening and closing brackets. Ensure types match and stack is empty at the end."], "statement": "You receive a string `s` assembled only from the six symbols `(`, `)`, `{`, `}`, `[` and `]`. Call the arrangement correctly nested when each closing symbol pairs with a previously seen unmatched opener of the identical shape, pairs finish in the reverse of the order in which they were opened, and no opener is left waiting at the end. Return `true` for correctly nested inputs and `false` otherwise.\n\n**Constraints:**\n\n- 1 \u2264 s.length \u2264 10^4\n- s consists of parentheses only '()[]{}'.\n", "solution": "## Approach\n\nUse a stack to match brackets: push opening brackets onto the stack, and when a closing bracket appears, check that it matches the top of the stack.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n)\n- **Space Complexity:** O(n)\n\n## Implementation\n\n```python\nclass Solution:\n def isValid(self, s: str) -> bool:\n pairs = {')': '(', ']': '[', '}': '{'}\n stack = []\n for c in s:\n if c in pairs:\n if not stack or stack.pop() != pairs[c]:\n return False\n else:\n stack.append(c)\n return not stack\n```\n", "starter": {"go": "package main\n\nfunc IsValid(s string) bool {\n \n}", "python": "class Solution:\n def isValid(self, s: str) -> bool:\n pass\n", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool isValid(string s) {\n return false;\n }\n};"}, "fn": "isValid", "params": [{"name": "s", "type": "string"}], "outputType": "boolean", "tests": [["()"], ["()[]{}"], ["(]"], ["([)]"], ["{[]}"], ["("], ["[]"], ["{}"], ["()()"], ["([])"], ["{[()]}"], ["]"], ["["], ["(("], ["))"], ["(){}[]"], ["((()))"], ["[[[]]]"], ["{{{}}}"], ["([{}])"], ["({[]})"], ["()("], [")("], ["([]{}())"], ["{(})"]], "expected": [true, true, false, false, true, false, true, true, true, true, true, false, false, false, false, true, true, true, true, true, true, false, false, true, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "144", "slug": "valid-parenthesis-string", "id": 144, "title": "Valid Parenthesis String", "difficulty": "Medium", "category": "greedy", "link": "https://leetcode.com/problems/valid-parenthesis-string/", "examples": [{"input": "s = \"()\"", "output": "true", "explanation": "Simple matched parentheses."}, {"input": "s = \"(*)\"", "output": "true", "explanation": "The characters in \"(*)\" can be arranged so all parentheses are properly matched."}, {"input": "s = \"(*))\"", "output": "true", "explanation": "The characters in \"(*))\" can be arranged so all parentheses are properly matched."}], "hints": ["Track a range of possible unmatched opening-parenthesis counts rather than choosing each star immediately.", "An opening parenthesis increases both bounds; a closing parenthesis decreases both; a star can decrease the lower bound and increase the upper bound.", "Clamp the lower bound at zero, reject if the upper bound becomes negative, and require the final lower bound to be zero."], "statement": "Given a string `s` containing only `(`, `)` and `*`, return whether it can represent a valid parenthesis string.\n\nEach `*` may independently be treated as `(`, as `)`, or as an empty string. A valid parenthesis string has matching pairs in the correct order.\n\n**Constraints:**\n\n- `1 <= s.length <= 100`\n- Every character in `s` is `(`, `)` or `*`.\n", "solution": "## Approach\n\nTrack the minimum and maximum possible numbers of unmatched opening parentheses after each character. An opening parenthesis increases both bounds, a closing parenthesis decreases both, and a star decreases the minimum while increasing the maximum. Clamp the minimum at zero, reject if the maximum becomes negative, and require a final minimum of zero.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), with one pass over the string.\n- **Space Complexity:** O(1) auxiliary space.\n\n## Implementation\n\n```python\nclass Solution:\n def checkValidString(self, s: str) -> bool:\n minimum_open = 0\n maximum_open = 0\n for character in s:\n if character == \"(\":\n minimum_open += 1\n maximum_open += 1\n elif character == \")\":\n minimum_open -= 1\n maximum_open -= 1\n else:\n minimum_open -= 1\n maximum_open += 1\n if maximum_open < 0:\n return False\n minimum_open = max(minimum_open, 0)\n return minimum_open == 0\n```\n", "starter": {"go": "package main\n\nfunc CheckValidString(s string) bool {\n \n}", "python": "class Solution:\n def checkValidString(self, s: str) -> bool:\n pass\n", "cpp": "#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n bool checkValidString(string s) {\n return false;\n }\n};"}, "fn": "checkValidString", "params": [{"name": "s", "type": "string"}], "outputType": "boolean", "tests": [["()"], ["(*)"], ["(*))"], ["*"], ["("], [")"], ["**"], ["***"], ["(*"], ["*)"], ["(())"], ["()()"], ["(()"], ["())"], ["((()))"], ["(()())"], ["((*)"], ["(*()"], ["(*))("], ["((**))"], ["(*()*"], ["()*"], ["*()"], ["*(*)"], ["(((******))"], ["(((((*))))"], ["(((((*)))"], ["(*()*)"], ["(*)(*)"], ["((*)*)"], ["(((*)*))"], ["())*"], ["*(()"], ["**(()))"], ["(()**)"], ["((**)"], [")*("], ["*)("], ["((*"], ["*))"], ["(((())))"], ["(()(()))"], ["()(()())"], ["((()()))"], ["(*(*(*)))"], ["***((()))"], ["((()))***"], ["*(*(*"], ["*)*)*)"], ["((*)(*))"], ["(()*())"], ["((*)())"], ["((**))()"], ["()((**))"], ["(((()*)))"], ["(*()(()))"], ["((*)*(()))"], ["()()()()"], ["((((()))))*"], ["*((((()))))"], ["((((*))))"], ["(()(()(*)()))"], ["*()**()**"], ["((**(())))"], ["(()))((*"], ["@javascript:'*'.repeat(100)"], ["@javascript:')'+'*'.repeat(99)"]], "expected": [true, true, true, true, false, false, true, true, true, true, true, true, false, false, true, true, true, true, false, true, true, true, true, true, true, true, false, true, true, true, true, false, false, true, true, true, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "446", "slug": "valid-perfect-square", "id": 446, "title": "Valid Perfect Square", "difficulty": "Easy", "category": "math", "link": "https://leetcode.com/problems/valid-perfect-square/", "examples": [{"input": "num = 16", "output": "true", "explanation": "4 * 4 equals 16."}, {"input": "num = 14", "output": "false", "explanation": "No integer squares to 14."}], "hints": ["Binary search the candidate root between 1 and num / 2.", "Compare with mid * mid using 64-bit arithmetic to avoid overflow.", "Alternatively subtract consecutive odd numbers 1, 3, 5, ... until reaching zero or below."], "statement": "Given a positive integer `num`, decide whether it is a perfect square: some\ninteger multiplied by itself. Do not rely on built-in square-root helpers;\nuse integer arithmetic such as binary search instead.\n\nFor example, `16` is a square (`4 * 4`) while `14` is not, since no integer\nsquares to it.\n\n**Constraints:**\n- `1 <= num <= 2^31 - 1`\n", "solution": "## Approach\n\nBinary search candidate roots from 1 to `num / 2`, squaring each midpoint with\n64-bit arithmetic so large inputs cannot overflow. An exact hit means the\nnumber is a perfect square; exhausting the range means it is not.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log num).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def isPerfectSquare(self, num: int) -> bool:\n if num < 1:\n return False\n if num == 1:\n return True\n lo, hi = 1, num // 2\n while lo <= hi:\n mid = (lo + hi) // 2\n sq = mid * mid\n if sq == num:\n return True\n if sq < num:\n lo = mid + 1\n else:\n hi = mid - 1\n return False\n```\n", "starter": {"go": "package main\n\nfunc IsPerfectSquare(num int) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def isPerfectSquare(self, num: int) -> bool:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool isPerfectSquare(int num) {\n return false;\n }\n};"}, "fn": "isPerfectSquare", "params": [{"name": "num", "type": "int"}], "outputType": "boolean", "tests": [["16"], ["14"], ["1"], ["25"], ["2"], ["3"], ["4"], ["9"], ["15"], ["26"], ["100"], ["101"], ["10000"], ["9999"], ["2147483647"], ["2147395600"], ["2147395599"], ["36"], ["49"], ["50"], ["81"], ["80"], ["121"], ["122"], ["1000000"], ["99980001"], ["9801"], ["9800"], ["36"], ["48"], ["64"], ["63"], ["100000000"], ["808201"], ["808200"], ["144"], ["145"], ["169"], ["168"], ["196"], ["197"], ["225"], ["226"], ["10000"], ["1024"], ["1023"]], "expected": [true, false, true, true, false, false, true, true, false, false, true, false, true, false, false, true, false, true, true, false, true, false, true, false, true, true, true, false, true, false, true, false, true, true, false, true, false, true, false, true, false, true, false, true, true, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "892", "slug": "valid-permutations-for-di-sequence", "id": 892, "title": "Valid Permutations for DI Sequence", "difficulty": "Hard", "category": "dp", "link": "https://leetcode.com/problems/valid-permutations-for-di-sequence/", "examples": [{"input": "s = \"DID\"", "output": "5", "explanation": "Five of the 24 orders obey down-up-down."}, {"input": "s = \"D\"", "output": "1", "explanation": "Only [1,0] descends."}, {"input": "s = \"I\"", "output": "1", "explanation": "Only [0,1] climbs."}], "hints": ["Let dp[i][j] count ways for the prefix ending with rank j among the first i+1 values.", "For an I step, dp[i][j] is the prefix sum of dp[i-1] below j; for a D step it is the suffix sum above j-1. Use running sums modulo 1e9+7."], "statement": "You receive a pattern string `s` of length `n` where each character is either `D` (the next number must drop) or `I` (the next number must climb). Consider shuffles of the numbers `0` through `n` inclusive: a shuffle is acceptable when every neighbouring pair obeys the corresponding letter.\n\nCount the acceptable shuffles, giving the total modulo `10^9 + 7`.\n\n**Constraints:**\n- `n == s.length`\n- `1 <= n <= 200`\n- `s[i]` is `'I'` or `'D'`.\n", "solution": "## Approach\n\nProcess the pattern left to right while tracking relative ranks rather than exact values. After handling `i` letters, `dp[j]` records how many partial orders end with rank `j`. An `I` step allows any smaller previous rank, so the new row is a prefix sum of the old row; a `D` step allows any larger-or-equal previous rank, so it is a suffix sum. All operations run modulo `1_000_000_007`, and the final row sums to the total number of full permutations.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^2) for n up to 200, one linear sweep per character.\n- **Space Complexity:** O(n) with two rolling rows.\n\n## Implementation\n\n```python\nclass Solution:\n def numPermsDISequence(self, s: str) -> int:\n MOD = 10 ** 9 + 7\n n = len(s)\n dp = [1] * (n + 1)\n for i, ch in enumerate(s):\n ndp = [0] * (n + 1)\n if ch == 'I':\n pre = 0\n for j in range(i + 2):\n ndp[j] = pre\n if j <= i:\n pre = (pre + dp[j]) % MOD\n else:\n suf = 0\n for j in range(i, -1, -1):\n suf = (suf + dp[j]) % MOD\n ndp[j] = suf\n dp = ndp\n return sum(dp) % MOD\n```\n", "starter": {"go": "package main\n\nfunc NumPermsDISequence(s string) int {\n \n}", "python": "class Solution:\n def numPermsDISequence(self, s: str) -> int:\n pass", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n int numPermsDISequence(string s) {\n return 0;\n }\n};"}, "fn": "numPermsDISequence", "params": [{"name": "s", "type": "string"}], "outputType": "int", "tests": [["DID"], ["D"], ["I"], ["DI"], ["ID"], ["DD"], ["II"], ["DDD"], ["III"], ["DIDID"], ["IDIDI"], ["DDDD"], ["IIII"], ["DIDI"], ["IDID"], ["DDII"], ["IIDD"], ["DIDD"], ["IDDI"], ["DIDDI"], ["IIDDI"], ["DDDDD"], ["IIIII"], ["DIDIDI"], ["IDIDID"], ["DDIDD"], ["IIDID"], ["DIDIDID"]], "expected": [5, 1, 1, 2, 2, 1, 1, 1, 1, 61, 61, 1, 1, 16, 16, 6, 6, 9, 11, 40, 26, 1, 1, 272, 272, 19, 35, 1385], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "635", "slug": "valid-square", "id": 635, "title": "Valid Square", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/valid-square/", "examples": [{"input": "p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0,1]", "output": "true", "explanation": "The four corners of a unit square."}, {"input": "p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0,12]", "output": "false", "explanation": "One corner is stretched away."}, {"input": "p1 = [1,0], p2 = [-1,0], p3 = [0,1], p4 = [0,-1]", "output": "true", "explanation": "A diamond with side root 2."}], "hints": ["A square has four equal sides and two equal diagonals twice as long in squared length.", "Compute all six pairwise squared distances and sort them.", "Reject zero side length to rule out repeated points."], "statement": "Four points in order-free form are given as `p1` through `p4`, each `[x,y]`. Decide whether they are exactly the four corners of a square, in any order. Sides must be positive and equal, diagonals equal and longer by a factor of two in squared length.\n\n**Constraints:**\n- Coordinates fit in 32-bit integers.\n- Points may repeat or be collinear.\n", "solution": "## Approach\n\nSquared distances avoid roots. A square yields four equal small values and two equal large ones with the large equal to twice the small; any repeated point gives a zero side and fails.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1).\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def validSquare(self, p1: List[int], p2: List[int], p3: List[int], p4: List[int]) -> bool:\n def d2(a, b):\n return (a[0]-b[0])**2 + (a[1]-b[1])**2\n pts = [p1, p2, p3, p4]\n d = sorted(d2(pts[i], pts[j]) for i in range(4) for j in range(i+1, 4))\n return d[0] > 0 and d[0]==d[1]==d[2]==d[3] and d[4]==d[5]==2*d[0]\n```\n", "starter": {"go": "package main\n\nfunc ValidSquare(p1 []int, p2 []int, p3 []int, p4 []int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def validSquare(self, p1: List[int], p2: List[int], p3: List[int], p4: List[int]) -> bool:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool validSquare(vector<int>& p1, vector<int>& p2, vector<int>& p3, vector<int>& p4) {\n return false;\n }\n};"}, "fn": "validSquare", "params": [{"name": "p1", "type": "int_array"}, {"name": "p2", "type": "int_array"}, {"name": "p3", "type": "int_array"}, {"name": "p4", "type": "int_array"}], "outputType": "boolean", "tests": [["[0,0]", "[1,1]", "[1,0]", "[0,1]"], ["[0,0]", "[1,1]", "[1,0]", "[0,12]"], ["[1,0]", "[-1,0]", "[0,1]", "[0,-1]"], ["[0,0]", "[0,0]", "[0,0]", "[0,0]"], ["[0,0]", "[1,0]", "[1,1]", "[0,1]"], ["[0,0]", "[2,0]", "[2,2]", "[0,2]"], ["[0,0]", "[1,0]", "[1,1]", "[0,2]"], ["[0,0]", "[3,0]", "[3,3]", "[0,3]"], ["[2,2]", "[5,2]", "[5,5]", "[2,5]"], ["[0,0]", "[1,1]", "[2,0]", "[1,-1]"], ["[0,0]", "[2,1]", "[1,3]", "[-1,2]"], ["[0,0]", "[2,1]", "[1,3]", "[-1,1]"], ["[5,5]", "[5,6]", "[6,6]", "[6,5]"], ["[-1,-1]", "[1,-1]", "[1,1]", "[-1,1]"], ["[0,0]", "[0,1]", "[1,0]", "[1,1]"], ["[0,0]", "[0,2]", "[2,0]", "[2,2]"], ["[1,1]", "[2,3]", "[4,2]", "[3,0]"], ["[1,1]", "[2,3]", "[4,2]", "[3,1]"], ["[0,0]", "[1,2]", "[3,1]", "[2,-1]"], ["[0,0]", "[4,0]", "[4,1]", "[0,1]"], ["[10,10]", "[13,10]", "[13,13]", "[10,13]"], ["[0,0]", "[5,5]", "[5,0]", "[0,5]"], ["[2,0]", "[0,2]", "[-2,0]", "[0,-2]"], ["[0,0]", "[0,0]", "[1,1]", "[1,0]"], ["[1,2]", "[3,4]", "[5,2]", "[3,0]"], ["[1,2]", "[3,4]", "[5,2]", "[3,1]"], ["[10000,0]", "[0,10000]", "[-10000,0]", "[0,-10000]"], ["[0,0]", "[7,0]", "[7,7]", "[0,8]"]], "expected": [true, false, true, false, true, true, false, true, true, true, true, false, true, true, true, true, true, false, true, false, true, true, true, false, true, false, true, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "76", "slug": "valid-sudoku", "id": 76, "title": "Valid Sudoku", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/valid-sudoku/", "examples": [{"input": "board = [\"53..7....\",\"6..195...\",\".98....6.\",\"8...6...3\",\"4..8.3..1\",\"7...2...6\",\".6....28.\",\"...419..5\",\"....8..79\"]", "output": "true", "explanation": "No duplicates in any row, column, or 3x3 sub-box. The board is valid."}, {"input": "board = [\"83..7....\",\"6..195...\",\".98....6.\",\"8...6...3\",\"4..8.3..1\",\"7...2...6\",\".6....28.\",\"...419..5\",\"....8..79\"]", "output": "false", "explanation": "The top-left 3 x 3 box contains two 8s."}, {"input": "board = [\".........\",\".........\",\".........\",\".........\",\".........\",\".........\",\".........\",\".........\",\".........\"]", "output": "true", "explanation": "No duplicates in any row, column, or 3x3 sub-box. The board is valid."}], "hints": ["Track the digits already seen in each row, column, and 3 x 3 box.", "A 9-bit mask can represent the used digits for one unit."], "statement": "Determine whether a partially filled `9 x 9` Sudoku board is valid. Only the\nfilled cells need to be checked according to these rules:\n\n- Each row must contain the digits `1` through `9` at most once.\n- Each column must contain the digits `1` through `9` at most once.\n- Each of the nine `3 x 3` sub-boxes must contain the digits `1` through `9` at most once.\n\nThe board is provided as nine strings of length nine. A `.` represents an empty\ncell. A valid partial board does not need to be solvable.\n\n**Constraints:**\n\n- `board.length == 9`\n- `board[i].length == 9`\n- Every cell is `.` or a digit from `1` to `9`.\n", "solution": "## Approach\n\nMaintain one set for each row, column, and `3 x 3` box. For every filled cell,\ncheck all three corresponding sets before inserting the digit; a prior match\nmeans the board is invalid.\n\n## Complexity Analysis\n\n- **Time Complexity:** `O(1)` because the board always contains 81 cells.\n- **Space Complexity:** `O(1)` because there are always 27 sets holding at most nine digits each.\n\n## Implementation\n\n```python\nfrom typing import List\n\n\nclass Solution:\n def isValidSudoku(self, board: List[str]) -> bool:\n rows = [set() for _ in range(9)]\n columns = [set() for _ in range(9)]\n boxes = [set() for _ in range(9)]\n for row in range(9):\n for column in range(9):\n cell = board[row][column]\n if cell == \".\":\n continue\n box = (row // 3) * 3 + column // 3\n if cell in rows[row] or cell in columns[column] or cell in boxes[box]:\n return False\n rows[row].add(cell)\n columns[column].add(cell)\n boxes[box].add(cell)\n return True\n```\n", "starter": {"go": "package main\n\nfunc IsValidSudoku(board []string) bool {\n return false\n}", "python": "from typing import List\n\nclass Solution:\n def isValidSudoku(self, board: List[str]) -> bool:\n return False\n", "cpp": "#include <string>\n#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n bool isValidSudoku(vector<string>& board) {\n return false;\n }\n};"}, "fn": "isValidSudoku", "params": [{"name": "board", "type": "string_array"}], "outputType": "boolean", "tests": [["[\"53..7....\",\"6..195...\",\".98....6.\",\"8...6...3\",\"4..8.3..1\",\"7...2...6\",\".6....28.\",\"...419..5\",\"....8..79\"]"], ["[\"83..7....\",\"6..195...\",\".98....6.\",\"8...6...3\",\"4..8.3..1\",\"7...2...6\",\".6....28.\",\"...419..5\",\"....8..79\"]"], ["[\".........\",\".........\",\".........\",\".........\",\".........\",\".........\",\".........\",\".........\",\".........\"]"], ["[\"534678912\",\"672195348\",\"198342567\",\"859761423\",\"426853791\",\"713924856\",\"961537284\",\"287419635\",\"345286179\"]"], ["[\".3..78912\",\"672195.48\",\"198342.67\",\"8597614.3\",\"4268.3791\",\"7.3924856\",\"9615.7284\",\"28.419635\",\"3452.6179\"]"], ["[\"5.4678912\",\"672195.4.\",\".9.3..567\",\"85..61423\",\"4.6853..1\",\"7.39..8.6\",\"96153....\",\"28.419.35\",\"3452861.9\"]"], ["[\"53.67.9.2\",\".7.1.5.48\",\".98.42..7\",\"85.7...2.\",\"42...37..\",\"..39248..\",\".6..372.4\",\"2...1963.\",\"...28.1.9\"]"], ["[\".34.7....\",\".....5.4.\",\"198......\",\"..97.....\",\".2.8.379.\",\"7..9..85.\",\"...5.7.8.\",\"..7..96..\",\"..5....7.\"]"], ["[\"534678.12\",\"67219..48\",\"19834.5.7\",\"8.9761.23\",\"4268537.1\",\"7139..8.6\",\"9..537..4\",\"28.41.635\",\"34528.179\"]"], ["[\"534678..2\",\"67219.348\",\"1..342.67\",\".597614.3\",\"4.6.5..91\",\".1...48.6\",\"9.1..728.\",\"2..419..5\",\"34.286.7.\"]"], ["[\"5.46.8...\",\"672..5.4.\",\"....42.6.\",\"..9...4.3\",\"...85..91\",\"713.2.85.\",\"....3.284\",\"2..4.96..\",\".4.286..9\"]"], ["[\"....78...\",\"....9....\",\"....4.5..\",\".....1...\",\".........\",\"71..2....\",\".6......4\",\".87..9..5\",\".4.....7.\"]"], ["[\"5..678912\",\"672195348\",\"198..2...\",\"8597614.3\",\"426.5.79.\",\"713.2.856\",\"9615372.4\",\"28..19635\",\"34.28.179\"]"], ["[\"..46789.2\",\"6.2.9..4.\",\"1.....567\",\".5...14.3\",\"4.68537.1\",\"71...4.5.\",\".6..37..4\",\"287.196.5\",\"3..2..1.9\"]"], ["[\"..4....1.\",\"........8\",\"1.8.4....\",\"....61.2.\",\".2...3.9.\",\"71..2.8..\",\".6.53.28.\",\"...4.963.\",\".4.2...7.\"]"], ["[\".....8...\",\"..2......\",\"19....56.\",\".5.......\",\".2....7..\",\"......8..\",\"....3..8.\",\".8.......\",\".....6...\"]"], ["[\".34678.12\",\"672..53.8\",\"19.3.2567\",\"859.61423\",\"426853.91\",\"71.9..856\",\"9..5.7.84\",\"2.74196..\",\"3452...79\"]"], ["[\".3...89..\",\"6.219...8\",\"19....5.7\",\".5..6142.\",\".2.8.379.\",\"7..9.4.5.\",\"9.....284\",\"2.7..9...\",\".4....179\"]"], ["[\"..4...9..\",\"..2.9..48\",\"1..3....7\",\"......4..\",\"..6.53...\",\"...92..56\",\".....72..\",\".87...635\",\"34.......\"]"], ["[\"534.78912\",\".7..95.48\",\"198342567\",\"8.9761.23\",\".26853791\",\"71..24.56\",\".61.37284\",\"287.1963.\",\"345286179\"]"], ["[\".346.8...\",\"67219.348\",\".98342567\",\".5..6142.\",\"4268.37..\",\".1.9.....\",\"..1537284\",\"2..41.63.\",\"..5.8.179\"]"], ["[\"53.67....\",\"....9....\",\"19.......\",\"85..6.4..\",\"..68..7.1\",\".1.9.485.\",\".61..7.84\",\"..741..35\",\"34528.1.9\"]"], ["[\".34....1.\",\".7......8\",\"1.83.25..\",\".59....23\",\"42.......\",\"713..48..\",\".615.7...\",\".87...6..\",\"...2.6.79\"]"], ["[\"53467.912\",\"672.95348\",\"1...4.567\",\"8597.1423\",\"4.68.3.91\",\"71392485.\",\"961537.8.\",\"...4196.5\",\"34.28.179\"]"], ["[\"....789..\",\"672.9.34.\",\"..8..256.\",\"859.614.3\",\"...853...\",\"71392..56\",\"961...2..\",\"287.1.63.\",\"34..8.179\"]"], ["[\"..46.891.\",\".....53..\",\"19.34..6.\",\"8..76.423\",\"...8.....\",\"....248..\",\".615...84\",\"..74.9...\",\"345...1..\"]"], ["[\".........\",\"...1.5...\",\"...3....7\",\".........\",\"....5..9.\",\"7....4...\",\"...5.....\",\"...4.9.3.\",\"3.5.86...\"]"], ["[\"53.67.912\",\"67.1.5348\",\"198.42567\",\"859.6.4.3\",\"4.6.537.1\",\"713.248.6\",\"9.1.372.4\",\"2.7.1963.\",\"34528.179\"]"], ["[\".3..7.91.\",\".72.....8\",\"1..3..5..\",\"8.9761423\",\"4268....1\",\"71.9248.6\",\"9...3.2..\",\"...4.96..\",\"..5286.79\"]"], ["[\"5...78.1.\",\"67..95..8\",\"1.8.....7\",\"...7...23\",\".26......\",\"....2..5.\",\"...5..2..\",\"28....63.\",\"....8....\"]"], ["[\"5.4.78912\",\"672195348\",\"19834256.\",\"8597614.3\",\".268537.1\",\"71392.85.\",\"9615.7284\",\"2874196.5\",\"345.86179\"]"], ["[\"55..789.2\",\"..21.5.4.\",\".9.342567\",\".5.761...\",\"...85379.\",\"713.2..5.\",\".6.53728.\",\"2.7.1..3.\",\".4...6.79\"]"], ["[\"53467.9.2\",\"..212.34.\",\"1....25..\",\"859.614.3\",\".2..5.7..\",\"7.3.2.8.6\",\"9615.....\",\"..7.19.3.\",\"34..86.79\"]"], ["[\"53.678.12\",\".7..9.348\",\"1...4.54.\",\".5.7.1.23\",\"426......\",\".13924.56\",\".6.537284\",\"2..419635\",\".45..6.7.\"]"], ["[\"...67.91.\",\".7.19...8\",\"1.8342.6.\",\"84.7.1423\",\"...8.37.1\",\"7.3.24..6\",\"9...37.8.\",\"2.7.19.3.\",\"..5.861..\"]"], ["[\"..4678912\",\"6.219..4.\",\"1..3..5..\",\"..9...4.3\",\".2.8137.1\",\"713.248.6\",\".61.37...\",\"2...19635\",\"34.2.6179\"]"], ["[\".34678.12\",\"6.2195348\",\"1983...6.\",\".5976.423\",\"4268...91\",\"71.9...1.\",\"96153..84\",\"28.419635\",\"...286..9\"]"], ["[\"....7..12\",\"672..5.48\",\".98.4.56.\",\"8597614..\",\"..6..37.1\",\".139....6\",\"951537..4\",\"2874196..\",\"34...6179\"]"], ["[\"5.46..912\",\"..21.5.4.\",\"1.834.567\",\".597.142.\",\"42685..9.\",\"7.39...5.\",\"9....72..\",\"2.7419935\",\"...2..1.9\"]"], ["[\".34678912\",\".7.1.53..\",\"1.834.5.7\",\"85...1423\",\"4..8..791\",\"..3924.56\",\"9.153.28.\",\".8..1..35\",\"7..286.79\"]"], ["[\"53457.912\",\"6.219.3.8\",\"1...42.6.\",\"8...614.3\",\"42...37..\",\"71.92..5.\",\"96.5..284\",\".8.419635\",\"3.528..79\"]"], ["[\"5346789..\",\".72..524.\",\".983.2.67\",\"8...61..3\",\"4..8.3791\",\"7...2..5.\",\"...5.7284\",\"......635\",\"3.528..79\"]"], ["[\"5.4.78912\",\"6.2195.4.\",\"4..342.6.\",\".59.6.4.3\",\".26..3791\",\"7...24..6\",\".6153.28.\",\"2874.96.5\",\"3.5..617.\"]"], ["[\"53.67...2\",\".72.9...8\",\"19.3..567\",\"..94..4..\",\"426.5.7.1\",\"7..92..5.\",\"96.537.8.\",\"28741.635\",\".45286..9\"]"], ["[\"5.46789.2\",\"67..95.4.\",\"198342.67\",\".59....23\",\"4268531.1\",\"7.392.8.6\",\"961537.84\",\"28.4.9.35\",\".4....17.\"]"], ["[\".3.678..2\",\"67219..48\",\"19.34.5.7\",\"85976.4.3\",\"...85....\",\"7119.485.\",\"96153728.\",\"2.74196.5\",\"..5286.79\"]"], ["[\".34...91.\",\"6721.5348\",\".98.42567\",\"85..614.3\",\"426.5379.\",\".1..24856\",\"9.15.5284\",\"28741.63.\",\"345.8617.\"]"], ["[\"..46789.2\",\"672195.48\",\"19.34...7\",\".597.1423\",\"4..8..7.1\",\"..3924856\",\"9.15.7284\",\".8.419639\",\"..5286.79\"]"], ["[\"53.6.8.12\",\"67...5..8\",\".983...67\",\".59761.2.\",\"42685.7.1\",\"71..2.85.\",\"96..37284\",\"28.41963.\",\".47...17.\"]"], ["[\"5.4675912\",\".7.19534.\",\".983...67\",\"8.9761423\",\"426..3791\",\"713..4..6\",\"9..5....4\",\"28..196.5\",\".4.2.6.79\"]"], ["[\".34678912\",\"6.21...42\",\".98342567\",\".59..14..\",\"...8.379.\",\"....2485.\",\".6.537284\",\".87.1963.\",\"34..86.79\"]"], ["[\"53.67.9.2\",\"672.953.8\",\"..4.42.6.\",\"8.9761.23\",\"4..8.379.\",\"71.9.4856\",\".6153.2..\",\"...4...3.\",\".4.2.6179\"]"], ["[\"..4.789.2\",\"67.1.5.4.\",\"..8.4.56.\",\"85976144.\",\"426.53..1\",\"7139.4.56\",\"96153.284\",\"2.7419635\",\".452.61..\"]"], ["[\"53..7.912\",\".7..95.48\",\"1983..56.\",\".59.61.23\",\"41.8.37.1\",\"71392.856\",\"96..3.284\",\".874...35\",\"..52.617.\"]"], ["[\"5346..912\",\"...195.48\",\"....4.56.\",\".5..61423\",\"4..8.37.1\",\"713.1...6\",\".6153.28.\",\"2.741.6.5\",\"3..2.6...\"]"], ["[\"5...7.9.2\",\"6..195348\",\"19.3..56.\",\"..9.6.42.\",\".2.85..9.\",\"7...2.8.6\",\"...537254\",\".8.....35\",\".45...179\"]"], ["[\"53..789.2\",\"67219534.\",\"19.342567\",\"8.97.1..3\",\".2..537.1\",\".1.9..85.\",\"96..37..4\",\"29.4.9...\",\"345.8..7.\"]"], ["[\"5346.891.\",\"67.1.5348\",\"198342...\",\"8.97..423\",\"..685....\",\"7.39.4..6\",\"96.537284\",\".8741.6.5\",\"3.5.76.79\"]"], ["[\"53..78952\",\"6.21.5348\",\"198342..7\",\".5.7.142.\",\"4.68537..\",\"71392.856\",\"9.1.37.84\",\"2.741..3.\",\"..5.86.7.\"]"], ["[\".3.67...2\",\"6.2295.48\",\".9.342...\",\"8597614.3\",\".2...3...\",\"713924856\",\".615.728.\",\".8.4196.5\",\"345..6.79\"]"], ["[\"1........\",\".........\",\".........\",\".........\",\".........\",\".........\",\".........\",\".........\",\".........\"]"], ["[\"........9\",\".........\",\".........\",\".........\",\".........\",\".........\",\".........\",\".........\",\".........\"]"]], "expected": [true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "792", "slug": "valid-tic-tac-toe-state", "id": 792, "title": "Valid Tic-Tac-Toe State", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/valid-tic-tac-toe-state/", "examples": [{"input": "board = [\"O--\",\"---\",\"---\"]", "output": "false", "explanation": "The first mark must be X, so a lone O is impossible."}, {"input": "board = [\"XOX\",\"-X-\",\"---\"]", "output": "false", "explanation": "Four X against one O violates strict alternation."}, {"input": "board = [\"XOX\",\"O-O\",\"XOX\"]", "output": "true", "explanation": "Five X and four O with no line is a complete draw."}], "hints": ["Count the marks first: O can never outnumber X, and X can lead by at most one because X moves first.", "Scan the eight possible lines for an X win and an O win; both winning together is always illegal.", "An X win needs exactly one extra X, while an O win needs equal counts, since the winner made the final move. Adaptation: empty is '-'."], "statement": "You are given the current layout of a 3 by 3 tic-tac-toe board as an array of three strings. Each string has length 3 and each character is `X`, `O`, or `-` for an empty cell (the original statement uses a blank space, adapted here to a dash so that trailing blanks survive transport).\n\nThe opening move is always made by `X`, and the two sides then alternate strictly: `X`, `O`, `X`, `O`, and so on. A side claims victory as soon as any row, column, or diagonal is filled with three of its own marks. Play halts immediately after such a line appears, so no further marks are placed afterwards.\n\nDecide whether the supplied layout could have arisen from a legal game played under these rules.\n\n**Constraints:**\n- `board.length == 3`\n- `board[i].length == 3`\n- Each character of `board` is `X`, `O`, or `-`\n- Adaptation: empty cells use `-` instead of a blank space.\n", "solution": "## Approach\n\nNormalize each row to length three, treating dash as empty, then count `X` and `O` and test the eight winning lines. A reachable layout must satisfy turn-order counts and the stop-after-win rule: `O` never leads, `X` leads by at most one, both sides never win together, an `X` win needs one extra `X`, and an `O` win needs equal counts.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1), only nine cells and eight lines are inspected.\n- **Space Complexity:** O(1), only a few counters are used.\n\n## Implementation\n\n```python\nclass Solution:\n def validTicTacToe(self, board) -> bool:\n b = []\n for r in board:\n r = r.replace(' ', '-').replace('.', '-')\n while len(r) < 3:\n r += '-'\n b.append(r[:3])\n x = sum(r.count('X') for r in b)\n o = sum(r.count('O') for r in b)\n if o > x or x > o + 1:\n return False\n def win(p):\n for i in range(3):\n if b[i][0] == b[i][1] == b[i][2] == p:\n return True\n if b[0][i] == b[1][i] == b[2][i] == p:\n return True\n if b[0][0] == b[1][1] == b[2][2] == p:\n return True\n if b[0][2] == b[1][1] == b[2][0] == p:\n return True\n return False\n xw, ow = win('X'), win('O')\n if xw and ow:\n return False\n if xw and x != o + 1:\n return False\n if ow and x != o:\n return False\n return True\n```\n", "starter": {"go": "package main\n\nfunc ValidTicTacToe(board []string) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def validTicTacToe(self, board: List[str]) -> bool:\n return False", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool validTicTacToe(vector<string>& board) {\n return false;\n }\n};"}, "fn": "validTicTacToe", "params": [{"name": "board", "type": "string_array"}], "outputType": "boolean", "tests": [["[\"O--\", \"---\", \"---\"]"], ["[\"XOX\", \"-X-\", \"---\"]"], ["[\"XXX\", \"---\", \"OOO\"]"], ["[\"XOX\", \"O-O\", \"XOX\"]"], ["[\"---\", \"---\", \"---\"]"], ["[\"X--\", \"---\", \"---\"]"], ["[\"XXX\", \"OO-\", \"---\"]"], ["[\"OOO\", \"XX-\", \"X--\"]"], ["[\"XOX\", \"OXO\", \"OXO\"]"], ["[\"XXX\", \"OOO\", \"---\"]"], ["[\"X--\", \"X--\", \"X--\"]"], ["[\"O--\", \"O--\", \"O--\"]"], ["[\"XOX\", \"OX-\", \"OX-\"]"], ["[\"XXO\", \"XOO\", \"OXX\"]"], ["[\"X-O\", \"-X-\", \"O-X\"]"], ["[\"XXX\", \"XOO\", \"OO-\"]"], ["[\"OOO\", \"XXX\", \"---\"]"], ["[\"X--\", \"-O-\", \"---\"]"], ["[\"OXO\", \"XOX\", \"OXO\"]"], ["[\"XXX\", \"OO-\", \"OO-\"]"], ["[\"OXX\", \"OXO\", \"XOO\"]"], ["[\"XOO\", \"X--\", \"X--\"]"], ["[\"OXX\", \"---\", \"---\"]"], ["[\"XX-\", \"OO-\", \"---\"]"], ["[\"XOX\", \"OXX\", \"OXO\"]"], ["[\"---\", \"XXX\", \"OOO\"]"], ["[\"X-X\", \"OOO\", \"X--\"]"], ["[\"XXX\", \"-O-\", \"-O-\"]"]], "expected": [false, false, false, true, true, true, true, true, false, false, false, false, true, false, true, false, false, true, false, false, false, true, true, true, true, false, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "644", "slug": "valid-triangle-number", "id": 644, "title": "Valid Triangle Number", "difficulty": "Medium", "category": "two-pointer", "link": "https://leetcode.com/problems/valid-triangle-number/", "examples": [{"input": "nums = [2,2,3,4]", "output": "3", "explanation": "Triples (2,3,4) once and (2,2,3) twice satisfy the side rule, giving 3."}, {"input": "nums = [4,2,3,4]", "output": "4", "explanation": "All triples except (2,3,4)? Actually sorting to [2,3,4,4] leaves four valid triples."}, {"input": "nums = [1,1,1]", "output": "1", "explanation": "The single triple 1+1>1 is valid."}], "hints": ["Sort the lengths first; then the triangle test for a triple reduces to checking the two smaller sides against the largest.", "Fix the largest side and use two pointers on the prefix: when the pair sum beats the largest, every index between them also works.", "Move the right pointer down on success (counting a batch) and the left pointer up otherwise."], "statement": "You are given side lengths in an array `nums`. Count how many index triples `i < j < k` could serve as the three sides of a non-degenerate triangle.\n\nThree lengths form a genuine triangle exactly when the sum of any two exceeds the third. After sorting, it suffices to verify that the two shorter sides beat the longest one.\n\nReturn the number of valid triples.\n\n**Constraints:**\n- `1 <= nums.length <= 1000`\n- `0 <= nums[i] <= 1000`\n", "solution": "## Approach\n\nSort the array so each triple can be judged by its two smaller sides versus the largest. Lock the largest index and sweep the two smaller pointers inward: if their sum clears the largest, then every element between the left pointer and the right pointer also clears it, so a whole batch is counted and the right pointer steps down; otherwise the left pointer steps up. Repeating for every largest position visits each triple class once.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^2), dominated by the two-pointer sweep per largest index after an O(n log n) sort.\n- **Space Complexity:** O(1) besides the sort workspace.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def triangleNumber(self, nums: List[int]) -> int:\n nums.sort()\n n = len(nums)\n count = 0\n for k in range(2, n):\n i, j = 0, k - 1\n while i < j:\n if nums[i] + nums[j] > nums[k]:\n count += j - i\n j -= 1\n else:\n i += 1\n return count\n```\n", "starter": {"go": "package main\n\nfunc TriangleNumber(nums []int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def triangleNumber(self, nums: List[int]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int triangleNumber(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "triangleNumber", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[2,2,3,4]"], ["[4,2,3,4]"], ["[1,1,1]"], ["[0,0,0]"], ["[0,1,1]"], ["[1,2,3]"], ["[2,2,2]"], ["[3,4,5]"], ["[5,5,5,5]"], ["[1,2,3,4,5]"], ["[10,10,10]"], ["[0,0,1]"], ["[82,82,82,82,82]"], ["[1,1,3,4]"], ["[2,3,4,5,6]"], ["[7,10,5,2,8]"], ["[1000,1000,1000]"], ["[1,1000,1000,1000]"], ["[2,2,3]"], ["[4,5,6,7]"], ["[1,1,2,2,3]"], ["[9,9,9,9,9,9]"], ["[0,2,2]"], ["[6,6,6,10]"], ["[13,12,11,10]"], ["[2,2,2,2,3]"], ["[50,50,100]"], ["[999,1000,1000]"]], "expected": [3, 4, 1, 0, 0, 0, 1, 1, 4, 3, 1, 0, 10, 0, 7, 5, 1, 4, 1, 4, 3, 20, 0, 4, 4, 10, 0, 1], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "482", "slug": "valid-word-abbreviation", "id": 482, "title": "Valid Word Abbreviation", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/valid-word-abbreviation/", "examples": [{"input": "word = \"internationalization\", abbr = \"i12iz4n\"", "output": "true", "explanation": "The numbers 12 and 4 skip the matching middle blocks."}, {"input": "word = \"apple\", abbr = \"a2e\"", "output": "false", "explanation": "Skipping 2 letters after a lands on l, not e."}, {"input": "word = \"word\", abbr = \"4\"", "output": "true", "explanation": "A single number covering the whole length is valid."}], "hints": ["Walk both strings with two pointers, advancing the word by numeric jumps.", "A number with a leading zero is always invalid, and a lone zero never skips anything.", "Both pointers must finish together for the abbreviation to match."], "statement": "An abbreviation replaces blocks of letters with their lengths: for example, `w3d` could stand for a four-letter word starting with `w` and ending with `d` with three letters skipped in between.\n\nGiven a dictionary word `word` and a candidate shorthand `abbr` (letters and digits), decide whether `abbr` correctly abbreviates `word`. Read digits as a skipped count: leading zeros are forbidden (so `01` or `0` as a skip is invalid), and each skipped block must match that many characters. Plain letters must match exactly.\n\nReturn `true` when the whole shorthand consumes the whole word, otherwise `false`.\n\n**Constraints:**\n- `1 <= word.length <= 20`\n- `1 <= abbr.length <= 20`\n- `word` holds lowercase letters; `abbr` holds lowercase letters and digits.\n", "solution": "## Approach\n\nScan the word and the shorthand together. Digits accumulate into a skip count (rejecting any number that starts with zero), which advances the word pointer without consuming shorthand letters beyond the number; letters must match the current word character. Skips that run past the end fail at once. Success needs both pointers to land exactly at their ends.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n + m), where n and m are the two lengths.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def validWordAbbreviation(self, word: str, abbr: str) -> bool:\n i = j = 0\n n, m = len(word), len(abbr)\n while j < m:\n c = abbr[j]\n if c.isdigit():\n if c == \"0\":\n return False\n num = 0\n while j < m and abbr[j].isdigit():\n num = num * 10 + int(abbr[j])\n j += 1\n i += num\n if i > n:\n return False\n else:\n if i >= n or word[i] != c:\n return False\n i += 1\n j += 1\n return i == n and j == m\n```\n", "starter": {"go": "package main\n\nfunc ValidWordAbbreviation(word string, abbr string) bool {\n \n}", "python": "class Solution:\n def validWordAbbreviation(self, word: str, abbr: str) -> bool:\n pass", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool validWordAbbreviation(string word, string abbr) {\n return false;\n }\n};"}, "fn": "validWordAbbreviation", "params": [{"name": "word", "type": "string"}, {"name": "abbr", "type": "string"}], "outputType": "boolean", "tests": [["internationalization", "i12iz4n"], ["apple", "a2e"], ["word", "4"], ["a", "1"], ["a", "a"], ["a", "2"], ["ab", "a1"], ["ab", "2"], ["ab", "a0"], ["ab", "01"], ["hi", "h1"], ["hi", "1i"], ["hi", "2"], ["hello", "h3o"], ["hello", "h2lo"], ["hello", "5"], ["hello", "hello"], ["hello", "h01lo"], ["substitution", "s10n"], ["substitution", "s11n"], ["substitution", "12"], ["apple", "a3e"], ["apple", "5"], ["apple", "apple"], ["apple", "a4"], ["abbreviation", "a10n"], ["abbreviation", "a9n"], ["x", "x"], ["xy", "x1"], ["xyz", "x1z"]], "expected": [true, false, true, true, true, false, true, true, false, false, true, true, true, true, true, true, true, false, true, false, true, true, true, true, true, true, false, true, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "493", "slug": "valid-word-square", "id": 493, "title": "Valid Word Square", "difficulty": "Easy", "category": "array", "link": "https://leetcode.com/problems/valid-word-square/", "examples": [{"input": "words = [\"abcd\",\"bnrt\",\"crmy\",\"dtye\"]", "output": "true", "explanation": "Each row matches its corresponding column."}, {"input": "words = [\"ball\",\"area\",\"read\",\"lady\"]", "output": "false", "explanation": "Column 3 does not spell \"lady\"."}, {"input": "words = [\"abcd\",\"bnrt\",\"crm\",\"dt\"]", "output": "true", "explanation": "Shorter rows still mirror their columns."}], "hints": ["Compare words[i][j] against words[j][i] for every in-range pair.", "Treat a missing character on exactly one side as a mismatch.", "You only need to scan rows; columns are covered by symmetry."], "statement": "You are handed a sequence of words `words`. Imagine stacking them as rows of a rectangle: the first word forms row 0, the second forms row 1, and so on. Such a stacking counts as a square layout when two requirements hold: the number of rows equals the length of the first word, and reading down column `c` spells exactly the word in row `c` for every valid `c`.\n\nIn other words, for every pair of positions `(i, j)` that falls inside the layout, the character at row `i`, column `j` must match the character at row `j`, column `i`. Rows may have different lengths; if either side of a compared pair is missing, the layout is invalid unless both sides are missing.\n\nReturn `true` when `words` forms such a layout, otherwise `false`.\n\n**Constraints:**\n- `1 <= words.length <= 500`\n- `1 <= words[i].length <= 500`\n- `words[i]` holds only lowercase English letters.\n- All words together hold at most `250000` characters.\n\nAdaptation: the source signature takes a list of strings; here it is modeled as `string_array` (`String[]`) so every supported language runner can feed it directly.\n", "solution": "## Approach\n\nWalk every row `i` and every column `j` inside that row. The mirror position `(j, i)` must exist and hold the same letter; a missing character on exactly one side, or a differing letter, rejects the layout. If the whole scan succeeds, rows and columns mirror each other.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(total characters in `words`). Each character pair is examined once.\n- **Space Complexity:** O(1) besides the input.\n\n## Implementation\n\n```python\nclass Solution:\n def validWordSquare(self, words):\n n = len(words)\n for i, row in enumerate(words):\n for j, ch in enumerate(row):\n if j >= n:\n return False\n if i >= len(words[j]):\n return False\n if words[j][i] != ch:\n return False\n return True\n```\n", "starter": {"go": "package main\n\nfunc ValidWordSquare(words []string) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def validWordSquare(self, words: List[str]) -> bool:\n pass", "cpp": "#include <string>\n#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool validWordSquare(vector<string>& words) {\n return false;\n }\n};"}, "fn": "validWordSquare", "params": [{"name": "words", "type": "string_array"}], "outputType": "boolean", "tests": [["[\"abcd\",\"bnrt\",\"crmy\",\"dtye\"]"], ["[\"ball\",\"area\",\"read\",\"lady\"]"], ["[\"abcd\",\"bnrt\",\"crm\",\"dt\"]"], ["[\"a\"]"], ["[\"ab\",\"ba\"]"], ["[\"ab\",\"bc\"]"], ["[\"abc\",\"b\"]"], ["[\"aaa\",\"aaa\",\"aaa\"]"], ["[\"abcd\",\"bnrt\",\"crmy\",\"dty\"]"], ["[\"abcd\",\"bnrt\",\"crmy\",\"dtye\",\"e\"]"], ["[\"a\",\"b\",\"c\"]"], ["[\"ab\",\"b\"]"], ["[\"o\"]"], ["[\"xy\",\"yx\",\"zz\"]"], ["[\"abc\",\"bca\",\"cab\"]"], ["[\"abcd\",\"bnrt\",\"crmy\",\"dtyex\"]"], ["[\"aa\",\"aa\"]"], ["[\"ab\",\"ba\",\"ab\"]"], ["[\"q\"]"], ["[\"abcde\",\"bcdef\",\"cdefg\",\"defgh\",\"efghi\"]"], ["[\"abc\",\"bcd\",\"cde\"]"], ["[\"ab\",\"ab\"]"], ["[\"a\",\"a\"]"], ["[\"abc\",\"bca\"]"], ["[\"aa\",\"ab\"]"], ["[\"abcd\",\"bnrt\",\"crmy\"]"], ["[\"aaa\",\"aaa\"]"], ["[\"aba\",\"bab\",\"aba\"]"], ["[\"ab\",\"ba\",\"ab\",\"ba\"]"], ["[\"x\",\"y\"]"]], "expected": [true, false, true, true, true, true, false, true, true, false, false, true, true, false, true, false, true, false, true, true, true, false, false, false, true, false, false, true, false, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "68", "slug": "validate-binary-search-tree", "id": 68, "title": "Validate Binary Search Tree", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/validate-binary-search-tree/", "examples": [{"input": "root = [2,1,3]", "output": "true", "explanation": "Every node satisfies the BST property: all left descendants < node.val < all right descendants."}, {"input": "root = [5,1,4,null,null,3,6]", "output": "false", "explanation": "Node 4 is in the right subtree of Node 5 but has a smaller value, violating the BST property."}, {"input": "root = []", "output": "true", "explanation": "Every node satisfies the BST property: all left descendants < node.val < all right descendants."}], "hints": ["Use DFS with value bounds (min/max) to verify BST properties for every node."], "statement": "You are handed the `root` of a binary tree. Report whether the tree honors binary-search-tree ordering everywhere: for every node, each value in its entire left descendant group must lie strictly below the node's own value, each value in its entire right descendant group must lie strictly above it, and the left and right child groups must each independently satisfy this same ordering.\n\n**Constraints:**\n\n- The number of nodes in the tree is in the range [1, 10^4].\n- -2^31 \u2264 Node.val \u2264 2^31 - 1\n", "solution": "## Approach\n\nPerform an inorder traversal \u2014 a BST must yield strictly increasing values. Use a stack to traverse iteratively and track the previous value.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n)\n- **Space Complexity:** O(h)\n\n## Implementation\n\n```python\nfrom typing import Optional\nclass Solution:\n def isValidBST(self, root: Optional[TreeNode]) -> bool:\n stack = []\n cur = root\n prev = float('-inf')\n while cur or stack:\n while cur:\n stack.append(cur)\n cur = cur.left\n cur = stack.pop()\n if cur.val <= prev:\n return False\n prev = cur.val\n cur = cur.right\n return True\n```\n", "starter": {"go": "// Definition for a binary tree node.\n// type TreeNode struct {\n// Val int\n// Left *TreeNode\n// Right *TreeNode\n// }\npackage main\n\nfunc IsValidBST(root *TreeNode) bool {\n \n}", "python": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, val=0, left=None, right=None):\n# self.val = val\n# self.left = left\n# self.right = right\n\nclass Solution:\n def isValidBST(self, root) -> bool:\n # TODO: return True if valid BST\n pass\n", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\nclass Solution {\npublic:\n bool isValidBST(TreeNode* root) {\n \n }\n};\n"}, "fn": "isValidBST", "params": [{"name": "root", "type": "tree_node", "visualizeType": "tree_node"}], "outputType": "boolean", "tests": [["[2,1,3]"], ["[5,1,4,null,null,3,6]"], ["[1,1]"], ["[2147483647]"], ["[10,5,15,null,null,6,20]"], ["[0]"], ["[1]"], ["[-2147483648]"], ["[5,3,7,2,4,6,8]"], ["[3,1,5,0,2,4,6]"], ["[4,2,6,1,3,5,7]"], ["[1,null,2,null,3]"], ["[3,null,5,null,7]"], ["[2,null,3,null,1]"], ["[0,-1]"], ["[0,null,1]"], ["[-100,-200,-50]"], ["[100,50,150,25,75,125,175]"], ["[50,30,70,20,40,60,80]"], ["[1,2]"], ["[2,2,2]"], ["[5,4,null,3]"], ["[-2147483648,null,2147483647]"], ["[3,2,4,1]"], ["[10,5,15,3,7,null,18]"], ["[6,2,8,1,4,7,9]"], ["[2,1]"], ["[1,null,2]"], ["[5,1,6,null,null,3]"], ["[7,4,9,2,5,8,10]"]], "expected": [true, false, false, true, false, true, true, true, true, true, true, true, true, false, true, true, true, true, true, false, false, true, true, true, true, true, true, true, false, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "533", "slug": "validate-ip-address", "id": 533, "title": "Validate IP Address", "difficulty": "Medium", "category": "string", "link": "https://leetcode.com/problems/validate-ip-address/", "examples": [{"input": "queryIP = \"172.16.254.1\"", "output": "\"IPv4\"", "explanation": "Four decimal groups, each 0-255 with no leading zeroes."}, {"input": "queryIP = \"2001:0db8:85a3:0:0:8A2E:0370:7334\"", "output": "\"IPv6\"", "explanation": "Eight groups of 1-4 hexadecimal digits."}, {"input": "queryIP = \"256.256.256.256\"", "output": "\"Neither\"", "explanation": "256 exceeds the largest allowed IPv4 group value of 255."}], "hints": ["Split on dots and on colons separately, keeping empty pieces so missing groups are caught.", "IPv4 forbids leading zeroes and values above 255; IPv6 needs exactly 8 groups of 1-4 hex digits with no shorthand."], "statement": "You are given a string `queryIP`. Return `\"IPv4\"` if it is a valid IPv4 address, `\"IPv6\"` if it is a valid IPv6 address, and `\"Neither\"` otherwise.\n\nA valid IPv4 address has 4 decimal groups separated by dots: each group has 1-3 digits, holds a value from 0 to 255, and must not have leading zeroes (so `\"0\"` is fine but `\"01\"` is not).\n\nA valid IPv6 address has 8 groups separated by colons: each group has 1-4 hexadecimal digits (`0-9`, `a-f`, `A-F`). The `::` shorthand is not allowed here, so empty groups are invalid.\n\n**Constraints:**\n- `1 <= queryIP.length <= 500`\n- `queryIP` consists of digits, English letters, `'.'` and `':'`.\n", "solution": "## Approach\n\nTest the IPv4 shape first: split on dots while keeping empty pieces, require exactly 4 groups, and accept only 1-3 digit groups with no leading zeroes and numeric value at most 255. Otherwise test the IPv6 shape: split on colons, require exactly 8 groups, each 1-4 hexadecimal digits. Anything failing both checks is neither.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), a few linear scans over the input.\n- **Space Complexity:** O(n) for the split pieces.\n\n## Implementation\n\n```python\nclass Solution:\n def validIPAddress(self, queryIP: str) -> str:\n def ipv4(ip: str) -> bool:\n g = ip.split(\".\")\n if len(g) != 4:\n return False\n for p in g:\n if not 1 <= len(p) <= 3 or not p.isdigit():\n return False\n if len(p) > 1 and p[0] == \"0\":\n return False\n if int(p) > 255:\n return False\n return True\n\n def ipv6(ip: str) -> bool:\n g = ip.split(\":\")\n if len(g) != 8:\n return False\n ok = set(\"0123456789abcdefABCDEF\")\n for p in g:\n if not 1 <= len(p) <= 4 or any(c not in ok for c in p):\n return False\n return True\n\n if ipv4(queryIP):\n return \"IPv4\"\n if ipv6(queryIP):\n return \"IPv6\"\n return \"Neither\"\n```\n", "starter": {"go": "package main\n\nfunc ValidIPAddress(queryIP string) string {\n \n}", "python": "class Solution:\n def validIPAddress(self, queryIP: str) -> str:\n pass", "cpp": "#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n string validIPAddress(string queryIP) {\n return \"\";\n }\n};"}, "fn": "validIPAddress", "params": [{"name": "queryIP", "type": "string"}], "outputType": "string", "tests": [["172.16.254.1"], ["2001:0db8:85a3:0:0:8A2E:0370:7334"], ["256.256.256.256"], ["0.0.0.0"], ["1.1.1.1"], ["01.01.01.01"], ["1.1.1"], ["1.1.1.1.1"], ["1.1.1.abc"], ["2001:db8:85a3:0:0:8A2E:370:7334"], ["02001:0db8:85a3:0:0:8A2E:0370:7334"], ["2001:0db8:85a3::8A2E:0370:7334"], ["1e1.4.5.6"], ["1081:db8:85a3:01:-0:8A2E:0370:7334"], ["0:0:0:0:0:0:0:0"], ["FFFF:0:0:0:0:0:0:0"], ["192.168.1.1"], ["256.0.0.0"], ["a:b:c:d:e:f:0:1"], ["a:b:c:d:e:f:0:"], [".1.1.1"], ["255.255.255.255"], ["0.0.0.1"], ["00.0.0.0"], ["1.2.3.04"], ["fe80:0000:0000:0000:0202:b3ff:fe1e:8329"], ["abcd:ef01:2345:6789:abcd:ef01:2345:6789"], ["12345::6789"], ["1.1.1.1:"], ["2001:0db8:85a3:0:0:8A2E:0370:7334:1234"]], "expected": ["IPv4", "IPv6", "Neither", "IPv4", "IPv4", "Neither", "Neither", "Neither", "Neither", "IPv6", "Neither", "Neither", "Neither", "Neither", "IPv6", "IPv6", "IPv4", "Neither", "IPv6", "Neither", "Neither", "IPv4", "IPv4", "Neither", "Neither", "IPv6", "IPv6", "Neither", "Neither", "Neither"], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "933", "slug": "validate-stack-sequences", "id": 933, "title": "Validate Stack Sequences", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/validate-stack-sequences/", "examples": [{"input": "pushed = [1,2,3,4,5], popped = [4,5,3,2,1]", "output": "true", "explanation": "Push and pop in an order that frees 4, 5, 3, 2, 1."}, {"input": "pushed = [1,2,3,4,5], popped = [4,3,5,1,2]", "output": "false", "explanation": "1 is trapped beneath 2 when it is wanted."}], "hints": ["Replay the process: push each value, then pop from the top while it matches the next wanted output.", "The sequence is valid exactly when every wanted value gets popped by the end of the replay."], "statement": "Check whether a pop order could have come from a push order through one stack.\n\nItems are pushed onto an empty stack in the order listed by `pushed`, and at any moment the top item may be popped. The popped items, in order, should equal `popped`. All values are distinct and `popped` is a rearrangement of `pushed`.\n\nGiven both orders, return `true` when the pop sequence is achievable and `false` otherwise.\n\n**Constraints:**\n- `1 <= pushed.length <= 1000`\n- `0 <= pushed[i] <= 1000`\n- Values in `pushed` are pairwise distinct.\n- `popped` holds exactly the same values in some order.\n", "solution": "## Approach\n\nSimulate the stack directly. Push the input values in order, and after every push pop the top while it equals the next value demanded by the pop order. If the whole pop order is consumed, the sequence is feasible; leftover demand means some value was buried and the answer is false.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), each value is pushed and popped at most once.\n- **Space Complexity:** O(n) for the simulation stack.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool:\n st = []\n j = 0\n for x in pushed:\n st.append(x)\n while st and j < len(popped) and st[-1] == popped[j]:\n st.pop()\n j += 1\n return j == len(popped)\n```\n", "starter": {"go": "package main\n\nfunc ValidateStackSequences(pushed []int, popped []int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool:\n pass", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n bool validateStackSequences(vector<int>& pushed, vector<int>& popped) {\n return 0;\n }\n};"}, "fn": "validateStackSequences", "params": [{"name": "pushed", "type": "int_array"}, {"name": "popped", "type": "int_array"}], "outputType": "boolean", "tests": [["[1, 2, 3, 4, 5]", "[4, 5, 3, 2, 1]"], ["[1, 2, 3, 4, 5]", "[4, 3, 5, 1, 2]"], ["[1]", "[1]"], ["[1, 2]", "[1, 2]"], ["[1, 2]", "[2, 1]"], ["[1, 2, 3]", "[1, 2, 3]"], ["[1, 2, 3]", "[3, 2, 1]"], ["[1, 2, 3]", "[2, 3, 1]"], ["[1, 2, 3]", "[3, 1, 2]"], ["[2, 1, 0]", "[1, 0, 2]"], ["[1, 2, 3, 4]", "[2, 1, 4, 3]"], ["[1, 2, 3, 4]", "[3, 1, 2, 4]"], ["[0, 1, 2]", "[2, 1, 0]"], ["[0, 1, 2]", "[1, 2, 0]"], ["[5, 4, 3, 2, 1]", "[1, 2, 3, 4, 5]"], ["[1, 3, 2]", "[2, 3, 1]"], ["[1, 2, 3, 4, 5]", "[5, 4, 3, 2, 1]"], ["[1, 2, 3, 4, 5]", "[1, 2, 3, 4, 5]"], ["[1, 2, 3, 4, 5]", "[2, 3, 5, 4, 1]"], ["[1, 2, 3, 4, 5]", "[3, 5, 4, 2, 1]"], ["[10, 20, 30]", "[30, 20, 10]"], ["[10, 20, 30]", "[20, 30, 10]"], ["[4, 3, 2, 1]", "[1, 2, 3, 4]"], ["[7]", "[7]"], ["[1, 2, 3, 4]", "[4, 3, 2, 1]"], ["[1, 2, 3, 4]", "[1, 3, 2, 4]"], ["[2, 3, 1]", "[1, 3, 2]"], ["[1, 2, 3]", "[2, 1, 3]"]], "expected": [true, false, true, true, true, true, true, true, false, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "359", "slug": "verify-preorder-sequence-in-binary-search-tree", "id": 359, "title": "Verify Preorder Sequence in Binary Search Tree", "difficulty": "Medium", "category": "stack", "link": "https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree/", "examples": [{"input": "preorder = [5,2,1,3,6]", "output": "true", "explanation": "Root 5 with left child 2 (children 1 and 3) and right child 6 produces this order."}, {"input": "preorder = [5,2,6,1,3]", "output": "false", "explanation": "After 6 enters the right subtree of 5, the later value 1 cannot return to the left side."}, {"input": "preorder = [1]", "output": "true", "explanation": "A single node always forms a valid walk."}], "hints": ["Track the smallest value allowed for the next entry; it rises whenever the walk moves into a right subtree.", "Keep a stack of ancestors and pop while the current value is larger, updating the lower bound to the last popped value."], "statement": "Given an array `preorder` of distinct integers, decide whether it could be the preorder walk of some binary search tree. In a preorder walk the root comes first, then the whole left subtree, then the whole right subtree, and every left descendant is smaller than its ancestor while every right descendant is larger.\n\nReturn `true` when such a tree exists and `false` otherwise.\n\n**Constraints:**\n- `1 <= preorder.length <= 10^4`\n- `-10^4 <= preorder[i] <= 10^4`\n- All values in `preorder` are distinct.\n", "solution": "## Approach\n\nScan the sequence while remembering the smallest value the next entry is allowed to take. Maintain a stack of ancestors: when the current value exceeds the stack top, pop ancestors and raise the lower bound to the last popped value, which models moving into a right subtree. If any value arrives at or below the bound, the order is impossible.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the length of `preorder`. Each value is pushed and popped at most once.\n- **Space Complexity:** O(n) for the stack in the worst case.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def verifyPreorder(self, preorder: List[int]) -> bool:\n stack: List[int] = []\n low = float(\"-inf\")\n for v in preorder:\n if v <= low:\n return False\n while stack and v > stack[-1]:\n low = stack.pop()\n stack.append(v)\n return True\n```\n", "starter": {"go": "package main\n\nfunc VerifyPreorder(preorder []int) bool {\n return false\n}", "python": "from typing import List\n\nclass Solution:\n def verifyPreorder(self, preorder: List[int]) -> bool:\n return False\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n bool verifyPreorder(vector<int>& preorder) {\n return false;\n }\n};"}, "fn": "verifyPreorder", "params": [{"name": "preorder", "type": "int_array"}], "outputType": "boolean", "tests": [["[5,2,1,3,6]"], ["[5,2,6,1,3]"], ["[1]"], ["[4,2,1,3,6,5,7]"], ["[1,2,3,4,5]"], ["[5,4,3,2,1]"], ["[3,1,2]"], ["[3,2,1]"], ["[2,1,3]"], ["[2,3,1]"], ["[8,4,2,6,10,9,12]"], ["[8,10,9]"], ["[10,5,1,7,40,50]"], ["[10,5,40,1,50]"], ["[0]"], ["[-4,-2,-1,-3]"], ["[100,50,25,75,150,125,175]"], ["[100,150,50]"], ["[1,3,2]"], ["[3,1,4,2]"], ["[6,2,1,4,3,5,8,7,9]"], ["[6,8,2]"], ["[5,3,2,1,4,7,6,8]"], ["[5,3,7,2,6,1]"], ["[42,21,63,10,30,50,80]"], ["[42,63,21]"]], "expected": [true, false, true, true, true, true, true, true, true, false, true, true, true, false, true, false, true, false, true, false, true, false, true, false, false, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "417", "slug": "verify-preorder-serialization-of-a-binary-tree", "id": 417, "title": "Verify Preorder Serialization of a Binary Tree", "difficulty": "Medium", "category": "stack", "link": "https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/", "examples": [{"input": "preorder = \"9,3,4,#,#,1,#,#,2,#,6,#,#\"", "output": "true", "explanation": "Every real node provides two child slots and every marker consumes one, ending exactly balanced."}, {"input": "preorder = \"1,#\"", "output": "false", "explanation": "Only one child token follows the root, so one required slot is never filled."}, {"input": "preorder = \"9,#,#,1\"", "output": "false", "explanation": "The tree finishes after three tokens, leaving the final value orphaned."}], "hints": ["Track open slots: start with one, spend one per token, and add two for each real node.", "Fail early when slots go negative, and accept only when exactly zero remain at the end."], "statement": "A binary tree can be written down by walking it in preorder (node first, then left branch, then right branch). Each visited position contributes one token: the node's stored number when the position holds a real node, or the marker `#` when the position is an empty child. Tokens are joined with commas into a single line.\n\nFor instance, a small tree might become `\"9,3,4,#,#,1,#,#,2,#,6,#,#\"`, where every `#` stands for a missing child.\n\nYou receive such a comma-separated line `preorder`. Decide whether it could have arisen from some binary tree walked in preorder. Each token is either a decimal integer or `#`, and the line itself is always well-formed (no blank tokens, no double commas).\n\nYou must answer without rebuilding the tree.\n\n**Constraints:**\n- `1 <= preorder.length <= 10^4`\n- Tokens are integers in `[0, 100]` or `#`, separated by single commas.\n", "solution": "## Approach\n\nImagine each token must occupy one open child slot. Begin with a single slot for the root. Reading left to right, every token consumes a slot; a numeric token additionally opens two fresh slots for its own children while `#` opens none. Dropping below zero means a token arrived with nowhere to attach, and leftover slots at the end mean the tree is incomplete. Only an exact zero balance is valid.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the length of the string. Tokens are scanned once.\n- **Space Complexity:** O(n) for the split tokens, or O(1) with manual scanning.\n\n## Implementation\n\n```python\nclass Solution:\n def isValidSerialization(self, preorder: str) -> bool:\n slots = 1\n for tok in preorder.split(\",\"):\n slots -= 1\n if slots < 0:\n return False\n if tok != \"#\":\n slots += 2\n return slots == 0\n```\n", "starter": {"go": "package main\n\nfunc IsValidSerialization(preorder string) bool {\n \n}", "python": "class Solution:\n def isValidSerialization(self, preorder: str) -> bool:\n pass", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n bool isValidSerialization(string preorder) {\n return false;\n }\n};"}, "fn": "isValidSerialization", "params": [{"name": "preorder", "type": "string"}], "outputType": "boolean", "tests": [["9,3,4,#,#,1,#,#,2,#,6,#,#"], ["1,#"], ["9,#,#,1"], ["#"], ["1,#,#"], ["3,#,#"], ["1,2,#,#,#"], ["1,#,2,#,#"], ["9,#,9,#,9,#,#"], ["1,#,#,#"], ["3,4,#,#,#"], ["0,#,#"], ["100,#,#"], ["1,2,3,#,#,#,#"], ["1,#,2,#,3,#,#"], ["9,3,4,#,#,1,#,#,2,#,6,#,#"], ["1,2,#,#,3,#,#"], ["5,#,#,#"], ["#,#"], ["10,20,#,#,30,#,#"], ["7,#,8,#,#"], ["1,1,1,#,#,1,#,#,1,#,#"], ["0,0,#,#,#"], ["99,#,99,#,#"], ["1,#,1,#,1,#,#"], ["8,8,#,#,#"], ["50,#,#"], ["12,#,#"]], "expected": [true, false, false, true, true, true, true, true, true, false, true, true, true, true, true, true, true, false, false, true, true, true, true, true, true, true, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "216", "slug": "verifying-an-alien-dictionary", "id": 216, "title": "Verifying an Alien Dictionary", "difficulty": "Easy", "category": "graph", "link": "https://leetcode.com/problems/verifying-an-alien-dictionary/", "examples": [{"input": "words = [\"hello\",\"leetcode\"], order = \"hlabcdefgijkmnopqrstuvwxyz\"", "output": "true", "explanation": "As 'h' comes before 'l' in this language, the sequence is sorted."}, {"input": "words = [\"word\",\"world\",\"row\"], order = \"worldabcefghijkmnpqstuvxyz\"", "output": "false"}, {"input": "words = [\"apple\",\"app\"], order = \"abcdefghijklmnopqrstuvwxyz\"", "output": "false"}], "hints": ["Build a rank map from order, then compare adjacent words using that rank."], "statement": "Suppose a foreign tongue writes with the usual English lowercase letters, yet arranges its alphabet in a different sequence captured by the permutation string `order`.\n\nYou are handed a list `words` written in that tongue. Return `true` exactly when the list advances in non-decreasing dictionary sequence under the foreign alphabet ordering, and `false` otherwise. In particular, whenever one entry forms a prefix of the following entry, the shorter entry is required to come first.\n\n**Constraints:**\n- `1 <= words.length <= 100`\n- `1 <= words[i].length <= 20`\n- `order.length == 26`\n- All characters in `words[i]` and `order` are English lowercase letters\n", "solution": "## Approach\n\nMap each letter to its rank in `order`. Compare every pair of adjacent words with that ranking; a shorter prefix must come first when prefixes match.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(total characters)\n- **Space Complexity:** O(1)\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def isAlienSorted(self, words: List[str], order: str) -> bool:\n rank = {c: i for i, c in enumerate(order)}\n def le(a, b):\n for x, y in zip(a, b):\n if rank[x] < rank[y]:\n return True\n if rank[x] > rank[y]:\n return False\n return len(a) <= len(b)\n return all(le(words[i], words[i+1]) for i in range(len(words)-1))\n```\n", "starter": {"go": "package main\n\nfunc IsAlienSorted(words []string, order string) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def isAlienSorted(self, words: List[str], order: str) -> bool:\n ", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n bool isAlienSorted(vector<string>& words, string order) {\n \n }\n};"}, "fn": "isAlienSorted", "params": [{"name": "words", "type": "string_array"}, {"name": "order", "type": "string"}], "outputType": "boolean", "tests": [["[\"hello\",\"leetcode\"]", "hlabcdefgijkmnopqrstuvwxyz"], ["[\"word\",\"world\",\"row\"]", "worldabcefghijkmnpqstuvxyz"], ["[\"apple\",\"app\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"a\",\"b\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"hello\",\"hello\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"zub\",\"zub\"]", "worldabcefghijkmnpqstuvxyz"], ["[\"kuvp\",\"q\"]", "ngxlkthsjuoqcpavbfdermiywz"], ["[\"fxasxpc\",\"dfbdrifhp\",\"nwzgs\",\"cmwqriv\",\"ebulyzdv\",\"meiq\"]", "zkgwaverwomldsyxujtqphbcif"], ["[\"aa\",\"a\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"a\",\"aa\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"a\",\"b\",\"c\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"c\",\"b\",\"a\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"ab\",\"aa\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"aa\",\"ab\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"app\",\"apple\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"apple\",\"app\",\"apricot\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"a\"]", "zyxwvutsrqponmlkjihgfedcba"], ["[\"z\",\"y\",\"x\"]", "zyxwvutsrqponmlkjihgfedcba"], ["[\"hello\",\"hell\"]", "hlabcdefgijkmnopqrstuvwxyz"], ["[\"hell\",\"hello\"]", "hlabcdefgijkmnopqrstuvwxyz"], ["[\"ab\",\"cd\",\"ef\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"ba\",\"ab\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"abcd\",\"abce\",\"abcf\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"x\",\"xx\",\"xxx\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"xa\",\"xb\",\"xc\"]", "azyxwvutsrqponmlkjihgfedcb"], ["[\"ax\",\"bx\",\"cx\"]", "azyxwvutsrqponmlkjihgfedcb"], ["[\"abcdefghijklmnopqrst\",\"abcdefghijklmnob\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"q\",\"qq\",\"qqq\",\"qqqq\"]", "qwertyuiopasdfghjklzxcvbnm"], ["[\"mno\",\"mnp\",\"mnq\"]", "abcdefghijklmnopqrstuvwxyz"], ["[\"zz\",\"zy\",\"zx\"]", "zyxwvutsrqponmlkjihgfedcba"]], "expected": [true, false, false, true, true, true, true, false, false, true, true, false, false, true, true, false, true, true, false, true, true, false, true, true, false, false, false, true, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "970", "slug": "vertical-order-traversal-of-a-binary-tree", "id": 970, "title": "Vertical Order Traversal of a Binary Tree", "difficulty": "Hard", "category": "tree", "link": "https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/", "examples": [{"input": "root = [3,9,20,null,null,15,7]", "output": "[[9],[3,15],[20],[7]]", "explanation": "Columns -1, 0, 1, 2 hold [9], [3,15], [20], [7]; within column 0 the shallower 3 precedes 15."}, {"input": "root = [1,2,3,4,5,6,7]", "output": "[[4],[2],[1,5,6],[3],[7]]", "explanation": "Nodes sharing a column and row are ordered by value, so column 0 reads 1, 5, 6."}, {"input": "root = [1,2,3,4,6,5,7]", "output": "[[4],[2],[1,5,6],[3],[7]]", "explanation": "Swapping 5 and 6 keeps the same column report because same-row ties break by value."}], "hints": ["Record every node as a (column, row, value) triple with a depth-first walk: left decrements column, right increments it, both increment row.", "Sort all triples by column, then row, then value.", "Group the sorted values by column from leftmost to rightmost."], "statement": "Place the binary tree on a grid: the root sits at column 0 and row 0; a left child moves to column - 1 and row + 1, while a right child moves to column + 1 and row + 1.\n\nCollect nodes column by column from left to right. Inside one column, order nodes by row from top to bottom; nodes sharing both column and row are ordered by value increasingly. Return the sequence of columns, each as a list of values in that order.\n\n**Constraints:**\n- The tree holds 1 to 1000 nodes.\n- Node values range from 0 to 1000.\n", "solution": "## Approach\n\nWalk the tree tracking each node's column and row (root at 0,0; left is column-1, right is column+1, both row+1). Store (column, row, value) triples for all nodes, sort them by column then row then value, and finally group consecutive triples with equal columns into the output lists. The sort directly implements the required ordering including the value tie-break.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log n), where n is the node count, dominated by sorting the triples.\n- **Space Complexity:** O(n) for the triple list and the grouped output.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def verticalTraversal(self, root) -> List[List[int]]:\n nodes = []\n def dfs(node, col, row):\n if not node:\n return\n nodes.append((col, row, node.val))\n dfs(node.left, col - 1, row + 1)\n dfs(node.right, col + 1, row + 1)\n dfs(root, 0, 0)\n nodes.sort()\n ans = []\n prev = None\n for c, r, v in nodes:\n if c != prev:\n ans.append([])\n prev = c\n ans[-1].append(v)\n return ans\n```\n", "starter": {"go": "// Definition for a binary tree node.\n// type TreeNode struct {\n// Val int\n// Left *TreeNode\n// Right *TreeNode\n// }\npackage main\n\nfunc VerticalTraversal(root *TreeNode) [][]int {\n \n}", "python": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, val=0, left=None, right=None):\n# self.val = val\n# self.left = left\n# self.right = right\nfrom typing import List\nclass Solution:\n def verticalTraversal(self, root) -> List[List[int]]:\n pass", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\n#include <vector>\n#include <algorithm>\nusing namespace std;\nclass Solution {\npublic:\n vector<vector<int>> verticalTraversal(TreeNode* root) {\n return {};\n }\n};"}, "fn": "verticalTraversal", "params": [{"name": "root", "type": "tree_node"}], "outputType": "int_list_2d", "tests": [["[3,9,20,null,null,15,7]"], ["[1,2,3,4,5,6,7]"], ["[1,2,3,4,6,5,7]"], ["[1]"], ["[1,2]"], ["[1,null,3]"], ["[1,2,3]"], ["[0,5,1,9,null,2,null,null,null,null,3,4,8,6]"], ["[1,2,3,4,5]"], ["[1,null,2,3,4]"], ["[3,9,8,4,0,1,7]"], ["[3,9,8,4,0,1,7,null,null,null,2,5]"], ["[0,2,1,3,null,null,null,4,5,null,7,6,null,10,8,11,9]"], ["[1,2,null,3]"], ["[1,null,2,null,3]"], ["[2,1,3]"], ["[4,2,6,1,3,5,7]"], ["[1,2,3,4,null,null,5]"], ["[0,-1,1]"], ["[]"], ["[10,5,15,3,7,12,20]"], ["[5,3,8,1,4,7,9]"], ["[1,2,3,null,4,null,5]"], ["[0,0,0]"], ["[3,1,4,null,2]"], ["[7,3,9,1,5,8,10]"], ["[2,null,3,null,4,null,5]"], ["[1,3,2,5,4,6,7]"]], "expected": [[[9], [3, 15], [20], [7]], [[4], [2], [1, 5, 6], [3], [7]], [[4], [2], [1, 5, 6], [3], [7]], [[1]], [[2], [1]], [[1], [3]], [[2], [1], [3]], [[9], [5, 6], [0, 2, 4], [1, 3], [8]], [[4], [2], [1, 5], [3]], [[1, 3], [2], [4]], [[4], [9], [3, 0, 1], [8], [7]], [[4], [9, 5], [3, 0, 1], [8, 2], [7]], [[4, 10, 11], [3, 6, 7], [2, 5, 8, 9], [0], [1]], [[3], [2], [1]], [[1], [2], [3]], [[1], [2], [3]], [[1], [2], [4, 3, 5], [6], [7]], [[4], [2], [1], [3], [5]], [[-1], [0], [1]], [], [[3], [5], [10, 7, 12], [15], [20]], [[1], [3], [5, 4, 7], [8], [9]], [[2], [1, 4], [3], [5]], [[0], [0], [0]], [[1], [3, 2], [4]], [[1], [3], [7, 5, 8], [9], [10]], [[2], [3], [4], [5]], [[5], [3], [1, 4, 6], [2], [7]]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "952", "slug": "vowel-spellchecker", "id": 952, "title": "Vowel Spellchecker", "difficulty": "Medium", "category": "hash-table", "link": "https://leetcode.com/problems/vowel-spellchecker/", "examples": [{"input": "wordlist = [\"KiTe\",\"kite\",\"hare\",\"Hare\"], queries = [\"kite\",\"Kite\",\"KiTe\",\"Hare\",\"HARE\",\"Hear\",\"hear\",\"keti\",\"keet\",\"keto\"]", "output": "[\"kite\",\"KiTe\",\"KiTe\",\"Hare\",\"hare\",\"\",\"\",\"KiTe\",\"\",\"KiTe\"]", "explanation": "Exact hits win first ('kite', 'KiTe', 'Hare'); case-insensitive matches resolve 'Kite' and 'HARE'; vowel-tolerant matches catch 'keti' and 'keto'."}, {"input": "wordlist = [\"yellow\"], queries = [\"YellOw\"]", "output": "[\"yellow\"]", "explanation": "No exact hit exists, but lowercasing both sides matches 'yellow'."}, {"input": "wordlist = [\"hello\",\"world\"], queries = [\"Hello\",\"WORLD\",\"hallo\",\"warld\",\"xyz\"]", "output": "[\"hello\",\"world\",\"hello\",\"world\",\"\"]", "explanation": "'hallo' shares the consonant skeleton of 'hello', while 'xyz' matches nothing and yields an empty string."}], "hints": ["Build the exact set plus lowercase-first and vowel-masked-first maps in a single pass.", "Keep the first vocabulary word for each masked key; later duplicates must not overwrite it.", "Lowercase before masking so uppercase vowels collapse to the same wildcard."], "statement": "A spellchecker holds a vocabulary `wordlist`. Each lookup query is answered by the first rule below that produces a match, scanning the vocabulary in order for rules 2 and 3:\n\n1. Exact match: the query appears in the vocabulary verbatim \u2014 return it unchanged.\n2. Case-insensitive match: some vocabulary word equals the query after lowercasing both \u2014 return that vocabulary word.\n3. Vowel-error match: some vocabulary word equals the query after lowercasing both and replacing every vowel (`a`, `e`, `i`, `o`, `u`) with a wildcard \u2014 return that vocabulary word.\n4. Otherwise return the empty string.\n\nAnswer every query in `queries` and return the answers in order as a string list.\n\n**Constraints:**\n- `0 <= wordlist.length, queries.length <= 5000`\n- Words contain only English letters; matching is described purely by the rules above.\n- The vocabulary arrives as a string array and the answers form a string list.\n", "solution": "## Approach\n\nPrecompute three lookup structures from the vocabulary: an exact set, a lowercased map keeping each key's first vocabulary word, and a vowel-masked map (lowercase with vowels replaced by a placeholder) likewise keeping first words. Each query then checks the three structures in priority order, falling back to the empty string. All maps are built once, so every query costs only string-length work.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(total characters in wordlist and queries).\n- **Space Complexity:** O(total characters in wordlist) for the three maps.\n\n## Implementation\n\n```python\nclass Solution:\n def spellchecker(self, wordlist: list[str], queries: list[str]) -> list[str]:\n def mask(w):\n return \"\".join(\"*\" if c in \"aeiouAEIOU\" else c.lower() for c in w)\n\n exact = set(wordlist)\n case_map, vowel_map = {}, {}\n for w in wordlist:\n lw = w.lower()\n if lw not in case_map:\n case_map[lw] = w\n m = mask(w)\n if m not in vowel_map:\n vowel_map[m] = w\n ans = []\n for q in queries:\n if q in exact:\n ans.append(q)\n elif q.lower() in case_map:\n ans.append(case_map[q.lower()])\n elif mask(q) in vowel_map:\n ans.append(vowel_map[mask(q)])\n else:\n ans.append(\"\")\n return ans\n```\n", "starter": {"go": "package main\n\nfunc Spellchecker(wordlist []string, queries []string) []string {\n return nil\n}", "python": "from typing import List\nclass Solution:\n def spellchecker(self, wordlist: List[str], queries: List[str]) -> List[str]:\n return []", "cpp": "#include <string>\n#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<string> spellchecker(vector<string>& wordlist, vector<string>& queries) {\n return {};\n }\n};"}, "fn": "spellchecker", "params": [{"name": "wordlist", "type": "string_array"}, {"name": "queries", "type": "string_array"}], "outputType": "string_list", "tests": [["[\"KiTe\",\"kite\",\"hare\",\"Hare\"]", "[\"kite\",\"Kite\",\"KiTe\",\"Hare\",\"HARE\",\"Hear\",\"hear\",\"keti\",\"keet\",\"keto\"]"], ["[\"yellow\"]", "[\"YellOw\"]"], ["[\"hello\",\"world\"]", "[\"Hello\",\"WORLD\",\"hallo\",\"warld\",\"xyz\"]"], ["[\"ae\",\"aa\"]", "[\"aa\",\"ae\",\"oe\"]"], ["[\"kite\",\"Kite\",\"KiTe\"]", "[\"kite\",\"KITE\",\"kete\",\"keto\"]"], ["[\"YellOw\"]", "[\"yellow\",\"YELLOW\",\"YellOw\"]"], ["[\"a\",\"e\",\"i\",\"o\",\"u\"]", "[\"A\",\"E\",\"b\",\"I\",\"O\",\"U\"]"], ["[\"abc\",\"def\"]", "[\"ABC\",\"DEF\",\"abf\",\"deg\",\"ghi\"]"], ["[\"Foo\",\"bar\",\"BAR\"]", "[\"foo\",\"Foo\",\"BAR\",\"bar\",\"Bar\",\"far\",\"bor\"]"], ["[\"mno\",\"mno\"]", "[\"MNO\",\"mno\",\"mne\"]"], ["[\"apple\",\"apply\"]", "[\"Apple\",\"APPLE\",\"epple\",\"applo\",\"appla\"]"], ["[\"x\"]", "[\"X\",\"x\",\"y\",\"e\"]"], ["[\"Open\",\"open\"]", "[\"OPEN\",\"apen\",\"opin\",\"open\"]"], ["[\"cat\",\"bat\",\"rat\"]", "[\"CAT\",\"cut\",\"BET\",\"rot\",\"dog\"]"], ["[\"spell\",\"checker\"]", "[\"SPELL\",\"spell\",\"spall\",\"CHECKER\",\"chacker\",\"checkor\"]"], ["[\"Aeiou\"]", "[\"aeiou\",\"AEIOU\",\"Aeiou\",\"ooooo\"]"], ["[\"bcdfg\"]", "[\"BCDFG\",\"bcdfg\",\"bedfg\"]"], ["[\"programming\",\"contest\"]", "[\"PROGRAMMING\",\"prigramming\",\"CONTEST\",\"cuntest\",\"xyz\"]"], ["[\"z\"]", "[\"Z\",\"a\",\"e\"]"], ["[\"same\",\"SAME\"]", "[\"same\",\"Same\",\"SAME\",\"seme\",\"soma\"]"], ["[\"up\",\"down\"]", "[\"UP\",\"Down\",\"DOWN\",\"ap\",\"dawn\"]"], ["[\"left\",\"right\"]", "[\"LEFT\",\"lift\",\"RIGHT\",\"roght\",\"reft\"]"], ["[\"one\",\"two\",\"three\"]", "[\"ONE\",\"ane\",\"TWO\",\"thee\",\"THREE\",\"thrae\",\"four\"]"], ["[\"qwerty\"]", "[\"QWERTY\",\"qwerty\",\"qwarty\",\"qwerti\"]"], ["[\"hello\"]", "[]"], ["[]", "[\"hello\",\"world\"]"], ["[\"Abc\",\"aBc\",\"abC\"]", "[\"abc\",\"ABC\",\"Abc\",\"ebc\",\"obc\"]"], ["[\"vowel\",\"VOWEL\"]", "[\"Vowel\",\"vowel\",\"VOWEL\",\"vawel\",\"viwel\",\"vowelx\"]"]], "expected": [["kite", "KiTe", "KiTe", "Hare", "hare", "", "", "KiTe", "", "KiTe"], ["yellow"], ["hello", "world", "hello", "world", ""], ["aa", "ae", "ae"], ["kite", "kite", "kite", "kite"], ["YellOw", "YellOw", "YellOw"], ["a", "e", "", "i", "o", "u"], ["abc", "def", "", "", ""], ["Foo", "Foo", "BAR", "bar", "bar", "", "bar"], ["mno", "mno", "mno"], ["apple", "apple", "apple", "apple", "apple"], ["x", "x", "", ""], ["Open", "Open", "Open", "open"], ["cat", "cat", "bat", "rat", ""], ["spell", "spell", "spell", "checker", "checker", "checker"], ["Aeiou", "Aeiou", "Aeiou", "Aeiou"], ["bcdfg", "bcdfg", ""], ["programming", "programming", "contest", "contest", ""], ["z", "", ""], ["same", "same", "SAME", "same", "same"], ["up", "down", "down", "up", "down"], ["left", "left", "right", "right", ""], ["one", "one", "two", "", "three", "three", ""], ["qwerty", "qwerty", "qwerty", ""], [], ["", ""], ["Abc", "Abc", "Abc", "Abc", "Abc"], ["vowel", "vowel", "VOWEL", "vowel", "vowel", ""]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "868", "slug": "walking-robot-simulation", "id": 868, "title": "Walking Robot Simulation", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/walking-robot-simulation/", "examples": [{"input": "commands = [4,-1,3], obstacles = []", "output": "25", "explanation": "The robot walks to (0, 4), turns east, then walks to (3, 4), where 3*3 + 4*4 = 25."}, {"input": "commands = [4,-1,4,-2,4], obstacles = [[2,4]]", "output": "65", "explanation": "The robot reaches (0, 4), is stopped by the obstacle at (2, 4) and halts at (1, 4), then turns north and finishes at (1, 8), giving 1 + 64 = 65."}, {"input": "commands = [6,-1,-1,6], obstacles = []", "output": "36", "explanation": "The robot walks north to (0, 6), turns around, and walks back to the origin. The farthest point is (0, 6) with distance squared 36."}], "hints": ["Store every obstacle in a hash set so each single-step move can be checked in O(1).", "Keep a direction index 0..3 for north, east, south, west; -2 subtracts one (mod 4) and -1 adds one."], "statement": "A robot starts at position `(0, 0)` facing north. It follows a list of integer `commands`:\n\n- A value of `-2` turns it 90 degrees to the left without moving.\n- A value of `-1` turns it 90 degrees to the right without moving.\n- A value `k` between `1` and `9` moves it forward `k` steps, one cell at a time. If the next cell holds an obstacle, the robot stops that command early and stays where it is.\n\n`obstacles` lists the blocked cells as `[x, y]` pairs. After running every command, return the largest Euclidean distance squared (`x*x + y*y`) the robot ever reached.\n\n**Constraints:**\n- `1 <= commands.length <= 10^4`\n- Each command is `-2`, `-1`, or an integer from `1` to `9`.\n- `0 <= obstacles.length <= 10^4`\n- `-30000 <= obstacles[i][0], obstacles[i][1] <= 30000`\n- The final answer fits in a 32-bit signed integer.\n", "solution": "## Approach\n\nCollect all obstacles into a set of coordinate pairs for constant-time lookup. Walk through the commands while tracking the position and a heading index (north, east, south, west). Turns only rotate the heading; a move command advances one cell at a time and stops early when the next cell is blocked. After every step, refresh the best value of `x*x + y*y`.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(C + S), where C is the number of commands and S is the total number of single steps walked (at most 9 per move command).\n- **Space Complexity:** O(B) for the obstacle set, where B is the number of obstacles.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def robotSim(self, commands: List[int], obstacles: List[List[int]]) -> int:\n blocked = {(x, y) for x, y in obstacles}\n dirs = [(0, 1), (1, 0), (0, -1), (-1, 0)]\n d = x = y = best = 0\n for c in commands:\n if c == -2:\n d = (d + 3) % 4\n elif c == -1:\n d = (d + 1) % 4\n else:\n for _ in range(c):\n nx, ny = x + dirs[d][0], y + dirs[d][1]\n if (nx, ny) in blocked:\n break\n x, y = nx, ny\n best = max(best, x * x + y * y)\n return best\n```\n", "starter": {"go": "package main\n\nfunc RobotSim(commands []int, obstacles [][]int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def robotSim(self, commands: List[int], obstacles: List[List[int]]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int robotSim(vector<int>& commands, vector<vector<int>>& obstacles) {\n return 0;\n }\n};"}, "fn": "robotSim", "params": [{"name": "commands", "type": "int_array"}, {"name": "obstacles", "type": "int_array_2d"}], "outputType": "int", "tests": [["[4,-1,3]", "[]"], ["[4,-1,4,-2,4]", "[[2,4]]"], ["[6,-1,-1,6]", "[]"], ["[1]", "[]"], ["[-1]", "[]"], ["[-2]", "[]"], ["[-2,-1,-2,-1]", "[]"], ["[9,9,9]", "[]"], ["[9,-1,9]", "[]"], ["[4,-1,3]", "[[3,4]]"], ["[1,-1,1,-1,1,-1,1]", "[]"], ["[4]", "[[0,1],[0,2],[0,3],[0,4]]"], ["[2,-2,2,-2,2]", "[]"], ["[9,9,9,9,9,9,9,9,9,9]", "[]"], ["[4,-1,3]", "[[100,100],[-50,-50]]"], ["[4,-2,4]", "[]"], ["[5,-1,5,-1,5,-1,5]", "[]"], ["[9]", "[[0,1]]"], ["[3]", "[[0,2]]"], ["[3,-1,3,-1,3,-1,3]", "[]"], ["[1,1,1,-1,1,1]", "[]"], ["[2,-1,2,-1,2]", "[[1,2]]"], ["[7,-2,7]", "[]"], ["[-1,-2]", "[]"], ["[9,-1,9,-1,9,-1,9]", "[]"], ["[2]", "[[0,0]]"], ["[4,-1,4,-1,4,-1,4]", "[]"], ["[6,-2,6,-2,6]", "[]"]], "expected": [25, 65, 36, 1, 0, 0, 0, 729, 162, 20, 2, 0, 8, 8100, 25, 32, 50, 0, 1, 18, 13, 4, 98, 0, 162, 4, 32, 72], "loose": false}