README ¶ Leetcode in Go 😉 These are my solutions of leetcode problems. My leetcode profile Expand ▾ Collapse ▴ Directories ¶ Show internal Expand all Path Synopsis problems 0001-two-sum 0002-add-two-numbers 0003-longest-substring-without-repeating-characters 0004-median-of-two-sorted-arrays 0005-longest-palindromic-substring 0006-zigzag-conversion 0007-reverse-integer 0008-string-to-integer 0009-palindrome-number 0011-conteiner-with-most-water 0012-integer-to-roman 0014-longest-common-prefix 0015-3Sum 0016-3Sum-closest 0017-letter-combinations-of-a-phone-number 0018-4Sum 0019-remove-nth-node-from-end-of-list 0020-valid-parentheses 0021-merge-two-sorted-lists 0022-generate-parentheses 0023-merge-k-sorted-lists 0024-swap-nodes-in-pairs 0025-reverse-nodes-in-k-group 0026-remove-duplicates 0027-remove-element 0028-implement-strstr 0029-divide-two-integers 0031-next-permutation 0032-longest-valid-parentheses 0033-search-in-rotated-sorted-array 0034-find-first-and-last-position-of-element-in-sorted-array 0035-search-insert-position 0036-valid-sudoku 0037-sudoku-solver 0039-combination-sum 0040-combination-sum-II 0042-trapping-rain-water 0043-multiply-strings 0045-jump-game-II 0046-permutations 0047-permutations-II 0048-rotate-image 0049-group-anagrams 0051-n-queens 0052-n-queens-II 0053-maximum-subarray 0054-spiral-matrix 0055-jump-game 0056-merge-intervals 0057-insert-interval 0058-length-of-last-word 0059-spiral-matrix-II 0061-rotate-list 0062-unique-paths 0063-unique-paths-II 0064-minimum-path-sum 0065-valid-number 0066-plus-one 0067-add-binary 0070-climbing-stairs 0071-simplify-path 0073-set-matrix-zeroes 0074-search-a-2d-matrix 0075-sort-colors 0076-minimum-window-substring 0077-combinations 0078-subsets 0079-word-search 0080-remove-duplacates-from-sorted-array-II 0081-search-in-rotated-sorted-array-II 0083-remove-duplicates-from-sorted-list 0084-largest-rectangle-in-histogram 0085-maximal-rectangle 0086-partition-list 0088-merge-sorted-array 0089-gray-code 0090-subsets-II 0091-decode-ways 0092-reverse-linked-list-II 0094-binary-tree-inorder-traversal 0095-unique-binary-search-trees-II 0096-unique-binary-search-trees 0097-interleaving-string 0099-recover-binary-search-tree 0100-is-same-tree 0101-symmetric-tree 0102-binary-tree-level-order-traversal 0104-maximum-depth-of-binary-tree 0105-construct-binary-tree-from-preorder-and-inorder-traversal 0106-construct-binary-tree-from-inorder-and-postorder-traversal 0107-binary-tree-level-order-traversal-II 0108-convert-sorted-array-to-binary-search-tree 0109-convert-sorted-list-to-binary-search-tree 0110-balanced-binary-tree 0111-minimum-depth-of-binary-tree 0112-path-sum 0113-path-sum-II 0114-flatten-binary-tree-to-linked-list 0115-distinct-subsequences 0116-populating-next-right-pointers-in-each-node 0117-populating-next-right-pointers-in-each-node-II 0118-pascals-triangle 0119-pascals-triangle-II 0120-triangle 0121-best-time-to-buy-and-sell-stock 0122-best-time-to-buy-and-sell-stock-II 0123-best-time-to-buy-and-sell-stock-III 0125-valid-palindrome 0126-word-ladder-II 0127-word-ladder 0128-longest-consecutive-sequence 0129-sum-root-to-leaf-numbers 0130-surrounded-regions 0131-palindrome-partitioning 0132-palindrome-partitioning-II 0133-clone-graph 0134-gas-station 0135-candy 0136-single-number 0138-copy-list-with-random-pointer 0139-word-break 0141-linked-list-cycle 0142-linked-list-cycle-II 0143-reorder-list 0144-binary-tree-preorder-traversal 0145-binary-tree-postorder-traversal 0146-lru-cache 0147-insertion-sort-list 0148-sort-list 0150-evaluate-reverse-polish-notation 0151-reverse-words-in-a-string 0152-maximum-product-subarray 0153-find-minimum-in-rotated-sorted-array 0154-find-minimum-in-rotated-sorted-array-II 0155-min-stack 0160-intersection-of-two-linked-lists 0162-find-peak-element 0164-maximum-gap 0165-compare-version-numbers 0167-two-sum-II 0168-excel-sheet-column-title 0169-majority-element 0171-excel-sheet-column-number 0173-binary-search-tree-iterator 0174-dungeon-game 0189-rotate-array 0190-reverse-bits 0191-number-of-1-bits 0198-house-robber 0200-number-of-islands 0201-bitwise-and-of-numbers-range 0202-happy-number 0203-remove-linked-list-elements 0204-count-primes 0205-isomorphic-strings 0206-reverse-linked-list 0207-course-schedule 0208-implement-trie-prefix-tree 0210-course-schedule-II 0211-design-add-and-search-words-data-structure 0212-word-search-II 0213-house-robber-II 0215-kth-largest-element-in-an-array 0216-combination-sum-III 0217-contains-duplicate 0219-contains-duplicate-II 0221-maximal-square 0222-count-complete-tree-nodes 0224-basic-calculator 0225-implement-stack-using-queues 0226-invert-binary-tree 0227-basic-calculator-II 0228-summary-ranges 0230-kth-smallest-element-in-a-bst 0231-power-of-two 0234-palindrome-linked-list 0235-lowest-common-ancestor-of-a-binary-search-tree 0236-lowest-common-ancestor-of-a-binary-tree 0237-delete-node-in-a-linked-list 0238-product-of-array-except-self 0241-different-ways-to-add-parentheses 0242-valid-anagram 0257-binary-tree-paths 0260-single-number-III 0268-missing-number 0278-first-bad-version 0279-perfect-squares 0282-expression-add-operators 0283-move-zeroes 0284-peeking-iterator 0287-find-the-duplicate-number 0289-game-of-life 0290-word-pattern 0295-find-median-from-data-stream 0299-bulls-and-cows 0300-longest-increasing-subsequence 0303-range-sum-query-immutable 0304-range-sum-query-2d-immutable 0307-range-sum-query-mutable 0309-best-time-to-buy-and-sell-stock-with-cooldown 0310-minimum-height-trees 0312-burst-balloons 0315-count-of-smaller-numbers-after-self 0316-remove-duplicate-letters 0318-maximum-product-of-word-lengths 0322-coin-change 0326-power-of-three 0328-odd-even-linked-list 0329-longest-increasing-path-in-a-matrix 0330-patching-array 0331-verify-preorder-serialization-of-a-binary-tree 0336-palindrome-pairs 0337-house-robber-III 0338-counting-bits 0341-flatten-nested-list-iterator 0342-power-of-four 0344-reverse-string 0347-top-k-frequent-elements 0349-intersection-of-two-arrays 0350-intersection-of-two-arrays-II 0354-russian-doll-envelopes 0363-max-sum-of-rectangle-no-larger-than-k 0367-valid-perfect-square 0368-largest-divisible-subset 0374-guess-number-higher-or-lower 0376-wiggle-subsequence 0377-combination-sum-IV 0378-kth-smallest-element-in-a-sorted-matrix 0380-insert-delete-getrandom-O1 0382-linked-list-random-node 0383-ransom-note 0384-shuffle-an-array 0387-first-unique-character-in-a-string 0389-find-the-difference 0392-is-subsequence 0394-decode-string 0399-evaluate-division 0401-binary-watch 0402-remove-k-digits 0404-sum-of-left-leaves 0409-longest-palindrome 0410-split-array-largest-sum 0412-fizz-buzz 0414-third-maximum-number 0415-add-strings 0416-partition-equal-subset-sum 0417-pacific-atlantic-water-flow 0421-maximum-xor-of-two-numbers-in-an-array 0423-reconstruct-original-digits-from-english 0429-n-ary-tree-level-order-traversal 0430-flatten-a-multilevel-doubly-linked-list 0437-path-sum-III 0438-find-all-anagrams-in-a-string 0441-arranging-coins 0442-find-all-duplicates-in-an-array 0448-find-all-numbers-disappeared-in-an-array 0450-delete-node-in-a-bst 0451-sort-characters-by-frequency 0452-minimum-number-of-arrows-to-burst-balloons 0453-minimum-moves-to-equal-array-elements 0454-4Sum-II 0455-assign-cookies 0456-132-pattern 0459-repeated-substring-pattern 0462-minimum-moves-to-equal-array-elements-II 0463-island-perimeter 0473-matchsticks-to-square 0474-ones-and-zeroes 0476-number-complement 0478-generate-random-point-in-a-circle 0485-max-consecutive-ones 0492-construct-the-rectangle 0494-target-sum 0495-teemo-attacking 0496-next-greater-element-I 0500-keyboard-row 0501-find-mode-in-binary-search-tree 0504-base-7 0509-fibonacci-number 0520-detect-capital 0522-longest-uncommon-subsequence-II 0525-contiguous-array 0530-minimum-absolute-difference-in-bst 0532-k-diff-pairs-in-an-array 0535-encode-and-decode-tiny-url 0537-complex-number-multiplication 0538-convert-bst-to-greater-tree 0540-single-element-in-a-sorted-array 0542-01-matrix 0543-diameter-of-binary-tree 0546-remove-boxes 0551-student-attendance-record-I 0554-brick-wall 0557-reverse-words-in-a-string-III 0560-subarray-sum-equals-k 0561-array-partition-I 0563-binary-tree-tilt 0565-array-nesting 0566-reshape-the-matrix 0567-permutation-in-string 0572-subtree-of-another-tree 0575-distrbute-candies 0576-out-of-boundary-paths 0581-shortest-unsorted-continuous-subarray 0583-delete-operation-for-two-strings 0589-n-ary-tree-preorder-traversal 0598-range-addition-II 0600-non-negative-integers-without-consecutive-ones 0605-can-place-flowers 0609-find-duplicate-file-in-system 0611-valid-triangle-number 0617-merge-two-binary-trees 0622-design-circular-queue 0623-add-one-row-to-tree 0629-k-inverse-pairs-array 0630-course-schedule-III 0633-sum-of-square-numbers 0637-average-of-levels-in-binary-tree 0639-decode-ways-II 0643-maximum-average-subarray-I 0645-set-mismatch 0647-palindromic-substrings 0653-two-sum-IV-input-is-a-bst 0657-robot-return-to-origin 0658-find-k-closest-elements 0662-maximum-width-of-binary-tree 0665-non-decreasing-array 0667-beautiful-arrangement-II 0668-kth-smallest-number-in-multiplication-table 0669-trim-a-binary-search-tree 0671-second-minimum-node-in-a-binary-tree 0677-map-sum-pairs 0680-valid-palindrome-II 0682-baseball-game 0684-redundant-connection 0695-max-area-of-island 0696-count-binary-substrings 0698-partition-to-k-equal-sum-subsets 0700-search-in-a-binary-search-tree 0701-insert-into-a-binary-search-tree 0703-kth-largest-element-in-a-stream 0704-binary-search 0705-design-hash-set 0706-design-hashmap 0709-to-lower-case 0714-best-time-to-buy-and-sell-stock-with-transaction-fee 0718-maximum-length-of-repeated-subarray 0721-accounts-merge 0725-split-linked-list-in-parts 0728-self-dividing-numbers 0729-my-calendar-I 0739-daily-temperatures 0743-network-delay-time 0745-prefix-and-suffix-search 0746-min-cost-climbing-stairs 0752-open-the-lock 0763-partition-labels 0764-largest-plus-sign 0771-jewels-and-stones 0775-global-and-local-inversions 0778-swim-in-rising-water 0782-transform-to-chessboard 0785-is-graph-bipartite 0790-domino-and-tromino-tiling 0791-custom-sort-string 0792-number-of-matching-subsequences 0795-number-of-subarrays-with-bounded-maximum 0797-all-paths-from-source-to-target 0804-unique-morse-code-words 0814-binary-tree-pruning 0816-ambiguous-coordinates 0819-most-common-word 0820-short-encoding-of-words 0823-binary-trees-with-factors 0827-making-a-large-island 0832-flipping-an-image 0834-sum-of-distances-in-tree 0836-rectangle-overlap 0838-push-dominoes 0841-keys-and-rooms 0844-backspace-string-compare 0847-shortest-path-visiting-all-nodes 0848-shifting-letters 0849-maximize-distance-to-closest-person 0850-rectangle-area-II 0852-peak-index-in-a-mountain-array 0856-score-of-parentheses 0860-lemonade-change 0867-transpose-matrix 0869-reordered-power-of-2 0870-advantage-shuffle 0871-minimum-number-of-refueling-stops 0874-walking-robot-simulation 0875-koko-eating-bananas 0876-middle-of-the-linked-list 0877-stone-game 0878-nth-magical-number 0881-boats-to-save-people 0882-reachable-nodes-in-subdivided-graph 0890-find-and-replace-pattern 0895-maximum-frequency-stack 0897-increasing-order-search-tree 0899-orderly-queue 0902-numbers-at-most-n-given-digit-set 0905-sort-array-by-parity 0906-super-palindromes 0914-x-of-a-kind-in-a-deck-of-cards 0915-partition-array-into-disjoint-intervals 0916-word-subsets 0917-reverse-only-letters 0922-sort-array-by-parity-II 0923-3Sum-with-multiplicity 0926-flip-string-to-monotone-increasing 0927-three-equal-parts 0929-unique-email-addresses 0932-beautiful-array 0936-stamping-the-sequence 0938-range-sum-of-bst 0941-valid-mountain-array 0943-find-the-shortest-superstring 0946-validate-stack-sequences 0952-largest-component-size-by-common-factor 0953-verifying-an-alien-dictionary 0954-array-of-doubled-pairs 0961-n-repeated-element-in-size-2n-array 0966-vowel-spellchecker 0968-binary-tree-cameras 0970-powerful-integers 0971-flip-binary-tree-to-match-preorder-traversal 0973-k-closest-points-to-origin 0977-squares-of-a-sorted-array 0978-longest-turbulent-subarray 0980-unique-paths-III 0986-interval-list-intersections 0989-add-to-array-form-of-integer 0991-broken-calculator 0993-cousins-in-binary-tree 0994-rotting-oranges 0997-find-the-town-judge 1002-find-common-characters 1004-max-consecutive-ones-III 1007-minimum-domino-rotations-for-equal-row 1008-construct-binary-search-tree-from-preorder-traversal 1009-complement-of-base-10-integer 1010-pairs-of-songs-with-total-durations-divisible-by-60 1015-smallest-integer-divisible-by-k 1021-remove-outermost-parentheses 1022-sum-of-root-to-leaf-binary-numbers 1026-maximum-difference-between-node-and-ancestor 1029-two-city-scheduling 1030-matrix-cells-in-distance-order 1032-stream-of-characters 1041-robot-bounded-in-circle 1044-longest-duplicate-substring 1046-last-stone-weight 1047-remove-all-adjacent-duplicates-in-string 1048-longest-string-chain 1051-height-checker 1074-number-of-submatrices-that-sum-to-target 1091-shortest-path-in-binary-matrix 1094-car-pooling 1108-defanging-an-ip-address 1122-relative-sort-array 1137-n-th-tribonacci-number 1143-longest-common-subsequence 1160-find-words-that-can-be-formed-by-characters 1178-number-of-valid-words-for-each-puzzle 1189-maximum-number-of-balloons 1192-critical-connections-in-a-network 1200-minimum-absolute-difference 1202-smallest-string-with-swaps 1207-unique-number-of-occurrences 1209-remove-all-adjacent-duplicates-in-string-II 1217-minimum-cost-to-move-chips-to-the-same-position 1220-count-vowels-permutation 1221-split-a-string-in-balanced-strings 1232-check-if-it-is-a-straight-line 1239-maximum-length-of-a-concatenated-string-with-unique-characters 1249-minimum-remove-to-make-valid-parentheses 1252-cells-with-odd-values-in-a-matrix 1260-shift-2d-grid 1266-minimum-time-visiting-all-points 1268-search-suggestions-system 1275-find-winner-on-a-tic-tac-toe-game 1281-subtract-the-product-and-sum-of-digits-of-an-integer 1286-iterator-for-combination 1288-remove-covered-intervals 1290-convert-binary-number-in-a-linked-list-to-integer 1291-sequential-digits 1293-shortest-path-in-a-grid-with-obstacles-elimination 1295-find-numbers-with-even-number-of-digits 1302-deepest-leaves-sum 1304-find-n-unique-integers-sum-up-to-zero 1305-all-elements-in-two-binary-search-trees 1306-jump-game-III 1309-decrypt-string-from-alphabet-to-integer-mapping 1313-decompress-run-length-encoded-list 1323-maximum-69-number 1328-break-a-palindrome 1332-remove-palindromic-subsequences 1337-the-k-weakest-rows-in-a-matrix 1338-reduce-array-size-to-the-half 1339-maximum-product-of-splitted-binary-tree 1342-number-of-steps-to-reduce-a-number-to-zero 1345-jump-game-IV 1351-count-negative-numbers-in-a-sorted-matrix 1354-construct-target-array-with-multiple-sums 1365-how-many-numbers-are-smaller-than-the-current-number 1383-maximum-performance-of-a-team 1389-create-target-array-in-the-given-order 1396-design-underground-system 1413-minimum-value-to-get-positive-step-by-step-sum 1423-maximum-points-you-can-obtain-from-gards 1431-kids-with-the-greatest-number-of-candies 1436-destination-city 1446-consecutive-characters 1448-count-good-nodes-in-binary-tree 1450-number-of-students-doing-homework-at-a-given-time 1461-check-if-a-string-contains-all-binary-codes-of-size-k 1463-cherry-pickup-II 1464-maximum-product-of-two-elements-in-an-array 1465-maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts 1470-shuffle-the-array 1475-final-prices-with-a-special-discount-in-a-shop 1480-running-sum-of-1d-array 1486-xor-operation-in-an-array 1510-stone-game-IV 1512-number-of-good-pairs 1518-water-bottles 1528-shuffle-string 1534-count-good-triplets 1551-minimum-operations-to-make-array-equal 1566-detect-pattern-of-length-m-repeated-k-or-more-times 1572-matrix-diagonal-sum 1584-min-cost-to-connect-all-points 1588-sum-of-all-odd-length-subarrays 1603-design-parking-system 1614-maximum-nesting-depth-of-the-parentheses 1629-slowest-key 1631-path-with-minimum-effort 1636-sort-array-by-increasing-frequency 1641-count-sorted-vowel-strings 1642-furthest-building-you-can-reach 1652-defuse-the-bomb 1656-design-an-ordered-stream 1658-minimum-operations-to-reduce-x-to-zero 1662-check-if-two-string-arrays-are-equivalent 1663-smallest-string-with-a-given-numeric-value 1664-ways-to-make-a-fair-array 1672-richest-customer-wealth 1675-minimize-deviation-in-array 1679-max-number-of-k-sum-pairs 1684-count-the-number-of-consistent-strings 1688-count-of-matches-in-tournament 1689-partitioning-into-minimum-number-of-deci-binary-numbers 1690-stone-game-VII 1695-maximum-erasure-value 1696-jump-game-VI 1704-determine-if-string-halves-are-alike 1706-where-will-the-ball-fall 1710-maximum-units-on-a-truck 1721-swapping-nodes-in-a-linked-list 1725-number-of-rectangles-that-can-form-the-largest-square 1732-find-the-highest-altitude 1748-sum-of-unique-elements 1773-count-items-matching-a-rule 1791-find-center-of-star-graph 1800-maximum-ascending-subarray-sum 1816-truncate-sentence 1827-minimum-operations-to-make-the-array-increasing 1832-check-if-the-sentence-is-pangram 1837-sum-of-digits-in-base-k 1844-replace-all-digits-with-characters 1859-sorting-the-sentence 1913-maximum-product-difference-between-two-pairs 1920-build-array-from-permutation 1929-concatenation-of-array 1967-number-of-strings-that-appear-as-substring-in-word 1979-find-greatest-common-divisor-of-array 2000-reverse-prefix-of-word 2006-count-number-of-pairs-with-absolute-difference-k 2011-final-value-of-variable-after-performing-operations 2037-minimum-number-of-moves-to-seat-everyone 2057-smallest-index-with-equal-value 2089-find-target-indices-after-sorting-array 2103-rings-and-rods 2108-find-first-palindromic-string-in-the-array 2114-maximum-number-of-words-found-in-sentences 2119-a-number-after-a-double-reversal 2154-keep-multiplying-found-values-by-two 2160-minimum-sum-of-four-digit-number-after-splitting-digits 2169-count-operations-to-obtain-zero 2180-count-integers-with-even-digit-sum 2206-divide-array-into-equal-pairs 2215-find-the-difference-of-two-arrays 2236-root-equals-sum-of-children structs linked-list tree utils Click to show internal directories. Click to hide internal directories.