offcode 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1038) hide show
  1. package/README.md +38 -2
  2. package/data/index.json +1 -0
  3. package/data/problems/01-matrix.json +1 -0
  4. package/data/problems/1-bit-and-2-bit-characters.json +1 -0
  5. package/data/problems/132-pattern.json +1 -0
  6. package/data/problems/2-keys-keyboard.json +1 -0
  7. package/data/problems/24-game.json +1 -0
  8. package/data/problems/3sum-closest.json +1 -0
  9. package/data/problems/3sum-smaller.json +1 -0
  10. package/data/problems/3sum-with-multiplicity.json +1 -0
  11. package/data/problems/3sum.json +1 -0
  12. package/data/problems/4-keys-keyboard.json +1 -0
  13. package/data/problems/4sum-ii.json +1 -0
  14. package/data/problems/4sum.json +1 -0
  15. package/data/problems/accounts-merge.json +1 -0
  16. package/data/problems/add-binary.json +1 -0
  17. package/data/problems/add-bold-tag-in-string.json +1 -0
  18. package/data/problems/add-digits.json +1 -0
  19. package/data/problems/add-one-row-to-tree.json +1 -0
  20. package/data/problems/add-strings.json +1 -0
  21. package/data/problems/add-to-array-form-of-integer.json +1 -0
  22. package/data/problems/add-two-numbers-ii.json +1 -0
  23. package/data/problems/add-two-numbers.json +1 -0
  24. package/data/problems/additive-number.json +1 -0
  25. package/data/problems/advantage-shuffle.json +1 -0
  26. package/data/problems/alien-dictionary.json +1 -0
  27. package/data/problems/all-nodes-distance-k-in-binary-tree.json +1 -0
  28. package/data/problems/all-oone-data-structure.json +1 -0
  29. package/data/problems/all-paths-from-source-to-target.json +1 -0
  30. package/data/problems/all-possible-full-binary-trees.json +1 -0
  31. package/data/problems/ambiguous-coordinates.json +1 -0
  32. package/data/problems/android-unlock-patterns.json +1 -0
  33. package/data/problems/arithmetic-slices-ii-subsequence.json +1 -0
  34. package/data/problems/arithmetic-slices.json +1 -0
  35. package/data/problems/arranging-coins.json +1 -0
  36. package/data/problems/array-nesting.json +1 -0
  37. package/data/problems/array-of-doubled-pairs.json +1 -0
  38. package/data/problems/array-partition.json +1 -0
  39. package/data/problems/assign-cookies.json +1 -0
  40. package/data/problems/asteroid-collision.json +1 -0
  41. package/data/problems/available-captures-for-rook.json +1 -0
  42. package/data/problems/average-of-levels-in-binary-tree.json +1 -0
  43. package/data/problems/backspace-string-compare.json +1 -0
  44. package/data/problems/bag-of-tokens.json +1 -0
  45. package/data/problems/balanced-binary-tree.json +1 -0
  46. package/data/problems/base-7.json +1 -0
  47. package/data/problems/baseball-game.json +1 -0
  48. package/data/problems/basic-absolute-value.json +1 -0
  49. package/data/problems/basic-array-max.json +1 -0
  50. package/data/problems/basic-array-min.json +1 -0
  51. package/data/problems/basic-array-sum-rec.json +1 -0
  52. package/data/problems/basic-array-sum.json +1 -0
  53. package/data/problems/basic-average-floor.json +1 -0
  54. package/data/problems/basic-bubble-sort.json +1 -0
  55. package/data/problems/basic-calculator-ii.json +1 -0
  56. package/data/problems/basic-calculator-iii.json +1 -0
  57. package/data/problems/basic-calculator-iv.json +1 -0
  58. package/data/problems/basic-calculator.json +1 -0
  59. package/data/problems/basic-collatz-steps.json +1 -0
  60. package/data/problems/basic-contains-value.json +1 -0
  61. package/data/problems/basic-count-above.json +1 -0
  62. package/data/problems/basic-count-char.json +1 -0
  63. package/data/problems/basic-count-digits.json +1 -0
  64. package/data/problems/basic-count-evens.json +1 -0
  65. package/data/problems/basic-count-pairs.json +1 -0
  66. package/data/problems/basic-count-vowels.json +1 -0
  67. package/data/problems/basic-count-words.json +1 -0
  68. package/data/problems/basic-countdown.json +1 -0
  69. package/data/problems/basic-double-array.json +1 -0
  70. package/data/problems/basic-factorial-rec.json +1 -0
  71. package/data/problems/basic-factorial.json +1 -0
  72. package/data/problems/basic-fibonacci.json +1 -0
  73. package/data/problems/basic-find-index.json +1 -0
  74. package/data/problems/basic-gcd.json +1 -0
  75. package/data/problems/basic-grade-letter.json +1 -0
  76. package/data/problems/basic-has-duplicate.json +1 -0
  77. package/data/problems/basic-is-even.json +1 -0
  78. package/data/problems/basic-is-leap-year.json +1 -0
  79. package/data/problems/basic-is-sorted.json +1 -0
  80. package/data/problems/basic-max-frequency.json +1 -0
  81. package/data/problems/basic-max-of-three.json +1 -0
  82. package/data/problems/basic-max-of-two.json +1 -0
  83. package/data/problems/basic-palindrome-text.json +1 -0
  84. package/data/problems/basic-power-rec.json +1 -0
  85. package/data/problems/basic-power.json +1 -0
  86. package/data/problems/basic-repeat-string.json +1 -0
  87. package/data/problems/basic-reverse-array.json +1 -0
  88. package/data/problems/basic-reverse-number.json +1 -0
  89. package/data/problems/basic-reverse-text-rec.json +1 -0
  90. package/data/problems/basic-reverse-text.json +1 -0
  91. package/data/problems/basic-second-largest.json +1 -0
  92. package/data/problems/basic-sort-two.json +1 -0
  93. package/data/problems/basic-staircase.json +1 -0
  94. package/data/problems/basic-string-length.json +1 -0
  95. package/data/problems/basic-sum-1-to-n.json +1 -0
  96. package/data/problems/basic-sum-digits-rec.json +1 -0
  97. package/data/problems/basic-sum-multiples.json +1 -0
  98. package/data/problems/basic-sum-of-digits.json +1 -0
  99. package/data/problems/basic-temperature-advice.json +1 -0
  100. package/data/problems/basic-to-upper.json +1 -0
  101. package/data/problems/basic-triangle-sum.json +1 -0
  102. package/data/problems/battleships-in-a-board.json +1 -0
  103. package/data/problems/beautiful-arrangement-ii.json +1 -0
  104. package/data/problems/beautiful-arrangement.json +1 -0
  105. package/data/problems/beautiful-array.json +1 -0
  106. package/data/problems/best-meeting-point.json +1 -0
  107. package/data/problems/best-time-to-buy-and-sell-stock-ii.json +1 -0
  108. package/data/problems/best-time-to-buy-and-sell-stock-iii.json +1 -0
  109. package/data/problems/best-time-to-buy-and-sell-stock-iv.json +1 -0
  110. package/data/problems/best-time-to-buy-and-sell-stock-with-cooldown.json +1 -0
  111. package/data/problems/best-time-to-buy-and-sell-stock-with-transaction-fee.json +1 -0
  112. package/data/problems/best-time-to-buy-and-sell-stock.json +1 -0
  113. package/data/problems/binary-gap.json +1 -0
  114. package/data/problems/binary-number-with-alternating-bits.json +1 -0
  115. package/data/problems/binary-search-tree-iterator.json +1 -0
  116. package/data/problems/binary-search.json +1 -0
  117. package/data/problems/binary-subarrays-with-sum.json +1 -0
  118. package/data/problems/binary-tree-cameras.json +1 -0
  119. package/data/problems/binary-tree-inorder-traversal.json +1 -0
  120. package/data/problems/binary-tree-level-order-traversal-ii.json +1 -0
  121. package/data/problems/binary-tree-level-order-traversal.json +1 -0
  122. package/data/problems/binary-tree-longest-consecutive-sequence-ii.json +1 -0
  123. package/data/problems/binary-tree-longest-consecutive-sequence.json +1 -0
  124. package/data/problems/binary-tree-maximum-path-sum.json +1 -0
  125. package/data/problems/binary-tree-paths.json +1 -0
  126. package/data/problems/binary-tree-postorder-traversal.json +1 -0
  127. package/data/problems/binary-tree-preorder-traversal.json +1 -0
  128. package/data/problems/binary-tree-pruning.json +1 -0
  129. package/data/problems/binary-tree-right-side-view.json +1 -0
  130. package/data/problems/binary-tree-tilt.json +1 -0
  131. package/data/problems/binary-tree-upside-down.json +1 -0
  132. package/data/problems/binary-tree-vertical-order-traversal.json +1 -0
  133. package/data/problems/binary-tree-zigzag-level-order-traversal.json +1 -0
  134. package/data/problems/binary-trees-with-factors.json +1 -0
  135. package/data/problems/binary-watch.json +1 -0
  136. package/data/problems/bitwise-and-of-numbers-range.json +1 -0
  137. package/data/problems/bitwise-ors-of-subarrays.json +1 -0
  138. package/data/problems/boats-to-save-people.json +1 -0
  139. package/data/problems/bold-words-in-string.json +1 -0
  140. package/data/problems/bomb-enemy.json +1 -0
  141. package/data/problems/boundary-of-binary-tree.json +1 -0
  142. package/data/problems/brick-wall.json +1 -0
  143. package/data/problems/bricks-falling-when-hit.json +1 -0
  144. package/data/problems/broken-calculator.json +1 -0
  145. package/data/problems/buddy-strings.json +1 -0
  146. package/data/problems/build-a-matrix-with-conditions.json +1 -0
  147. package/data/problems/bulb-switcher-ii.json +1 -0
  148. package/data/problems/bulb-switcher.json +1 -0
  149. package/data/problems/bulls-and-cows.json +1 -0
  150. package/data/problems/burst-balloons.json +1 -0
  151. package/data/problems/bus-routes.json +1 -0
  152. package/data/problems/can-i-win.json +1 -0
  153. package/data/problems/can-place-flowers.json +1 -0
  154. package/data/problems/candy-crush.json +1 -0
  155. package/data/problems/candy.json +1 -0
  156. package/data/problems/capacity-to-ship-packages-within-d-days.json +1 -0
  157. package/data/problems/car-fleet.json +1 -0
  158. package/data/problems/car-pooling.json +1 -0
  159. package/data/problems/card-flipping-game.json +1 -0
  160. package/data/problems/cat-and-mouse.json +1 -0
  161. package/data/problems/chalkboard-xor-game.json +1 -0
  162. package/data/problems/champagne-tower.json +1 -0
  163. package/data/problems/cheapest-flights-within-k-stops.json +1 -0
  164. package/data/problems/check-completeness-of-a-binary-tree.json +1 -0
  165. package/data/problems/cherry-pickup.json +1 -0
  166. package/data/problems/circular-array-loop.json +1 -0
  167. package/data/problems/climbing-stairs.json +1 -0
  168. package/data/problems/clone-graph.json +1 -0
  169. package/data/problems/closest-binary-search-tree-value-ii.json +1 -0
  170. package/data/problems/closest-binary-search-tree-value.json +1 -0
  171. package/data/problems/closest-leaf-in-a-binary-tree.json +1 -0
  172. package/data/problems/coin-change-ii.json +1 -0
  173. package/data/problems/coin-change.json +1 -0
  174. package/data/problems/coin-path.json +1 -0
  175. package/data/problems/combination-sum-ii.json +1 -0
  176. package/data/problems/combination-sum-iii.json +1 -0
  177. package/data/problems/combination-sum-iv.json +1 -0
  178. package/data/problems/combination-sum.json +1 -0
  179. package/data/problems/combinations.json +1 -0
  180. package/data/problems/compare-version-numbers.json +1 -0
  181. package/data/problems/complete-binary-tree-inserter.json +1 -0
  182. package/data/problems/complex-number-multiplication.json +1 -0
  183. package/data/problems/concatenated-words.json +1 -0
  184. package/data/problems/concatenation-of-array.json +1 -0
  185. package/data/problems/consecutive-numbers-sum.json +1 -0
  186. package/data/problems/construct-binary-tree-from-inorder-and-postorder-traversal.json +1 -0
  187. package/data/problems/construct-binary-tree-from-preorder-and-inorder-traversal.json +1 -0
  188. package/data/problems/construct-binary-tree-from-preorder-and-postorder-traversal.json +1 -0
  189. package/data/problems/construct-binary-tree-from-string.json +1 -0
  190. package/data/problems/construct-quad-tree.json +1 -0
  191. package/data/problems/construct-string-from-binary-tree.json +1 -0
  192. package/data/problems/construct-the-rectangle.json +1 -0
  193. package/data/problems/contain-virus.json +1 -0
  194. package/data/problems/container-with-most-water.json +1 -0
  195. package/data/problems/contains-duplicate-ii.json +1 -0
  196. package/data/problems/contains-duplicate-iii.json +1 -0
  197. package/data/problems/contains-duplicate.json +1 -0
  198. package/data/problems/contiguous-array.json +1 -0
  199. package/data/problems/continuous-subarray-sum.json +1 -0
  200. package/data/problems/convert-a-number-to-hexadecimal.json +1 -0
  201. package/data/problems/convert-binary-search-tree-to-sorted-doubly-linked-list.json +1 -0
  202. package/data/problems/convert-bst-to-greater-tree.json +1 -0
  203. package/data/problems/convert-sorted-array-to-binary-search-tree.json +1 -0
  204. package/data/problems/convert-sorted-list-to-binary-search-tree.json +1 -0
  205. package/data/problems/convex-polygon.json +1 -0
  206. package/data/problems/copy-list-with-random-pointer.json +1 -0
  207. package/data/problems/count-and-say.json +1 -0
  208. package/data/problems/count-binary-substrings.json +1 -0
  209. package/data/problems/count-complete-tree-nodes.json +1 -0
  210. package/data/problems/count-different-palindromic-subsequences.json +1 -0
  211. package/data/problems/count-good-nodes-in-binary-tree.json +1 -0
  212. package/data/problems/count-numbers-with-unique-digits.json +1 -0
  213. package/data/problems/count-of-range-sum.json +1 -0
  214. package/data/problems/count-of-smaller-numbers-after-self.json +1 -0
  215. package/data/problems/count-primes.json +1 -0
  216. package/data/problems/count-the-repetitions.json +1 -0
  217. package/data/problems/count-unique-characters-of-all-substrings-of-a-given-string.json +1 -0
  218. package/data/problems/count-univalue-subtrees.json +1 -0
  219. package/data/problems/counting-bits.json +1 -0
  220. package/data/problems/couples-holding-hands.json +1 -0
  221. package/data/problems/course-schedule-ii.json +1 -0
  222. package/data/problems/course-schedule-iii.json +1 -0
  223. package/data/problems/course-schedule-iv.json +1 -0
  224. package/data/problems/course-schedule.json +1 -0
  225. package/data/problems/cousins-in-binary-tree.json +1 -0
  226. package/data/problems/cracking-the-safe.json +1 -0
  227. package/data/problems/create-maximum-number.json +1 -0
  228. package/data/problems/custom-sort-string.json +1 -0
  229. package/data/problems/cut-off-trees-for-golf-event.json +1 -0
  230. package/data/problems/daily-temperatures.json +1 -0
  231. package/data/problems/data-stream-as-disjoint-intervals.json +1 -0
  232. package/data/problems/decode-string.json +1 -0
  233. package/data/problems/decode-ways-ii.json +1 -0
  234. package/data/problems/decode-ways.json +1 -0
  235. package/data/problems/decoded-string-at-index.json +1 -0
  236. package/data/problems/degree-of-an-array.json +1 -0
  237. package/data/problems/delete-and-earn.json +1 -0
  238. package/data/problems/delete-columns-to-make-sorted-ii.json +1 -0
  239. package/data/problems/delete-columns-to-make-sorted-iii.json +1 -0
  240. package/data/problems/delete-columns-to-make-sorted.json +1 -0
  241. package/data/problems/delete-leaves-with-a-given-value.json +1 -0
  242. package/data/problems/delete-node-in-a-bst.json +1 -0
  243. package/data/problems/delete-node-in-a-linked-list.json +1 -0
  244. package/data/problems/delete-operation-for-two-strings.json +1 -0
  245. package/data/problems/design-add-and-search-words-data-structure.json +1 -0
  246. package/data/problems/design-circular-deque.json +1 -0
  247. package/data/problems/design-circular-queue.json +1 -0
  248. package/data/problems/design-compressed-string-iterator.json +1 -0
  249. package/data/problems/design-excel-sum-formula.json +1 -0
  250. package/data/problems/design-hashmap.json +1 -0
  251. package/data/problems/design-hashset.json +1 -0
  252. package/data/problems/design-hit-counter.json +1 -0
  253. package/data/problems/design-in-memory-file-system.json +1 -0
  254. package/data/problems/design-linked-list.json +1 -0
  255. package/data/problems/design-log-storage-system.json +1 -0
  256. package/data/problems/design-phone-directory.json +1 -0
  257. package/data/problems/design-search-autocomplete-system.json +1 -0
  258. package/data/problems/design-snake-game.json +1 -0
  259. package/data/problems/design-tic-tac-toe.json +1 -0
  260. package/data/problems/design-twitter.json +1 -0
  261. package/data/problems/detect-capital.json +1 -0
  262. package/data/problems/detect-squares.json +1 -0
  263. package/data/problems/di-string-match.json +1 -0
  264. package/data/problems/diagonal-traverse.json +1 -0
  265. package/data/problems/diameter-of-binary-tree.json +1 -0
  266. package/data/problems/different-ways-to-add-parentheses.json +1 -0
  267. package/data/problems/distinct-subsequences-ii.json +1 -0
  268. package/data/problems/distinct-subsequences.json +1 -0
  269. package/data/problems/distribute-candies.json +1 -0
  270. package/data/problems/distribute-coins-in-binary-tree.json +1 -0
  271. package/data/problems/divide-two-integers.json +1 -0
  272. package/data/problems/domino-and-tromino-tiling.json +1 -0
  273. package/data/problems/dota2-senate.json +1 -0
  274. package/data/problems/dungeon-game.json +1 -0
  275. package/data/problems/edit-distance.json +1 -0
  276. package/data/problems/elimination-game.json +1 -0
  277. package/data/problems/employee-free-time.json +1 -0
  278. package/data/problems/employee-importance.json +1 -0
  279. package/data/problems/encode-and-decode-strings.json +1 -0
  280. package/data/problems/encode-and-decode-tinyurl.json +1 -0
  281. package/data/problems/encode-n-ary-tree-to-binary-tree.json +1 -0
  282. package/data/problems/encode-string-with-shortest-length.json +1 -0
  283. package/data/problems/equal-rational-numbers.json +1 -0
  284. package/data/problems/equal-tree-partition.json +1 -0
  285. package/data/problems/erect-the-fence.json +1 -0
  286. package/data/problems/escape-the-ghosts.json +1 -0
  287. package/data/problems/evaluate-division.json +1 -0
  288. package/data/problems/evaluate-reverse-polish-notation.json +1 -0
  289. package/data/problems/exam-room.json +1 -0
  290. package/data/problems/excel-sheet-column-number.json +1 -0
  291. package/data/problems/excel-sheet-column-title.json +1 -0
  292. package/data/problems/exclusive-time-of-functions.json +1 -0
  293. package/data/problems/expression-add-operators.json +1 -0
  294. package/data/problems/expressive-words.json +1 -0
  295. package/data/problems/extra-characters-in-a-string.json +1 -0
  296. package/data/problems/factor-combinations.json +1 -0
  297. package/data/problems/factorial-trailing-zeroes.json +1 -0
  298. package/data/problems/fair-candy-swap.json +1 -0
  299. package/data/problems/falling-squares.json +1 -0
  300. package/data/problems/fibonacci-number.json +1 -0
  301. package/data/problems/find-all-anagrams-in-a-string.json +1 -0
  302. package/data/problems/find-all-duplicates-in-an-array.json +1 -0
  303. package/data/problems/find-all-numbers-disappeared-in-an-array.json +1 -0
  304. package/data/problems/find-anagram-mappings.json +1 -0
  305. package/data/problems/find-and-replace-in-string.json +1 -0
  306. package/data/problems/find-and-replace-pattern.json +1 -0
  307. package/data/problems/find-bottom-left-tree-value.json +1 -0
  308. package/data/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree.json +1 -0
  309. package/data/problems/find-duplicate-file-in-system.json +1 -0
  310. package/data/problems/find-duplicate-subtrees.json +1 -0
  311. package/data/problems/find-eventual-safe-states.json +1 -0
  312. package/data/problems/find-first-and-last-position-of-element-in-sorted-array.json +1 -0
  313. package/data/problems/find-in-mountain-array.json +1 -0
  314. package/data/problems/find-k-closest-elements.json +1 -0
  315. package/data/problems/find-k-pairs-with-smallest-sums.json +1 -0
  316. package/data/problems/find-k-th-smallest-pair-distance.json +1 -0
  317. package/data/problems/find-largest-value-in-each-tree-row.json +1 -0
  318. package/data/problems/find-leaves-of-binary-tree.json +1 -0
  319. package/data/problems/find-median-from-data-stream.json +1 -0
  320. package/data/problems/find-minimum-in-rotated-sorted-array-ii.json +1 -0
  321. package/data/problems/find-minimum-in-rotated-sorted-array.json +1 -0
  322. package/data/problems/find-mode-in-binary-search-tree.json +1 -0
  323. package/data/problems/find-peak-element.json +1 -0
  324. package/data/problems/find-permutation.json +1 -0
  325. package/data/problems/find-pivot-index.json +1 -0
  326. package/data/problems/find-right-interval.json +1 -0
  327. package/data/problems/find-smallest-letter-greater-than-target.json +1 -0
  328. package/data/problems/find-the-celebrity.json +1 -0
  329. package/data/problems/find-the-closest-palindrome.json +1 -0
  330. package/data/problems/find-the-derangement-of-an-array.json +1 -0
  331. package/data/problems/find-the-difference.json +1 -0
  332. package/data/problems/find-the-duplicate-number.json +1 -0
  333. package/data/problems/find-the-index-of-the-first-occurrence-in-a-string.json +1 -0
  334. package/data/problems/find-the-shortest-superstring.json +1 -0
  335. package/data/problems/find-the-town-judge.json +1 -0
  336. package/data/problems/first-bad-version.json +1 -0
  337. package/data/problems/first-missing-positive.json +1 -0
  338. package/data/problems/first-unique-character-in-a-string.json +1 -0
  339. package/data/problems/fizz-buzz.json +1 -0
  340. package/data/problems/flatten-2d-vector.json +1 -0
  341. package/data/problems/flatten-a-multilevel-doubly-linked-list.json +1 -0
  342. package/data/problems/flatten-binary-tree-to-linked-list.json +1 -0
  343. package/data/problems/flatten-nested-list-iterator.json +1 -0
  344. package/data/problems/flip-binary-tree-to-match-preorder-traversal.json +1 -0
  345. package/data/problems/flip-equivalent-binary-trees.json +1 -0
  346. package/data/problems/flip-game-ii.json +1 -0
  347. package/data/problems/flip-game.json +1 -0
  348. package/data/problems/flip-string-to-monotone-increasing.json +1 -0
  349. package/data/problems/flipping-an-image.json +1 -0
  350. package/data/problems/flood-fill.json +1 -0
  351. package/data/problems/fraction-addition-and-subtraction.json +1 -0
  352. package/data/problems/fraction-to-recurring-decimal.json +1 -0
  353. package/data/problems/freedom-trail.json +1 -0
  354. package/data/problems/friends-of-appropriate-ages.json +1 -0
  355. package/data/problems/frog-jump.json +1 -0
  356. package/data/problems/fruit-into-baskets.json +1 -0
  357. package/data/problems/game-of-life.json +1 -0
  358. package/data/problems/gas-station.json +1 -0
  359. package/data/problems/generalized-abbreviation.json +1 -0
  360. package/data/problems/generate-parentheses.json +1 -0
  361. package/data/problems/generate-random-point-in-a-circle.json +1 -0
  362. package/data/problems/global-and-local-inversions.json +1 -0
  363. package/data/problems/goat-latin.json +1 -0
  364. package/data/problems/graph-valid-tree.json +1 -0
  365. package/data/problems/gray-code.json +1 -0
  366. package/data/problems/greatest-common-divisor-of-strings.json +1 -0
  367. package/data/problems/greatest-common-divisor-traversal.json +1 -0
  368. package/data/problems/group-anagrams.json +1 -0
  369. package/data/problems/group-shifted-strings.json +1 -0
  370. package/data/problems/groups-of-special-equivalent-strings.json +1 -0
  371. package/data/problems/guess-number-higher-or-lower-ii.json +1 -0
  372. package/data/problems/guess-number-higher-or-lower.json +1 -0
  373. package/data/problems/guess-the-word.json +1 -0
  374. package/data/problems/h-index-ii.json +1 -0
  375. package/data/problems/h-index.json +1 -0
  376. package/data/problems/hamming-distance.json +1 -0
  377. package/data/problems/hand-of-straights.json +1 -0
  378. package/data/problems/happy-number.json +1 -0
  379. package/data/problems/heaters.json +1 -0
  380. package/data/problems/house-robber-ii.json +1 -0
  381. package/data/problems/house-robber-iii.json +1 -0
  382. package/data/problems/house-robber.json +1 -0
  383. package/data/problems/image-overlap.json +1 -0
  384. package/data/problems/image-smoother.json +1 -0
  385. package/data/problems/implement-magic-dictionary.json +1 -0
  386. package/data/problems/implement-queue-using-stacks.json +1 -0
  387. package/data/problems/implement-rand10-using-rand7.json +1 -0
  388. package/data/problems/implement-stack-using-queues.json +1 -0
  389. package/data/problems/implement-trie-prefix-tree.json +1 -0
  390. package/data/problems/increasing-order-search-tree.json +1 -0
  391. package/data/problems/increasing-triplet-subsequence.json +1 -0
  392. package/data/problems/inorder-successor-in-bst-ii.json +1 -0
  393. package/data/problems/inorder-successor-in-bst.json +1 -0
  394. package/data/problems/insert-delete-getrandom-o1-duplicates-allowed.json +1 -0
  395. package/data/problems/insert-delete-getrandom-o1.json +1 -0
  396. package/data/problems/insert-greatest-common-divisors-in-linked-list.json +1 -0
  397. package/data/problems/insert-interval.json +1 -0
  398. package/data/problems/insert-into-a-binary-search-tree.json +1 -0
  399. package/data/problems/insert-into-a-sorted-circular-linked-list.json +1 -0
  400. package/data/problems/insertion-sort-list.json +1 -0
  401. package/data/problems/integer-break.json +1 -0
  402. package/data/problems/integer-replacement.json +1 -0
  403. package/data/problems/integer-to-english-words.json +1 -0
  404. package/data/problems/integer-to-roman.json +1 -0
  405. package/data/problems/interleaving-string.json +1 -0
  406. package/data/problems/intersection-of-two-arrays-ii.json +1 -0
  407. package/data/problems/intersection-of-two-arrays.json +1 -0
  408. package/data/problems/intersection-of-two-linked-lists.json +1 -0
  409. package/data/problems/interval-list-intersections.json +1 -0
  410. package/data/problems/invert-binary-tree.json +1 -0
  411. package/data/problems/ip-to-cidr.json +1 -0
  412. package/data/problems/ipo.json +1 -0
  413. package/data/problems/is-graph-bipartite.json +1 -0
  414. package/data/problems/is-subsequence.json +1 -0
  415. package/data/problems/island-perimeter.json +1 -0
  416. package/data/problems/isomorphic-strings.json +1 -0
  417. package/data/problems/jewels-and-stones.json +1 -0
  418. package/data/problems/jump-game-ii.json +1 -0
  419. package/data/problems/jump-game-vii.json +1 -0
  420. package/data/problems/jump-game.json +1 -0
  421. package/data/problems/k-closest-points-to-origin.json +1 -0
  422. package/data/problems/k-diff-pairs-in-an-array.json +1 -0
  423. package/data/problems/k-empty-slots.json +1 -0
  424. package/data/problems/k-inverse-pairs-array.json +1 -0
  425. package/data/problems/k-similar-strings.json +1 -0
  426. package/data/problems/k-th-smallest-in-lexicographical-order.json +1 -0
  427. package/data/problems/k-th-smallest-prime-fraction.json +1 -0
  428. package/data/problems/k-th-symbol-in-grammar.json +1 -0
  429. package/data/problems/keyboard-row.json +1 -0
  430. package/data/problems/keys-and-rooms.json +1 -0
  431. package/data/problems/kill-process.json +1 -0
  432. package/data/problems/knight-dialer.json +1 -0
  433. package/data/problems/knight-probability-in-chessboard.json +1 -0
  434. package/data/problems/koko-eating-bananas.json +1 -0
  435. package/data/problems/kth-largest-element-in-a-stream.json +1 -0
  436. package/data/problems/kth-largest-element-in-an-array.json +1 -0
  437. package/data/problems/kth-smallest-element-in-a-bst.json +1 -0
  438. package/data/problems/kth-smallest-element-in-a-sorted-matrix.json +1 -0
  439. package/data/problems/kth-smallest-number-in-multiplication-table.json +1 -0
  440. package/data/problems/largest-bst-subtree.json +1 -0
  441. package/data/problems/largest-component-size-by-common-factor.json +1 -0
  442. package/data/problems/largest-divisible-subset.json +1 -0
  443. package/data/problems/largest-number-at-least-twice-of-others.json +1 -0
  444. package/data/problems/largest-number.json +1 -0
  445. package/data/problems/largest-palindrome-product.json +1 -0
  446. package/data/problems/largest-perimeter-triangle.json +1 -0
  447. package/data/problems/largest-plus-sign.json +1 -0
  448. package/data/problems/largest-rectangle-in-histogram.json +1 -0
  449. package/data/problems/largest-sum-of-averages.json +1 -0
  450. package/data/problems/largest-time-for-given-digits.json +1 -0
  451. package/data/problems/largest-triangle-area.json +1 -0
  452. package/data/problems/last-stone-weight-ii.json +1 -0
  453. package/data/problems/last-stone-weight.json +1 -0
  454. package/data/problems/leaf-similar-trees.json +1 -0
  455. package/data/problems/least-operators-to-express-number.json +1 -0
  456. package/data/problems/lemonade-change.json +1 -0
  457. package/data/problems/length-of-last-word.json +1 -0
  458. package/data/problems/length-of-longest-fibonacci-subsequence.json +1 -0
  459. package/data/problems/letter-case-permutation.json +1 -0
  460. package/data/problems/letter-combinations-of-a-phone-number.json +1 -0
  461. package/data/problems/lexicographical-numbers.json +1 -0
  462. package/data/problems/lfu-cache.json +1 -0
  463. package/data/problems/license-key-formatting.json +1 -0
  464. package/data/problems/line-reflection.json +1 -0
  465. package/data/problems/linked-list-components.json +1 -0
  466. package/data/problems/linked-list-cycle-ii.json +1 -0
  467. package/data/problems/linked-list-cycle.json +1 -0
  468. package/data/problems/linked-list-random-node.json +1 -0
  469. package/data/problems/logger-rate-limiter.json +1 -0
  470. package/data/problems/logical-or-of-two-binary-grids-represented-as-quad-trees.json +1 -0
  471. package/data/problems/lonely-pixel-i.json +1 -0
  472. package/data/problems/lonely-pixel-ii.json +1 -0
  473. package/data/problems/long-pressed-name.json +1 -0
  474. package/data/problems/longest-absolute-file-path.json +1 -0
  475. package/data/problems/longest-common-prefix.json +1 -0
  476. package/data/problems/longest-common-subsequence.json +1 -0
  477. package/data/problems/longest-consecutive-sequence.json +1 -0
  478. package/data/problems/longest-continuous-increasing-subsequence.json +1 -0
  479. package/data/problems/longest-happy-string.json +1 -0
  480. package/data/problems/longest-harmonious-subsequence.json +1 -0
  481. package/data/problems/longest-increasing-path-in-a-matrix.json +1 -0
  482. package/data/problems/longest-increasing-subsequence.json +1 -0
  483. package/data/problems/longest-line-of-consecutive-one-in-matrix.json +1 -0
  484. package/data/problems/longest-mountain-in-array.json +1 -0
  485. package/data/problems/longest-palindrome.json +1 -0
  486. package/data/problems/longest-palindromic-subsequence.json +1 -0
  487. package/data/problems/longest-palindromic-substring.json +1 -0
  488. package/data/problems/longest-repeating-character-replacement.json +1 -0
  489. package/data/problems/longest-substring-with-at-least-k-repeating-characters.json +1 -0
  490. package/data/problems/longest-substring-with-at-most-k-distinct-characters.json +1 -0
  491. package/data/problems/longest-substring-with-at-most-two-distinct-characters.json +1 -0
  492. package/data/problems/longest-substring-without-repeating-characters.json +1 -0
  493. package/data/problems/longest-turbulent-subarray.json +1 -0
  494. package/data/problems/longest-uncommon-subsequence-i.json +1 -0
  495. package/data/problems/longest-uncommon-subsequence-ii.json +1 -0
  496. package/data/problems/longest-univalue-path.json +1 -0
  497. package/data/problems/longest-valid-parentheses.json +1 -0
  498. package/data/problems/longest-word-in-dictionary-through-deleting.json +1 -0
  499. package/data/problems/longest-word-in-dictionary.json +1 -0
  500. package/data/problems/loud-and-rich.json +1 -0
  501. package/data/problems/lowest-common-ancestor-of-a-binary-search-tree.json +1 -0
  502. package/data/problems/lowest-common-ancestor-of-a-binary-tree.json +1 -0
  503. package/data/problems/lru-cache.json +1 -0
  504. package/data/problems/magic-squares-in-grid.json +1 -0
  505. package/data/problems/magical-string.json +1 -0
  506. package/data/problems/majority-element-ii.json +1 -0
  507. package/data/problems/majority-element.json +1 -0
  508. package/data/problems/making-a-large-island.json +1 -0
  509. package/data/problems/map-sum-pairs.json +1 -0
  510. package/data/problems/masking-personal-information.json +1 -0
  511. package/data/problems/matchsticks-to-square.json +1 -0
  512. package/data/problems/max-area-of-island.json +1 -0
  513. package/data/problems/max-chunks-to-make-sorted-ii.json +1 -0
  514. package/data/problems/max-chunks-to-make-sorted.json +1 -0
  515. package/data/problems/max-consecutive-ones-ii.json +1 -0
  516. package/data/problems/max-consecutive-ones.json +1 -0
  517. package/data/problems/max-increase-to-keep-city-skyline.json +1 -0
  518. package/data/problems/max-points-on-a-line.json +1 -0
  519. package/data/problems/max-stack.json +1 -0
  520. package/data/problems/max-sum-of-rectangle-no-larger-than-k.json +1 -0
  521. package/data/problems/maximal-rectangle.json +1 -0
  522. package/data/problems/maximal-square.json +1 -0
  523. package/data/problems/maximize-distance-to-closest-person.json +1 -0
  524. package/data/problems/maximum-average-subarray-i.json +1 -0
  525. package/data/problems/maximum-average-subarray-ii.json +1 -0
  526. package/data/problems/maximum-binary-tree-ii.json +1 -0
  527. package/data/problems/maximum-binary-tree.json +1 -0
  528. package/data/problems/maximum-depth-of-binary-tree.json +1 -0
  529. package/data/problems/maximum-depth-of-n-ary-tree.json +1 -0
  530. package/data/problems/maximum-distance-in-arrays.json +1 -0
  531. package/data/problems/maximum-frequency-stack.json +1 -0
  532. package/data/problems/maximum-gap.json +1 -0
  533. package/data/problems/maximum-length-of-pair-chain.json +1 -0
  534. package/data/problems/maximum-length-of-repeated-subarray.json +1 -0
  535. package/data/problems/maximum-product-of-three-numbers.json +1 -0
  536. package/data/problems/maximum-product-of-word-lengths.json +1 -0
  537. package/data/problems/maximum-product-subarray.json +1 -0
  538. package/data/problems/maximum-size-subarray-sum-equals-k.json +1 -0
  539. package/data/problems/maximum-subarray.json +1 -0
  540. package/data/problems/maximum-sum-circular-subarray.json +1 -0
  541. package/data/problems/maximum-sum-of-3-non-overlapping-subarrays.json +1 -0
  542. package/data/problems/maximum-swap.json +1 -0
  543. package/data/problems/maximum-vacation-days.json +1 -0
  544. package/data/problems/maximum-width-of-binary-tree.json +1 -0
  545. package/data/problems/maximum-width-ramp.json +1 -0
  546. package/data/problems/maximum-xor-of-two-numbers-in-an-array.json +1 -0
  547. package/data/problems/median-of-two-sorted-arrays.json +1 -0
  548. package/data/problems/meeting-rooms-ii.json +1 -0
  549. package/data/problems/meeting-rooms-iii.json +1 -0
  550. package/data/problems/meeting-rooms.json +1 -0
  551. package/data/problems/merge-intervals.json +1 -0
  552. package/data/problems/merge-k-sorted-lists.json +1 -0
  553. package/data/problems/merge-sorted-array.json +1 -0
  554. package/data/problems/merge-strings-alternately.json +1 -0
  555. package/data/problems/merge-triplets-to-form-target-triplet.json +1 -0
  556. package/data/problems/merge-two-binary-trees.json +1 -0
  557. package/data/problems/merge-two-sorted-lists.json +1 -0
  558. package/data/problems/middle-of-the-linked-list.json +1 -0
  559. package/data/problems/min-cost-climbing-stairs.json +1 -0
  560. package/data/problems/min-cost-to-connect-all-points.json +1 -0
  561. package/data/problems/min-stack.json +1 -0
  562. package/data/problems/minesweeper.json +1 -0
  563. package/data/problems/mini-parser.json +1 -0
  564. package/data/problems/minimize-malware-spread-ii.json +1 -0
  565. package/data/problems/minimize-malware-spread.json +1 -0
  566. package/data/problems/minimize-max-distance-to-gas-station.json +1 -0
  567. package/data/problems/minimum-absolute-difference-in-bst.json +1 -0
  568. package/data/problems/minimum-add-to-make-parentheses-valid.json +1 -0
  569. package/data/problems/minimum-area-rectangle-ii.json +1 -0
  570. package/data/problems/minimum-area-rectangle.json +1 -0
  571. package/data/problems/minimum-array-end.json +1 -0
  572. package/data/problems/minimum-ascii-delete-sum-for-two-strings.json +1 -0
  573. package/data/problems/minimum-cost-for-tickets.json +1 -0
  574. package/data/problems/minimum-cost-to-hire-k-workers.json +1 -0
  575. package/data/problems/minimum-cost-to-merge-stones.json +1 -0
  576. package/data/problems/minimum-depth-of-binary-tree.json +1 -0
  577. package/data/problems/minimum-distance-between-bst-nodes.json +1 -0
  578. package/data/problems/minimum-factorization.json +1 -0
  579. package/data/problems/minimum-falling-path-sum.json +1 -0
  580. package/data/problems/minimum-genetic-mutation.json +1 -0
  581. package/data/problems/minimum-height-trees.json +1 -0
  582. package/data/problems/minimum-increment-to-make-array-unique.json +1 -0
  583. package/data/problems/minimum-index-sum-of-two-lists.json +1 -0
  584. package/data/problems/minimum-interval-to-include-each-query.json +1 -0
  585. package/data/problems/minimum-moves-to-equal-array-elements-ii.json +1 -0
  586. package/data/problems/minimum-moves-to-equal-array-elements.json +1 -0
  587. package/data/problems/minimum-number-of-arrows-to-burst-balloons.json +1 -0
  588. package/data/problems/minimum-number-of-k-consecutive-bit-flips.json +1 -0
  589. package/data/problems/minimum-number-of-refueling-stops.json +1 -0
  590. package/data/problems/minimum-path-sum.json +1 -0
  591. package/data/problems/minimum-size-subarray-sum.json +1 -0
  592. package/data/problems/minimum-swaps-to-make-sequences-increasing.json +1 -0
  593. package/data/problems/minimum-time-difference.json +1 -0
  594. package/data/problems/minimum-unique-word-abbreviation.json +1 -0
  595. package/data/problems/minimum-window-subsequence.json +1 -0
  596. package/data/problems/minimum-window-substring.json +1 -0
  597. package/data/problems/mirror-reflection.json +1 -0
  598. package/data/problems/missing-number.json +1 -0
  599. package/data/problems/missing-ranges.json +1 -0
  600. package/data/problems/monotone-increasing-digits.json +1 -0
  601. package/data/problems/monotonic-array.json +1 -0
  602. package/data/problems/most-common-word.json +1 -0
  603. package/data/problems/most-frequent-subtree-sum.json +1 -0
  604. package/data/problems/most-profit-assigning-work.json +1 -0
  605. package/data/problems/most-stones-removed-with-same-row-or-column.json +1 -0
  606. package/data/problems/move-zeroes.json +1 -0
  607. package/data/problems/moving-average-from-data-stream.json +1 -0
  608. package/data/problems/multiply-strings.json +1 -0
  609. package/data/problems/my-calendar-i.json +1 -0
  610. package/data/problems/my-calendar-ii.json +1 -0
  611. package/data/problems/my-calendar-iii.json +1 -0
  612. package/data/problems/n-ary-tree-level-order-traversal.json +1 -0
  613. package/data/problems/n-ary-tree-postorder-traversal.json +1 -0
  614. package/data/problems/n-ary-tree-preorder-traversal.json +1 -0
  615. package/data/problems/n-queens-ii.json +1 -0
  616. package/data/problems/n-queens.json +1 -0
  617. package/data/problems/n-repeated-element-in-size-2n-array.json +1 -0
  618. package/data/problems/n-th-tribonacci-number.json +1 -0
  619. package/data/problems/nested-list-weight-sum-ii.json +1 -0
  620. package/data/problems/nested-list-weight-sum.json +1 -0
  621. package/data/problems/network-delay-time.json +1 -0
  622. package/data/problems/new-21-game.json +1 -0
  623. package/data/problems/next-closest-time.json +1 -0
  624. package/data/problems/next-greater-element-i.json +1 -0
  625. package/data/problems/next-greater-element-ii.json +1 -0
  626. package/data/problems/next-greater-element-iii.json +1 -0
  627. package/data/problems/next-permutation.json +1 -0
  628. package/data/problems/nim-game.json +1 -0
  629. package/data/problems/non-decreasing-array.json +1 -0
  630. package/data/problems/non-decreasing-subsequences.json +1 -0
  631. package/data/problems/non-negative-integers-without-consecutive-ones.json +1 -0
  632. package/data/problems/non-overlapping-intervals.json +1 -0
  633. package/data/problems/nth-digit.json +1 -0
  634. package/data/problems/nth-magical-number.json +1 -0
  635. package/data/problems/number-complement.json +1 -0
  636. package/data/problems/number-of-1-bits.json +1 -0
  637. package/data/problems/number-of-atoms.json +1 -0
  638. package/data/problems/number-of-boomerangs.json +1 -0
  639. package/data/problems/number-of-connected-components-in-an-undirected-graph.json +1 -0
  640. package/data/problems/number-of-corner-rectangles.json +1 -0
  641. package/data/problems/number-of-digit-one.json +1 -0
  642. package/data/problems/number-of-distinct-islands-ii.json +1 -0
  643. package/data/problems/number-of-distinct-islands.json +1 -0
  644. package/data/problems/number-of-islands-ii.json +1 -0
  645. package/data/problems/number-of-islands.json +1 -0
  646. package/data/problems/number-of-lines-to-write-string.json +1 -0
  647. package/data/problems/number-of-longest-increasing-subsequence.json +1 -0
  648. package/data/problems/number-of-matching-subsequences.json +1 -0
  649. package/data/problems/number-of-music-playlists.json +1 -0
  650. package/data/problems/number-of-provinces.json +1 -0
  651. package/data/problems/number-of-recent-calls.json +1 -0
  652. package/data/problems/number-of-segments-in-a-string.json +1 -0
  653. package/data/problems/number-of-squareful-arrays.json +1 -0
  654. package/data/problems/number-of-subarrays-with-bounded-maximum.json +1 -0
  655. package/data/problems/numbers-at-most-n-given-digit-set.json +1 -0
  656. package/data/problems/numbers-with-same-consecutive-differences.json +1 -0
  657. package/data/problems/odd-even-jump.json +1 -0
  658. package/data/problems/odd-even-linked-list.json +1 -0
  659. package/data/problems/one-edit-distance.json +1 -0
  660. package/data/problems/ones-and-zeroes.json +1 -0
  661. package/data/problems/online-election.json +1 -0
  662. package/data/problems/online-stock-span.json +1 -0
  663. package/data/problems/open-the-lock.json +1 -0
  664. package/data/problems/optimal-account-balancing.json +1 -0
  665. package/data/problems/optimal-division.json +1 -0
  666. package/data/problems/orderly-queue.json +1 -0
  667. package/data/problems/out-of-boundary-paths.json +1 -0
  668. package/data/problems/output-contest-matches.json +1 -0
  669. package/data/problems/pacific-atlantic-water-flow.json +1 -0
  670. package/data/problems/paint-fence.json +1 -0
  671. package/data/problems/paint-house-ii.json +1 -0
  672. package/data/problems/paint-house.json +1 -0
  673. package/data/problems/palindrome-linked-list.json +1 -0
  674. package/data/problems/palindrome-number.json +1 -0
  675. package/data/problems/palindrome-pairs.json +1 -0
  676. package/data/problems/palindrome-partitioning-ii.json +1 -0
  677. package/data/problems/palindrome-partitioning.json +1 -0
  678. package/data/problems/palindrome-permutation-ii.json +1 -0
  679. package/data/problems/palindrome-permutation.json +1 -0
  680. package/data/problems/palindromic-substrings.json +1 -0
  681. package/data/problems/pancake-sorting.json +1 -0
  682. package/data/problems/parse-lisp-expression.json +1 -0
  683. package/data/problems/partition-array-into-disjoint-intervals.json +1 -0
  684. package/data/problems/partition-equal-subset-sum.json +1 -0
  685. package/data/problems/partition-labels.json +1 -0
  686. package/data/problems/partition-list.json +1 -0
  687. package/data/problems/partition-to-k-equal-sum-subsets.json +1 -0
  688. package/data/problems/pascals-triangle-ii.json +1 -0
  689. package/data/problems/pascals-triangle.json +1 -0
  690. package/data/problems/patching-array.json +1 -0
  691. package/data/problems/path-sum-ii.json +1 -0
  692. package/data/problems/path-sum-iii.json +1 -0
  693. package/data/problems/path-sum-iv.json +1 -0
  694. package/data/problems/path-sum.json +1 -0
  695. package/data/problems/path-with-minimum-effort.json +1 -0
  696. package/data/problems/peak-index-in-a-mountain-array.json +1 -0
  697. package/data/problems/peeking-iterator.json +1 -0
  698. package/data/problems/perfect-number.json +1 -0
  699. package/data/problems/perfect-rectangle.json +1 -0
  700. package/data/problems/perfect-squares.json +1 -0
  701. package/data/problems/permutation-in-string.json +1 -0
  702. package/data/problems/permutation-sequence.json +1 -0
  703. package/data/problems/permutations-ii.json +1 -0
  704. package/data/problems/permutations.json +1 -0
  705. package/data/problems/plus-one-linked-list.json +1 -0
  706. package/data/problems/plus-one.json +1 -0
  707. package/data/problems/poor-pigs.json +1 -0
  708. package/data/problems/populating-next-right-pointers-in-each-node-ii.json +1 -0
  709. package/data/problems/populating-next-right-pointers-in-each-node.json +1 -0
  710. package/data/problems/positions-of-large-groups.json +1 -0
  711. package/data/problems/possible-bipartition.json +1 -0
  712. package/data/problems/pour-water.json +1 -0
  713. package/data/problems/power-of-four.json +1 -0
  714. package/data/problems/power-of-three.json +1 -0
  715. package/data/problems/power-of-two.json +1 -0
  716. package/data/problems/powerful-integers.json +1 -0
  717. package/data/problems/powx-n.json +1 -0
  718. package/data/problems/predict-the-winner.json +1 -0
  719. package/data/problems/prefix-and-suffix-search.json +1 -0
  720. package/data/problems/preimage-size-of-factorial-zeroes-function.json +1 -0
  721. package/data/problems/prime-number-of-set-bits-in-binary-representation.json +1 -0
  722. package/data/problems/prime-palindrome.json +1 -0
  723. package/data/problems/print-binary-tree.json +1 -0
  724. package/data/problems/prison-cells-after-n-days.json +1 -0
  725. package/data/problems/product-of-array-except-self.json +1 -0
  726. package/data/problems/profitable-schemes.json +1 -0
  727. package/data/problems/projection-area-of-3d-shapes.json +1 -0
  728. package/data/problems/push-dominoes.json +1 -0
  729. package/data/problems/pyramid-transition-matrix.json +1 -0
  730. package/data/problems/queue-reconstruction-by-height.json +1 -0
  731. package/data/problems/rabbits-in-forest.json +1 -0
  732. package/data/problems/race-car.json +1 -0
  733. package/data/problems/random-flip-matrix.json +1 -0
  734. package/data/problems/random-pick-index.json +1 -0
  735. package/data/problems/random-pick-with-blacklist.json +1 -0
  736. package/data/problems/random-pick-with-weight.json +1 -0
  737. package/data/problems/random-point-in-non-overlapping-rectangles.json +1 -0
  738. package/data/problems/range-addition-ii.json +1 -0
  739. package/data/problems/range-addition.json +1 -0
  740. package/data/problems/range-module.json +1 -0
  741. package/data/problems/range-sum-of-bst.json +1 -0
  742. package/data/problems/range-sum-query-2d-immutable.json +1 -0
  743. package/data/problems/range-sum-query-2d-mutable.json +1 -0
  744. package/data/problems/range-sum-query-immutable.json +1 -0
  745. package/data/problems/range-sum-query-mutable.json +1 -0
  746. package/data/problems/ransom-note.json +1 -0
  747. package/data/problems/reach-a-number.json +1 -0
  748. package/data/problems/reachable-nodes-in-subdivided-graph.json +1 -0
  749. package/data/problems/reaching-points.json +1 -0
  750. package/data/problems/read-n-characters-given-read4-ii-call-multiple-times.json +1 -0
  751. package/data/problems/read-n-characters-given-read4.json +1 -0
  752. package/data/problems/rearrange-string-k-distance-apart.json +1 -0
  753. package/data/problems/reconstruct-itinerary.json +1 -0
  754. package/data/problems/reconstruct-original-digits-from-english.json +1 -0
  755. package/data/problems/recover-binary-search-tree.json +1 -0
  756. package/data/problems/rectangle-area-ii.json +1 -0
  757. package/data/problems/rectangle-area.json +1 -0
  758. package/data/problems/rectangle-overlap.json +1 -0
  759. package/data/problems/redundant-connection-ii.json +1 -0
  760. package/data/problems/redundant-connection.json +1 -0
  761. package/data/problems/regions-cut-by-slashes.json +1 -0
  762. package/data/problems/regular-expression-matching.json +1 -0
  763. package/data/problems/relative-ranks.json +1 -0
  764. package/data/problems/remove-9.json +1 -0
  765. package/data/problems/remove-boxes.json +1 -0
  766. package/data/problems/remove-comments.json +1 -0
  767. package/data/problems/remove-duplicate-letters.json +1 -0
  768. package/data/problems/remove-duplicates-from-sorted-array-ii.json +1 -0
  769. package/data/problems/remove-duplicates-from-sorted-array.json +1 -0
  770. package/data/problems/remove-duplicates-from-sorted-list-ii.json +1 -0
  771. package/data/problems/remove-duplicates-from-sorted-list.json +1 -0
  772. package/data/problems/remove-element.json +1 -0
  773. package/data/problems/remove-invalid-parentheses.json +1 -0
  774. package/data/problems/remove-k-digits.json +1 -0
  775. package/data/problems/remove-linked-list-elements.json +1 -0
  776. package/data/problems/remove-nth-node-from-end-of-list.json +1 -0
  777. package/data/problems/reorder-data-in-log-files.json +1 -0
  778. package/data/problems/reorder-list.json +1 -0
  779. package/data/problems/reordered-power-of-2.json +1 -0
  780. package/data/problems/reorganize-string.json +1 -0
  781. package/data/problems/repeated-dna-sequences.json +1 -0
  782. package/data/problems/repeated-string-match.json +1 -0
  783. package/data/problems/repeated-substring-pattern.json +1 -0
  784. package/data/problems/replace-words.json +1 -0
  785. package/data/problems/reshape-the-matrix.json +1 -0
  786. package/data/problems/restore-ip-addresses.json +1 -0
  787. package/data/problems/reveal-cards-in-increasing-order.json +1 -0
  788. package/data/problems/reverse-bits.json +1 -0
  789. package/data/problems/reverse-integer.json +1 -0
  790. package/data/problems/reverse-linked-list-ii.json +1 -0
  791. package/data/problems/reverse-linked-list.json +1 -0
  792. package/data/problems/reverse-nodes-in-k-group.json +1 -0
  793. package/data/problems/reverse-only-letters.json +1 -0
  794. package/data/problems/reverse-pairs.json +1 -0
  795. package/data/problems/reverse-string-ii.json +1 -0
  796. package/data/problems/reverse-string.json +1 -0
  797. package/data/problems/reverse-vowels-of-a-string.json +1 -0
  798. package/data/problems/reverse-words-in-a-string-ii.json +1 -0
  799. package/data/problems/reverse-words-in-a-string-iii.json +1 -0
  800. package/data/problems/reverse-words-in-a-string.json +1 -0
  801. package/data/problems/rle-iterator.json +1 -0
  802. package/data/problems/robot-return-to-origin.json +1 -0
  803. package/data/problems/robot-room-cleaner.json +1 -0
  804. package/data/problems/roman-to-integer.json +1 -0
  805. package/data/problems/rotate-array.json +1 -0
  806. package/data/problems/rotate-function.json +1 -0
  807. package/data/problems/rotate-image.json +1 -0
  808. package/data/problems/rotate-list.json +1 -0
  809. package/data/problems/rotate-string.json +1 -0
  810. package/data/problems/rotated-digits.json +1 -0
  811. package/data/problems/rotting-oranges.json +1 -0
  812. package/data/problems/russian-doll-envelopes.json +1 -0
  813. package/data/problems/same-tree.json +1 -0
  814. package/data/problems/satisfiability-of-equality-equations.json +1 -0
  815. package/data/problems/score-after-flipping-matrix.json +1 -0
  816. package/data/problems/score-of-parentheses.json +1 -0
  817. package/data/problems/scramble-string.json +1 -0
  818. package/data/problems/search-a-2d-matrix-ii.json +1 -0
  819. package/data/problems/search-a-2d-matrix.json +1 -0
  820. package/data/problems/search-in-a-binary-search-tree.json +1 -0
  821. package/data/problems/search-in-a-sorted-array-of-unknown-size.json +1 -0
  822. package/data/problems/search-in-rotated-sorted-array-ii.json +1 -0
  823. package/data/problems/search-in-rotated-sorted-array.json +1 -0
  824. package/data/problems/search-insert-position.json +1 -0
  825. package/data/problems/second-minimum-node-in-a-binary-tree.json +1 -0
  826. package/data/problems/self-crossing.json +1 -0
  827. package/data/problems/self-dividing-numbers.json +1 -0
  828. package/data/problems/sentence-screen-fitting.json +1 -0
  829. package/data/problems/sentence-similarity-ii.json +1 -0
  830. package/data/problems/sentence-similarity.json +1 -0
  831. package/data/problems/sequence-reconstruction.json +1 -0
  832. package/data/problems/serialize-and-deserialize-binary-tree.json +1 -0
  833. package/data/problems/serialize-and-deserialize-bst.json +1 -0
  834. package/data/problems/serialize-and-deserialize-n-ary-tree.json +1 -0
  835. package/data/problems/set-intersection-size-at-least-two.json +1 -0
  836. package/data/problems/set-matrix-zeroes.json +1 -0
  837. package/data/problems/set-mismatch.json +1 -0
  838. package/data/problems/shifting-letters.json +1 -0
  839. package/data/problems/shopping-offers.json +1 -0
  840. package/data/problems/short-encoding-of-words.json +1 -0
  841. package/data/problems/shortest-bridge.json +1 -0
  842. package/data/problems/shortest-completing-word.json +1 -0
  843. package/data/problems/shortest-distance-from-all-buildings.json +1 -0
  844. package/data/problems/shortest-distance-to-a-character.json +1 -0
  845. package/data/problems/shortest-palindrome.json +1 -0
  846. package/data/problems/shortest-path-to-get-all-keys.json +1 -0
  847. package/data/problems/shortest-path-visiting-all-nodes.json +1 -0
  848. package/data/problems/shortest-subarray-with-sum-at-least-k.json +1 -0
  849. package/data/problems/shortest-unsorted-continuous-subarray.json +1 -0
  850. package/data/problems/shortest-word-distance-ii.json +1 -0
  851. package/data/problems/shortest-word-distance-iii.json +1 -0
  852. package/data/problems/shortest-word-distance.json +1 -0
  853. package/data/problems/shuffle-an-array.json +1 -0
  854. package/data/problems/similar-rgb-color.json +1 -0
  855. package/data/problems/similar-string-groups.json +1 -0
  856. package/data/problems/simplify-path.json +1 -0
  857. package/data/problems/single-element-in-a-sorted-array.json +1 -0
  858. package/data/problems/single-number-ii.json +1 -0
  859. package/data/problems/single-number-iii.json +1 -0
  860. package/data/problems/single-number.json +1 -0
  861. package/data/problems/single-threaded-cpu.json +1 -0
  862. package/data/problems/sliding-puzzle.json +1 -0
  863. package/data/problems/sliding-window-maximum.json +1 -0
  864. package/data/problems/sliding-window-median.json +1 -0
  865. package/data/problems/smallest-good-base.json +1 -0
  866. package/data/problems/smallest-range-covering-elements-from-k-lists.json +1 -0
  867. package/data/problems/smallest-range-i.json +1 -0
  868. package/data/problems/smallest-range-ii.json +1 -0
  869. package/data/problems/smallest-rectangle-enclosing-black-pixels.json +1 -0
  870. package/data/problems/smallest-rotation-with-highest-score.json +1 -0
  871. package/data/problems/smallest-string-starting-from-leaf.json +1 -0
  872. package/data/problems/smallest-subtree-with-all-the-deepest-nodes.json +1 -0
  873. package/data/problems/snakes-and-ladders.json +1 -0
  874. package/data/problems/solve-the-equation.json +1 -0
  875. package/data/problems/sort-an-array.json +1 -0
  876. package/data/problems/sort-array-by-parity-ii.json +1 -0
  877. package/data/problems/sort-array-by-parity.json +1 -0
  878. package/data/problems/sort-characters-by-frequency.json +1 -0
  879. package/data/problems/sort-colors.json +1 -0
  880. package/data/problems/sort-list.json +1 -0
  881. package/data/problems/sort-transformed-array.json +1 -0
  882. package/data/problems/soup-servings.json +1 -0
  883. package/data/problems/sparse-matrix-multiplication.json +1 -0
  884. package/data/problems/special-binary-string.json +1 -0
  885. package/data/problems/spiral-matrix-ii.json +1 -0
  886. package/data/problems/spiral-matrix-iii.json +1 -0
  887. package/data/problems/spiral-matrix.json +1 -0
  888. package/data/problems/split-array-into-consecutive-subsequences.json +1 -0
  889. package/data/problems/split-array-into-fibonacci-sequence.json +1 -0
  890. package/data/problems/split-array-largest-sum.json +1 -0
  891. package/data/problems/split-array-with-equal-sum.json +1 -0
  892. package/data/problems/split-array-with-same-average.json +1 -0
  893. package/data/problems/split-bst.json +1 -0
  894. package/data/problems/split-concatenated-strings.json +1 -0
  895. package/data/problems/split-linked-list-in-parts.json +1 -0
  896. package/data/problems/sqrtx.json +1 -0
  897. package/data/problems/squares-of-a-sorted-array.json +1 -0
  898. package/data/problems/squirrel-simulation.json +1 -0
  899. package/data/problems/stamping-the-sequence.json +1 -0
  900. package/data/problems/stickers-to-spell-word.json +1 -0
  901. package/data/problems/stone-game-ii.json +1 -0
  902. package/data/problems/stone-game-iii.json +1 -0
  903. package/data/problems/stone-game.json +1 -0
  904. package/data/problems/strange-printer.json +1 -0
  905. package/data/problems/string-compression.json +1 -0
  906. package/data/problems/string-to-integer-atoi.json +1 -0
  907. package/data/problems/string-without-aaa-or-bbb.json +1 -0
  908. package/data/problems/strobogrammatic-number-ii.json +1 -0
  909. package/data/problems/strobogrammatic-number-iii.json +1 -0
  910. package/data/problems/strobogrammatic-number.json +1 -0
  911. package/data/problems/strong-password-checker.json +1 -0
  912. package/data/problems/student-attendance-record-i.json +1 -0
  913. package/data/problems/student-attendance-record-ii.json +1 -0
  914. package/data/problems/subarray-product-less-than-k.json +1 -0
  915. package/data/problems/subarray-sum-equals-k.json +1 -0
  916. package/data/problems/subarray-sums-divisible-by-k.json +1 -0
  917. package/data/problems/subarrays-with-k-different-integers.json +1 -0
  918. package/data/problems/subdomain-visit-count.json +1 -0
  919. package/data/problems/subsets-ii.json +1 -0
  920. package/data/problems/subsets.json +1 -0
  921. package/data/problems/substring-with-concatenation-of-all-words.json +1 -0
  922. package/data/problems/subtree-of-another-tree.json +1 -0
  923. package/data/problems/sudoku-solver.json +1 -0
  924. package/data/problems/sum-of-all-subset-xor-totals.json +1 -0
  925. package/data/problems/sum-of-distances-in-tree.json +1 -0
  926. package/data/problems/sum-of-even-numbers-after-queries.json +1 -0
  927. package/data/problems/sum-of-left-leaves.json +1 -0
  928. package/data/problems/sum-of-square-numbers.json +1 -0
  929. package/data/problems/sum-of-subarray-minimums.json +1 -0
  930. package/data/problems/sum-of-subsequence-widths.json +1 -0
  931. package/data/problems/sum-of-two-integers.json +1 -0
  932. package/data/problems/sum-root-to-leaf-numbers.json +1 -0
  933. package/data/problems/summary-ranges.json +1 -0
  934. package/data/problems/super-egg-drop.json +1 -0
  935. package/data/problems/super-palindromes.json +1 -0
  936. package/data/problems/super-pow.json +1 -0
  937. package/data/problems/super-ugly-number.json +1 -0
  938. package/data/problems/super-washing-machines.json +1 -0
  939. package/data/problems/surface-area-of-3d-shapes.json +1 -0
  940. package/data/problems/surrounded-regions.json +1 -0
  941. package/data/problems/swap-adjacent-in-lr-string.json +1 -0
  942. package/data/problems/swap-nodes-in-pairs.json +1 -0
  943. package/data/problems/swim-in-rising-water.json +1 -0
  944. package/data/problems/symmetric-tree.json +1 -0
  945. package/data/problems/tag-validator.json +1 -0
  946. package/data/problems/tallest-billboard.json +1 -0
  947. package/data/problems/target-sum.json +1 -0
  948. package/data/problems/task-scheduler.json +1 -0
  949. package/data/problems/teemo-attacking.json +1 -0
  950. package/data/problems/ternary-expression-parser.json +1 -0
  951. package/data/problems/text-justification.json +1 -0
  952. package/data/problems/the-maze-ii.json +1 -0
  953. package/data/problems/the-maze-iii.json +1 -0
  954. package/data/problems/the-maze.json +1 -0
  955. package/data/problems/the-skyline-problem.json +1 -0
  956. package/data/problems/third-maximum-number.json +1 -0
  957. package/data/problems/three-equal-parts.json +1 -0
  958. package/data/problems/time-based-key-value-store.json +1 -0
  959. package/data/problems/to-lower-case.json +1 -0
  960. package/data/problems/toeplitz-matrix.json +1 -0
  961. package/data/problems/top-k-frequent-elements.json +1 -0
  962. package/data/problems/top-k-frequent-words.json +1 -0
  963. package/data/problems/total-hamming-distance.json +1 -0
  964. package/data/problems/transform-to-chessboard.json +1 -0
  965. package/data/problems/transpose-matrix.json +1 -0
  966. package/data/problems/trapping-rain-water-ii.json +1 -0
  967. package/data/problems/trapping-rain-water.json +1 -0
  968. package/data/problems/triangle.json +1 -0
  969. package/data/problems/trim-a-binary-search-tree.json +1 -0
  970. package/data/problems/triples-with-bitwise-and-equal-to-zero.json +1 -0
  971. package/data/problems/two-sum-ii-input-array-is-sorted.json +1 -0
  972. package/data/problems/two-sum-iii-data-structure-design.json +1 -0
  973. package/data/problems/two-sum-iv-input-is-a-bst.json +1 -0
  974. package/data/problems/two-sum.json +1 -0
  975. package/data/problems/ugly-number-ii.json +1 -0
  976. package/data/problems/ugly-number.json +1 -0
  977. package/data/problems/uncommon-words-from-two-sentences.json +1 -0
  978. package/data/problems/unique-binary-search-trees-ii.json +1 -0
  979. package/data/problems/unique-binary-search-trees.json +1 -0
  980. package/data/problems/unique-email-addresses.json +1 -0
  981. package/data/problems/unique-morse-code-words.json +1 -0
  982. package/data/problems/unique-paths-ii.json +1 -0
  983. package/data/problems/unique-paths-iii.json +1 -0
  984. package/data/problems/unique-paths.json +1 -0
  985. package/data/problems/unique-substrings-in-wraparound-string.json +1 -0
  986. package/data/problems/unique-word-abbreviation.json +1 -0
  987. package/data/problems/univalued-binary-tree.json +1 -0
  988. package/data/problems/utf-8-validation.json +1 -0
  989. package/data/problems/valid-anagram.json +1 -0
  990. package/data/problems/valid-mountain-array.json +1 -0
  991. package/data/problems/valid-number.json +1 -0
  992. package/data/problems/valid-palindrome-ii.json +1 -0
  993. package/data/problems/valid-palindrome.json +1 -0
  994. package/data/problems/valid-parentheses.json +1 -0
  995. package/data/problems/valid-parenthesis-string.json +1 -0
  996. package/data/problems/valid-perfect-square.json +1 -0
  997. package/data/problems/valid-permutations-for-di-sequence.json +1 -0
  998. package/data/problems/valid-square.json +1 -0
  999. package/data/problems/valid-sudoku.json +1 -0
  1000. package/data/problems/valid-tic-tac-toe-state.json +1 -0
  1001. package/data/problems/valid-triangle-number.json +1 -0
  1002. package/data/problems/valid-word-abbreviation.json +1 -0
  1003. package/data/problems/valid-word-square.json +1 -0
  1004. package/data/problems/validate-binary-search-tree.json +1 -0
  1005. package/data/problems/validate-ip-address.json +1 -0
  1006. package/data/problems/validate-stack-sequences.json +1 -0
  1007. package/data/problems/verify-preorder-sequence-in-binary-search-tree.json +1 -0
  1008. package/data/problems/verify-preorder-serialization-of-a-binary-tree.json +1 -0
  1009. package/data/problems/verifying-an-alien-dictionary.json +1 -0
  1010. package/data/problems/vertical-order-traversal-of-a-binary-tree.json +1 -0
  1011. package/data/problems/vowel-spellchecker.json +1 -0
  1012. package/data/problems/walking-robot-simulation.json +1 -0
  1013. package/data/problems/walls-and-gates.json +1 -0
  1014. package/data/problems/water-and-jug-problem.json +1 -0
  1015. package/data/problems/wiggle-sort-ii.json +1 -0
  1016. package/data/problems/wiggle-sort.json +1 -0
  1017. package/data/problems/wiggle-subsequence.json +1 -0
  1018. package/data/problems/wildcard-matching.json +1 -0
  1019. package/data/problems/word-abbreviation.json +1 -0
  1020. package/data/problems/word-break-ii.json +1 -0
  1021. package/data/problems/word-break.json +1 -0
  1022. package/data/problems/word-ladder-ii.json +1 -0
  1023. package/data/problems/word-ladder.json +1 -0
  1024. package/data/problems/word-pattern-ii.json +1 -0
  1025. package/data/problems/word-pattern.json +1 -0
  1026. package/data/problems/word-search-ii.json +1 -0
  1027. package/data/problems/word-search.json +1 -0
  1028. package/data/problems/word-squares.json +1 -0
  1029. package/data/problems/word-subsets.json +1 -0
  1030. package/data/problems/x-of-a-kind-in-a-deck-of-cards.json +1 -0
  1031. package/data/problems/zigzag-conversion.json +1 -0
  1032. package/data/problems/zigzag-iterator.json +1 -0
  1033. package/data/problems/zuma-game.json +1 -0
  1034. package/dist/cli.js +793 -0
  1035. package/dist/web/assets/index-DCYvZg7a.js +150 -0
  1036. package/dist/web/assets/index-gSBueMfH.css +1 -0
  1037. package/dist/web/index.html +13 -0
  1038. package/package.json +44 -4
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "542", "slug": "generate-random-point-in-a-circle", "id": 542, "title": "Generate Random Point in a Circle", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/generate-random-point-in-a-circle/", "examples": [{"input": "operations = [\"RandPoint\",\"randPoint\",\"randPoint\",\"randPoint\"], values = [[1,0,0],[],[],[]]", "output": "[null,[0.1,0.2],[0,0],[-0.5,0.5]]", "explanation": "Any point within distance 1 of the origin is accepted; returning the center itself is valid."}, {"input": "operations = [\"RandPoint\",\"randPoint\"], values = [[2,3,-1],[]]", "output": "[null,[3,-1]]", "explanation": "The center (3,-1) is distance 0 from itself, so it is always a valid (though not uniform) answer."}, {"input": "operations = [\"RandPoint\",\"randPoint\",\"randPoint\"], values = [[5,2,-3],[],[]]", "output": "[null,[2,-3],[6.5,-1.0]]", "explanation": "Both the center and any point within 5.0 of (2,-3) pass the checker."}], "hints": ["Sample uniformly by area: scale the radius by sqrt(u) for u uniform in [0,1), with the angle uniform in [0, 2*pi).", "Convert the polar offset back with cosine and sine, then shift by (xCenter, yCenter).", "The judge checks only that each point lies within the circle (with a tiny tolerance), not the distribution."], "statement": "Given the radius and the position of the center of a circle, implement the function `randPoint` which generates a uniform random point inside the circle.\n\nImplement the `RandPoint` class:\n\n- `RandPoint(double radius, double xCenter, double yCenter)` Initializes the object with the radius of the circle `radius` and the position of the center `(xCenter, yCenter)`.\n- `double[] randPoint()` Returns a random point inside the circle. A point on the circumference of the circle is considered to be in the circle. The answer is returned as an array `[x, y]`.\n\nThe class is named `RandPoint` here instead of LeetCode's `Solution` because the judge harness reserves `Solution` for its driver; the constructor and methods match the original. (C# only: the point method is named `NextPoint`, since C# forbids a method sharing its class's name.)\n\nGrading: each `randPoint` output must parse as `[x,y]` doubles satisfying `(x - xCenter)^2 + (y - yCenter)^2 <= radius^2 * (1 + 1e-9) + 1e-9`. Any valid trace is accepted \u2014 uniformity over the disk is not statistically tested. In this judge the constructor arguments arrive as integers (integral radius and center, all valid LeetCode inputs); outputs use the compact `\"[x,y]\"` text form.\n\n**Constraints:**\n- `0 < radius <= 10^8`\n- `-10^7 <= xCenter, yCenter <= 10^7`\n- At most `3 * 10^4` calls will be made to `randPoint`.\n", "solution": "## Approach\n\nSample uniformly by area with the polar method: draw `u` uniform in `[0,1)` and an angle `theta` uniform in `[0, 2*pi)`. Scaling the radius by `sqrt(u)` (not `u` itself, which would bunch points near the center) makes the area density uniform; convert the polar offset back with cosine and sine and shift by the center. The checker verifies only that each point lies within the circle (with a tiny tolerance), so returning the center is valid but not uniform.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1) per `randPoint`.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nimport math\nimport random\nfrom typing import List\n\nclass RandPoint:\n def __init__(self, radius: float, x_center: float, y_center: float):\n self.radius = radius\n self.x_center = x_center\n self.y_center = y_center\n\n def randPoint(self) -> List[float]:\n u = random.random()\n theta = random.random() * 2.0 * math.pi\n d = self.radius * math.sqrt(u)\n return [self.x_center + d * math.cos(theta),\n self.y_center + d * math.sin(theta)]\n```\n", "starter": {"go": "package main\n\ntype RandPoint struct {\n\n}\n\nfunc Constructor(radius float64, xCenter float64, yCenter float64) RandPoint {\n return RandPoint{}\n}\n\nfunc (this *RandPoint) RandPoint() []float64 {\n return []float64{}\n}", "python": "from typing import List\n\nclass RandPoint:\n def __init__(self, radius: float, x_center: float, y_center: float):\n\n def randPoint(self) -> List[float]:\n return []", "cpp": "#include <vector>\nusing namespace std;\n\nclass RandPoint {\npublic:\n RandPoint(double radius, double xCenter, double yCenter) {\n \n }\n\n vector<double> randPoint() {\n return {};\n }\n};"}, "fn": "solve", "params": [{"name": "operations", "type": "string_array"}, {"name": "values", "type": "int_array_2d"}], "outputType": "string_list", "tests": [["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[1, 0, 0], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[2, 3, -1], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[10, 0, 0], [], [], [], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[1, -5, 7], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[5, 2, -3], [], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[100, 1000, -1000], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[3, 8, 8], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[7, -2, 4], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\"]", "[[1, 1, 1], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[50, -100, 200], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[4, 0, 0], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[3, 0, 0], [], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[5, -2, 7], [], [], [], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[1, 1, 1], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[100, 0, 0], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[2, 2, 2], [], [], [], [], [], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[7, -5, 3], [], [], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[4, 6, -6], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"RandPoint\", \"randPoint\"]", "[[2, 0, 0], [], [], [3, 1, 1], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[6, 0, 0], [], [], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[9, -9, 9], [], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[2, 5, -5], [], [], [], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[8, 3, 3], [], [], [], [], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[5, 5, 5], [], [], [], [], [], [], []]"], ["[\"RandPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\", \"randPoint\"]", "[[10, -4, 2], [], [], [], [], [], []]"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "775", "slug": "global-and-local-inversions", "id": 775, "title": "Global and Local Inversions", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/global-and-local-inversions/", "examples": [{"input": "nums = [1,0,2]", "output": "true", "explanation": "One global and one local inversion coincide."}, {"input": "nums = [1,2,0]", "output": "false", "explanation": "Two globals but one local."}, {"input": "nums = [0,2,1]", "output": "true", "explanation": "A single adjacent swap."}], "hints": ["Extra global inversions always span at least two positions, so compare each prefix maximum with later values.", "Track the maximum of nums[0..i-2] while scanning i from 2 upward; if it ever exceeds nums[i], a non-local inversion exists.", "Equivalently, an ideal permutation satisfies |nums[i] - i| <= 1 for every index."], "statement": "You are given a permutation `nums` of the integers `0` through `n - 1`.\n\nA global inversion is a pair of positions `i < j` with `nums[i] > nums[j]`. A local inversion is an index `i` with `nums[i] > nums[i+1]` (an adjacent global inversion). Every local inversion is global, but not vice versa.\n\nReturn `true` when the two counts coincide and `false` otherwise.\n\n**Constraints:**\n- `n == nums.length`\n- `1 <= n <= 10^5`\n- `0 <= nums[i] < n`\n- All values are distinct\n", "solution": "## Approach\n\nA permutation has a non-local inversion exactly when some value reaches at least two spots forward past a larger prefix. Scanning from left to right while remembering the maximum of all entries at least two positions behind the cursor detects that event: if the remembered maximum ever exceeds the current value, a global inversion without a local witness exists.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) for one linear scan.\n- **Space Complexity:** O(1) besides the input.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def isIdealPermutation(self, nums: List[int]) -> bool:\n cmax = -1\n for i in range(2, len(nums)):\n cmax = max(cmax, nums[i - 2])\n if cmax > nums[i]:\n return False\n return True\n```\n", "starter": {"go": "package main\n\nfunc IsIdealPermutation(nums []int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def isIdealPermutation(self, nums: List[int]) -> bool:\n pass\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool isIdealPermutation(vector<int>& nums) {\n return false;\n }\n};"}, "fn": "isIdealPermutation", "params": [{"name": "nums", "type": "int_array"}], "outputType": "boolean", "tests": [["[1,0,2]"], ["[1,2,0]"], ["[0,2,1]"], ["[0]"], ["[0,1]"], ["[1,0]"], ["[0,1,2]"], ["[2,0,1]"], ["[0,1,2,3,4]"], ["[1,0,3,2,4]"], ["[1,0,2,4,3]"], ["[2,1,0]"], ["[0,2,1,3]"], ["[3,2,1,0]"], ["[0,3,1,2]"], ["[1,3,0,2]"], ["[2,0,3,1]"], ["[4,3,2,1,0]"], ["[0,1,3,2]"], ["[2,3,0,1]"], ["[1,2,3,0]"], ["[0,4,1,2,3]"], ["[3,0,1,2]"], ["[5,0,1,2,3,4]"], ["[0,1,2,4,3,5]"], ["[2,1,4,3,6,5]"], ["[1,0,2,3,5,4]"], ["[4,0,1,2,3]"]], "expected": [true, false, true, true, true, true, true, false, true, true, true, false, true, false, false, false, false, false, true, false, false, false, false, false, true, true, true, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "822", "slug": "goat-latin", "id": 822, "title": "Goat Latin", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/goat-latin/", "examples": [{"input": "sentence = \"I speak Goat Latin\"", "output": "\"Imaa peaksmaaa oatGmaaaa atinLmaaaaa\"", "explanation": "\"I\" keeps its order and gains \"maa\"; \"speak\" moves \"s\" to the end and gains \"maaa\"."}, {"input": "sentence = \"The quick brown fox jumped over the lazy dog\"", "output": "\"heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa\""}, {"input": "sentence = \"a\"", "output": "\"amaa\""}], "hints": ["Split the sentence on single spaces and remember each word's 1-based position for the trailing a's.", "Check only the first character against both lowercase and uppercase vowels before deciding whether to rotate.", "Build each result word as core + \"ma\" + \"a\" repeated by position, then join with spaces."], "statement": "A sentence is made of words separated by single spaces, with no leading or trailing spaces. Transform it into a playful variant with these rules, applied to each word in order:\n\n- If a word begins with a vowel (`a`, `e`, `i`, `o`, `u`, in either lowercase or uppercase), leave the word as is.\n- Otherwise, remove its first letter and append that letter to the end of the word.\n- Append the two letters `ma` to every modified word above.\n- Finally, append the letter `a` once for the first word, twice for the second word, three times for the third word, and so on.\n\nReturn the transformed words joined with single spaces.\n\n**Constraints:**\n- `1 <= sentence.length <= 150`\n- `sentence` consists of English letters and single spaces only\n- Words are separated by exactly one space, with no leading or trailing spaces\n", "solution": "## Approach\n\nSplit the sentence into words and handle each word by its 1-based index. When the first character is a vowel (checked in both cases) keep the word unchanged, otherwise rotate the leading character to the end. Append \"ma\" plus the index-many copies of \"a\", then rejoin everything with single spaces.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^2) in the worst case where n is the sentence length, because of the growing trailing a's; linear in the input plus output size.\n- **Space Complexity:** O(n^2) for the output string in the worst case.\n\n## Implementation\n\n```python\nclass Solution:\n def toGoatLatin(self, sentence: str) -> str:\n vowels = set(\"aeiouAEIOU\")\n out = []\n for i, w in enumerate(sentence.split(\" \"), 1):\n if w[0] in vowels:\n cur = w + \"ma\"\n else:\n cur = w[1:] + w[0] + \"ma\"\n cur += \"a\" * i\n out.append(cur)\n return \" \".join(out)\n```\n", "starter": {"go": "package main\n\nfunc ToGoatLatin(sentence string) string {\n \n}", "python": "class Solution:\n def toGoatLatin(self, sentence: str) -> str:\n pass", "cpp": "#include <string>\nusing namespace std;\nclass Solution {\npublic:\n string toGoatLatin(string sentence) {\n return \"\";\n }\n};"}, "fn": "toGoatLatin", "params": [{"name": "sentence", "type": "string"}], "outputType": "string", "tests": [["I speak Goat Latin"], ["The quick brown fox jumped over the lazy dog"], ["a"], ["b"], ["A"], ["Z"], ["apple"], ["Hello"], ["xyz"], ["a e i o u"], ["A E I O U"], ["Goat"], ["Latin"], ["I"], ["am"], ["aA eE iI oO uU"], ["Programming is fun"], ["OpenAI creates tools"], ["z"], ["Q"], ["quick"], ["Quick brown"], ["An example with vowels"], ["rhythm myths"], ["Eye"], ["under over"], ["Sphinx of black quartz judge my vow"], ["Each word starts with either a vowel or a consonant sound"]], "expected": ["Imaa peaksmaaa oatGmaaaa atinLmaaaaa", "heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa", "amaa", "bmaa", "Amaa", "Zmaa", "applemaa", "elloHmaa", "yzxmaa", "amaa emaaa imaaaa omaaaaa umaaaaaa", "Amaa Emaaa Imaaaa Omaaaaa Umaaaaaa", "oatGmaa", "atinLmaa", "Imaa", "ammaa", "aAmaa eEmaaa iImaaaa oOmaaaaa uUmaaaaaa", "rogrammingPmaa ismaaa unfmaaaa", "OpenAImaa reatescmaaa oolstmaaaa", "zmaa", "Qmaa", "uickqmaa", "uickQmaa rownbmaaa", "Anmaa examplemaaa ithwmaaaa owelsvmaaaaa", "hythmrmaa ythsmmaaa", "Eyemaa", "undermaa overmaaa", "phinxSmaa ofmaaa lackbmaaaa uartzqmaaaaa udgejmaaaaaa ymmaaaaaaa owvmaaaaaaaa", "Eachmaa ordwmaaa tartssmaaaa ithwmaaaaa eithermaaaaaa amaaaaaaa owelvmaaaaaaaa ormaaaaaaaaa amaaaaaaaaaa onsonantcmaaaaaaaaaaa oundsmaaaaaaaaaaaa"], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "33", "slug": "graph-valid-tree", "id": 33, "title": "Graph Valid Tree", "difficulty": "Medium", "category": "graph", "link": "https://leetcode.com/problems/graph-valid-tree/", "examples": [{"input": "n=5, edges=[[0,1],[0,2],[0,3],[1,4]]", "output": "true", "explanation": "The graph has 4 edges and all 5 nodes are reachable, so it is a valid tree."}, {"input": "n=5, edges=[[0,1],[1,2],[2,3],[1,3],[1,4]]", "output": "false", "explanation": "As shown in the diagram, nodes 1, 2, and 3 form a cycle, which violates the tree properties. Therefore, it is not a valid tree.\n\n![Graph cycle](/api/problems/graph-valid-tree/asset/explanation2.png)"}], "hints": ["An undirected graph is a tree iff it is connected and has exactly n-1 edges. Use Union-Find or BFS/DFS."], "statement": "Given n nodes labeled 0..n-1 and a list of undirected edges, return true if they make up a valid tree.\n\n**Constraints:**\n\n- 1 <= n <= 2000\n- 0 <= edges.length <= 10^4\n- edges[i].length == 2\n- 0 <= ai, bi < n\n", "solution": "## Approach\n\nA graph is a valid tree if and only if it has exactly `n - 1` edges and is fully connected. If the number of edges is not `n - 1`, we immediately return `False`. Otherwise, we perform a Depth-First Search (DFS) starting from node 0 to check if we can reach all nodes. If the traversal visits all `n` nodes, then the graph is a valid tree.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n) to build the adjacency list and perform DFS.\n- **Space Complexity:** O(n) for the adjacency list and the recursion stack.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def validTree(self, n: int, edges: List[List[int]]) -> bool:\n if len(edges) != n - 1:\n return False\n \n # Build adjacency list\n adj = [[] for _ in range(n)]\n for u, v in edges:\n adj[u].append(v)\n adj[v].append(u)\n \n visited = [False] * n\n \n # DFS to traverse and check connectivity\n def dfs(node: int):\n visited[node] = True\n for neighbor in adj[node]:\n if not visited[neighbor]:\n dfs(neighbor)\n \n dfs(0)\n return all(visited)\n```\n", "starter": {"go": "package main\n\nfunc ValidTree(n int, edges [][]int) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def validTree(self, n: int, edges: List[List[int]]) -> bool:\n pass\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n bool validTree(int n, vector<vector<int>>& edges) {\n return false;\n }\n};"}, "fn": "validTree", "params": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int_array_2d", "visualizeType": "undirected_edges", "numNodesRef": "n"}], "outputType": "boolean", "tests": [["5", "[[0,1],[0,2],[0,3],[1,4]]"], ["5", "[[0,1],[1,2],[2,3],[1,3],[1,4]]"], ["1", "[]"], ["2", "[[0,1]]"], ["2", "[]"], ["3", "[[0,1],[1,2]]"], ["3", "[[0,1],[0,2]]"], ["3", "[[0,1]]"], ["3", "[[0,1],[1,2],[2,0]]"], ["4", "[[0,1],[1,2],[2,3]]"], ["4", "[[0,1],[2,3]]"], ["4", "[[0,1],[1,2],[2,3],[3,0]]"], ["4", "[[0,1],[0,2],[0,3]]"], ["4", "[[0,1],[1,2],[1,2]]"], ["6", "[[0,1],[0,2],[0,3],[0,4],[0,5]]"], ["6", "[[0,1],[1,2],[2,3],[3,4],[4,5]]"], ["6", "[[0,1],[1,2],[2,3],[3,4],[4,5],[5,0]]"], ["6", "[[0,1],[2,3],[4,5]]"], ["1", "[[0,0]]"], ["2", "[[0,0]]"], ["3", "[[0,1],[1,2],[0,2]]"], ["5", "[[0,1],[1,2],[2,3],[3,4]]"], ["5", "[[0,1],[1,2],[3,4]]"], ["5", "[]"], ["4", "[]"], ["7", "[[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]]"], ["7", "[[0,1],[0,2],[1,3],[1,4],[2,5],[3,6]]"], ["8", "[[0,1],[1,2],[2,3],[4,5],[5,6],[6,7]]"], ["10", "[[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7],[0,8],[0,9]]"], ["3", "[[1,2],[2,0]]"], ["4", "[[3,2],[2,1],[1,0]]"], ["5", "[[0,1],[0,2],[0,3]]"]], "expected": [true, false, true, true, false, true, true, false, false, true, false, false, true, false, true, true, false, false, false, false, false, true, false, false, false, true, true, false, true, true, true, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "278", "slug": "gray-code", "id": 278, "title": "Gray Code", "difficulty": "Medium", "category": "math", "link": "https://leetcode.com/problems/gray-code/", "examples": [{"input": "n = 2", "output": "[0,1,3,2]", "explanation": "Binary forms 00, 01, 11, 10 change one bit at each step."}, {"input": "n = 1", "output": "[0,1]", "explanation": "With one bit, 0 then 1 differ in the only position."}, {"input": "n = 0", "output": "[0]", "explanation": "Zero bits still produce the single value 0."}], "hints": ["Entry i of the binary-reflected code is i ^ (i >> 1).", "Alternatively mirror the (n-1)-bit sequence and set the top bit on the reversed copy.", "Any ordering is accepted as long as it starts at 0, covers all values, and flips one bit per step."], "statement": "An `n`-bit Gray sequence lists every number from `0` to `2^n - 1` exactly once so that consecutive values differ in precisely one binary digit. Build any such ordering starting from `0`.\n\nOne classic construction mirrors the previous sequence: prefix the old order with `0`, then append its reverse prefixed with `1`. Equivalently, entry `i` can be written directly as `i ^ (i >> 1)`.\n\n**Constraints:**\n- `0 <= n <= 16`\n- Any valid Gray ordering is accepted.\n\n> **Adaptation note:** the original LeetCode return type is `List<Integer>`; this problem uses the portable `int_list` output type with the same values.\n", "solution": "## Approach\n\nEmit the binary-reflected code directly with the formula `i ^ (i >> 1)` for every `i` from `0` to `2^n - 1`. Flipping the lowest set bit of the increment guarantees neighbors differ in exactly one position while covering all values once.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(2^n), one constant-time step per entry.\n- **Space Complexity:** O(2^n) for the output list.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def grayCode(self, n: int) -> List[int]:\n return [i ^ (i >> 1) for i in range(1 << n)]\n```\n", "starter": {"go": "package main\n\nfunc GrayCode(n int) []int {\n return []int{}\n}", "python": "from typing import List\nclass Solution:\n def grayCode(self, n: int) -> List[int]:\n return []\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<int> grayCode(int n) {\n return {};\n }\n};"}, "fn": "grayCode", "params": [{"name": "n", "type": "int"}], "outputType": "int_list", "tests": [["2"], ["1"], ["0"], ["3"], ["4"], ["5"], ["6"], ["7"], ["8"], ["9"], ["10"], ["11"], ["12"], ["0"], ["1"], ["2"], ["3"], ["4"], ["5"], ["6"], ["7"], ["8"], ["9"], ["10"], ["3"], ["4"], ["5"], ["2"], ["1"], ["0"]], "expected": [[0, 1, 3, 2], [0, 1], [0], [0, 1, 3, 2, 6, 7, 5, 4], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 1536, 1537, 1539, 1538, 1542, 1543, 1541, 1540, 1548, 1549, 1551, 1550, 1546, 1547, 1545, 1544, 1560, 1561, 1563, 1562, 1566, 1567, 1565, 1564, 1556, 1557, 1559, 1558, 1554, 1555, 1553, 1552, 1584, 1585, 1587, 1586, 1590, 1591, 1589, 1588, 1596, 1597, 1599, 1598, 1594, 1595, 1593, 1592, 1576, 1577, 1579, 1578, 1582, 1583, 1581, 1580, 1572, 1573, 1575, 1574, 1570, 1571, 1569, 1568, 1632, 1633, 1635, 1634, 1638, 1639, 1637, 1636, 1644, 1645, 1647, 1646, 1642, 1643, 1641, 1640, 1656, 1657, 1659, 1658, 1662, 1663, 1661, 1660, 1652, 1653, 1655, 1654, 1650, 1651, 1649, 1648, 1616, 1617, 1619, 1618, 1622, 1623, 1621, 1620, 1628, 1629, 1631, 1630, 1626, 1627, 1625, 1624, 1608, 1609, 1611, 1610, 1614, 1615, 1613, 1612, 1604, 1605, 1607, 1606, 1602, 1603, 1601, 1600, 1728, 1729, 1731, 1730, 1734, 1735, 1733, 1732, 1740, 1741, 1743, 1742, 1738, 1739, 1737, 1736, 1752, 1753, 1755, 1754, 1758, 1759, 1757, 1756, 1748, 1749, 1751, 1750, 1746, 1747, 1745, 1744, 1776, 1777, 1779, 1778, 1782, 1783, 1781, 1780, 1788, 1789, 1791, 1790, 1786, 1787, 1785, 1784, 1768, 1769, 1771, 1770, 1774, 1775, 1773, 1772, 1764, 1765, 1767, 1766, 1762, 1763, 1761, 1760, 1696, 1697, 1699, 1698, 1702, 1703, 1701, 1700, 1708, 1709, 1711, 1710, 1706, 1707, 1705, 1704, 1720, 1721, 1723, 1722, 1726, 1727, 1725, 1724, 1716, 1717, 1719, 1718, 1714, 1715, 1713, 1712, 1680, 1681, 1683, 1682, 1686, 1687, 1685, 1684, 1692, 1693, 1695, 1694, 1690, 1691, 1689, 1688, 1672, 1673, 1675, 1674, 1678, 1679, 1677, 1676, 1668, 1669, 1671, 1670, 1666, 1667, 1665, 1664, 1920, 1921, 1923, 1922, 1926, 1927, 1925, 1924, 1932, 1933, 1935, 1934, 1930, 1931, 1929, 1928, 1944, 1945, 1947, 1946, 1950, 1951, 1949, 1948, 1940, 1941, 1943, 1942, 1938, 1939, 1937, 1936, 1968, 1969, 1971, 1970, 1974, 1975, 1973, 1972, 1980, 1981, 1983, 1982, 1978, 1979, 1977, 1976, 1960, 1961, 1963, 1962, 1966, 1967, 1965, 1964, 1956, 1957, 1959, 1958, 1954, 1955, 1953, 1952, 2016, 2017, 2019, 2018, 2022, 2023, 2021, 2020, 2028, 2029, 2031, 2030, 2026, 2027, 2025, 2024, 2040, 2041, 2043, 2042, 2046, 2047, 2045, 2044, 2036, 2037, 2039, 2038, 2034, 2035, 2033, 2032, 2000, 2001, 2003, 2002, 2006, 2007, 2005, 2004, 2012, 2013, 2015, 2014, 2010, 2011, 2009, 2008, 1992, 1993, 1995, 1994, 1998, 1999, 1997, 1996, 1988, 1989, 1991, 1990, 1986, 1987, 1985, 1984, 1856, 1857, 1859, 1858, 1862, 1863, 1861, 1860, 1868, 1869, 1871, 1870, 1866, 1867, 1865, 1864, 1880, 1881, 1883, 1882, 1886, 1887, 1885, 1884, 1876, 1877, 1879, 1878, 1874, 1875, 1873, 1872, 1904, 1905, 1907, 1906, 1910, 1911, 1909, 1908, 1916, 1917, 1919, 1918, 1914, 1915, 1913, 1912, 1896, 1897, 1899, 1898, 1902, 1903, 1901, 1900, 1892, 1893, 1895, 1894, 1890, 1891, 1889, 1888, 1824, 1825, 1827, 1826, 1830, 1831, 1829, 1828, 1836, 1837, 1839, 1838, 1834, 1835, 1833, 1832, 1848, 1849, 1851, 1850, 1854, 1855, 1853, 1852, 1844, 1845, 1847, 1846, 1842, 1843, 1841, 1840, 1808, 1809, 1811, 1810, 1814, 1815, 1813, 1812, 1820, 1821, 1823, 1822, 1818, 1819, 1817, 1816, 1800, 1801, 1803, 1802, 1806, 1807, 1805, 1804, 1796, 1797, 1799, 1798, 1794, 1795, 1793, 1792, 1280, 1281, 1283, 1282, 1286, 1287, 1285, 1284, 1292, 1293, 1295, 1294, 1290, 1291, 1289, 1288, 1304, 1305, 1307, 1306, 1310, 1311, 1309, 1308, 1300, 1301, 1303, 1302, 1298, 1299, 1297, 1296, 1328, 1329, 1331, 1330, 1334, 1335, 1333, 1332, 1340, 1341, 1343, 1342, 1338, 1339, 1337, 1336, 1320, 1321, 1323, 1322, 1326, 1327, 1325, 1324, 1316, 1317, 1319, 1318, 1314, 1315, 1313, 1312, 1376, 1377, 1379, 1378, 1382, 1383, 1381, 1380, 1388, 1389, 1391, 1390, 1386, 1387, 1385, 1384, 1400, 1401, 1403, 1402, 1406, 1407, 1405, 1404, 1396, 1397, 1399, 1398, 1394, 1395, 1393, 1392, 1360, 1361, 1363, 1362, 1366, 1367, 1365, 1364, 1372, 1373, 1375, 1374, 1370, 1371, 1369, 1368, 1352, 1353, 1355, 1354, 1358, 1359, 1357, 1356, 1348, 1349, 1351, 1350, 1346, 1347, 1345, 1344, 1472, 1473, 1475, 1474, 1478, 1479, 1477, 1476, 1484, 1485, 1487, 1486, 1482, 1483, 1481, 1480, 1496, 1497, 1499, 1498, 1502, 1503, 1501, 1500, 1492, 1493, 1495, 1494, 1490, 1491, 1489, 1488, 1520, 1521, 1523, 1522, 1526, 1527, 1525, 1524, 1532, 1533, 1535, 1534, 1530, 1531, 1529, 1528, 1512, 1513, 1515, 1514, 1518, 1519, 1517, 1516, 1508, 1509, 1511, 1510, 1506, 1507, 1505, 1504, 1440, 1441, 1443, 1442, 1446, 1447, 1445, 1444, 1452, 1453, 1455, 1454, 1450, 1451, 1449, 1448, 1464, 1465, 1467, 1466, 1470, 1471, 1469, 1468, 1460, 1461, 1463, 1462, 1458, 1459, 1457, 1456, 1424, 1425, 1427, 1426, 1430, 1431, 1429, 1428, 1436, 1437, 1439, 1438, 1434, 1435, 1433, 1432, 1416, 1417, 1419, 1418, 1422, 1423, 1421, 1420, 1412, 1413, 1415, 1414, 1410, 1411, 1409, 1408, 1152, 1153, 1155, 1154, 1158, 1159, 1157, 1156, 1164, 1165, 1167, 1166, 1162, 1163, 1161, 1160, 1176, 1177, 1179, 1178, 1182, 1183, 1181, 1180, 1172, 1173, 1175, 1174, 1170, 1171, 1169, 1168, 1200, 1201, 1203, 1202, 1206, 1207, 1205, 1204, 1212, 1213, 1215, 1214, 1210, 1211, 1209, 1208, 1192, 1193, 1195, 1194, 1198, 1199, 1197, 1196, 1188, 1189, 1191, 1190, 1186, 1187, 1185, 1184, 1248, 1249, 1251, 1250, 1254, 1255, 1253, 1252, 1260, 1261, 1263, 1262, 1258, 1259, 1257, 1256, 1272, 1273, 1275, 1274, 1278, 1279, 1277, 1276, 1268, 1269, 1271, 1270, 1266, 1267, 1265, 1264, 1232, 1233, 1235, 1234, 1238, 1239, 1237, 1236, 1244, 1245, 1247, 1246, 1242, 1243, 1241, 1240, 1224, 1225, 1227, 1226, 1230, 1231, 1229, 1228, 1220, 1221, 1223, 1222, 1218, 1219, 1217, 1216, 1088, 1089, 1091, 1090, 1094, 1095, 1093, 1092, 1100, 1101, 1103, 1102, 1098, 1099, 1097, 1096, 1112, 1113, 1115, 1114, 1118, 1119, 1117, 1116, 1108, 1109, 1111, 1110, 1106, 1107, 1105, 1104, 1136, 1137, 1139, 1138, 1142, 1143, 1141, 1140, 1148, 1149, 1151, 1150, 1146, 1147, 1145, 1144, 1128, 1129, 1131, 1130, 1134, 1135, 1133, 1132, 1124, 1125, 1127, 1126, 1122, 1123, 1121, 1120, 1056, 1057, 1059, 1058, 1062, 1063, 1061, 1060, 1068, 1069, 1071, 1070, 1066, 1067, 1065, 1064, 1080, 1081, 1083, 1082, 1086, 1087, 1085, 1084, 1076, 1077, 1079, 1078, 1074, 1075, 1073, 1072, 1040, 1041, 1043, 1042, 1046, 1047, 1045, 1044, 1052, 1053, 1055, 1054, 1050, 1051, 1049, 1048, 1032, 1033, 1035, 1034, 1038, 1039, 1037, 1036, 1028, 1029, 1031, 1030, 1026, 1027, 1025, 1024], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512, 1536, 1537, 1539, 1538, 1542, 1543, 1541, 1540, 1548, 1549, 1551, 1550, 1546, 1547, 1545, 1544, 1560, 1561, 1563, 1562, 1566, 1567, 1565, 1564, 1556, 1557, 1559, 1558, 1554, 1555, 1553, 1552, 1584, 1585, 1587, 1586, 1590, 1591, 1589, 1588, 1596, 1597, 1599, 1598, 1594, 1595, 1593, 1592, 1576, 1577, 1579, 1578, 1582, 1583, 1581, 1580, 1572, 1573, 1575, 1574, 1570, 1571, 1569, 1568, 1632, 1633, 1635, 1634, 1638, 1639, 1637, 1636, 1644, 1645, 1647, 1646, 1642, 1643, 1641, 1640, 1656, 1657, 1659, 1658, 1662, 1663, 1661, 1660, 1652, 1653, 1655, 1654, 1650, 1651, 1649, 1648, 1616, 1617, 1619, 1618, 1622, 1623, 1621, 1620, 1628, 1629, 1631, 1630, 1626, 1627, 1625, 1624, 1608, 1609, 1611, 1610, 1614, 1615, 1613, 1612, 1604, 1605, 1607, 1606, 1602, 1603, 1601, 1600, 1728, 1729, 1731, 1730, 1734, 1735, 1733, 1732, 1740, 1741, 1743, 1742, 1738, 1739, 1737, 1736, 1752, 1753, 1755, 1754, 1758, 1759, 1757, 1756, 1748, 1749, 1751, 1750, 1746, 1747, 1745, 1744, 1776, 1777, 1779, 1778, 1782, 1783, 1781, 1780, 1788, 1789, 1791, 1790, 1786, 1787, 1785, 1784, 1768, 1769, 1771, 1770, 1774, 1775, 1773, 1772, 1764, 1765, 1767, 1766, 1762, 1763, 1761, 1760, 1696, 1697, 1699, 1698, 1702, 1703, 1701, 1700, 1708, 1709, 1711, 1710, 1706, 1707, 1705, 1704, 1720, 1721, 1723, 1722, 1726, 1727, 1725, 1724, 1716, 1717, 1719, 1718, 1714, 1715, 1713, 1712, 1680, 1681, 1683, 1682, 1686, 1687, 1685, 1684, 1692, 1693, 1695, 1694, 1690, 1691, 1689, 1688, 1672, 1673, 1675, 1674, 1678, 1679, 1677, 1676, 1668, 1669, 1671, 1670, 1666, 1667, 1665, 1664, 1920, 1921, 1923, 1922, 1926, 1927, 1925, 1924, 1932, 1933, 1935, 1934, 1930, 1931, 1929, 1928, 1944, 1945, 1947, 1946, 1950, 1951, 1949, 1948, 1940, 1941, 1943, 1942, 1938, 1939, 1937, 1936, 1968, 1969, 1971, 1970, 1974, 1975, 1973, 1972, 1980, 1981, 1983, 1982, 1978, 1979, 1977, 1976, 1960, 1961, 1963, 1962, 1966, 1967, 1965, 1964, 1956, 1957, 1959, 1958, 1954, 1955, 1953, 1952, 2016, 2017, 2019, 2018, 2022, 2023, 2021, 2020, 2028, 2029, 2031, 2030, 2026, 2027, 2025, 2024, 2040, 2041, 2043, 2042, 2046, 2047, 2045, 2044, 2036, 2037, 2039, 2038, 2034, 2035, 2033, 2032, 2000, 2001, 2003, 2002, 2006, 2007, 2005, 2004, 2012, 2013, 2015, 2014, 2010, 2011, 2009, 2008, 1992, 1993, 1995, 1994, 1998, 1999, 1997, 1996, 1988, 1989, 1991, 1990, 1986, 1987, 1985, 1984, 1856, 1857, 1859, 1858, 1862, 1863, 1861, 1860, 1868, 1869, 1871, 1870, 1866, 1867, 1865, 1864, 1880, 1881, 1883, 1882, 1886, 1887, 1885, 1884, 1876, 1877, 1879, 1878, 1874, 1875, 1873, 1872, 1904, 1905, 1907, 1906, 1910, 1911, 1909, 1908, 1916, 1917, 1919, 1918, 1914, 1915, 1913, 1912, 1896, 1897, 1899, 1898, 1902, 1903, 1901, 1900, 1892, 1893, 1895, 1894, 1890, 1891, 1889, 1888, 1824, 1825, 1827, 1826, 1830, 1831, 1829, 1828, 1836, 1837, 1839, 1838, 1834, 1835, 1833, 1832, 1848, 1849, 1851, 1850, 1854, 1855, 1853, 1852, 1844, 1845, 1847, 1846, 1842, 1843, 1841, 1840, 1808, 1809, 1811, 1810, 1814, 1815, 1813, 1812, 1820, 1821, 1823, 1822, 1818, 1819, 1817, 1816, 1800, 1801, 1803, 1802, 1806, 1807, 1805, 1804, 1796, 1797, 1799, 1798, 1794, 1795, 1793, 1792, 1280, 1281, 1283, 1282, 1286, 1287, 1285, 1284, 1292, 1293, 1295, 1294, 1290, 1291, 1289, 1288, 1304, 1305, 1307, 1306, 1310, 1311, 1309, 1308, 1300, 1301, 1303, 1302, 1298, 1299, 1297, 1296, 1328, 1329, 1331, 1330, 1334, 1335, 1333, 1332, 1340, 1341, 1343, 1342, 1338, 1339, 1337, 1336, 1320, 1321, 1323, 1322, 1326, 1327, 1325, 1324, 1316, 1317, 1319, 1318, 1314, 1315, 1313, 1312, 1376, 1377, 1379, 1378, 1382, 1383, 1381, 1380, 1388, 1389, 1391, 1390, 1386, 1387, 1385, 1384, 1400, 1401, 1403, 1402, 1406, 1407, 1405, 1404, 1396, 1397, 1399, 1398, 1394, 1395, 1393, 1392, 1360, 1361, 1363, 1362, 1366, 1367, 1365, 1364, 1372, 1373, 1375, 1374, 1370, 1371, 1369, 1368, 1352, 1353, 1355, 1354, 1358, 1359, 1357, 1356, 1348, 1349, 1351, 1350, 1346, 1347, 1345, 1344, 1472, 1473, 1475, 1474, 1478, 1479, 1477, 1476, 1484, 1485, 1487, 1486, 1482, 1483, 1481, 1480, 1496, 1497, 1499, 1498, 1502, 1503, 1501, 1500, 1492, 1493, 1495, 1494, 1490, 1491, 1489, 1488, 1520, 1521, 1523, 1522, 1526, 1527, 1525, 1524, 1532, 1533, 1535, 1534, 1530, 1531, 1529, 1528, 1512, 1513, 1515, 1514, 1518, 1519, 1517, 1516, 1508, 1509, 1511, 1510, 1506, 1507, 1505, 1504, 1440, 1441, 1443, 1442, 1446, 1447, 1445, 1444, 1452, 1453, 1455, 1454, 1450, 1451, 1449, 1448, 1464, 1465, 1467, 1466, 1470, 1471, 1469, 1468, 1460, 1461, 1463, 1462, 1458, 1459, 1457, 1456, 1424, 1425, 1427, 1426, 1430, 1431, 1429, 1428, 1436, 1437, 1439, 1438, 1434, 1435, 1433, 1432, 1416, 1417, 1419, 1418, 1422, 1423, 1421, 1420, 1412, 1413, 1415, 1414, 1410, 1411, 1409, 1408, 1152, 1153, 1155, 1154, 1158, 1159, 1157, 1156, 1164, 1165, 1167, 1166, 1162, 1163, 1161, 1160, 1176, 1177, 1179, 1178, 1182, 1183, 1181, 1180, 1172, 1173, 1175, 1174, 1170, 1171, 1169, 1168, 1200, 1201, 1203, 1202, 1206, 1207, 1205, 1204, 1212, 1213, 1215, 1214, 1210, 1211, 1209, 1208, 1192, 1193, 1195, 1194, 1198, 1199, 1197, 1196, 1188, 1189, 1191, 1190, 1186, 1187, 1185, 1184, 1248, 1249, 1251, 1250, 1254, 1255, 1253, 1252, 1260, 1261, 1263, 1262, 1258, 1259, 1257, 1256, 1272, 1273, 1275, 1274, 1278, 1279, 1277, 1276, 1268, 1269, 1271, 1270, 1266, 1267, 1265, 1264, 1232, 1233, 1235, 1234, 1238, 1239, 1237, 1236, 1244, 1245, 1247, 1246, 1242, 1243, 1241, 1240, 1224, 1225, 1227, 1226, 1230, 1231, 1229, 1228, 1220, 1221, 1223, 1222, 1218, 1219, 1217, 1216, 1088, 1089, 1091, 1090, 1094, 1095, 1093, 1092, 1100, 1101, 1103, 1102, 1098, 1099, 1097, 1096, 1112, 1113, 1115, 1114, 1118, 1119, 1117, 1116, 1108, 1109, 1111, 1110, 1106, 1107, 1105, 1104, 1136, 1137, 1139, 1138, 1142, 1143, 1141, 1140, 1148, 1149, 1151, 1150, 1146, 1147, 1145, 1144, 1128, 1129, 1131, 1130, 1134, 1135, 1133, 1132, 1124, 1125, 1127, 1126, 1122, 1123, 1121, 1120, 1056, 1057, 1059, 1058, 1062, 1063, 1061, 1060, 1068, 1069, 1071, 1070, 1066, 1067, 1065, 1064, 1080, 1081, 1083, 1082, 1086, 1087, 1085, 1084, 1076, 1077, 1079, 1078, 1074, 1075, 1073, 1072, 1040, 1041, 1043, 1042, 1046, 1047, 1045, 1044, 1052, 1053, 1055, 1054, 1050, 1051, 1049, 1048, 1032, 1033, 1035, 1034, 1038, 1039, 1037, 1036, 1028, 1029, 1031, 1030, 1026, 1027, 1025, 1024, 3072, 3073, 3075, 3074, 3078, 3079, 3077, 3076, 3084, 3085, 3087, 3086, 3082, 3083, 3081, 3080, 3096, 3097, 3099, 3098, 3102, 3103, 3101, 3100, 3092, 3093, 3095, 3094, 3090, 3091, 3089, 3088, 3120, 3121, 3123, 3122, 3126, 3127, 3125, 3124, 3132, 3133, 3135, 3134, 3130, 3131, 3129, 3128, 3112, 3113, 3115, 3114, 3118, 3119, 3117, 3116, 3108, 3109, 3111, 3110, 3106, 3107, 3105, 3104, 3168, 3169, 3171, 3170, 3174, 3175, 3173, 3172, 3180, 3181, 3183, 3182, 3178, 3179, 3177, 3176, 3192, 3193, 3195, 3194, 3198, 3199, 3197, 3196, 3188, 3189, 3191, 3190, 3186, 3187, 3185, 3184, 3152, 3153, 3155, 3154, 3158, 3159, 3157, 3156, 3164, 3165, 3167, 3166, 3162, 3163, 3161, 3160, 3144, 3145, 3147, 3146, 3150, 3151, 3149, 3148, 3140, 3141, 3143, 3142, 3138, 3139, 3137, 3136, 3264, 3265, 3267, 3266, 3270, 3271, 3269, 3268, 3276, 3277, 3279, 3278, 3274, 3275, 3273, 3272, 3288, 3289, 3291, 3290, 3294, 3295, 3293, 3292, 3284, 3285, 3287, 3286, 3282, 3283, 3281, 3280, 3312, 3313, 3315, 3314, 3318, 3319, 3317, 3316, 3324, 3325, 3327, 3326, 3322, 3323, 3321, 3320, 3304, 3305, 3307, 3306, 3310, 3311, 3309, 3308, 3300, 3301, 3303, 3302, 3298, 3299, 3297, 3296, 3232, 3233, 3235, 3234, 3238, 3239, 3237, 3236, 3244, 3245, 3247, 3246, 3242, 3243, 3241, 3240, 3256, 3257, 3259, 3258, 3262, 3263, 3261, 3260, 3252, 3253, 3255, 3254, 3250, 3251, 3249, 3248, 3216, 3217, 3219, 3218, 3222, 3223, 3221, 3220, 3228, 3229, 3231, 3230, 3226, 3227, 3225, 3224, 3208, 3209, 3211, 3210, 3214, 3215, 3213, 3212, 3204, 3205, 3207, 3206, 3202, 3203, 3201, 3200, 3456, 3457, 3459, 3458, 3462, 3463, 3461, 3460, 3468, 3469, 3471, 3470, 3466, 3467, 3465, 3464, 3480, 3481, 3483, 3482, 3486, 3487, 3485, 3484, 3476, 3477, 3479, 3478, 3474, 3475, 3473, 3472, 3504, 3505, 3507, 3506, 3510, 3511, 3509, 3508, 3516, 3517, 3519, 3518, 3514, 3515, 3513, 3512, 3496, 3497, 3499, 3498, 3502, 3503, 3501, 3500, 3492, 3493, 3495, 3494, 3490, 3491, 3489, 3488, 3552, 3553, 3555, 3554, 3558, 3559, 3557, 3556, 3564, 3565, 3567, 3566, 3562, 3563, 3561, 3560, 3576, 3577, 3579, 3578, 3582, 3583, 3581, 3580, 3572, 3573, 3575, 3574, 3570, 3571, 3569, 3568, 3536, 3537, 3539, 3538, 3542, 3543, 3541, 3540, 3548, 3549, 3551, 3550, 3546, 3547, 3545, 3544, 3528, 3529, 3531, 3530, 3534, 3535, 3533, 3532, 3524, 3525, 3527, 3526, 3522, 3523, 3521, 3520, 3392, 3393, 3395, 3394, 3398, 3399, 3397, 3396, 3404, 3405, 3407, 3406, 3402, 3403, 3401, 3400, 3416, 3417, 3419, 3418, 3422, 3423, 3421, 3420, 3412, 3413, 3415, 3414, 3410, 3411, 3409, 3408, 3440, 3441, 3443, 3442, 3446, 3447, 3445, 3444, 3452, 3453, 3455, 3454, 3450, 3451, 3449, 3448, 3432, 3433, 3435, 3434, 3438, 3439, 3437, 3436, 3428, 3429, 3431, 3430, 3426, 3427, 3425, 3424, 3360, 3361, 3363, 3362, 3366, 3367, 3365, 3364, 3372, 3373, 3375, 3374, 3370, 3371, 3369, 3368, 3384, 3385, 3387, 3386, 3390, 3391, 3389, 3388, 3380, 3381, 3383, 3382, 3378, 3379, 3377, 3376, 3344, 3345, 3347, 3346, 3350, 3351, 3349, 3348, 3356, 3357, 3359, 3358, 3354, 3355, 3353, 3352, 3336, 3337, 3339, 3338, 3342, 3343, 3341, 3340, 3332, 3333, 3335, 3334, 3330, 3331, 3329, 3328, 3840, 3841, 3843, 3842, 3846, 3847, 3845, 3844, 3852, 3853, 3855, 3854, 3850, 3851, 3849, 3848, 3864, 3865, 3867, 3866, 3870, 3871, 3869, 3868, 3860, 3861, 3863, 3862, 3858, 3859, 3857, 3856, 3888, 3889, 3891, 3890, 3894, 3895, 3893, 3892, 3900, 3901, 3903, 3902, 3898, 3899, 3897, 3896, 3880, 3881, 3883, 3882, 3886, 3887, 3885, 3884, 3876, 3877, 3879, 3878, 3874, 3875, 3873, 3872, 3936, 3937, 3939, 3938, 3942, 3943, 3941, 3940, 3948, 3949, 3951, 3950, 3946, 3947, 3945, 3944, 3960, 3961, 3963, 3962, 3966, 3967, 3965, 3964, 3956, 3957, 3959, 3958, 3954, 3955, 3953, 3952, 3920, 3921, 3923, 3922, 3926, 3927, 3925, 3924, 3932, 3933, 3935, 3934, 3930, 3931, 3929, 3928, 3912, 3913, 3915, 3914, 3918, 3919, 3917, 3916, 3908, 3909, 3911, 3910, 3906, 3907, 3905, 3904, 4032, 4033, 4035, 4034, 4038, 4039, 4037, 4036, 4044, 4045, 4047, 4046, 4042, 4043, 4041, 4040, 4056, 4057, 4059, 4058, 4062, 4063, 4061, 4060, 4052, 4053, 4055, 4054, 4050, 4051, 4049, 4048, 4080, 4081, 4083, 4082, 4086, 4087, 4085, 4084, 4092, 4093, 4095, 4094, 4090, 4091, 4089, 4088, 4072, 4073, 4075, 4074, 4078, 4079, 4077, 4076, 4068, 4069, 4071, 4070, 4066, 4067, 4065, 4064, 4000, 4001, 4003, 4002, 4006, 4007, 4005, 4004, 4012, 4013, 4015, 4014, 4010, 4011, 4009, 4008, 4024, 4025, 4027, 4026, 4030, 4031, 4029, 4028, 4020, 4021, 4023, 4022, 4018, 4019, 4017, 4016, 3984, 3985, 3987, 3986, 3990, 3991, 3989, 3988, 3996, 3997, 3999, 3998, 3994, 3995, 3993, 3992, 3976, 3977, 3979, 3978, 3982, 3983, 3981, 3980, 3972, 3973, 3975, 3974, 3970, 3971, 3969, 3968, 3712, 3713, 3715, 3714, 3718, 3719, 3717, 3716, 3724, 3725, 3727, 3726, 3722, 3723, 3721, 3720, 3736, 3737, 3739, 3738, 3742, 3743, 3741, 3740, 3732, 3733, 3735, 3734, 3730, 3731, 3729, 3728, 3760, 3761, 3763, 3762, 3766, 3767, 3765, 3764, 3772, 3773, 3775, 3774, 3770, 3771, 3769, 3768, 3752, 3753, 3755, 3754, 3758, 3759, 3757, 3756, 3748, 3749, 3751, 3750, 3746, 3747, 3745, 3744, 3808, 3809, 3811, 3810, 3814, 3815, 3813, 3812, 3820, 3821, 3823, 3822, 3818, 3819, 3817, 3816, 3832, 3833, 3835, 3834, 3838, 3839, 3837, 3836, 3828, 3829, 3831, 3830, 3826, 3827, 3825, 3824, 3792, 3793, 3795, 3794, 3798, 3799, 3797, 3796, 3804, 3805, 3807, 3806, 3802, 3803, 3801, 3800, 3784, 3785, 3787, 3786, 3790, 3791, 3789, 3788, 3780, 3781, 3783, 3782, 3778, 3779, 3777, 3776, 3648, 3649, 3651, 3650, 3654, 3655, 3653, 3652, 3660, 3661, 3663, 3662, 3658, 3659, 3657, 3656, 3672, 3673, 3675, 3674, 3678, 3679, 3677, 3676, 3668, 3669, 3671, 3670, 3666, 3667, 3665, 3664, 3696, 3697, 3699, 3698, 3702, 3703, 3701, 3700, 3708, 3709, 3711, 3710, 3706, 3707, 3705, 3704, 3688, 3689, 3691, 3690, 3694, 3695, 3693, 3692, 3684, 3685, 3687, 3686, 3682, 3683, 3681, 3680, 3616, 3617, 3619, 3618, 3622, 3623, 3621, 3620, 3628, 3629, 3631, 3630, 3626, 3627, 3625, 3624, 3640, 3641, 3643, 3642, 3646, 3647, 3645, 3644, 3636, 3637, 3639, 3638, 3634, 3635, 3633, 3632, 3600, 3601, 3603, 3602, 3606, 3607, 3605, 3604, 3612, 3613, 3615, 3614, 3610, 3611, 3609, 3608, 3592, 3593, 3595, 3594, 3598, 3599, 3597, 3596, 3588, 3589, 3591, 3590, 3586, 3587, 3585, 3584, 2560, 2561, 2563, 2562, 2566, 2567, 2565, 2564, 2572, 2573, 2575, 2574, 2570, 2571, 2569, 2568, 2584, 2585, 2587, 2586, 2590, 2591, 2589, 2588, 2580, 2581, 2583, 2582, 2578, 2579, 2577, 2576, 2608, 2609, 2611, 2610, 2614, 2615, 2613, 2612, 2620, 2621, 2623, 2622, 2618, 2619, 2617, 2616, 2600, 2601, 2603, 2602, 2606, 2607, 2605, 2604, 2596, 2597, 2599, 2598, 2594, 2595, 2593, 2592, 2656, 2657, 2659, 2658, 2662, 2663, 2661, 2660, 2668, 2669, 2671, 2670, 2666, 2667, 2665, 2664, 2680, 2681, 2683, 2682, 2686, 2687, 2685, 2684, 2676, 2677, 2679, 2678, 2674, 2675, 2673, 2672, 2640, 2641, 2643, 2642, 2646, 2647, 2645, 2644, 2652, 2653, 2655, 2654, 2650, 2651, 2649, 2648, 2632, 2633, 2635, 2634, 2638, 2639, 2637, 2636, 2628, 2629, 2631, 2630, 2626, 2627, 2625, 2624, 2752, 2753, 2755, 2754, 2758, 2759, 2757, 2756, 2764, 2765, 2767, 2766, 2762, 2763, 2761, 2760, 2776, 2777, 2779, 2778, 2782, 2783, 2781, 2780, 2772, 2773, 2775, 2774, 2770, 2771, 2769, 2768, 2800, 2801, 2803, 2802, 2806, 2807, 2805, 2804, 2812, 2813, 2815, 2814, 2810, 2811, 2809, 2808, 2792, 2793, 2795, 2794, 2798, 2799, 2797, 2796, 2788, 2789, 2791, 2790, 2786, 2787, 2785, 2784, 2720, 2721, 2723, 2722, 2726, 2727, 2725, 2724, 2732, 2733, 2735, 2734, 2730, 2731, 2729, 2728, 2744, 2745, 2747, 2746, 2750, 2751, 2749, 2748, 2740, 2741, 2743, 2742, 2738, 2739, 2737, 2736, 2704, 2705, 2707, 2706, 2710, 2711, 2709, 2708, 2716, 2717, 2719, 2718, 2714, 2715, 2713, 2712, 2696, 2697, 2699, 2698, 2702, 2703, 2701, 2700, 2692, 2693, 2695, 2694, 2690, 2691, 2689, 2688, 2944, 2945, 2947, 2946, 2950, 2951, 2949, 2948, 2956, 2957, 2959, 2958, 2954, 2955, 2953, 2952, 2968, 2969, 2971, 2970, 2974, 2975, 2973, 2972, 2964, 2965, 2967, 2966, 2962, 2963, 2961, 2960, 2992, 2993, 2995, 2994, 2998, 2999, 2997, 2996, 3004, 3005, 3007, 3006, 3002, 3003, 3001, 3000, 2984, 2985, 2987, 2986, 2990, 2991, 2989, 2988, 2980, 2981, 2983, 2982, 2978, 2979, 2977, 2976, 3040, 3041, 3043, 3042, 3046, 3047, 3045, 3044, 3052, 3053, 3055, 3054, 3050, 3051, 3049, 3048, 3064, 3065, 3067, 3066, 3070, 3071, 3069, 3068, 3060, 3061, 3063, 3062, 3058, 3059, 3057, 3056, 3024, 3025, 3027, 3026, 3030, 3031, 3029, 3028, 3036, 3037, 3039, 3038, 3034, 3035, 3033, 3032, 3016, 3017, 3019, 3018, 3022, 3023, 3021, 3020, 3012, 3013, 3015, 3014, 3010, 3011, 3009, 3008, 2880, 2881, 2883, 2882, 2886, 2887, 2885, 2884, 2892, 2893, 2895, 2894, 2890, 2891, 2889, 2888, 2904, 2905, 2907, 2906, 2910, 2911, 2909, 2908, 2900, 2901, 2903, 2902, 2898, 2899, 2897, 2896, 2928, 2929, 2931, 2930, 2934, 2935, 2933, 2932, 2940, 2941, 2943, 2942, 2938, 2939, 2937, 2936, 2920, 2921, 2923, 2922, 2926, 2927, 2925, 2924, 2916, 2917, 2919, 2918, 2914, 2915, 2913, 2912, 2848, 2849, 2851, 2850, 2854, 2855, 2853, 2852, 2860, 2861, 2863, 2862, 2858, 2859, 2857, 2856, 2872, 2873, 2875, 2874, 2878, 2879, 2877, 2876, 2868, 2869, 2871, 2870, 2866, 2867, 2865, 2864, 2832, 2833, 2835, 2834, 2838, 2839, 2837, 2836, 2844, 2845, 2847, 2846, 2842, 2843, 2841, 2840, 2824, 2825, 2827, 2826, 2830, 2831, 2829, 2828, 2820, 2821, 2823, 2822, 2818, 2819, 2817, 2816, 2304, 2305, 2307, 2306, 2310, 2311, 2309, 2308, 2316, 2317, 2319, 2318, 2314, 2315, 2313, 2312, 2328, 2329, 2331, 2330, 2334, 2335, 2333, 2332, 2324, 2325, 2327, 2326, 2322, 2323, 2321, 2320, 2352, 2353, 2355, 2354, 2358, 2359, 2357, 2356, 2364, 2365, 2367, 2366, 2362, 2363, 2361, 2360, 2344, 2345, 2347, 2346, 2350, 2351, 2349, 2348, 2340, 2341, 2343, 2342, 2338, 2339, 2337, 2336, 2400, 2401, 2403, 2402, 2406, 2407, 2405, 2404, 2412, 2413, 2415, 2414, 2410, 2411, 2409, 2408, 2424, 2425, 2427, 2426, 2430, 2431, 2429, 2428, 2420, 2421, 2423, 2422, 2418, 2419, 2417, 2416, 2384, 2385, 2387, 2386, 2390, 2391, 2389, 2388, 2396, 2397, 2399, 2398, 2394, 2395, 2393, 2392, 2376, 2377, 2379, 2378, 2382, 2383, 2381, 2380, 2372, 2373, 2375, 2374, 2370, 2371, 2369, 2368, 2496, 2497, 2499, 2498, 2502, 2503, 2501, 2500, 2508, 2509, 2511, 2510, 2506, 2507, 2505, 2504, 2520, 2521, 2523, 2522, 2526, 2527, 2525, 2524, 2516, 2517, 2519, 2518, 2514, 2515, 2513, 2512, 2544, 2545, 2547, 2546, 2550, 2551, 2549, 2548, 2556, 2557, 2559, 2558, 2554, 2555, 2553, 2552, 2536, 2537, 2539, 2538, 2542, 2543, 2541, 2540, 2532, 2533, 2535, 2534, 2530, 2531, 2529, 2528, 2464, 2465, 2467, 2466, 2470, 2471, 2469, 2468, 2476, 2477, 2479, 2478, 2474, 2475, 2473, 2472, 2488, 2489, 2491, 2490, 2494, 2495, 2493, 2492, 2484, 2485, 2487, 2486, 2482, 2483, 2481, 2480, 2448, 2449, 2451, 2450, 2454, 2455, 2453, 2452, 2460, 2461, 2463, 2462, 2458, 2459, 2457, 2456, 2440, 2441, 2443, 2442, 2446, 2447, 2445, 2444, 2436, 2437, 2439, 2438, 2434, 2435, 2433, 2432, 2176, 2177, 2179, 2178, 2182, 2183, 2181, 2180, 2188, 2189, 2191, 2190, 2186, 2187, 2185, 2184, 2200, 2201, 2203, 2202, 2206, 2207, 2205, 2204, 2196, 2197, 2199, 2198, 2194, 2195, 2193, 2192, 2224, 2225, 2227, 2226, 2230, 2231, 2229, 2228, 2236, 2237, 2239, 2238, 2234, 2235, 2233, 2232, 2216, 2217, 2219, 2218, 2222, 2223, 2221, 2220, 2212, 2213, 2215, 2214, 2210, 2211, 2209, 2208, 2272, 2273, 2275, 2274, 2278, 2279, 2277, 2276, 2284, 2285, 2287, 2286, 2282, 2283, 2281, 2280, 2296, 2297, 2299, 2298, 2302, 2303, 2301, 2300, 2292, 2293, 2295, 2294, 2290, 2291, 2289, 2288, 2256, 2257, 2259, 2258, 2262, 2263, 2261, 2260, 2268, 2269, 2271, 2270, 2266, 2267, 2265, 2264, 2248, 2249, 2251, 2250, 2254, 2255, 2253, 2252, 2244, 2245, 2247, 2246, 2242, 2243, 2241, 2240, 2112, 2113, 2115, 2114, 2118, 2119, 2117, 2116, 2124, 2125, 2127, 2126, 2122, 2123, 2121, 2120, 2136, 2137, 2139, 2138, 2142, 2143, 2141, 2140, 2132, 2133, 2135, 2134, 2130, 2131, 2129, 2128, 2160, 2161, 2163, 2162, 2166, 2167, 2165, 2164, 2172, 2173, 2175, 2174, 2170, 2171, 2169, 2168, 2152, 2153, 2155, 2154, 2158, 2159, 2157, 2156, 2148, 2149, 2151, 2150, 2146, 2147, 2145, 2144, 2080, 2081, 2083, 2082, 2086, 2087, 2085, 2084, 2092, 2093, 2095, 2094, 2090, 2091, 2089, 2088, 2104, 2105, 2107, 2106, 2110, 2111, 2109, 2108, 2100, 2101, 2103, 2102, 2098, 2099, 2097, 2096, 2064, 2065, 2067, 2066, 2070, 2071, 2069, 2068, 2076, 2077, 2079, 2078, 2074, 2075, 2073, 2072, 2056, 2057, 2059, 2058, 2062, 2063, 2061, 2060, 2052, 2053, 2055, 2054, 2050, 2051, 2049, 2048], [0], [0, 1], [0, 1, 3, 2], [0, 1, 3, 2, 6, 7, 5, 4], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101, 100, 108, 109, 111, 110, 106, 107, 105, 104, 120, 121, 123, 122, 126, 127, 125, 124, 116, 117, 119, 118, 114, 115, 113, 112, 80, 81, 83, 82, 86, 87, 85, 84, 92, 93, 95, 94, 90, 91, 89, 88, 72, 73, 75, 74, 78, 79, 77, 76, 68, 69, 71, 70, 66, 67, 65, 64, 192, 193, 195, 194, 198, 199, 197, 196, 204, 205, 207, 206, 202, 203, 201, 200, 216, 217, 219, 218, 222, 223, 221, 220, 212, 213, 215, 214, 210, 211, 209, 208, 240, 241, 243, 242, 246, 247, 245, 244, 252, 253, 255, 254, 250, 251, 249, 248, 232, 233, 235, 234, 238, 239, 237, 236, 228, 229, 231, 230, 226, 227, 225, 224, 160, 161, 163, 162, 166, 167, 165, 164, 172, 173, 175, 174, 170, 171, 169, 168, 184, 185, 187, 186, 190, 191, 189, 188, 180, 181, 183, 182, 178, 179, 177, 176, 144, 145, 147, 146, 150, 151, 149, 148, 156, 157, 159, 158, 154, 155, 153, 152, 136, 137, 139, 138, 142, 143, 141, 140, 132, 133, 135, 134, 130, 131, 129, 128, 384, 385, 387, 386, 390, 391, 389, 388, 396, 397, 399, 398, 394, 395, 393, 392, 408, 409, 411, 410, 414, 415, 413, 412, 404, 405, 407, 406, 402, 403, 401, 400, 432, 433, 435, 434, 438, 439, 437, 436, 444, 445, 447, 446, 442, 443, 441, 440, 424, 425, 427, 426, 430, 431, 429, 428, 420, 421, 423, 422, 418, 419, 417, 416, 480, 481, 483, 482, 486, 487, 485, 484, 492, 493, 495, 494, 490, 491, 489, 488, 504, 505, 507, 506, 510, 511, 509, 508, 500, 501, 503, 502, 498, 499, 497, 496, 464, 465, 467, 466, 470, 471, 469, 468, 476, 477, 479, 478, 474, 475, 473, 472, 456, 457, 459, 458, 462, 463, 461, 460, 452, 453, 455, 454, 450, 451, 449, 448, 320, 321, 323, 322, 326, 327, 325, 324, 332, 333, 335, 334, 330, 331, 329, 328, 344, 345, 347, 346, 350, 351, 349, 348, 340, 341, 343, 342, 338, 339, 337, 336, 368, 369, 371, 370, 374, 375, 373, 372, 380, 381, 383, 382, 378, 379, 377, 376, 360, 361, 363, 362, 366, 367, 365, 364, 356, 357, 359, 358, 354, 355, 353, 352, 288, 289, 291, 290, 294, 295, 293, 292, 300, 301, 303, 302, 298, 299, 297, 296, 312, 313, 315, 314, 318, 319, 317, 316, 308, 309, 311, 310, 306, 307, 305, 304, 272, 273, 275, 274, 278, 279, 277, 276, 284, 285, 287, 286, 282, 283, 281, 280, 264, 265, 267, 266, 270, 271, 269, 268, 260, 261, 263, 262, 258, 259, 257, 256, 768, 769, 771, 770, 774, 775, 773, 772, 780, 781, 783, 782, 778, 779, 777, 776, 792, 793, 795, 794, 798, 799, 797, 796, 788, 789, 791, 790, 786, 787, 785, 784, 816, 817, 819, 818, 822, 823, 821, 820, 828, 829, 831, 830, 826, 827, 825, 824, 808, 809, 811, 810, 814, 815, 813, 812, 804, 805, 807, 806, 802, 803, 801, 800, 864, 865, 867, 866, 870, 871, 869, 868, 876, 877, 879, 878, 874, 875, 873, 872, 888, 889, 891, 890, 894, 895, 893, 892, 884, 885, 887, 886, 882, 883, 881, 880, 848, 849, 851, 850, 854, 855, 853, 852, 860, 861, 863, 862, 858, 859, 857, 856, 840, 841, 843, 842, 846, 847, 845, 844, 836, 837, 839, 838, 834, 835, 833, 832, 960, 961, 963, 962, 966, 967, 965, 964, 972, 973, 975, 974, 970, 971, 969, 968, 984, 985, 987, 986, 990, 991, 989, 988, 980, 981, 983, 982, 978, 979, 977, 976, 1008, 1009, 1011, 1010, 1014, 1015, 1013, 1012, 1020, 1021, 1023, 1022, 1018, 1019, 1017, 1016, 1000, 1001, 1003, 1002, 1006, 1007, 1005, 1004, 996, 997, 999, 998, 994, 995, 993, 992, 928, 929, 931, 930, 934, 935, 933, 932, 940, 941, 943, 942, 938, 939, 937, 936, 952, 953, 955, 954, 958, 959, 957, 956, 948, 949, 951, 950, 946, 947, 945, 944, 912, 913, 915, 914, 918, 919, 917, 916, 924, 925, 927, 926, 922, 923, 921, 920, 904, 905, 907, 906, 910, 911, 909, 908, 900, 901, 903, 902, 898, 899, 897, 896, 640, 641, 643, 642, 646, 647, 645, 644, 652, 653, 655, 654, 650, 651, 649, 648, 664, 665, 667, 666, 670, 671, 669, 668, 660, 661, 663, 662, 658, 659, 657, 656, 688, 689, 691, 690, 694, 695, 693, 692, 700, 701, 703, 702, 698, 699, 697, 696, 680, 681, 683, 682, 686, 687, 685, 684, 676, 677, 679, 678, 674, 675, 673, 672, 736, 737, 739, 738, 742, 743, 741, 740, 748, 749, 751, 750, 746, 747, 745, 744, 760, 761, 763, 762, 766, 767, 765, 764, 756, 757, 759, 758, 754, 755, 753, 752, 720, 721, 723, 722, 726, 727, 725, 724, 732, 733, 735, 734, 730, 731, 729, 728, 712, 713, 715, 714, 718, 719, 717, 716, 708, 709, 711, 710, 706, 707, 705, 704, 576, 577, 579, 578, 582, 583, 581, 580, 588, 589, 591, 590, 586, 587, 585, 584, 600, 601, 603, 602, 606, 607, 605, 604, 596, 597, 599, 598, 594, 595, 593, 592, 624, 625, 627, 626, 630, 631, 629, 628, 636, 637, 639, 638, 634, 635, 633, 632, 616, 617, 619, 618, 622, 623, 621, 620, 612, 613, 615, 614, 610, 611, 609, 608, 544, 545, 547, 546, 550, 551, 549, 548, 556, 557, 559, 558, 554, 555, 553, 552, 568, 569, 571, 570, 574, 575, 573, 572, 564, 565, 567, 566, 562, 563, 561, 560, 528, 529, 531, 530, 534, 535, 533, 532, 540, 541, 543, 542, 538, 539, 537, 536, 520, 521, 523, 522, 526, 527, 525, 524, 516, 517, 519, 518, 514, 515, 513, 512], [0, 1, 3, 2, 6, 7, 5, 4], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8], [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16], [0, 1, 3, 2], [0, 1], [0]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "244", "slug": "greatest-common-divisor-of-strings", "id": 244, "title": "Greatest Common Divisor of Strings", "difficulty": "Easy", "category": "string", "link": "https://leetcode.com/problems/greatest-common-divisor-of-strings/", "examples": [{"input": "str1 = \"ABCABC\", str2 = \"ABC\"", "output": "\"ABC\""}, {"input": "str1 = \"ABABAB\", str2 = \"ABAB\"", "output": "\"AB\""}, {"input": "str1 = \"LEET\", str2 = \"CODE\"", "output": "\"\""}], "hints": ["The greatest common divisor must be a prefix of both strings, so try every prefix of the shorter string from longest to shortest.", "A divisor x of length len divides a string of length L only if L is a multiple of len and the string is x repeated L / len times.", "Alternatively, if str1 + str2 != str2 + str1 there is no common divisor; otherwise the answer is the prefix of length gcd(str1.length, str2.length)."], "statement": "Call a string `t` a divisor of a string `s` precisely when building `s` is possible by writing `t` consecutively one or more times, i.e. `s = t + t + ... + t`.\n\nGiven two strings `str1` and `str2`, find the longest string `x` that divides each of them.\n\n**Constraints:**\n\n- `1 <= str1.length, str2.length <= 1000`\n- `str1` and `str2` use only uppercase English letters.\n", "solution": "## Approach\n\nA common divisor must be a prefix of both strings. The key observation: a string `x` can divide both `str1` and `str2` only if `str1 + str2 == str2 + str1`. If that fails, no common divisor exists. Otherwise, the largest such string is the prefix of length `gcd(str1.length, str2.length)` of either string.\n\nTo check divisibility directly: `x` divides a string of length `L` iff `L % x.length == 0` and the string equals `x` repeated `L / x.length` times.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(min(str1.length, str2.length)) for the string comparison, plus O(log(min len)) for the GCD computation. String concatenation comparisons are O(str1.length + str2.length).\n- **Space Complexity:** O(str1.length + str2.length) for the temporary concatenations (or O(1) with a direct divisibility check).\n\n## Implementation\n\n```python\nfrom math import gcd\n\nclass Solution:\n def gcdOfStrings(self, str1: str, str2: str) -> str:\n if str1 + str2 != str2 + str1:\n return \"\"\n return str1[:gcd(len(str1), len(str2))]\n```", "starter": {"go": "package main\n\nfunc GcdOfStrings(str1 string, str2 string) string {\n return \"\"\n}", "python": "class Solution:\n def gcdOfStrings(self, str1: str, str2: str) -> str:\n return \"\"\n", "cpp": "#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n string gcdOfStrings(string str1, string str2) {\n return \"\";\n }\n};"}, "fn": "gcdOfStrings", "params": [{"name": "str1", "type": "string"}, {"name": "str2", "type": "string"}], "outputType": "string", "tests": [["ABCABC", "ABC"], ["ABABAB", "ABAB"], ["LEET", "CODE"], ["AAAAAB", "AAA"], ["A", "A"], ["AB", "A"], ["ABC", "AB"], ["AAAAAAAAAA", "AAAAA"], ["ABCDEF", "ABC"], ["TAUXXTAUXXTAUXXTAUXXTAUXX", "TAUXXTAUXXTAUXXTAUXXTAUXXTAUXXTAUXXTAUXXTAUXX"], ["BBB", "BBBB"], ["ABABABAB", "ABAB"], ["AAAAAA", "AA"], ["ABCDABCDABCD", "ABCDABCD"], ["ABC", "ABC"], ["A", "B"], ["ABAB", "ABAB"], ["XYZXYZ", "XYZXYZXYZ"], ["ABCABCABC", "ABCABC"], ["AAAA", "AAAA"], ["ABABABABAB", "ABABAB"], ["ABCABCAB", "ABC"], ["HELLO", "HELLO"], ["HELLO", "WORLD"], ["Z", "Z"], ["ZZ", "ZZZ"], ["ABCD", "ABCDABCD"], ["XYXYXY", "XY"], ["AAAAAAAAAA", "A"], ["CXTXNCXTXNCXTXN", "CXTXN"], ["ABCDEF", "ABCDEF"], ["ABABAB", "CDCDCD"]], "expected": ["ABC", "AB", "", "", "A", "", "", "AAAAA", "", "TAUXX", "B", "ABAB", "AA", "ABCD", "ABC", "", "ABAB", "XYZ", "ABC", "AAAA", "AB", "", "HELLO", "", "Z", "Z", "ABCD", "XY", "A", "CXTXN", "ABCDEF", ""], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "226", "slug": "greatest-common-divisor-traversal", "id": 226, "title": "Greatest Common Divisor Traversal", "difficulty": "Hard", "category": "graph", "link": "https://leetcode.com/problems/greatest-common-divisor-traversal/", "examples": [{"input": "nums = [2,3,6]", "output": "true"}, {"input": "nums = [3,9,5]", "output": "false"}, {"input": "nums = [4,3,12,8]", "output": "true"}], "hints": ["Union indices that share a prime factor. If nums contains 1 and length > 1, return false."], "statement": "You are given a 0-indexed array of unique positive integers `nums`.\n\nYou can perform multiple operations on the array. In one operation you can choose two indices `i` and `j` (`i != j`) such that `gcd(nums[i], nums[j]) > 1` and traverse between them.\n\nReturn `true` if for every pair of indices `i` and `j` in `nums` there exists a sequence of operations that can take you from `i` to `j`, otherwise return `false`.\n\n**Constraints:**\n- `1 <= nums.length <= 10^5`\n- `1 <= nums[i] <= 10^5`\n- All values are unique\n", "solution": "## Approach\n\nUnion-find on indices. For each number, factorize and union with the first index that shared each prime factor. If any value is 1 and n>1, return false.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n * sqrt(M) + \u03b1)\n- **Space Complexity:** O(n + M)\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def canTraverseAllPairs(self, nums: List[int]) -> bool:\n n = len(nums)\n if n == 1:\n return True\n if 1 in nums:\n return False\n parent = list(range(n))\n def find(x):\n while parent[x] != x:\n parent[x] = parent[parent[x]]\n x = parent[x]\n return x\n def union(a, b):\n a, b = find(a), find(b)\n if a != b:\n parent[a] = b\n first = {}\n for i, x in enumerate(nums):\n v = x\n p = 2\n while p * p <= v:\n if v % p == 0:\n if p in first:\n union(first[p], i)\n else:\n first[p] = i\n while v % p == 0:\n v //= p\n p += 1\n if v > 1:\n if v in first:\n union(first[v], i)\n else:\n first[v] = i\n r = find(0)\n return all(find(i) == r for i in range(n))\n```\n", "starter": {"go": "package main\n\nfunc CanTraverseAllPairs(nums []int) bool {\n return false\n}", "python": "from typing import List\nclass Solution:\n def canTraverseAllPairs(self, nums: List[int]) -> bool:\n ", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n bool canTraverseAllPairs(vector<int>& nums) {\n return false;\n }\n};"}, "fn": "canTraverseAllPairs", "params": [{"name": "nums", "type": "int_array"}], "outputType": "boolean", "tests": [["[2,3,6]"], ["[3,9,5]"], ["[4,3,12,8]"], ["[1]"], ["[1,2]"], ["[7]"], ["[2,4,8,16]"], ["[2,3,5,7]"], ["[6,10,15]"], ["[2,3,5,6,10,15]"], ["[2]"], ["[100000]"], ["[6,10,15,35]"], ["[14,21,35]"], ["[11,13,17,19]"], ["[4,9,25]"], ["[4,9,6]"], ["[8,9,25,49]"], ["[12,18,27]"], ["[30,42,70,105]"], ["[2,3,5,7,11,13]"], ["[6,35,10,21]"], ["[1,2,3]"], ["[99991]"], ["[99991,99989]"], ["[100,75,50,25]"], ["[49,121,169]"], ["[49,77,121]"], ["[2,4,3,9]"], ["[2,6,35,77]"], ["[16,81,625]"], ["[16,24,81,27]"]], "expected": [true, false, true, true, false, true, true, false, true, true, true, true, true, true, false, false, true, false, true, true, false, true, false, true, false, true, false, true, false, false, false, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "54", "slug": "group-anagrams", "id": 54, "title": "Group Anagrams", "difficulty": "Medium", "category": "string", "link": "https://leetcode.com/problems/group-anagrams/", "examples": [{"input": "strs=[\"eat\",\"tea\",\"tan\",\"ate\",\"nat\",\"bat\"]", "output": "[[\"bat\"],[\"nat\",\"tan\"],[\"ate\",\"eat\",\"tea\"]] (order may vary)", "explanation": "\"eat\", \"tea\", \"ate\" have the same anagram; \"tan\" and \"nat\" have the same anagram; \"bat\" is alone."}], "hints": ["Hash strings by their sorted characters or character counts and aggregate into groups."], "statement": "Collect anagrams from a string array.\n\nYou receive an array `strs` holding strings. Partition its entries into collections so that words placed in the same collection are rearrangements of one another \u2014 that is, they share exactly the same multiset of letters. The sequence of the collections in your answer carries no importance.\n\n**Constraints:**\n\n- `1 \u2264 strs.length \u2264 10^4`\n- `0 \u2264 strs[i].length \u2264 100`\n- Each `strs[i]` is composed solely of lowercase English letters.\n", "solution": "## Approach\n\nGroup strings by a canonical key derived from sorting each string's characters. Anagrams produce identical sorted strings, so they map to the same group.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n * k log k), where n is the number of strings and k is the maximum string length.\n- **Space Complexity:** O(n * k) to store the groups.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import defaultdict\nclass Solution:\n def groupAnagrams(self, strs: List[str]) -> List[List[str]]:\n groups = defaultdict(list)\n for s in strs:\n key = ''.join(sorted(s))\n groups[key].append(s)\n return list(groups.values())\n```\n", "starter": {"go": "package main\n\nfunc GroupAnagrams(strs []string) [][]string {\n \n}", "python": "from typing import List\nclass Solution:\n def groupAnagrams(self, strs: List[str]) -> List[List[str]]:\n pass\n", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n vector<vector<string>> groupAnagrams(vector<string>& strs) {\n return {};\n }\n};"}, "fn": "groupAnagrams", "params": [{"name": "strs", "type": "string_array"}], "outputType": "string_list_2d", "tests": [["['eat', 'tea', 'tan', 'ate', 'nat', 'bat']"], ["['']"], ["['a']"], ["['', '']"], ["['bdddddddddd', 'bbbbbbbbbbc']"], ["['abc', 'bca', 'cab', 'xyz', 'zyx']"], ["['a', 'b', 'c', 'd']"], ["['ab', 'ba', 'ab', 'ba']"], ["['', 'a', '']"], ["['listen', 'silent', 'enlist', 'hello', 'olleh']"], ["['a', 'aa', 'aaa', 'aaaa']"], ["['abc', 'def', 'ghi']"], ["['eat', 'eat', 'eat']"], ["['ab', 'cd', 'ef', 'gh']"], ["['dusty', 'study', 'night', 'thing']"], ["['aab', 'aba', 'baa', 'abb', 'bab', 'bba']"], ["['', 'b', 'b', '', 'c']"], ["['abcde', 'edcba', 'abcde']"], ["['x', 'xx', 'xxx', 'xxxx', 'xxxxx']"], ["['cat', 'act', 'tac', 'dog', 'god', 'odg']"], ["['a', 'a', 'a', 'a', 'a']"], ["['abca', 'baca', 'caba', 'abcd']"], ["['hello', 'world', 'hello']"], ["['abc', 'acb', 'bac', 'bca', 'cab', 'cba']"], ["['z']"], ["['ab', 'aab', 'aaab', 'aaaab']"], ["['race', 'care', 'acre', 'racecar']"], ["['aa', 'bb', 'cc', 'ab', 'ba']"], ["['qwerty', 'ytrewq', 'asdf', 'fdsa']"], ["['aabbb', 'bbbaa', 'abbab']"], ["['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba']"], ["['mno', 'onm', 'nom', 'opq']"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "355", "slug": "group-shifted-strings", "id": 355, "title": "Group Shifted Strings", "difficulty": "Medium", "category": "string", "link": "https://leetcode.com/problems/group-shifted-strings/", "examples": [{"input": "strings = [\"abc\",\"bcd\",\"acef\",\"xyz\",\"az\",\"ba\",\"a\",\"z\"]", "output": "[[\"a\",\"z\"],[\"abc\",\"bcd\",\"xyz\"],[\"az\",\"ba\"],[\"acef\"]]", "explanation": "\"abc\", \"bcd\" and \"xyz\" share one shift pattern; \"az\" and \"ba\" share another; \"a\" and \"z\" are single letters; \"acef\" stands alone."}, {"input": "strings = [\"a\"]", "output": "[[\"a\"]]", "explanation": "A single string forms its own group."}], "hints": ["Normalize each string by shifting it so its first character becomes 'a'.", "Strings with equal normalized forms belong to the same group."], "statement": "Two strings belong to the same shift group when each character of one can be shifted forward by the same amount (wrapping from `z` to `a`) to obtain the other. For example, `\"abc\"` shifts to `\"bcd\"`, and `\"az\"` shifts to `\"ba\"`.\n\nGiven an array of lowercase strings `strings`, partition them so that strings in one group all shift into each other.\n\nReturn the groups in any order, with the strings inside each group in any order.\n\n*Type note:* the original signature returns a list of lists of strings; here it maps to `string_list_2d`.\n\n**Constraints:**\n- `1 <= strings.length <= 300`\n- `1 <= strings[i].length <= 50`\n- Each string holds lowercase English letters.\n", "solution": "## Approach\n\nNormalize every string by shifting all its characters back by the offset of its first letter, so each group shares one canonical form. Single-character strings all normalize to the same key. Collect strings with equal keys into groups with a hash map.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n * m), where n is the number of strings and m their maximum length.\n- **Space Complexity:** O(n * m) for the keys and groups.\n\n## Implementation\n\n```python\nfrom typing import List\n\nclass Solution:\n def groupStrings(self, strings: List[str]) -> List[List[str]]:\n groups = {}\n for s in strings:\n if len(s) <= 1:\n key = \"*\"\n else:\n shift = ord(s[0]) - ord(\"a\")\n key = \"\".join(chr((ord(c) - ord(\"a\") - shift) % 26 + ord(\"a\")) for c in s)\n groups.setdefault(key, []).append(s)\n return list(groups.values())\n```\n", "starter": {"go": "package main\n\nfunc GroupStrings(strings []string) [][]string {\n return [][]string{}\n}", "python": "from typing import List\nclass Solution:\n def groupStrings(self, strings: List[str]) -> List[List[str]]:\n return []\n", "cpp": "#include <string>\n#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<vector<string>> groupStrings(vector<string>& strings) {\n return {};\n }\n};"}, "fn": "groupStrings", "params": [{"name": "strings", "type": "string_array"}], "outputType": "string_list_2d", "tests": [["[\"abc\",\"bcd\",\"acef\",\"xyz\",\"az\",\"ba\",\"a\",\"z\"]"], ["[\"a\"]"], ["[\"abc\",\"bcd\"]"], ["[\"a\",\"z\"]"], ["[\"az\",\"ba\"]"], ["[\"abc\",\"def\",\"ghi\"]"], ["[\"acef\",\"bzdf\"]"], ["[\"ab\",\"bc\",\"cd\",\"za\"]"], ["[\"a\",\"b\",\"c\"]"], ["[\"fpb\",\"nsd\"]"], ["[\"hsulvzcy\",\"oclwdhuu\",\"q\"]"], ["[\"bcd\",\"xyz\",\"ijk\"]"], ["[\"ab\",\"cd\",\"yz\"]"], ["[\"abc\",\"bcd\",\"cde\",\"def\"]"], ["[\"alone\"]"], ["[\"aa\",\"bb\",\"cc\"]"], ["[\"abc\",\"az\",\"a\"]"], ["[\"mnop\",\"qrst\",\"abcd\"]"], ["[\"xyz\",\"yza\",\"zab\"]"], ["[\"q\",\"w\",\"e\",\"r\"]"], ["[\"ab\",\"ba\"]"], ["[\"abcde\",\"bcdef\",\"cdefg\"]"], ["[\"zzz\",\"aaa\"]"], ["[\"hello\",\"ifmmp\"]"], ["[\"abc\",\"def\",\"xyz\",\"az\"]"], ["[\"a\",\"b\",\"aa\",\"bb\"]"], ["[\"kite\",\"mjuf\"]"], ["[\"xyzabc\",\"yzabcd\"]"]], "expected": [[["abc", "bcd", "xyz"], ["az", "ba"], ["a", "z"], ["acef"]], [["a"]], [["abc", "bcd"]], [["a", "z"]], [["az", "ba"]], [["abc", "def", "ghi"]], [["bzdf"], ["acef"]], [["ab", "bc", "cd", "za"]], [["a", "b", "c"]], [["fpb"], ["nsd"]], [["oclwdhuu"], ["hsulvzcy"], ["q"]], [["bcd", "xyz", "ijk"]], [["ab", "cd", "yz"]], [["abc", "bcd", "cde", "def"]], [["alone"]], [["aa", "bb", "cc"]], [["abc"], ["az"], ["a"]], [["mnop", "qrst", "abcd"]], [["xyz", "yza", "zab"]], [["q", "w", "e", "r"]], [["ab"], ["ba"]], [["abcde", "bcdef", "cdefg"]], [["zzz", "aaa"]], [["hello", "ifmmp"]], [["abc", "def", "xyz"], ["az"]], [["aa", "bb"], ["a", "b"]], [["kite"], ["mjuf"]], [["xyzabc", "yzabcd"]]], "loose": true}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "884", "slug": "groups-of-special-equivalent-strings", "id": 884, "title": "Groups of Special-Equivalent Strings", "difficulty": "Medium", "category": "string", "link": "https://leetcode.com/problems/groups-of-special-equivalent-strings/", "examples": [{"input": "words = [\"abcd\",\"cdab\",\"cbad\",\"xyzz\",\"zzxy\",\"zzyx\"]", "output": "3", "explanation": "Three families: {abcd,cdab,cbad}, {xyzz,zzxy}, {zzyx}."}, {"input": "words = [\"abc\",\"acb\",\"bac\",\"bca\",\"cab\",\"cba\"]", "output": "3", "explanation": "Middle vs outer letters define three families."}], "hints": ["Build a canonical key per word: sort the characters at even indexes and those at odd indexes separately, then join them.", "Two words share a family exactly when their keys match, so the answer is the number of distinct keys in a hash set."], "statement": "All words in the list share one length. You may reorder letters freely, but only within the even slots among themselves and within the odd slots among themselves. Swapping two characters that both sit on even positions, or both on odd positions, is allowed as many times as you like.\n\nTwo words belong together when one can be turned into the other through such swaps. That happens exactly when their even-position multiset and their odd-position multiset match. Words that mutually match form a family; families do not overlap. Report how many distinct families appear.\n\n**Constraints:**\n- `1 <= words.length <= 1000`\n- `1 <= words[i].length <= 20`\n- `words[i]` holds only lowercase English letters.\n- Every word has the same length.\n", "solution": "## Approach\n\nEven positions never exchange letters with odd positions, so each word is fully described by two multisets: the letters on even spots and the letters on odd spots. Sorting both halves yields a canonical fingerprint; words with identical fingerprints can be morphed into each other and no others can. Counting distinct fingerprints with a set gives the number of families.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m * k log k) for m words of length k, dominated by sorting the two halves.\n- **Space Complexity:** O(m * k) for the stored keys in the worst case.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def numSpecialEquivGroups(self, words: List[str]) -> int:\n seen = set()\n for w in words:\n even = \"\".join(sorted(w[0::2]))\n odd = \"\".join(sorted(w[1::2]))\n seen.add(even + \"|\" + odd)\n return len(seen)\n```\n", "starter": {"go": "package main\n\nfunc NumSpecialEquivGroups(words []string) int {\n \n}", "python": "from typing import List\nclass Solution:\n def numSpecialEquivGroups(self, words: List[str]) -> int:\n pass", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n return 0;\n }\n};"}, "fn": "numSpecialEquivGroups", "params": [{"name": "words", "type": "string_array"}], "outputType": "int", "tests": [["['abcd', 'cdab', 'cbad', 'xyzz', 'zzxy', 'zzyx']"], ["['abc', 'acb', 'bac', 'bca', 'cab', 'cba']"], ["['a']"], ["['aa']"], ["['ab', 'ba']"], ["['abcd', 'abcd', 'abcd']"], ["['zzxy', 'xyzz']"], ["['abc', 'cba']"], ["['abcd', 'badc']"], ["['a', 'b', 'c']"], ["['aa', 'bb', 'cc']"], ["['ab', 'cd', 'ef']"], ["['abcd', 'dcba', 'cbad']"], ["['xy', 'yx']"], ["['aaa', 'aaa']"], ["['abcde', 'edcba']"], ["['abcd', 'cdab']"], ["['oobzsoo', 'oobzsoo']"], ["['abcd', 'acbd']"], ["['abc', 'def', 'ghi']"], ["['aabb', 'bbaa', 'abab']"], ["['abcd', 'abdc', 'acbd']"], ["['zz', 'zz', 'zz']"], ["['abca', 'abca']"], ["['abcd', 'efgh', 'ijkl']"], ["['abc', 'abc', 'abc']"], ["['qwerty', 'ytrewq']"], ["['abcd', 'cbad', 'xyzz']"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "452", "slug": "guess-number-higher-or-lower-ii", "id": 452, "title": "Guess Number Higher or Lower II", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/guess-number-higher-or-lower-ii/", "examples": [{"input": "n = 1", "output": "0", "explanation": "One candidate needs no payment."}, {"input": "n = 2", "output": "1", "explanation": "Guessing 1 risks at most 1."}, {"input": "n = 10", "output": "16", "explanation": "The best split caps the worst branch at 16."}], "hints": ["Define dp over intervals [lo, hi] as the cheapest worst-case cost inside.", "Trying guess x costs x plus the worse of the left and right subproblems.", "Fill intervals by increasing length; the answer is the cost over [1, n]."], "statement": "Pay for wrong guesses and guarantee a win with the least worst-case cash.\n\nA hidden integer lies between `1` and `n` inclusive. You name guesses; each miss costs the guessed value in dollars and tells you whether the hidden value is higher or lower, then you continue. A hit costs nothing extra and ends the game. Compute the smallest bankroll that guarantees finding the hidden value no matter which one it is.\n\n**Constraints:**\n- `1 <= n <= 200`\n", "solution": "## Approach\n\nTreat every interval `[lo, hi]` as a subgame needing its cheapest worst-case price. Guessing `x` inside it pays `x` plus the pricier of the two resulting sides; pick the `x` minimizing that total. Solve intervals from short to long so both sides are ready, and read the answer at `[1, n]`.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n^3), one scan of candidate guesses per interval.\n- **Space Complexity:** O(n^2) for the interval table.\n\n## Implementation\n\n```python\nclass Solution:\n def getMoneyAmount(self, n: int) -> int:\n if n <= 1:\n return 0\n dp = [[0] * (n + 2) for _ in range(n + 2)]\n for length in range(2, n + 1):\n for lo in range(1, n - length + 2):\n hi = lo + length - 1\n best = float(\"inf\")\n for x in range(lo, hi + 1):\n left = dp[lo][x - 1] if x - 1 >= lo else 0\n right = dp[x + 1][hi] if x + 1 <= hi else 0\n best = min(best, x + max(left, right))\n dp[lo][hi] = best\n return dp[1][n]\n```\n", "starter": {"go": "package main\n\nfunc GetMoneyAmount(n int) int {\n return 0\n}", "python": "class Solution:\n def getMoneyAmount(self, n: int) -> int:\n return 0\n", "cpp": "class Solution {\npublic:\n int getMoneyAmount(int n) {\n return 0;\n }\n};"}, "fn": "getMoneyAmount", "params": [{"name": "n", "type": "int"}], "outputType": "int", "tests": [["1"], ["2"], ["3"], ["4"], ["5"], ["6"], ["7"], ["8"], ["9"], ["10"], ["11"], ["12"], ["13"], ["14"], ["15"], ["16"], ["17"], ["18"], ["19"], ["20"], ["25"], ["30"], ["40"], ["50"], ["75"], ["100"], ["150"], ["200"], ["22"], ["33"]], "expected": [0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 21, 24, 27, 30, 34, 38, 42, 46, 49, 64, 79, 119, 172, 274, 400, 692, 952, 55, 90], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "374", "slug": "guess-number-higher-or-lower", "id": 374, "title": "Guess Number Higher or Lower", "difficulty": "Easy", "category": "binary-search", "link": "https://leetcode.com/problems/guess-number-higher-or-lower/", "examples": [{"input": "n = 10, pick = 6", "output": "6", "explanation": "The hidden number is 6; binary search with the guess API finds 6."}, {"input": "n = 1, pick = 1", "output": "1", "explanation": "With only one possible number, the answer is 1."}, {"input": "n = 2, pick = 1", "output": "1", "explanation": "Guessing 1 hits immediately; otherwise the API directs the search to 1."}], "hints": ["The judge never reveals pick; call game.guess(mid) to learn whether mid is higher (-1), lower (1), or equal (0).", "Binary-search the inclusive interval [1, n]; move to [mid+1, right] when the guess is low and [left, mid-1] when it is high.", "Compute mid as left + (right - left) / 2 to avoid overflow."], "statement": "You play the Guess Game with a hidden number `pick` in the range `1` to `n`.\nInteract with the judge object `game` \u2014 your code never receives `pick` directly:\n\n- `guess(num)` returns `-1` if `num > pick` (your guess is higher than the picked number),\n- `1` if `num < pick` (your guess is lower than the picked number),\n- `0` if `num == pick` (you found it).\n\nImplement `guessNumber(n, game)` so that it returns `pick`. Binary search finds it in `O(log n)` guesses; the judge counts your `guess` calls and reports Wrong Answer if you exceed **100** calls on a test case.\n\nMethod names per language: Java `game.guess(num)`, Python `game.guess(num)`, C++ `game.guess(num)`, C# `game.Guess(num)`, Rust `game.guess(num)`, Go `game.Guess(num)`, TypeScript `game.guess(num)`, PHP `$game->guess($num)`.\n\n**Constraints:**\n\n- `1 <= n <= 2^31 - 1`\n- `1 <= pick <= n`\n- At most 100 `guess` calls per test case.\n", "solution": "## Approach\n\nSimulate the hidden `guess` API with a local comparison against `pick`,\nthen binary-search the inclusive range `[1, n]`. When the simulated API\nsays the guess is low, discard the left half; when it says high, discard\nthe right half.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log n)\n- **Space Complexity:** O(1)\n\n## Implementation\n\n```python\nclass Solution:\n def guessNumber(self, n: int, pick: int) -> int:\n def guess(num: int) -> int:\n if num > pick:\n return -1\n if num < pick:\n return 1\n return 0\n\n left, right = 1, n\n while left <= right:\n mid = left + (right - left) // 2\n r = guess(mid)\n if r == 0:\n return mid\n if r < 0:\n right = mid - 1\n else:\n left = mid + 1\n return -1\n```\n", "starter": {"go": "package main\n\n// This is the guess API interface.\n// You should not implement it, or speculate about its implementation\n// type GuessGame struct { }\n// func (g *GuessGame) Guess(num int) int\n// Guess returns -1 if num is higher, 1 if lower, 0 if equal.\n// The judge counts your calls: at most 100 per test case.\nfunc GuessNumber(n int, game *GuessGame) int {\n return 0\n}", "python": "# The guess API is provided by the judge as `game`.\n# You should not implement it, or speculate about its implementation\n# class GuessGame:\n# def guess(self, num: int) -> int:\n# # -1 if num is higher than the picked number\n# # 1 if num is lower than the picked number\n# # 0 if num is equal to the picked number\n# The judge counts your calls: at most 100 per test case.\nclass Solution:\n def guessNumber(self, n: int, game: 'GuessGame') -> int:\n return 0\n", "cpp": "/**\n * // This is the guess API interface.\n * // You should not implement it, or speculate about its implementation\n * class GuessGame {\n * public:\n * int guess(int num);\n * };\n * // guess(num) returns -1 if num is higher, 1 if lower, 0 if equal.\n * // The judge counts your calls: at most 100 per test case.\n */\nclass Solution {\npublic:\n int guessNumber(int n, GuessGame& game) {\n return 0;\n }\n};"}, "fn": "guessNumber", "params": [{"name": "n", "type": "int"}, {"name": "pick", "type": "int"}], "outputType": "int", "tests": [["10", "6"], ["1", "1"], ["2", "1"], ["2", "2"], ["100", "42"], ["100", "1"], ["100", "100"], ["1000", "500"], ["1000", "999"], ["1000000", "1"], ["1000000", "1000000"], ["1000000", "123456"], ["2126753390", "1702766719"], ["2147483647", "2147483647"], ["2147483647", "1"], ["2147483647", "1073741823"], ["3", "2"], ["3", "3"], ["3", "1"], ["5", "3"], ["5", "5"], ["7", "4"], ["8", "8"], ["9", "5"], ["15", "8"], ["16", "1"], ["16", "16"], ["50", "25"], ["100", "50"], ["100", "99"], ["500", "1"], ["500", "500"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "841", "slug": "guess-the-word", "id": 841, "title": "Guess the Word", "difficulty": "Hard", "category": "string", "link": "https://leetcode.com/problems/guess-the-word/", "examples": [{"explanation": "Hidden word is the first entry; guess it via master.guess within 10 calls.", "input": "wordlist = [\"acckzz\",\"ccbazz\",\"eiowzz\",\"abcczz\"], secret = \"acckzz\"", "output": "solved"}, {"explanation": "Filtering by match scores leaves the secret; guess it via the judge.", "input": "wordlist = [\"hamada\",\"khaled\"], secret = \"khaled\"", "output": "solved"}, {"explanation": "Return the hidden entry through the guessing API.", "input": "wordlist = [\"abcdef\",\"abcdeg\",\"abcdeh\"], secret = \"abcdeg\"", "output": "solved"}], "hints": ["Score any pair by counting equal positions; this is the value master.guess returns.", "After each guess keep only candidates whose score against the guess equals the reported score.", "Pick the guess minimizing the largest score-group (minimax) so the candidate pool shrinks fastest."], "statement": "You are given a list of unique words `wordlist` and a hidden `secret` word chosen from that list. Interact with the judge object `master`:\n\n- `master.guess(word)` returns the number of positions where `word` matches `secret` (`0 <= matches <= word.length`), or `-1` if `word` is not in `wordlist`.\n- Each call counts as one guess. You may call `guess` at most **10** times.\n- You win if one of your guesses equals `secret` within the 10-guess budget.\n\nImplement `findSecretWord(wordlist, master)` so that it finds the secret within 10 guesses.\n\nYour function returns nothing \u2014 success is measured by the judge, which reports `solved:N` (`N` guesses used) or `failed:N`. The sample display shows the secret only so you can trace the game; your code never receives it directly.\n\n**Constraints:**\n\n- `1 <= wordlist.length <= 100`\n- `wordlist[i].length == 6`\n- `wordlist[i]` consists of lowercase English letters.\n- All strings in `wordlist` are unique.\n- `secret` is always an element of `wordlist`.\n- `master.guess` may be called at most 10 times per test case.\n", "solution": "## Approach\n\nInteract with the judge instead of reading the secret. Score any pair of words by counting equal positions \u2014 this is exactly what `master.guess` returns for words in the list (`-1` otherwise). Keep a candidate pool starting as the full wordlist; each round pick the minimax candidate whose largest match-group is smallest, call `master.guess` on it, and stop when the score equals the word length. Otherwise discard every candidate whose score against the guess differs from the reported score and repeat. The pool shrinks fast enough to hit the secret within 10 guesses.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(R * n^2 * L), where R <= 10 rounds, n the list size, and L the word length.\n- **Space Complexity:** O(n) for the candidate pool plus the judge's guess history.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def findSecretWord(self, wordlist: List[str], master: 'Master') -> None:\n def matches(a, b):\n return sum(1 for x, y in zip(a, b) if x == y)\n cand = list(wordlist)\n for _ in range(10):\n if not cand:\n break\n best, best_max = cand[0], 10 ** 9\n for g in cand:\n groups = {}\n for w in cand:\n m = matches(g, w)\n groups[m] = groups.get(m, 0) + 1\n mx = max(groups.values())\n if mx < best_max:\n best_max, best = mx, g\n m = master.guess(best)\n if m == len(best):\n return\n cand = [w for w in cand if matches(w, best) == m]\n if not cand:\n break\n```\n", "starter": {"go": "package main\n\n// This is the Master's API interface.\n// You should not implement it, or speculate about its implementation\n// type Master struct { }\n// func (m *Master) Guess(word string) int\nfunc FindSecretWord(wordlist []string, master *Master) {\n}", "python": "from typing import List\n# This is the Master's API interface.\n# You should not implement it, or speculate about its implementation\n# class Master:\n# def guess(self, word: str) -> int:\n# ...\nclass Solution:\n def findSecretWord(self, wordlist: List[str], master: 'Master') -> None:\n pass\n", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\n/**\n * // This is the Master's API interface.\n * // You should not implement it, or speculate about its implementation\n * class Master {\n * public:\n * int guess(string word);\n * };\n */\nclass Solution {\npublic:\n void findSecretWord(vector<string>& wordlist, Master& master) {\n }\n};"}, "fn": "findSecretWord", "params": [{"name": "wordlist", "type": "string_array"}, {"name": "secret", "type": "string"}], "outputType": "string", "tests": [["['acckzz', 'ccbazz', 'eiowzz', 'abcczz']", "acckzz"], ["['hamada', 'khaled']", "khaled"], ["['abcdef', 'abcdeg', 'abcdeh']", "abcdeg"], ["['abcdef', 'ghijkl', 'efghij', 'mnopqr']", "efghij"], ["['abcdef', 'uvwxyz', 'qwerty']", "qwerty"], ["['secret', 'secrex', 'secrey']", "secrey"], ["['aaaaaa', 'aaaaab', 'aaaabb', 'aaabbb']", "aaabbb"], ["['abcdef', 'abccef', 'abcccf']", "abcccf"], ["['banana', 'cabana', 'panama']", "panama"], ["['orange', 'orator', 'orates']", "orates"], ["['purple', 'people', 'pupple']", "people"], ["['abcdef', 'ghijkl', 'mnopqr', 'stuvwx']", "stuvwx"], ["['zzzzzz']", "zzzzzz"], ["['ctpkto', 'dosvcr', 'fozoio', 'fyyxcp', 'glatvl', 'htxnpk', 'icdkaa', 'iehomr', 'imzivm', 'mjwiyz', 'ottsdo', 'ouvxhw', 'pizqcs', 'pnexnj', 'qnoegb', 'sabcdq', 'sgqmuv', 'sqcmji', 'sutwky', 'svwtmg', 'umymlo', 'uuonvq', 'vuhyqm', 'vvqzdq', 'vvslfz', 'wepykf', 'wgefkw', 'wkbdgz', 'ypsgua', 'ytctof']", "ytctof"], ["['lsuymy', 'rmzfnx', 'sgtbax', 'txgqxt', 'wxpwwu', 'zbyygc']", "zbyygc"], ["['cwnqbh', 'hzbnas', 'icqsuw', 'ipeust', 'joyuzu', 'otjwzc', 'qtnhee', 'rveysf']", "rveysf"], ["['bimeim', 'brhwym', 'cjksqw', 'kcpqoq', 'nggyio', 'oromaw', 'prlhxo', 'rraemk', 'rrbkhv', 'vwbuhv']", "vwbuhv"], ["['aeecqk', 'bwzfvp', 'gkubwy', 'hawmjo', 'ndxtrw', 'njadnd', 'ofhoef', 'pxbjra', 'qhxaew', 'vqugyy', 'wzetlc', 'znpzwm']", "znpzwm"], ["['abgeoc', 'gtorvw', 'gzbvvs', 'jtdalt', 'mjrzls', 'mlwrbi', 'pdihcj', 'pdsklz', 'pzmrns', 'tpookq', 'udpgyt', 'uebqao', 'ujlrvf', 'zbjybk', 'zvvjin']", "zvvjin"], ["['abizjc', 'bjxyyx', 'cbpooc', 'cmajai', 'cqzmgf', 'ctmazo', 'elcwac', 'fwwoir', 'kmbhkn', 'lbhoag', 'mplkmd', 'ofamoy', 'pduloa', 'qbqpyk', 'qyjues', 'qynusu', 'skvayg', 'slehbm', 'thstct', 'tqndgs']", "tqndgs"], ["['bhfktu', 'bztfjx', 'gdhclk', 'ghwcdv', 'gstcju', 'hlzbrd', 'iwtmgr', 'jdyzvi', 'jjhuak', 'jxtbbn', 'lafqeu', 'nfgaqp', 'oikxqp', 'oozmko', 'otzfzp', 'sgarpi', 'skchab', 'sodomj', 'ubiwun', 'ugrbos', 'vfejay', 'wzfhqb', 'xhyjdw', 'xoppib', 'ynibmi']", "ynibmi"], ["['amxgek', 'aqkwaz', 'bhpiko', 'cebqfp', 'dbvwev', 'dgihww', 'dhmldd', 'doxojk', 'drypib', 'dtmqdj', 'ebrezb', 'erbgex', 'ezhlhh', 'ffikit', 'ibwvvk', 'ipfgbl', 'ixhpzh', 'luvwre', 'mtohkz', 'njodxc', 'nulhxz', 'nxrxrs', 'otofqn', 'qexctx', 'qjvdff', 'qmjbqj', 'qokcwy', 'qwemma', 'rqhpej', 'rubwxd', 'rzkihp', 'sdslva', 'skvnvl', 'slnylb', 'tylbov', 'yabknr', 'yeoloy', 'ykgnca', 'yvppoh', 'zadznz']", "zadznz"], ["['anvpha', 'aqetlu', 'bpbbpc', 'bqcnmc', 'daihwy', 'eewuoy', 'ejxdow', 'enmugu', 'ewfmky', 'fapcxq', 'fjtpcb', 'gikqom', 'glqchq', 'gnazfo', 'gnojil', 'gscvpf', 'hgicbg', 'ikgvee', 'ikicer', 'jgbmtn', 'jrlpzj', 'kduuza', 'kzvxsi', 'liemra', 'lkkbor', 'mkvnbv', 'nedyze', 'njkyoe', 'ojjign', 'onzjgg', 'orrbro', 'pbghta', 'pfqyyz', 'pgwutq', 'pvjbwk', 'qvjabd', 'qxdsko', 'rxidqq', 'saimmz', 'schhuv', 'ttmhyh', 'vnaupr', 'vwifra', 'wbkmry', 'xqecyw', 'xwcayh', 'yrkwkz', 'zdtceo', 'zrharl', 'zwsbrv']", "zwsbrv"], ["['acrbty', 'bhzgiu', 'caqqrx', 'chvjsj', 'ckxxrv', 'cpkngy', 'ctqrsu', 'dbmtqd', 'dqafvy', 'dwyauw', 'ebqmat', 'egjgri', 'ehsrhc', 'eobupu', 'eoyrcz', 'evrxrz', 'fzxagn', 'gdxquq', 'giipga', 'gjeubz', 'gnnkqq', 'gnxfah', 'gtivix', 'hqygke', 'httsrf', 'hwwqwn', 'hxvoia', 'jimtrg', 'joqujo', 'jvirtq', 'jxweeq', 'ksjrvu', 'kucvpp', 'kzghbd', 'liswem', 'lzvmcc', 'mblfct', 'muwceq', 'mvtdfq', 'mzzktr', 'nnfenx', 'omyerm', 'owspln', 'oxnlde', 'peahqz', 'pmvvxf', 'polbjx', 'pthwss', 'ptyxlq', 'qicphv', 'ryhujy', 'ssbjgh', 'suovdz', 'tojgvy', 'upszet', 'vmtwpc', 'vridkb', 'vthrcn', 'xxppak', 'yawoha']", "yawoha"], ["['acdgrq', 'acfich', 'aeacci', 'ahzfnd', 'aivkjo', 'apfrav', 'apxmbo', 'baowfs', 'bdpjxp', 'bdslyh', 'bfflee', 'bfwbce', 'biochg', 'biydpd', 'cmtaxw', 'cryhny', 'czfwkj', 'diohip', 'dmccko', 'dqnxbw', 'dqyvpn', 'eiyhlm', 'elebgi', 'engijf', 'eupans', 'euumjy', 'faiprc', 'fdlvqk', 'fnhcls', 'fqvywq', 'fyhyxc', 'gcnslp', 'hggmen', 'hgltyg', 'hlowsh', 'htnwsn', 'idgzwv', 'ifdovj', 'ifnghb', 'ihhjyk', 'iqrfwx', 'ixvdew', 'izuhze', 'jhuwps', 'jkddtr', 'koaypd', 'kxkoue', 'lianfv', 'lmnfle', 'mjrdin', 'mssqkb', 'mwgogu', 'myikad', 'ncnbib', 'ncpqhh', 'ngxagk', 'oduvhr', 'omzvoq', 'oqfyop', 'osdmah', 'osrczy', 'otzpeg', 'oxjoke', 'pzimrd', 'qisgix', 'qknzdw', 'qlettk', 'qrzghf', 'qssrnk', 'qvggdp', 'qvxwqa', 'rnwxcn', 'sckgxa', 'sfwijx', 'teigxb', 'uszkij', 'utmaxv', 'uwsldb', 'uyyyko', 'vdyvkw', 'vhykuh', 'vytxqe', 'wcyxuc', 'wegfkg', 'winvoy', 'wipsck', 'xaoqjd', 'xccmys', 'xkwtmy', 'xkzmys', 'ycaktr', 'yemyjp', 'yepwxc', 'yjfefp', 'ynblrr', 'zfbevk', 'zpirjz', 'zuqrpd', 'zwcooj', 'zxmtdl']", "zxmtdl"]], "expected": null, "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "374", "slug": "h-index-ii", "id": 374, "title": "H-Index II", "difficulty": "Medium", "category": "binary-search", "link": "https://leetcode.com/problems/h-index-ii/", "examples": [{"input": "citations = [0,1,3,5,6]", "output": "3", "explanation": "Three papers have at least 3 citations (3, 5, 6)."}, {"input": "citations = [1,2,100]", "output": "2", "explanation": "Two papers have at least 2 citations (2, 100)."}, {"input": "citations = [0]", "output": "0", "explanation": "No citation reaches 1."}], "hints": ["Input is already ascending, so binary-search the first index i with citations[i] >= n - i.", "The answer is n - i for that first feasible i, or 0 when none qualifies.", "Expected time is O(log n)."], "statement": "Given citation counts already sorted in non-decreasing order, compute the h-index in logarithmic time.\n\nThe h-index is the largest `h` with at least `h` papers cited at least `h`\ntimes. Implement `hIndex(citations)` where `citations` is ascending, using a\nbinary search rather than a linear scan.\n\n**Constraints:**\n- `1 <= citations.length <= 10^5`\n- `0 <= citations[i] <= 1000`\n- `citations` is sorted ascending.\n", "solution": "## Approach\n\nBecause the array is sorted, the predicate citations[i] >= n - i becomes true once and stays true. Binary-search the leftmost true index i and return n - i, or 0 when no index qualifies.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log n)\n- **Space Complexity:** O(1)\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def hIndex(self, citations: List[int]) -> int:\n n = len(citations)\n lo, hi = 0, n\n while lo < hi:\n mid = (lo + hi) // 2\n if citations[mid] >= n - mid:\n hi = mid\n else:\n lo = mid + 1\n h = n - lo\n if lo < n and citations[lo] >= h:\n return h\n return 0\n```\n", "starter": {"go": "package main\n\nfunc HIndex(citations []int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def hIndex(self, citations: List[int]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int hIndex(vector<int>& citations) {\n return 0;\n }\n};"}, "fn": "hIndex", "params": [{"name": "citations", "type": "int_array"}], "outputType": "int", "tests": [["[0,1,3,5,6]"], ["[1,2,100]"], ["[0]"], ["[1]"], ["[0,0,0]"], ["[1,1,1]"], ["[0,1,2]"], ["[1,2,3,4,5]"], ["[0,0,1,2]"], ["[2,2,2]"], ["[0,1,7,8,9]"], ["[100]"], ["[0,1]"], ["[1,10,20,30]"], ["[0,0,0,1]"], ["[5,5,5,5,5]"], ["[1,2,3]"], ["[0,2,5,5,6]"], ["[3,4,5]"], ["[10,20,30]"], ["[0,0,0,0]"], ["[0,1,2,3]"], ["[4,4,4,5,5]"], ["[0,0,5,5,5]"], ["[2,3,4,5,6]"], ["[0,0,0,0,1]"], ["[6,6,6,6]"], ["[1,1,2,2,3,3]"]], "expected": [3, 2, 0, 1, 0, 1, 1, 3, 1, 2, 3, 1, 1, 3, 1, 5, 2, 3, 3, 3, 0, 2, 4, 3, 3, 1, 4, 2], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "373", "slug": "h-index", "id": 373, "title": "H-Index", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/h-index/", "examples": [{"input": "citations = [3,0,6,1,5]", "output": "3", "explanation": "Three papers have at least 3 citations each (3, 6, 5)."}, {"input": "citations = [1,3,1]", "output": "1", "explanation": "Only h = 1 is feasible."}, {"input": "citations = [0]", "output": "0", "explanation": "No paper has a citation, so h is 0."}], "hints": ["Sort the counts, then the best h is the largest h with at least h values >= h.", "After sorting ascending, citations[n-h] >= h is the check for each candidate h.", "A counting bucket also works since values are bounded."], "statement": "Given citation counts for each paper, compute the researcher's h-index.\n\nThe h-index is the largest `h` such that at least `h` papers have `h` or\nmore citations each. Implement `hIndex(citations)` returning that maximum.\n\n**Constraints:**\n- `1 <= citations.length <= 5000`\n- `0 <= citations[i] <= 1000`\n", "solution": "## Approach\n\nSort the citation counts ascending. Then try h from n down to 1 and return the first h where the element at position n - h reaches h, which means h papers have at least h citations.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n log n) for sorting.\n- **Space Complexity:** O(1) extra.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def hIndex(self, citations: List[int]) -> int:\n citations = sorted(citations)\n n = len(citations)\n for h in range(n, 0, -1):\n if citations[n - h] >= h:\n return h\n return 0\n```\n", "starter": {"go": "package main\n\nfunc HIndex(citations []int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def hIndex(self, citations: List[int]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int hIndex(vector<int>& citations) {\n return 0;\n }\n};"}, "fn": "hIndex", "params": [{"name": "citations", "type": "int_array"}], "outputType": "int", "tests": [["[3,0,6,1,5]"], ["[1,3,1]"], ["[0]"], ["[1]"], ["[100]"], ["[0,0,0]"], ["[1,1,1]"], ["[4,4,4,4]"], ["[6,5,4,3,2,1]"], ["[0,1,2,3,4]"], ["[10,8,5,4,3]"], ["[1,2,3,4,5]"], ["[5,5,5,5,5]"], ["[0,1]"], ["[2,2,2]"], ["[1000,1000,1000]"], ["[0,0,1]"], ["[3,3,3]"], ["[11,15]"], ["[0,1,1]"], ["[7,7,7,7,7,7,7]"], ["[1,2,100]"], ["[2,3,4,5,6]"], ["[0,0,0,0]"], ["[5,6,7,8,9,10]"], ["[0,0,2]"], ["[4,4,4,5,5]"], ["[1000]"]], "expected": [3, 1, 0, 1, 1, 0, 1, 4, 3, 2, 4, 3, 5, 1, 2, 3, 1, 3, 2, 1, 7, 2, 3, 0, 5, 1, 4, 1], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "527", "slug": "hamming-distance", "id": 527, "title": "Hamming Distance", "difficulty": "Easy", "category": "bit-manipulation", "link": "https://leetcode.com/problems/hamming-distance/", "examples": [{"input": "x = 1, y = 4", "output": "2", "explanation": "1 is 0001 and 4 is 0100 in binary, which differ in the lowest and third bits."}, {"input": "x = 3, y = 1", "output": "1", "explanation": "3 is 0011 and 1 is 0001, differing only in the second bit."}], "hints": ["XOR the two numbers: the result has a 1 exactly where the inputs differ.", "Count the set bits of `x ^ y`."], "statement": "The Hamming distance between two integers is the number of bit positions at which their binary representations differ.\n\nYou are given two non-negative integers `x` and `y`. Return their Hamming distance.\n\n**Constraints:**\n- `0 <= x, y <= 2^31 - 1`\n", "solution": "## Approach\n\nXOR-ing the two numbers produces a value whose binary 1-bits sit exactly at the positions where the inputs disagree. Counting those set bits therefore yields the Hamming distance directly.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(1), a single XOR plus a population count over a fixed-width integer.\n- **Space Complexity:** O(1).\n\n## Implementation\n\n```python\nclass Solution:\n def hammingDistance(self, x: int, y: int) -> int:\n return bin(x ^ y).count(\"1\")\n```\n", "starter": {"go": "package main\n\nfunc HammingDistance(x int, y int) int {\n \n}", "python": "class Solution:\n def hammingDistance(self, x: int, y: int) -> int:\n pass", "cpp": "class Solution {\npublic:\n int hammingDistance(int x, int y) {\n return 0;\n }\n};"}, "fn": "hammingDistance", "params": [{"name": "x", "type": "int"}, {"name": "y", "type": "int"}], "outputType": "int", "tests": [["1", "4"], ["3", "1"], ["0", "0"], ["0", "1"], ["4", "4"], ["2147483647", "0"], ["10", "7"], ["255", "0"], ["1000000", "999999"], ["93", "73"], ["127", "128"], ["123456789", "987654321"], ["0", "2147483647"], ["1", "0"], ["7", "0"], ["15", "8"], ["1024", "1023"], ["65535", "0"], ["12345", "67890"], ["100", "100"], ["999999999", "0"], ["2147483647", "2147483647"], ["5", "3"], ["16", "15"], ["256", "255"], ["1000000000", "1000000000"], ["42", "21"], ["1000", "2000"], ["17", "19"], ["8", "8"]], "expected": [2, 1, 0, 1, 0, 31, 3, 8, 7, 2, 8, 15, 31, 1, 3, 3, 11, 16, 8, 0, 21, 0, 2, 5, 9, 0, 6, 4, 1, 0], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "141", "slug": "hand-of-straights", "id": 141, "title": "Hand of Straights", "difficulty": "Medium", "category": "greedy", "link": "https://leetcode.com/problems/hand-of-straights/", "examples": [{"input": "hand = [1,2,3,6,2,3,4,7,8], groupSize = 3", "output": "true", "explanation": "The groups can be [1,2,3], [2,3,4], and [6,7,8]."}, {"input": "hand = [1,2,3,4,5], groupSize = 4", "output": "false", "explanation": "The cards cannot be divided into groups of 4 consecutive cards."}, {"input": "hand = [1,2,3,4,5], groupSize = 1", "output": "true", "explanation": "The cards can be grouped into consecutive sequences of 1."}], "hints": ["The number of cards must be divisible by groupSize.", "Count each rank in sorted order. The smallest remaining rank must begin a group because nothing smaller can precede it.", "Use a sorted map to consume the required counts for each consecutive rank and detect a missing card immediately."], "statement": "You are given an array `hand` whose values are card ranks and a positive integer `groupSize`. Determine whether every card can be rearranged into groups of exactly `groupSize` consecutive ranks.\n\nEach card must be used exactly once.\n\n**Constraints:**\n\n- `1 <= hand.length <= 10000`\n- `0 <= hand[i] <= 1000000000`\n- `1 <= groupSize <= hand.length`\n", "solution": "## Approach\n\nCount every rank and visit distinct ranks in sorted order. If the smallest rank with remaining copies occurs `k` times, all `k` copies must begin groups because no smaller card remains to precede them. Consume `k` copies from that rank and each of the next `groupSize - 1` ranks; a missing count proves that no valid grouping exists.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n + u log u), where `u` is the number of distinct ranks.\n- **Space Complexity:** O(u) for the rank counts and sorted distinct ranks.\n\n## Implementation\n\n```python\nfrom collections import Counter\nfrom typing import List\n\n\nclass Solution:\n def isNStraightHand(self, hand: List[int], groupSize: int) -> bool:\n if len(hand) % groupSize != 0:\n return False\n\n counts = Counter(hand)\n for first in sorted(counts):\n copies = counts[first]\n if copies == 0:\n continue\n for card in range(first, first + groupSize):\n if counts[card] < copies:\n return False\n counts[card] -= copies\n return True\n```\n", "starter": {"go": "package main\n\nfunc IsNStraightHand(hand []int, groupSize int) bool {\n \n}", "python": "from typing import List\nclass Solution:\n def isNStraightHand(self, hand: List[int], groupSize: int) -> bool:\n pass\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n bool isNStraightHand(vector<int>& hand, int groupSize) {\n return false;\n }\n};"}, "fn": "isNStraightHand", "params": [{"name": "hand", "type": "int_array"}, {"name": "groupSize", "type": "int"}], "outputType": "boolean", "tests": [["[1,2,3,6,2,3,4,7,8]", "3"], ["[1,2,3,4,5]", "4"], ["[1]", "1"], ["[0,2]", "2"], ["[1,2]", "2"], ["[1,3]", "2"], ["[1,2,3,4]", "2"], ["[1,2,3,4]", "4"], ["[1,2,3,4]", "3"], ["[1,1,2,2,3,3]", "3"], ["[1,1,2,2,3,4]", "3"], ["[8,10,12]", "1"], ["[1,2,3,4,5,6]", "3"], ["[1,2,3,4,5,6]", "2"], ["[1,2,3,4,5,6]", "6"], ["[2,3,4,2,3,4]", "3"], ["[2,3,4,3,4,5]", "3"], ["[1,2,4,5]", "2"], ["[1,2,4,6]", "2"], ["[10,11,12,13,14,15]", "3"], ["[3,1,2,6,5,4]", "3"], ["[1,2,2,3,3,4]", "3"], ["[1,1,2,2,3,3,4,4]", "4"], ["[1,1,2,2,3,3,4]", "7"], ["[5,5,6,6,7,7]", "3"], ["[5,6,7,8,9,10]", "2"], ["[5,6,7,8,9,10]", "4"], ["[100,101,102]", "3"], ["[100,102,101,103]", "4"], ["[100,101,103,104]", "2"], ["[1,2,3,10,11,12,20,21,22]", "3"], ["[1,2,3,10,11,13]", "3"], ["[7,8,9,9,10,11]", "3"], ["[7,8,8,9,9,10]", "3"], ["[7,7,8,8,9,10]", "3"], ["[1,2,3,4,5,6,7,8]", "4"], ["[1,2,3,4,5,6,7,8]", "5"], ["[2,3,4,5,6,7,8,9]", "4"], ["[1,2,2,3]", "2"], ["[1,1,2,3]", "2"], ["[4,3,2,1,8,7,6,5]", "8"], ["[1,2,3,4,8,9,10,11]", "4"], ["[1,2,3,4,8,9,10,12]", "4"], ["[2,2,3,3,4,4,5,5]", "4"], ["[2,2,3,3,4,5,5,6]", "4"], ["[1,2,3,3,4,4,5,6,7]", "3"], ["[1,2,3,3,4,5,4,5,6]", "3"], ["[9,10,11,12]", "1"], ["[9,10,11,12]", "3"], ["[1,2,3,4,5,6,7,8,9,10]", "10"], ["[1,2,3,5,6,7,9,10,11]", "3"], ["[1,2,4,5,7,8]", "2"], ["[1,3,4,5,6,8]", "2"], ["[20,21,22,23,20,21,22,23]", "4"], ["[3,4,5,6,7,8,9,10,11]", "3"], ["[1000000000]", "1"], ["[999999999,1000000000]", "2"], ["@javascript:Array.from({length:10000},(_,i)=>999990001+i)", "10000"]], "expected": [true, false, true, false, true, false, true, true, false, true, false, true, true, true, true, true, true, true, false, true, true, true, true, false, true, true, false, true, true, true, true, false, true, true, false, true, false, true, true, false, true, true, false, true, false, false, true, true, false, true, true, true, false, true, true, true, true, true], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "145", "slug": "happy-number", "id": 145, "title": "Happy Number", "difficulty": "Easy", "category": "math", "link": "https://leetcode.com/problems/happy-number/", "examples": [{"input": "n = 19", "output": "true", "explanation": "The digit-square sequence reaches 1."}, {"input": "n = 2", "output": "false", "explanation": "The sequence enters a cycle that does not contain 1."}, {"input": "n = 1", "output": "true", "explanation": "1 is already 1, so its digit-square sequence stays at 1."}], "hints": ["Write a helper that computes the sum of the squares of an integer's digits.", "A non-happy sequence must eventually repeat because digit-square sums are bounded.", "Use a set to detect repetition, or use Floyd's slow-and-fast pointer cycle detection for constant extra space."], "statement": "Write a function that determines whether a positive integer is a **happy number**.\n\nStarting with the integer, repeatedly replace it with the sum of the squares of its decimal digits. A number is happy if this process eventually reaches `1`. If the process enters a cycle that does not contain `1`, the number is not happy.\n\n**Constraints:**\n- `1 <= n <= 2^31 - 1`\n", "solution": "## Approach\n\nUse Floyd's cycle detection on the sequence produced by repeatedly summing the squares of the current number's digits. A slow pointer advances by one transformation and a fast pointer advances by two. The number is happy if the fast pointer reaches `1`; otherwise, equal pointers identify a cycle that does not contain `1`.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(log n). The first digit-square transformation examines every digit, and subsequent values are bounded by a constant for 32-bit inputs.\n- **Space Complexity:** O(1). The algorithm keeps only two sequence values.\n\n## Implementation\n\n```python\nclass Solution:\n def isHappy(self, n: int) -> bool:\n slow = n\n fast = self._next(n)\n while fast != 1 and slow != fast:\n slow = self._next(slow)\n fast = self._next(self._next(fast))\n return fast == 1\n\n def _next(self, n: int) -> int:\n total = 0\n while n > 0:\n digit = n % 10\n total += digit * digit\n n //= 10\n return total\n```\n", "starter": {"go": "package main\n\nfunc IsHappy(n int) bool {\n return false\n}", "python": "class Solution:\n def isHappy(self, n: int) -> bool:\n return False\n", "cpp": "class Solution {\npublic:\n bool isHappy(int n) {\n return false;\n }\n};"}, "fn": "isHappy", "params": [{"name": "n", "type": "int"}], "outputType": "boolean", "tests": [["1"], ["2"], ["3"], ["4"], ["5"], ["6"], ["7"], ["8"], ["9"], ["10"], ["11"], ["12"], ["13"], ["14"], ["15"], ["16"], ["17"], ["18"], ["19"], ["20"], ["21"], ["22"], ["23"], ["24"], ["25"], ["26"], ["27"], ["28"], ["29"], ["30"], ["31"], ["32"], ["33"], ["34"], ["35"], ["36"], ["37"], ["38"], ["39"], ["40"], ["41"], ["42"], ["43"], ["44"], ["45"], ["46"], ["47"], ["48"], ["49"], ["50"], ["68"], ["70"], ["79"], ["82"], ["85"], ["86"], ["91"], ["94"], ["97"], ["100"], ["111"], ["116"], ["130"], ["139"], ["190"], ["192"], ["203"], ["1000"], ["999999999"], ["2147483646"], ["2147483647"]], "expected": [true, false, false, false, false, false, true, false, false, true, false, false, true, false, false, false, false, false, true, false, false, false, true, false, false, false, false, true, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, true, false, true, true, true, true, false, true, true, true, true, true, false, false, true, true, true, true, true, true, false, false, false], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "539", "slug": "heaters", "id": 539, "title": "Heaters", "difficulty": "Medium", "category": "array", "link": "https://leetcode.com/problems/heaters/", "examples": [{"input": "houses = [1,2,3], heaters = [2]", "output": "1", "explanation": "Radius 1 from heater 2 reaches every house."}, {"input": "houses = [1,2,3,4], heaters = [1,4]", "output": "1", "explanation": "Each heater covers its two nearest houses."}, {"input": "houses = [1,5], heaters = [2]", "output": "3", "explanation": "House 5 is distance 3 from the heater."}], "hints": ["Sort both arrays first.", "For each house, binary-search the nearest heater and record the distance.", "The answer is the largest of those nearest distances."], "statement": "Houses and heaters sit at integer spots on a single line. Every heater warms the interval centered on it with some shared radius `r`: a house at `h` is warm when some heater at `t` satisfies `|h - t| <= r`. All heaters must use the same radius.\n\nFind the smallest radius that leaves every house warm.\n\n**Constraints:**\n\n- `1 <= houses.length, heaters.length <= 3 * 10^4`\n- `1 <= houses[i], heaters[i] <= 10^9`\n", "solution": "## Approach\n\nSort the houses and the heaters. For every house, locate where it would slot into the sorted heater list with binary search: only the immediate predecessor and successor can be closest, so compute both distances and keep the smaller one. The required shared radius is the maximum over houses of those nearest distances, because the farthest house dictates the radius.\n\n## Complexity Analysis\n\n- **Time Complexity:** O((H + T) log T) for sorting plus one binary search per house, where H is the house count and T the heater count.\n- **Space Complexity:** O(1) extra besides sorting.\n\n## Implementation\n\n```python\nimport bisect\nfrom typing import List\n\nclass Solution:\n def findRadius(self, houses: List[int], heaters: List[int]) -> int:\n houses = sorted(houses)\n heaters = sorted(heaters)\n ans = 0\n for h in houses:\n i = bisect.bisect_left(heaters, h)\n best = float(\"inf\")\n if i < len(heaters):\n best = min(best, heaters[i] - h)\n if i > 0:\n best = min(best, h - heaters[i - 1])\n ans = max(ans, best)\n return ans\n```\n", "starter": {"go": "package main\n\nfunc FindRadius(houses []int, heaters []int) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def findRadius(self, houses: List[int], heaters: List[int]) -> int:\n return 0\n", "cpp": "#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n int findRadius(vector<int>& houses, vector<int>& heaters) {\n return 0;\n }\n};"}, "fn": "findRadius", "params": [{"name": "houses", "type": "int_array"}, {"name": "heaters", "type": "int_array"}], "outputType": "int", "tests": [["[1,2,3]", "[2]"], ["[1,2,3,4]", "[1,4]"], ["[1,5]", "[2]"], ["[1]", "[1]"], ["[1,2,3,4,5]", "[3]"], ["[5,10,15]", "[5,15]"], ["[1,100]", "[50]"], ["[1,2,3]", "[1,2,3]"], ["[10,20,30]", "[25]"], ["[1,5,10]", "[2,8]"], ["[1000000000]", "[1]"], ["[1,1000000000]", "[500000000]"], ["[4,4,4,4]", "[4]"], ["[1,3,5,7,9]", "[2,6,10]"], ["[2,4,6,8]", "[1,9]"], ["[7]", "[3,9]"], ["[1,2,3,4,5,6,7]", "[4]"], ["[12,15,18]", "[13,17]"], ["[1,10,20,30]", "[5,25]"], ["[3,6,9]", "[3,6,9]"], ["[1,2,3,5]", "[2,5]"], ["[10]", "[10]"], ["[1,3,5]", "[3]"], ["[100,200,300]", "[150]"], ["[1,1000,2000]", "[500,1500]"], ["[5,5,5]", "[5]"], ["[1,2,1000000000]", "[1000000000]"], ["[8,12,16,20]", "[10,18]"], ["[2,3,4,9,10]", "[5]"], ["[50,60,70]", "[55,65]"]], "expected": [1, 1, 3, 0, 2, 5, 50, 0, 15, 3, 999999999, 500000000, 0, 1, 3, 2, 3, 2, 5, 0, 1, 0, 2, 150, 500, 0, 999999999, 2, 5, 5], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "23", "slug": "house-robber-ii", "id": 23, "title": "House Robber II", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/house-robber-ii/", "examples": [{"input": "nums=[2,3,2]", "output": "3", "explanation": "The houses form a circle, so house 0 (2) and house 2 (2) are adjacent. Robbing only house 1 (value 3) yields the maximum."}, {"input": "nums=[1,2,3,1]", "output": "4", "explanation": "The houses form a circle. Robbing houses 0 (1) and 2 (3) for a total of 4 is the maximum."}], "hints": ["Split into two cases: rob from [0..n-2] or [1..n-1], and take the max."], "statement": "Houses are arranged in a circle. Find the maximum amount of money you can rob without robbing adjacent houses.\n\n**Constraints:**\n\n- 1 \u2264 nums.length \u2264 100\n- 0 \u2264 nums[i] \u2264 1000\n", "solution": "## Approach\n\nSince houses are arranged in a circle (first and last are adjacent), split into two linear cases: rob houses 0 to n-2 or rob houses 1 to n-1. Use the standard House Robber I DP on each case and take the maximum.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the number of houses.\n- **Space Complexity:** O(1), using only constant extra space.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def rob(self, nums: List[int]) -> int:\n if len(nums) == 1:\n return nums[0]\n def helper(arr):\n a, b = 0, 0\n for x in arr:\n a, b = b, max(b, a + x)\n return b\n return max(helper(nums[:-1]), helper(nums[1:]))\n```\n", "starter": {"go": "package main\n\nfunc Rob(nums []int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def rob(self, nums: List[int]) -> int:\n pass\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int rob(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "rob", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[2,3,2]"], ["[1,2,3,1]"], ["[1,2,3]"], ["@javascript: JSON.stringify(Array.from({length: 100}, (_,i)=> (i%3===0? 100: 1)))"], ["[1]"], ["[0]"], ["[1000]"], ["[2,3]"], ["[1,2]"], ["[5,5]"], ["[1,2,3,4]"], ["[4,3,2,1]"], ["[5,1,1,5]"], ["[0,0,0]"], ["[10,1,10,1,10]"], ["[1,100,1,100,1]"], ["[200,1,200,1,200]"], ["[1000,0,1000,0,1000]"], ["[0,1000,0,1000,0]"], ["[3,3,3,3]"], ["[1,1,1,1,1,1]"], ["[10,20,30]"], ["[30,20,10]"], ["[5,10,5,10,5,10]"], ["[100,50,100,50,100]"], ["[0,5,0,5,0,5]"], ["[7,7,7,7,7]"], ["[1,0,1,0,1,0,1]"], ["[500,500,500]"], ["[10,1,1,10,1,1,10]"], ["[2,1,1,2,1,1,2]"], ["[1000,1000,1000,1000]"]], "expected": [3, 4, 3, 3301, 1, 0, 1000, 3, 2, 5, 6, 6, 6, 0, 20, 200, 400, 2000, 2000, 6, 3, 30, 30, 30, 200, 15, 14, 3, 500, 21, 5, 2000], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "200", "slug": "house-robber-iii", "id": 200, "title": "House Robber III", "difficulty": "Medium", "category": "tree", "link": "https://leetcode.com/problems/house-robber-iii/", "examples": [{"input": "root = [3,2,3,null,3,null,1]", "output": "7", "explanation": "Rob 3 (root) + 3 + 1 = 7."}, {"input": "root = [3,4,5,1,3,null,1]", "output": "9", "explanation": "Rob 4 + 5 = 9."}], "hints": ["For each node return [rob_this, skip_this]. rob_this = val + skip_left + skip_right."], "statement": "A burglar has discovered a district whose only access point is the house labeled `root`.\n\nEvery other house in the district reports to exactly one parent house, so a survey of the area shows the houses are arranged as a binary tree. If two houses sharing a direct connection are both entered during one night, an alarm summons the police.\n\nGiven the `root` of that binary tree, compute the largest sum of money collectible in one night while never entering two houses joined by an edge.\n\n**Constraints:**\n- The number of nodes in the tree is in the range `[1, 10^4]`\n- `0 <= Node.val <= 10^4`\n", "solution": "## Approach\n\nTree DP: for each node return `(rob, skip)`. Robbing the node means adding its value to the skip results of children. Skipping means taking the max of each child's rob/skip.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n)\n- **Space Complexity:** O(h)\n\n## Implementation\n\n```python\nclass Solution:\n def rob(self, root) -> int:\n def dfs(n):\n if not n:\n return (0, 0)\n lr, ls = dfs(n.left)\n rr, rs = dfs(n.right)\n rob = n.val + ls + rs\n skip = max(lr, ls) + max(rr, rs)\n return (rob, skip)\n return max(dfs(root))\n```\n", "starter": {"go": "package main\n\nfunc Rob(root *TreeNode) int {\n return 0\n}", "python": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, val=0, left=None, right=None):\n# self.val = val\n# self.left = left\n# self.right = right\nclass Solution:\n def rob(self, root) -> int:\n pass\n", "cpp": "/*\nDefinition for a binary tree node.\nstruct TreeNode {\n int val;\n TreeNode *left;\n TreeNode *right;\n TreeNode(): val(0), left(nullptr), right(nullptr) {}\n TreeNode(int x): val(x), left(nullptr), right(nullptr) {}\n TreeNode(int x, TreeNode* left, TreeNode* right): val(x), left(left), right(right) {}\n};\n*/\nclass Solution {\npublic:\n int rob(TreeNode* root) {\n return 0;\n }\n};"}, "fn": "rob", "params": [{"name": "root", "type": "tree_node", "visualizeType": "tree_node"}], "outputType": "int", "tests": [["[3,2,3,null,3,null,1]"], ["[3,4,5,1,3,null,1]"], ["[1]"], ["[2,1,3]"], ["[4,1,null,2,null,3]"], ["[2,1,3,null,4]"], ["[1,2,3,4,5,6,7]"], ["[10,5,15,3,7,null,18]"], ["[100]"], ["[1,null,2,null,3,null,4]"], ["[0]"], ["[5,3,8]"], ["[1,2,null,3]"], ["[1,null,2,null,3]"], ["[5,4,1,null,null,3,6]"], ["[0,0,0]"], ["[10,1,2]"], ["[2,null,3,null,4,null,5]"], ["[3,1,null,null,2]"], ["[7,4,9,1,6,8,10]"], ["[1,2,3,4,null,null,5]"], ["[10000]"], ["[0,1,2,3,4,5]"], ["[5,5,5,5,5]"], ["[4,2,6,1,3,5,7]"], ["[1,null,2,3]"], ["[2,3,null,1]"], ["[6,2,7,1,4,null,null,null,5]"], ["[9,8,7,6,5]"], ["[3,null,2,null,1]"], ["[1,2,3,null,4,null,5]"], ["[50,25,75,10,30,60,90]"]], "expected": [7, 9, 1, 4, 7, 7, 23, 38, 100, 6, 0, 11, 4, 4, 14, 0, 10, 8, 5, 32, 10, 10000, 12, 15, 20, 4, 3, 16, 20, 4, 10, 240], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "22", "slug": "house-robber", "id": 22, "title": "House Robber", "difficulty": "Medium", "category": "dp", "link": "https://leetcode.com/problems/house-robber/", "examples": [{"input": "nums=[1,2,3,1]", "output": "4", "explanation": "Robbing houses 0 (1) and 2 (3) without triggering adjacent alarms yields 4."}, {"input": "nums=[2,7,9,3,1]", "output": "12", "explanation": "Robbing houses 0 (2), 2 (9), and 4 (1) without triggering adjacent alarms yields 12."}], "hints": ["DP with two states per step: rob or skip current house."], "statement": "A row of houses lines a street, and `nums[i]` records how much cash sits inside the `i`-th house. Choose which houses to enter during one night so the total haul is as large as possible, under the rule that entering two neighboring houses triggers the alarm. Report the greatest total obtainable while never entering an adjacent pair.\n\n**Constraints:**\n\n- `1 \u2264 nums.length \u2264 100`\n- `0 \u2264 nums[i] \u2264 400`\n", "solution": "## Approach\n\nDynamic programming with two states: the maximum loot up to the previous house and the maximum loot up to the current house. At each step, either skip the current house or rob it (adding its value to the max from two houses ago).\n\n## Complexity Analysis\n\n- **Time Complexity:** O(n), where n is the number of houses.\n- **Space Complexity:** O(1), using only constant extra space.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def rob(self, nums: List[int]) -> int:\n a, b = 0, 0\n for x in nums:\n a, b = b, max(b, a + x)\n return b\n```\n", "starter": {"go": "package main\n\nfunc Rob(nums []int) int {\n \n}", "python": "from typing import List\nclass Solution:\n def rob(self, nums: List[int]) -> int:\n pass\n", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int rob(vector<int>& nums) {\n return 0;\n }\n};"}, "fn": "rob", "params": [{"name": "nums", "type": "int_array"}], "outputType": "int", "tests": [["[1,2,3,1]"], ["[2,7,9,3,1]"], ["[2,1,1,2]"], ["@javascript: JSON.stringify(Array.from({length: 100}, (_,i)=> (i%2===0? 1: 100)))"], ["[0]"], ["[5]"], ["[400]"], ["[0,0,0,0]"], ["[1,2]"], ["[2,1]"], ["[5,5,5,5]"], ["[0,5,0,5,0]"], ["[10,1,1,10]"], ["[3,1,3,1,3]"], ["[100,1,1,100,1,1,100]"], ["[1,3,1,3,100]"], ["[400,0,400,0,400]"], ["[0,400,0,400,0]"], ["[1,100,1,100,1]"], ["[5,1,2,6,20,2]"], ["[10,20,30,40,50]"], ["[50,40,30,20,10]"], ["[1,1,1,1,1,1]"], ["[0,1,0,1,0,1,0]"], ["[200,200,200]"], ["[1,2,3,4,5,6,7,8]"], ["[8,7,6,5,4,3,2,1]"], ["[400,400,400,400]"], ["[0,0,400,0,0]"], ["[1,0,0,0,1]"], ["[10,10,10,10,10,10]"], ["[3,10,3,1,2]"]], "expected": [4, 12, 4, 5000, 0, 5, 400, 0, 2, 2, 10, 10, 20, 9, 300, 103, 1200, 800, 200, 27, 90, 90, 3, 3, 400, 20, 20, 800, 400, 2, 30, 12], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "833", "slug": "image-overlap", "id": 833, "title": "Image Overlap", "difficulty": "Medium", "category": "matrix", "link": "https://leetcode.com/problems/image-overlap/", "examples": [{"input": "img1 = [[1,1,0],[0,1,0],[0,1,0]], img2 = [[0,0,0],[0,1,1],[0,0,1]]", "output": "3", "explanation": "The best shift aligns three ones."}, {"input": "img1 = [[1]], img2 = [[1]]", "output": "1"}, {"input": "img1 = [[0]], img2 = [[0]]", "output": "0"}], "hints": ["Only the positions of ones matter, so collect their coordinates from both matrices first.", "Each pair of ones (one from each matrix) votes for the shift vector that would align them; the most popular vector wins.", "An empty set of ones on either side means the answer is immediately zero."], "statement": "You are given two square binary matrices `img1` and `img2` of the same size. You may slide `img1` any number of cells up, down, left, or right (cells that move outside are discarded, and empty spots count as zero). After each shift, count the positions where both matrices show a `1`. Return the largest such overlap count over all possible shifts, including no shift.\n\n**Constraints:**\n- `n == img1.length == img2.length`\n- `n == img1[i].length == img2[i].length`\n- `1 <= n <= 30`\n- Entries are `0` or `1`\n", "solution": "## Approach\n\nGather the coordinates of ones in both matrices, since zeros never contribute. Every pair of ones (one from each image) determines the shift that would place them on top of each other, so count how many pairs agree on each shift vector. The highest count is the best achievable overlap, and an empty one-list on either side yields zero immediately.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(a * b) where a and b are the numbers of ones in the two images (at most n^4 for n by n inputs, fine for n <= 30).\n- **Space Complexity:** O(a * b) in the worst case for the shift histogram.\n\n## Implementation\n\n```python\nfrom typing import List\nfrom collections import Counter\n\nclass Solution:\n def largestOverlap(self, img1: List[List[int]], img2: List[List[int]]) -> int:\n a = [(i, j) for i, row in enumerate(img1) for j, v in enumerate(row) if v == 1]\n b = [(i, j) for i, row in enumerate(img2) for j, v in enumerate(row) if v == 1]\n if not a or not b:\n return 0\n votes = Counter((q0 - p0, q1 - p1) for p0, p1 in a for q0, q1 in b)\n return max(votes.values())\n```\n", "starter": {"go": "package main\n\nfunc LargestOverlap(img1 [][]int, img2 [][]int) int {\n return 0\n}", "python": "from typing import List\nclass Solution:\n def largestOverlap(self, img1: List[List[int]], img2: List[List[int]]) -> int:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n int largestOverlap(vector<vector<int>>& img1, vector<vector<int>>& img2) {\n return 0;\n }\n};"}, "fn": "largestOverlap", "params": [{"name": "img1", "type": "int_array_2d"}, {"name": "img2", "type": "int_array_2d"}], "outputType": "int", "tests": [["[[1, 1, 0], [0, 1, 0], [0, 1, 0]]", "[[0, 0, 0], [0, 1, 1], [0, 0, 1]]"], ["[[1]]", "[[1]]"], ["[[0]]", "[[0]]"], ["[[1]]", "[[0]]"], ["[[0]]", "[[1]]"], ["[[1, 1], [1, 1]]", "[[1, 1], [1, 1]]"], ["[[1, 0], [0, 1]]", "[[0, 1], [1, 0]]"], ["[[1, 0, 0], [0, 1, 0], [0, 0, 1]]", "[[0, 0, 1], [0, 1, 0], [1, 0, 0]]"], ["[[1, 1, 1], [1, 1, 1], [1, 1, 1]]", "[[1, 1, 1], [1, 1, 1], [1, 1, 1]]"], ["[[0, 0, 0], [0, 0, 0], [0, 0, 0]]", "[[1, 1, 1], [1, 1, 1], [1, 1, 1]]"], ["[[1, 0, 1], [0, 1, 0], [1, 0, 1]]", "[[0, 1, 0], [1, 0, 1], [0, 1, 0]]"], ["[[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 1]]", "[[0, 0, 1, 1], [0, 1, 0, 1], [1, 0, 1, 0], [1, 1, 0, 0]]"], ["[[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]", "[[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]"], ["[[0, 1], [1, 1]]", "[[1, 1], [1, 0]]"], ["[[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]", "[[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]"], ["[[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]", "[[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]"], ["[[1, 0], [0, 0]]", "[[0, 0], [0, 1]]"], ["[[0, 0], [1, 0]]", "[[0, 1], [0, 0]]"], ["[[1, 1, 0], [0, 0, 0], [0, 0, 0]]", "[[0, 0, 0], [0, 0, 0], [0, 1, 1]]"], ["[[1, 0, 0], [0, 0, 0], [0, 0, 0]]", "[[0, 0, 0], [0, 0, 0], [0, 0, 1]]"], ["[[1, 1, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]", "[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 0], [0, 1, 1, 1]]"], ["[[0, 1, 0], [0, 1, 0], [0, 1, 0]]", "[[1, 1, 1], [0, 0, 0], [0, 0, 0]]"], ["[[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]", "[[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]"], ["[[0, 0, 1], [0, 0, 1], [0, 0, 1]]", "[[1, 0, 0], [1, 0, 0], [1, 0, 0]]"], ["[[1, 0, 1], [1, 1, 1], [0, 0, 0]]", "[[0, 0, 0], [1, 1, 1], [1, 0, 1]]"], ["[[1, 1], [0, 1]]", "[[1, 0], [1, 1]]"], ["[[0, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]]", "[[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]"], ["[[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]", "[[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]"]], "expected": [3, 1, 0, 0, 0, 4, 1, 1, 9, 0, 3, 4, 2, 2, 3, 13, 1, 1, 2, 1, 3, 1, 8, 3, 4, 2, 4, 1], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "680", "slug": "image-smoother", "id": 680, "title": "Image Smoother", "difficulty": "Easy", "category": "matrix", "link": "https://leetcode.com/problems/image-smoother/", "examples": [{"input": "img = [[1,1,1],[1,0,1],[1,1,1]]", "output": "[[0,0,0],[0,0,0],[0,0,0]]", "explanation": "Each corner averages 3 neighbours, each edge 6, and the center 9; all floors are 0."}, {"input": "img = [[100,200,100],[200,50,200],[100,200,100]]", "output": "[[137,141,137],[141,150,141],[137,141,137]]", "explanation": "Averages include the cell plus every valid neighbour, rounded down."}], "hints": ["Compute every output cell from the original grid, not from partly smoothed values.", "Loop over the 3x3 window offsets (-1..1) and keep only in-bounds neighbours.", "Integer division already floors the average."], "statement": "You are given an `m x n` grid `img` of gray values.\n\nBuild a smoothed grid of the same size where each cell becomes the floor of the average of itself plus all valid neighbours (up to 8 surrounding cells plus itself). Cells on borders simply average fewer entries.\n\n**Constraints:**\n- `1 <= m, n <= 200`\n- `0 <= img[i][j] <= 255`\n", "solution": "## Approach\n\nRead every output cell from the untouched input. Gather the up-to-nine valid neighbours with offsets -1..1, skipping out-of-bounds positions, then store the integer average. A separate output grid prevents smoothed values from leaking into later cells.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(m * n) with constant window work per cell.\n- **Space Complexity:** O(m * n) for the answer grid.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def imageSmoother(self, img: List[List[int]]) -> List[List[int]]:\n m, n = len(img), len(img[0])\n ans = [[0] * n for _ in range(m)]\n for i in range(m):\n for j in range(n):\n s = c = 0\n for di in (-1, 0, 1):\n for dj in (-1, 0, 1):\n ni, nj = i + di, j + dj\n if 0 <= ni < m and 0 <= nj < n:\n s += img[ni][nj]\n c += 1\n ans[i][j] = s // c\n return ans\n```\n", "starter": {"go": "package main\n\nfunc ImageSmoother(img [][]int) [][]int {\n \n}", "python": "from typing import List\nclass Solution:\n def imageSmoother(self, img: List[List[int]]) -> List[List[int]]:\n pass", "cpp": "#include <vector>\nusing namespace std;\nclass Solution {\npublic:\n vector<vector<int>> imageSmoother(vector<vector<int>>& img) {\n return {};\n }\n};"}, "fn": "imageSmoother", "params": [{"name": "img", "type": "int_array_2d"}], "outputType": "int_array_2d", "tests": [["[[1,1,1],[1,0,1],[1,1,1]]"], ["[[100,200,100],[200,50,200],[100,200,100]]"], ["[[1]]"], ["[[1,2],[3,4]]"], ["[[0,0,0],[0,0,0]]"], ["[[255]]"], ["[[1,2,3],[4,5,6],[7,8,9]]"], ["[[5,5],[5,5]]"], ["[[1,0],[0,1]]"], ["[[10,20,30,40]]"], ["[[10],[20],[30]]"], ["[[0,255,0],[255,0,255],[0,255,0]]"], ["[[2,2,2],[2,2,2],[2,2,2]]"], ["[[1,2,3,4],[5,6,7,8]]"], ["[[9,8,7],[6,5,4],[3,2,1]]"], ["[[0,1],[1,0],[0,1]]"], ["[[100,100],[100,100],[100,100]]"], ["[[1,2],[3,4],[5,6]]"], ["[[7,7,7,7],[7,0,0,7],[7,7,7,7]]"], ["[[3,1,4],[1,5,9],[2,6,5]]"], ["[[0]]"], ["[[255,255],[255,255]]"], ["[[1,3,2,4]]"], ["[[4],[3],[2],[1]]"], ["[[8,4,2],[6,0,10],[12,14,16]]"], ["[[1,2,3],[4,5,6]]"], ["[[50,60,70,80,90]]"], ["[[11,22],[33,44],[55,66],[77,88]]"]], "expected": [[[0, 0, 0], [0, 0, 0], [0, 0, 0]], [[137, 141, 137], [141, 138, 141], [137, 141, 137]], [[1]], [[2, 2], [2, 2]], [[0, 0, 0], [0, 0, 0]], [[255]], [[3, 3, 4], [4, 5, 5], [6, 6, 7]], [[5, 5], [5, 5]], [[0, 0], [0, 0]], [[15, 20, 30, 35]], [[15], [20], [25]], [[127, 127, 127], [127, 113, 127], [127, 127, 127]], [[2, 2, 2], [2, 2, 2], [2, 2, 2]], [[3, 4, 5, 5], [3, 4, 5, 5]], [[7, 6, 6], [5, 5, 4], [4, 3, 3]], [[0, 0], [0, 0], [0, 0]], [[100, 100], [100, 100], [100, 100]], [[2, 2], [3, 3], [4, 4]], [[5, 4, 4, 5], [5, 5, 5, 5], [5, 4, 4, 5]], [[2, 3, 4], [3, 4, 5], [3, 4, 6]], [[0]], [[255, 255], [255, 255]], [[2, 2, 3, 3]], [[3], [3], [2], [1]], [[4, 5, 4], [7, 8, 7], [8, 9, 10]], [[3, 3, 4], [3, 3, 4]], [[55, 60, 70, 80, 85]], [[27, 27], [38, 38], [60, 60], [71, 71]]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "695", "slug": "implement-magic-dictionary", "id": 695, "title": "Implement Magic Dictionary", "difficulty": "Medium", "category": "trie", "link": "https://leetcode.com/problems/implement-magic-dictionary/", "examples": [{"input": "operations = [\"buildDict\",\"search\",\"search\",\"search\",\"search\"], words = [\"hello|leetcode\",\"hello\",\"hhllo\",\"hell\",\"leetcoded\"]", "output": "[0,1,0,0]", "explanation": "Only hhllo differs by exactly one letter from a stored word of equal length."}, {"input": "operations = [\"buildDict\",\"search\",\"search\"], words = [\"hello|hallo\",\"hello\",\"hallo\"]", "output": "[1,1]", "explanation": "hello matches hallo with one change and vice versa."}], "hints": ["A search succeeds when some stored word has equal length and differs in exactly one position.", "Design adaptation: this task uses runMagicDictionary(operations, words) instead of a class; for buildDict, words[i] packs the whole dictionary with '|' separators, while for search it holds the single query.", "Compare each query against stored words of the same length and count mismatches with early exit past one."], "statement": "Build a word store that supports a fuzzy lookup. Design adaptation: instead of implementing a class, you implement `runMagicDictionary(operations, words)` using only the allowed array types.\n\nCalling convention:\n\n- `operations[i]` is either `\"buildDict\"` or `\"search\"`.\n- When it is `\"buildDict\"`, `words[i]` packs the entire dictionary as words joined by `\"|\"` (for example `\"hello|leetcode\"`). An empty string means an empty dictionary. This call replaces any prior dictionary and produces no output entry.\n- When it is `\"search\"`, `words[i]` is a single query word. Append `1` to the answer when some dictionary word has the same length and differs in exactly one position; otherwise append `0`.\n\nReturn the list of `1/0` answers for the search calls in order.\n\n**Constraints:**\n- Operation count per test is between 1 and 20.\n- Words use lowercase letters; packed dictionaries use '|' only as a separator.\n", "solution": "## Approach\n\nKeep the current dictionary as a list. A packed build entry is split on '|' to refresh it. Each search scans stored words of equal length and counts differing positions, stopping early after two mismatches; exactly one mismatch means success.\n\n## Complexity Analysis\n\n- **Time Complexity:** O(D * L) per search, where D is dictionary size and L word length.\n- **Space Complexity:** O(D * L) to store the dictionary.\n\n## Implementation\n\n```python\nfrom typing import List\nclass Solution:\n def runMagicDictionary(self, operations: List[str], words: List[str]) -> List[int]:\n d = []\n ans = []\n for op, w in zip(operations, words):\n if op == \"buildDict\":\n d = [x for x in w.split(\"|\") if x] if w else []\n else:\n ok = False\n for cand in d:\n if len(cand) != len(w):\n continue\n diff = sum(1 for a, b in zip(cand, w) if a != b)\n if diff == 1:\n ok = True\n break\n ans.append(1 if ok else 0)\n return ans\n```\n", "starter": {"go": "package main\n\nfunc RunMagicDictionary(operations []string, words []string) []int {\n return nil\n}", "python": "from typing import List\nclass Solution:\n def runMagicDictionary(self, operations: List[str], words: List[str]) -> List[int]:\n pass", "cpp": "#include <vector>\n#include <string>\nusing namespace std;\nclass Solution {\npublic:\n vector<int> runMagicDictionary(vector<string>& operations, vector<string>& words) {\n return {};\n }\n};"}, "fn": "runMagicDictionary", "params": [{"name": "operations", "type": "string_array"}, {"name": "words", "type": "string_array"}], "outputType": "int_array", "tests": [["[\"buildDict\",\"search\",\"search\",\"search\",\"search\"]", "[\"hello|leetcode\",\"hello\",\"hhllo\",\"hell\",\"leetcoded\"]"], ["[\"buildDict\",\"search\",\"search\"]", "[\"hello|hallo\",\"hello\",\"hallo\"]"], ["[\"buildDict\",\"search\"]", "[\"a|b\",\"c\"]"], ["[\"buildDict\",\"search\",\"search\"]", "[\"judge|hudge\",\"judge\",\"hudge\"]"], ["[\"buildDict\",\"search\"]", "[\"hello\",\"hello\"]"], ["[\"buildDict\",\"search\"]", "[\"hello\",\"hhllo\"]"], ["[\"buildDict\",\"search\"]", "[\"\",\"hello\"]"], ["[\"buildDict\",\"search\",\"search\"]", "[\"a|b|c\",\"a\",\"d\"]"], ["[\"buildDict\",\"buildDict\",\"search\"]", "[\"a|b\",\"c|d\",\"c\"]"], ["[\"buildDict\",\"search\",\"search\",\"search\"]", "[\"apple|apply\",\"apple\",\"apply\",\"appla\"]"], ["[\"buildDict\",\"search\"]", "[\"ab|ba\",\"ab\"]"], ["[\"buildDict\",\"search\"]", "[\"ab|ba\",\"aa\"]"], ["[\"buildDict\",\"search\",\"search\"]", "[\"x|y|z\",\"x\",\"xy\"]"], ["[\"buildDict\",\"search\"]", "[\"longword|longwork\",\"longword\"]"], ["[\"buildDict\",\"search\",\"search\"]", "[\"cat|dog\",\"cot\",\"cog\"]"], ["[\"buildDict\",\"search\"]", "[\"aaa|aab\",\"aba\"]"], ["[\"buildDict\",\"search\",\"search\"]", "[\"hello|world\",\"hella\",\"worla\"]"], ["[\"buildDict\",\"search\"]", "[\"a\",\"b\"]"], ["[\"buildDict\",\"search\"]", "[\"a\",\"a\"]"], ["[\"buildDict\",\"search\",\"search\",\"search\",\"search\"]", "[\"ab|cd|ef\",\"ab\",\"ac\",\"cd\",\"ce\"]"], ["[\"buildDict\",\"search\"]", "[\"abcdefghijklmnopqrstuvwxyz|abcdefghijklmnopqrstuvwxyy\",\"abcdefghijklmnopqrstuvwxyz\"]"], ["[\"buildDict\",\"search\",\"search\"]", "[\"one|two|three\",\"one\",\"four\"]"], ["[\"buildDict\",\"search\"]", "[\"same|same\",\"same\"]"], ["[\"buildDict\",\"search\"]", "[\"same|some\",\"same\"]"], ["[\"buildDict\",\"search\",\"search\"]", "[\"p|q|r|s|t\",\"p\",\"u\"]"], ["[\"buildDict\",\"search\",\"search\"]", "[\"magic|magik\",\"magic\",\"magix\"]"], ["[\"buildDict\",\"search\"]", "[\"hello|hella|hellb\",\"hellc\"]"], ["[\"buildDict\",\"search\",\"search\"]", "[\"ab|ac\",\"ab\",\"ad\"]"]], "expected": [[0, 1, 0, 0], [1, 1], [1], [1, 1], [0], [1], [0], [1, 1], [1], [1, 1, 1], [0], [1], [1, 0], [1], [1, 1], [1], [1, 1], [1], [0], [0, 1, 0, 1], [1], [0, 0], [0], [1], [1, 1], [1, 1], [1], [1, 1]], "loose": false}
@@ -0,0 +1 @@
1
+ {"basic": false, "label": "178", "slug": "implement-queue-using-stacks", "id": 178, "title": "Implement Queue using Stacks", "difficulty": "Easy", "category": "stack", "link": "https://leetcode.com/problems/implement-queue-using-stacks/", "examples": [{"input": "operations = [\"push\",\"push\",\"peek\",\"pop\",\"empty\"], values = [1,2,0,0,0]", "output": "[1,1,0]", "explanation": "Push 1 then push 2. Peek returns 1, pop removes and returns 1, then empty returns false (encoded as 0) because 2 remains."}, {"input": "operations = [\"push\",\"peek\",\"pop\",\"empty\"], values = [1,0,0,0]", "output": "[1,1,1]", "explanation": "Push 1. Peek returns 1, pop returns 1, then the queue is empty so empty returns true (encoded as 1)."}, {"input": "operations = [\"push\",\"push\",\"push\",\"pop\",\"peek\",\"pop\",\"empty\"], values = [1,2,3,0,0,0,0]", "output": "[1,2,2,0]", "explanation": "Push 1, 2, 3. Pop returns 1, peek returns 2, pop returns 2, and empty returns false (0) because 3 remains."}], "hints": ["Use two stacks: push onto the input stack, and lazily move elements to the output stack when a peek or pop needs the front.", "Empty checks whether both stacks have no elements. Encode empty as 1 for true and 0 for false."], "statement": "Implement a first-in-first-out (FIFO) queue using only standard stack operations.\n\n`operations[i]` is one of `push`, `pop`, `peek`, or `empty`. The aligned value\n`values[i]` is used only by `push`; it is ignored for every other operation.\nReturn an array containing the result of each `pop`, `peek`, and `empty`\noperation, in the order those queries occur. `push` does not add anything to\nthe returned array. Encode `empty` as `1` for true and `0` for false.\n\nEvery trace is valid: `pop` and `peek` are never called on an empty queue.\n\n**Constraints:**\n\n- `1 <= operations.length == values.length <= 100`\n- `operations[i]` is `push`, `pop`, `peek`, or `empty`.\n- `1 <= values[i] <= 9` when `operations[i]` is `push`.\n- At most 100 calls are made in one trace.\n", "solution": "## Approach\n\nUse two stacks: push onto `in`, and keep `out` for the front of the queue.\nWhen `pop` or `peek` finds `out` empty, move every element from `in` to `out`\n(which reverses the order so the oldest element is on top). `empty` is true\nonly when both stacks are empty (encoded as `1`/`0`). Collect outputs only\nfor `pop`, `peek`, and `empty`.\n\n## Complexity Analysis\n\n- **Time Complexity:** `O(m)` amortized over `m` operations; each element moves at most once from `in` to `out`.\n- **Space Complexity:** `O(m)` for the two stacks in the worst case.\n\n## Implementation\n\n```python\nfrom typing import List\n\n\nclass Solution:\n def runQueueUsingStacks(self, operations: List[str], values: List[int]) -> List[int]:\n instack: List[int] = []\n outstack: List[int] = []\n answers: List[int] = []\n\n def move() -> None:\n if not outstack:\n while instack:\n outstack.append(instack.pop())\n\n for operation, value in zip(operations, values):\n if operation == \"push\":\n instack.append(value)\n elif operation == \"pop\":\n move()\n answers.append(outstack.pop())\n elif operation == \"peek\":\n move()\n answers.append(outstack[-1])\n else:\n answers.append(1 if not instack and not outstack else 0)\n return answers\n```\n", "starter": {"go": "package main\n\nfunc RunQueueUsingStacks(operations []string, values []int) []int {\n return []int{}\n}", "python": "from typing import List\n\nclass Solution:\n def runQueueUsingStacks(self, operations: List[str], values: List[int]) -> List[int]:\n return []\n", "cpp": "#include <string>\n#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<int> runQueueUsingStacks(vector<string>& operations, vector<int>& values) {\n return {};\n }\n};"}, "fn": "runQueueUsingStacks", "params": [{"name": "operations", "type": "string_array"}, {"name": "values", "type": "int_array"}], "outputType": "int_array", "tests": [["[\"push\",\"push\",\"peek\",\"pop\",\"empty\"]", "[1,2,0,0,0]"], ["[\"push\",\"peek\",\"pop\",\"empty\"]", "[1,0,0,0]"], ["[\"push\",\"push\",\"push\",\"pop\",\"peek\",\"pop\",\"empty\"]", "[1,2,3,0,0,0,0]"], ["[\"push\",\"empty\",\"peek\",\"pop\",\"empty\"]", "[5,0,0,0,0]"], ["[\"push\",\"pop\",\"empty\"]", "[9,0,0]"], ["[\"push\",\"push\",\"pop\",\"peek\",\"pop\",\"empty\"]", "[3,7,0,0,0,0]"], ["[\"push\",\"push\",\"push\",\"push\",\"peek\",\"pop\",\"peek\",\"pop\",\"empty\"]", "[1,2,3,4,0,0,0,0,0]"], ["[\"push\",\"push\",\"empty\",\"pop\",\"empty\",\"push\",\"peek\",\"empty\"]", "[4,5,0,0,0,6,0,0]"], ["[\"push\",\"push\",\"push\",\"push\",\"push\",\"pop\",\"pop\",\"pop\",\"pop\",\"pop\",\"empty\"]", "[9,8,7,6,5,0,0,0,0,0,0]"], ["[\"push\",\"peek\",\"peek\",\"pop\",\"empty\",\"push\",\"peek\",\"empty\"]", "[2,0,0,0,0,8,0,0]"], ["[\"push\",\"push\",\"pop\",\"push\",\"pop\",\"pop\",\"empty\"]", "[1,9,0,2,0,0,0]"], ["[\"push\",\"push\",\"push\",\"peek\",\"peek\",\"pop\",\"empty\",\"pop\",\"peek\",\"empty\"]", "[5,1,9,0,0,0,0,0,0,0]"], ["@javascript:JSON.stringify(Array(50).fill('push').flatMap((_,i)=>i%5===4?['push','peek','pop']:['push']))", "@javascript:JSON.stringify(Array.from({length:50},(_,i)=>(i%9)+1).flatMap((v,i)=>i%5===4?[v,0,0]:[v]))"], ["@javascript:JSON.stringify([...Array(60).fill('push'),...Array(30).fill('pop'),'peek','empty'])", "@javascript:JSON.stringify([...Array.from({length:60},(_,i)=>(i%9)+1),...Array(32).fill(0)])"], ["[\"push\",\"push\",\"push\",\"pop\",\"pop\",\"pop\",\"empty\"]", "[1,2,3,0,0,0,0]"], ["[\"push\",\"empty\",\"empty\",\"pop\",\"empty\"]", "[7,0,0,0,0]"], ["[\"push\",\"push\",\"peek\",\"peek\",\"pop\",\"peek\",\"empty\"]", "[4,6,0,0,0,0,0]"], ["[\"push\",\"pop\",\"push\",\"pop\",\"empty\"]", "[3,0,5,0,0]"], ["[\"push\",\"push\",\"pop\",\"push\",\"peek\",\"pop\",\"pop\",\"empty\"]", "[8,1,0,9,0,0,0,0]"], ["[\"empty\",\"push\",\"peek\",\"empty\"]", "[0,2,0,0]"], ["[\"push\",\"push\",\"push\",\"empty\",\"peek\",\"pop\",\"empty\"]", "[2,4,6,0,0,0,0]"], ["[\"push\",\"peek\",\"push\",\"peek\",\"pop\",\"pop\",\"empty\"]", "[1,0,2,0,0,0,0]"], ["[\"push\",\"push\",\"pop\",\"pop\",\"push\",\"peek\",\"empty\"]", "[5,5,0,0,5,0,0]"], ["[\"push\",\"push\",\"push\",\"push\",\"pop\",\"empty\",\"pop\",\"peek\",\"empty\"]", "[3,3,3,3,0,0,0,0,0]"], ["[\"push\",\"empty\",\"push\",\"empty\",\"pop\",\"peek\",\"empty\"]", "[1,0,2,0,0,0,0]"], ["[\"push\",\"pop\",\"push\",\"peek\",\"pop\",\"empty\",\"push\",\"empty\"]", "[6,0,4,0,0,0,7,0]"], ["[\"push\",\"push\",\"peek\",\"pop\",\"push\",\"peek\",\"pop\",\"pop\",\"empty\"]", "[9,1,0,0,2,0,0,0,0]"], ["[\"push\",\"push\",\"push\",\"pop\",\"push\",\"pop\",\"pop\",\"pop\",\"empty\"]", "[4,4,4,0,4,0,0,0,0]"], ["[\"empty\",\"empty\",\"push\",\"pop\",\"empty\"]", "[0,0,9,0,0]"], ["[\"push\",\"peek\",\"empty\",\"pop\",\"empty\"]", "[8,0,0,0,0]"], ["[\"push\",\"push\",\"empty\",\"peek\",\"pop\",\"push\",\"empty\"]", "[7,3,0,0,0,8,0]"], ["[\"push\",\"push\",\"pop\",\"empty\",\"push\",\"pop\",\"peek\",\"empty\"]", "[2,8,0,0,5,0,0,0]"]], "expected": [[1, 1, 0], [1, 1, 1], [1, 2, 2, 0], [0, 5, 5, 1], [9, 1], [3, 7, 7, 1], [1, 1, 2, 2, 0], [0, 4, 0, 5, 0], [9, 8, 7, 6, 5, 1], [2, 2, 2, 1, 8, 0], [1, 9, 2, 1], [5, 5, 5, 0, 1, 9, 0], [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 0], [1, 2, 3, 1], [0, 0, 7, 1], [4, 4, 4, 6, 0], [3, 5, 1], [8, 1, 1, 9, 1], [1, 2, 0], [0, 2, 2, 0], [1, 1, 1, 2, 1], [5, 5, 5, 0], [3, 0, 3, 3, 0], [0, 0, 1, 2, 0], [6, 4, 4, 1, 0], [9, 9, 1, 1, 2, 1], [4, 4, 4, 4, 1], [1, 1, 9, 1], [8, 0, 8, 1], [0, 7, 7, 0], [2, 0, 8, 5, 0]], "loose": false}