├── 0 - 1 Knapsack Problem - GFG ├── 0-1-knapsack-problem.cpp └── README.md ├── 0005-longest-palindromic-substring ├── 0005-longest-palindromic-substring.cpp ├── NOTES.md └── README.md ├── 000k-closest-points-to-origin └── README.md ├── 0070-climbing-stairs ├── 0070-climbing-stairs.cpp ├── NOTES.md └── README.md ├── 0082-remove-duplicates-from-sorted-list-ii ├── 0082-remove-duplicates-from-sorted-list-ii.cpp ├── NOTES.md └── README.md ├── 0086-partition-list ├── 0086-partition-list.cpp ├── NOTES.md └── README.md ├── 0095-unique-binary-search-trees-ii ├── 0095-unique-binary-search-trees-ii.cpp ├── NOTES.md └── README.md ├── 0096-unique-binary-search-trees ├── 0096-unique-binary-search-trees.cpp ├── NOTES.md └── README.md ├── 0099-recover-binary-search-tree ├── 0099-recover-binary-search-tree.cpp ├── NOTES.md └── README.md ├── 0116-populating-next-right-pointers-in-each-node ├── 0116-populating-next-right-pointers-in-each-node.cpp ├── NOTES.md └── README.md ├── 0117-populating-next-right-pointers-in-each-node-ii ├── 0117-populating-next-right-pointers-in-each-node-ii.cpp ├── NOTES.md └── README.md ├── 0118-pascals-triangle ├── NOTES.md └── README.md ├── 0119-pascals-triangle-ii ├── NOTES.md └── README.md ├── 0121-best-time-to-buy-and-sell-stock ├── 0121-best-time-to-buy-and-sell-stock.cpp ├── NOTES.md └── README.md ├── 0148-sort-list ├── 0148-sort-list.cpp ├── NOTES.md └── README.md ├── 0211-design-add-and-search-words-data-structure ├── 0211-design-add-and-search-words-data-structure.cpp ├── NOTES.md └── README.md ├── 0338-counting-bits ├── 0338-counting-bits.cpp ├── NOTES.md └── README.md ├── 0386-lexicographical-numbers ├── 0386-lexicographical-numbers.cpp ├── NOTES.md └── README.md ├── 0392-is-subsequence ├── NOTES.md └── README.md ├── 0419-battleships-in-a-board ├── 0419-battleships-in-a-board.cpp ├── NOTES.md └── README.md ├── 0429-n-ary-tree-level-order-traversal ├── 0429-n-ary-tree-level-order-traversal.cpp ├── NOTES.md └── README.md ├── 0438-find-all-anagrams-in-a-string ├── 0438-find-all-anagrams-in-a-string.cpp ├── NOTES.md └── README.md ├── 0445-add-two-numbers-ii ├── 0445-add-two-numbers-ii.cpp ├── NOTES.md └── README.md ├── 0449-serialize-and-deserialize-bst ├── 0449-serialize-and-deserialize-bst.cpp ├── NOTES.md └── README.md ├── 0450-delete-node-in-a-bst ├── 0450-delete-node-in-a-bst.cpp ├── NOTES.md └── README.md ├── 0508-most-frequent-subtree-sum ├── 0508-most-frequent-subtree-sum.cpp ├── NOTES.md └── README.md ├── 0509-fibonacci-number ├── 0509-fibonacci-number.cpp ├── NOTES.md └── README.md ├── 0623-add-one-row-to-tree ├── 0623-add-one-row-to-tree.cpp ├── NOTES.md └── README.md ├── 0652-find-duplicate-subtrees ├── 0652-find-duplicate-subtrees.cpp ├── NOTES.md └── README.md ├── 0701-insert-into-a-binary-search-tree ├── NOTES.md └── README.md ├── 0724-find-pivot-index ├── 0724-find-pivot-index.cpp ├── NOTES.md └── README.md ├── 0814-binary-tree-pruning ├── 0814-binary-tree-pruning.cpp ├── NOTES.md └── README.md ├── 0863-all-nodes-distance-k-in-binary-tree ├── 0863-all-nodes-distance-k-in-binary-tree.cpp ├── NOTES.md └── README.md ├── 0865-smallest-subtree-with-all-the-deepest-nodes ├── 0865-smallest-subtree-with-all-the-deepest-nodes.cpp ├── NOTES.md └── README.md ├── 0894-all-possible-full-binary-trees └── README.md ├── 0951-flip-equivalent-binary-trees ├── 0951-flip-equivalent-binary-trees.cpp ├── NOTES.md └── README.md ├── 0968-binary-tree-cameras ├── 0968-binary-tree-cameras.cpp ├── NOTES.md └── README.md ├── 0979-distribute-coins-in-binary-tree ├── 0979-distribute-coins-in-binary-tree.cpp ├── NOTES.md └── README.md ├── 0988-smallest-string-starting-from-leaf ├── NOTES.md └── README.md ├── 0990-satisfiability-of-equality-equations ├── 0990-satisfiability-of-equality-equations.cpp ├── NOTES.md └── README.md ├── 0add-two-numbers └── README.md ├── 0kth-largest-element-in-an-array └── README.md ├── 1-two-sum ├── 1-two-sum.cpp ├── NOTES.md └── README.md ├── 10-regular-expression-matching ├── 10-regular-expression-matching.cpp ├── NOTES.md └── README.md ├── 100-same-tree ├── 100-same-tree.cpp ├── NOTES.md └── README.md ├── 1009-complement-of-base-10-integer ├── 1009-complement-of-base-10-integer.cpp ├── NOTES.md └── README.md ├── 101-symmetric-tree ├── 101-symmetric-tree.cpp ├── NOTES.md └── README.md ├── 1019-next-greater-node-in-linked-list ├── 1019-next-greater-node-in-linked-list.cpp ├── NOTES.md └── README.md ├── 102-binary-tree-level-order-traversal ├── 102-binary-tree-level-order-traversal.cpp ├── NOTES.md └── README.md ├── 1022-sum-of-root-to-leaf-binary-numbers ├── 1022-sum-of-root-to-leaf-binary-numbers.cpp ├── NOTES.md └── README.md ├── 1026-maximum-difference-between-node-and-ancestor ├── 1026-maximum-difference-between-node-and-ancestor.cpp ├── NOTES.md └── README.md ├── 103-binary-tree-zigzag-level-order-traversal ├── 103-binary-tree-zigzag-level-order-traversal.cpp ├── NOTES.md └── README.md ├── 1030-matrix-cells-in-distance-order ├── 1030-matrix-cells-in-distance-order.cpp ├── NOTES.md └── README.md ├── 104-maximum-depth-of-binary-tree ├── 104-maximum-depth-of-binary-tree.cpp ├── NOTES.md └── README.md ├── 1043-partition-array-for-maximum-sum ├── 1043-partition-array-for-maximum-sum.cpp ├── NOTES.md └── README.md ├── 1046-last-stone-weight ├── 1046-last-stone-weight.cpp ├── NOTES.md └── README.md ├── 1047-remove-all-adjacent-duplicates-in-string ├── 1047-remove-all-adjacent-duplicates-in-string.cpp ├── NOTES.md └── README.md ├── 105-construct-binary-tree-from-preorder-and-inorder-traversal ├── 105-construct-binary-tree-from-preorder-and-inorder-traversal.cpp ├── NOTES.md └── README.md ├── 1054-distant-barcodes ├── 1054-distant-barcodes.cpp ├── NOTES.md └── README.md ├── 1056-confusing-number ├── 1056-confusing-number.cpp ├── NOTES.md └── README.md ├── 106-construct-binary-tree-from-inorder-and-postorder-traversal └── README.md ├── 1064-fixed-point ├── 1064-fixed-point.cpp ├── NOTES.md └── README.md ├── 1065-index-pairs-of-a-string ├── 1065-index-pairs-of-a-string.cpp ├── NOTES.md └── README.md ├── 107-binary-tree-level-order-traversal-ii └── README.md ├── 1071-greatest-common-divisor-of-strings ├── 1071-greatest-common-divisor-of-strings.cpp ├── NOTES.md └── README.md ├── 1079-letter-tile-possibilities ├── 1079-letter-tile-possibilities.cpp ├── NOTES.md └── README.md ├── 108-convert-sorted-array-to-binary-search-tree ├── 108-convert-sorted-array-to-binary-search-tree.cpp ├── NOTES.md └── README.md ├── 1080-insufficient-nodes-in-root-to-leaf-paths ├── 1080-insufficient-nodes-in-root-to-leaf-paths.cpp ├── NOTES.md └── README.md ├── 1085-sum-of-digits-in-the-minimum-number ├── 1085-sum-of-digits-in-the-minimum-number.cpp ├── NOTES.md └── README.md ├── 1086-high-five ├── 1086-high-five.cpp ├── NOTES.md └── README.md ├── 109-convert-sorted-list-to-binary-search-tree ├── 109-convert-sorted-list-to-binary-search-tree.cpp ├── NOTES.md └── README.md ├── 1094-car-pooling ├── 1094-car-pooling.cpp ├── NOTES.md └── README.md ├── 1099-two-sum-less-than-k ├── 1099-two-sum-less-than-k.cpp ├── NOTES.md └── README.md ├── 110-balanced-binary-tree ├── 110-balanced-binary-tree.cpp ├── NOTES.md └── README.md ├── 1100-find-k-length-substrings-with-no-repeated-characters ├── 1100-find-k-length-substrings-with-no-repeated-characters.cpp ├── NOTES.md └── README.md ├── 1104-path-in-zigzag-labelled-binary-tree ├── 1104-path-in-zigzag-labelled-binary-tree.cpp ├── NOTES.md └── README.md ├── 111-minimum-depth-of-binary-tree ├── 111-minimum-depth-of-binary-tree.cpp ├── NOTES.md └── README.md ├── 1119-remove-vowels-from-a-string ├── 1119-remove-vowels-from-a-string.cpp ├── NOTES.md └── README.md ├── 112-path-sum ├── 112-path-sum.cpp ├── NOTES.md └── README.md ├── 1123-lowest-common-ancestor-of-deepest-leaves ├── 1123-lowest-common-ancestor-of-deepest-leaves.cpp ├── NOTES.md └── README.md ├── 113-path-sum-ii ├── 113-path-sum-ii.cpp ├── NOTES.md └── README.md ├── 1133-largest-unique-number ├── 1133-largest-unique-number.cpp ├── NOTES.md └── README.md ├── 1134-armstrong-number ├── 1134-armstrong-number.cpp ├── NOTES.md └── README.md ├── 1137-n-th-tribonacci-number ├── 1137-n-th-tribonacci-number.cpp ├── NOTES.md └── README.md ├── 114-flatten-binary-tree-to-linked-list ├── 114-flatten-binary-tree-to-linked-list.cpp ├── NOTES.md └── README.md ├── 1140-stone-game-ii ├── 1140-stone-game-ii.cpp ├── NOTES.md └── README.md ├── 115-distinct-subsequences ├── 115-distinct-subsequences.cpp ├── NOTES.md └── README.md ├── 1150-check-if-a-number-is-majority-element-in-a-sorted-array ├── 1150-check-if-a-number-is-majority-element-in-a-sorted-array.cpp ├── NOTES.md └── README.md ├── 1154-day-of-the-year ├── 1154-day-of-the-year.cpp ├── NOTES.md └── README.md ├── 1161-maximum-level-sum-of-a-binary-tree ├── 1161-maximum-level-sum-of-a-binary-tree.cpp ├── NOTES.md └── README.md ├── 1165-single-row-keyboard ├── 1165-single-row-keyboard.cpp ├── NOTES.md └── README.md ├── 1171-remove-zero-sum-consecutive-nodes-from-linked-list ├── 1171-remove-zero-sum-consecutive-nodes-from-linked-list.cpp ├── NOTES.md └── README.md ├── 1176-diet-plan-performance ├── 1176-diet-plan-performance.cpp ├── NOTES.md └── README.md ├── 118-pascals-triangle ├── 118-pascals-triangle.cpp ├── NOTES.md └── README.md ├── 1180-count-substrings-with-only-one-distinct-letter ├── 1180-count-substrings-with-only-one-distinct-letter.cpp ├── NOTES.md └── README.md ├── 1196-how-many-apples-can-you-put-into-the-basket ├── 1196-how-many-apples-can-you-put-into-the-basket.cpp ├── NOTES.md └── README.md ├── 1198-find-smallest-common-element-in-all-rows ├── 1198-find-smallest-common-element-in-all-rows.cpp ├── NOTES.md └── README.md ├── 121-best-time-to-buy-and-sell-stock ├── 121-best-time-to-buy-and-sell-stock.cpp ├── NOTES.md └── README.md ├── 1213-intersection-of-three-sorted-arrays ├── 1213-intersection-of-three-sorted-arrays.cpp ├── NOTES.md └── README.md ├── 1214-two-sum-bsts ├── 1214-two-sum-bsts.cpp ├── NOTES.md └── README.md ├── 1218-longest-arithmetic-subsequence-of-given-difference ├── 1218-longest-arithmetic-subsequence-of-given-difference.cpp ├── NOTES.md └── README.md ├── 122-best-time-to-buy-and-sell-stock-ii ├── 122-best-time-to-buy-and-sell-stock-ii.cpp ├── NOTES.md └── README.md ├── 1228-missing-number-in-arithmetic-progression ├── 1228-missing-number-in-arithmetic-progression.cpp ├── NOTES.md └── README.md ├── 1243-array-transformation ├── 1243-array-transformation.cpp ├── NOTES.md └── README.md ├── 1245-tree-diameter ├── 1245-tree-diameter.cpp ├── NOTES.md └── README.md ├── 1249-minimum-remove-to-make-valid-parentheses ├── 1249-minimum-remove-to-make-valid-parentheses.cpp ├── NOTES.md └── README.md ├── 125-valid-palindrome ├── 125-valid-palindrome.cpp ├── NOTES.md └── README.md ├── 1256-encode-number ├── 1256-encode-number.cpp └── NOTES.md ├── 1261-find-elements-in-a-contaminated-binary-tree ├── 1261-find-elements-in-a-contaminated-binary-tree.cpp ├── NOTES.md └── README.md ├── 1265-print-immutable-linked-list-in-reverse ├── 1265-print-immutable-linked-list-in-reverse.cpp ├── NOTES.md └── README.md ├── 1276-number-of-burgers-with-no-waste-of-ingredients ├── 1276-number-of-burgers-with-no-waste-of-ingredients.java ├── NOTES.md └── README.md ├── 1281-subtract-the-product-and-sum-of-digits-of-an-integer ├── 1281-subtract-the-product-and-sum-of-digits-of-an-integer.cpp ├── NOTES.md └── README.md ├── 1286-iterator-for-combination ├── 1286-iterator-for-combination.cpp ├── NOTES.md └── README.md ├── 129-sum-root-to-leaf-numbers ├── 129-sum-root-to-leaf-numbers.cpp ├── NOTES.md └── README.md ├── 1290-convert-binary-number-in-a-linked-list-to-integer ├── 1290-convert-binary-number-in-a-linked-list-to-integer.cpp ├── NOTES.md └── README.md ├── 13-roman-to-integer ├── 13-roman-to-integer.cpp ├── NOTES.md └── README.md ├── 1302-deepest-leaves-sum ├── 1302-deepest-leaves-sum.cpp ├── NOTES.md └── README.md ├── 1305-all-elements-in-two-binary-search-trees ├── NOTES.md └── README.md ├── 1313-decompress-run-length-encoded-list ├── 1313-decompress-run-length-encoded-list.cpp ├── NOTES.md └── README.md ├── 1314-matrix-block-sum ├── 1314-matrix-block-sum.cpp ├── NOTES.md └── README.md ├── 1315-sum-of-nodes-with-even-valued-grandparent ├── 1315-sum-of-nodes-with-even-valued-grandparent.cpp ├── NOTES.md └── README.md ├── 1317-convert-integer-to-the-sum-of-two-no-zero-integers ├── 1317-convert-integer-to-the-sum-of-two-no-zero-integers.cpp ├── NOTES.md └── README.md ├── 1323-maximum-69-number ├── 1323-maximum-69-number.cpp ├── NOTES.md └── README.md ├── 1325-delete-leaves-with-a-given-value ├── 1325-delete-leaves-with-a-given-value.cpp ├── NOTES.md └── README.md ├── 133-clone-graph ├── 133-clone-graph.cpp ├── NOTES.md └── README.md ├── 1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance ├── 1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance.cpp ├── NOTES.md └── README.md ├── 1338-reduce-array-size-to-the-half ├── 1338-reduce-array-size-to-the-half.cpp ├── NOTES.md └── README.md ├── 1342-number-of-steps-to-reduce-a-number-to-zero ├── 1342-number-of-steps-to-reduce-a-number-to-zero.cpp ├── NOTES.md └── README.md ├── 1347-minimum-number-of-steps-to-make-two-strings-anagram ├── 1347-minimum-number-of-steps-to-make-two-strings-anagram.cpp ├── NOTES.md └── README.md ├── 1352-product-of-the-last-k-numbers ├── 1352-product-of-the-last-k-numbers.cpp ├── NOTES.md └── README.md ├── 136-single-number ├── 136-single-number.cpp ├── NOTES.md └── README.md ├── 1360-number-of-days-between-two-dates ├── 1360-number-of-days-between-two-dates.cpp ├── NOTES.md └── README.md ├── 1361-validate-binary-tree-nodes ├── NOTES.md └── README.md ├── 1367-linked-list-in-binary-tree ├── 1367-linked-list-in-binary-tree.cpp ├── NOTES.md └── README.md ├── 1372-longest-zigzag-path-in-a-binary-tree ├── 1372-longest-zigzag-path-in-a-binary-tree.cpp ├── NOTES.md └── README.md ├── 1376-time-needed-to-inform-all-employees ├── 1376-time-needed-to-inform-all-employees.cpp ├── NOTES.md └── README.md ├── 138-copy-list-with-random-pointer ├── 138-copy-list-with-random-pointer.cpp ├── NOTES.md └── README.md ├── 1381-design-a-stack-with-increment-operation ├── 1381-design-a-stack-with-increment-operation.cpp ├── NOTES.md └── README.md ├── 1382-balance-a-binary-search-tree ├── NOTES.md └── README.md ├── 1396-design-underground-system ├── 1396-design-underground-system.cpp ├── NOTES.md └── README.md ├── 1399-count-largest-group ├── 1399-count-largest-group.cpp └── NOTES.md ├── 14-longest-common-prefix ├── 14-longest-common-prefix.cpp ├── NOTES.md └── README.md ├── 140-word-break-ii ├── 140-word-break-ii.cpp ├── NOTES.md └── README.md ├── 1403-minimum-subsequence-in-non-increasing-order ├── 1403-minimum-subsequence-in-non-increasing-order.cpp ├── NOTES.md └── README.md ├── 1406-stone-game-iii ├── 1406-stone-game-iii.cpp ├── NOTES.md └── README.md ├── 141-linked-list-cycle ├── 141-linked-list-cycle.cpp ├── NOTES.md └── README.md ├── 1413-minimum-value-to-get-positive-step-by-step-sum ├── NOTES.md └── README.md ├── 1415-the-k-th-lexicographical-string-of-all-happy-strings-of-length-n ├── 1415-the-k-th-lexicographical-string-of-all-happy-strings-of-length-n.cpp ├── NOTES.md └── README.md ├── 1418-display-table-of-food-orders-in-a-restaurant ├── 1418-display-table-of-food-orders-in-a-restaurant.cpp ├── NOTES.md └── README.md ├── 142-linked-list-cycle-ii ├── 142-linked-list-cycle-ii.cpp ├── NOTES.md └── README.md ├── 1422-maximum-score-after-splitting-a-string ├── 1422-maximum-score-after-splitting-a-string.cpp ├── NOTES.md └── README.md ├── 1424-diagonal-traverse-ii ├── 1424-diagonal-traverse-ii.cpp ├── NOTES.md └── README.md ├── 1426-counting-elements ├── 1426-counting-elements.cpp ├── NOTES.md └── README.md ├── 1427-perform-string-shifts ├── 1427-perform-string-shifts.cpp ├── NOTES.md └── README.md ├── 143-reorder-list ├── 143-reorder-list.cpp ├── NOTES.md └── README.md ├── 1439-find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows ├── 1439-find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows.cpp ├── NOTES.md └── README.md ├── 144-binary-tree-preorder-traversal ├── 144-binary-tree-preorder-traversal.cpp ├── NOTES.md └── README.md ├── 1443-minimum-time-to-collect-all-apples-in-a-tree ├── 1443-minimum-time-to-collect-all-apples-in-a-tree.cpp ├── NOTES.md └── README.md ├── 1446-consecutive-characters ├── 1446-consecutive-characters.cpp ├── NOTES.md └── README.md ├── 1448-count-good-nodes-in-binary-tree ├── 1448-count-good-nodes-in-binary-tree.cpp ├── NOTES.md └── README.md ├── 145-binary-tree-postorder-traversal ├── 145-binary-tree-postorder-traversal.cpp ├── NOTES.md └── README.md ├── 1455-check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence ├── 1455-check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence.cpp ├── NOTES.md └── README.md ├── 1462-course-schedule-iv ├── 1462-course-schedule-iv.cpp ├── NOTES.md └── README.md ├── 1466-reorder-routes-to-make-all-paths-lead-to-the-city-zero ├── 1466-reorder-routes-to-make-all-paths-lead-to-the-city-zero.cpp ├── NOTES.md └── README.md ├── 1469-find-all-the-lonely-nodes ├── 1469-find-all-the-lonely-nodes.cpp ├── NOTES.md └── README.md ├── 147-insertion-sort-list ├── 147-insertion-sort-list.cpp ├── NOTES.md └── README.md ├── 148-sort-list ├── 148-sort-list.cpp ├── NOTES.md └── README.md ├── 1480-running-sum-of-1d-array ├── NOTES.md └── README.md ├── 1485-clone-binary-tree-with-random-pointer ├── 1485-clone-binary-tree-with-random-pointer.cpp ├── NOTES.md └── README.md ├── 1490-clone-n-ary-tree ├── 1490-clone-n-ary-tree.cpp ├── NOTES.md └── README.md ├── 1496-path-crossing ├── 1496-path-crossing.cpp ├── NOTES.md └── README.md ├── 150-evaluate-reverse-polish-notation ├── 150-evaluate-reverse-polish-notation.cpp ├── NOTES.md └── README.md ├── 1507-reformat-date ├── 1507-reformat-date.cpp ├── NOTES.md └── README.md ├── 1514-path-with-maximum-probability ├── 1514-path-with-maximum-probability.cpp ├── NOTES.md └── README.md ├── 1518-water-bottles ├── 1518-water-bottles.cpp ├── NOTES.md └── README.md ├── 152-maximum-product-subarray ├── 152-maximum-product-subarray.cpp ├── NOTES.md └── README.md ├── 1522-diameter-of-n-ary-tree ├── 1522-diameter-of-n-ary-tree.cpp ├── NOTES.md └── README.md ├── 1523-count-odd-numbers-in-an-interval-range ├── 1523-count-odd-numbers-in-an-interval-range.cpp ├── NOTES.md └── README.md ├── 1525-number-of-good-ways-to-split-a-string ├── 1525-number-of-good-ways-to-split-a-string.cpp └── NOTES.md ├── 1529-minimum-suffix-flips ├── 1529-minimum-suffix-flips.cpp ├── NOTES.md └── README.md ├── 1530-number-of-good-leaf-nodes-pairs ├── 1530-number-of-good-leaf-nodes-pairs.cpp ├── NOTES.md └── README.md ├── 1541-minimum-insertions-to-balance-a-parentheses-string ├── 1541-minimum-insertions-to-balance-a-parentheses-string.cpp ├── NOTES.md └── README.md ├── 1544-make-the-string-great ├── 1544-make-the-string-great.cpp ├── NOTES.md └── README.md ├── 155-min-stack ├── 155-min-stack.cpp ├── NOTES.md └── README.md ├── 1551-minimum-operations-to-make-array-equal ├── 1551-minimum-operations-to-make-array-equal.cpp ├── NOTES.md └── README.md ├── 1556-thousand-separator ├── 1556-thousand-separator.cpp ├── NOTES.md └── README.md ├── 1557-minimum-number-of-vertices-to-reach-all-nodes ├── 1557-minimum-number-of-vertices-to-reach-all-nodes.cpp ├── NOTES.md └── README.md ├── 1559-detect-cycles-in-2d-grid ├── 1559-detect-cycles-in-2d-grid.cpp ├── NOTES.md └── README.md ├── 1566-detect-pattern-of-length-m-repeated-k-or-more-times ├── 1566-detect-pattern-of-length-m-repeated-k-or-more-times.cpp ├── NOTES.md └── README.md ├── 1567-maximum-length-of-subarray-with-positive-product ├── 1567-maximum-length-of-subarray-with-positive-product.cpp └── README.md ├── 1570-dot-product-of-two-sparse-vectors ├── 1570-dot-product-of-two-sparse-vectors.cpp ├── NOTES.md └── README.md ├── 1576-replace-all-s-to-avoid-consecutive-repeating-characters ├── 1576-replace-all-s-to-avoid-consecutive-repeating-characters.cpp ├── NOTES.md └── README.md ├── 1578-minimum-time-to-make-rope-colorful ├── 1578-minimum-time-to-make-rope-colorful.cpp ├── NOTES.md └── README.md ├── 1588-sum-of-all-odd-length-subarrays ├── 1588-sum-of-all-odd-length-subarrays.cpp ├── NOTES.md └── README.md ├── 1592-rearrange-spaces-between-words ├── 1592-rearrange-spaces-between-words.cpp ├── NOTES.md └── README.md ├── 1598-crawler-log-folder ├── 1598-crawler-log-folder.cpp ├── NOTES.md └── README.md ├── 16-3sum-closest ├── 16-3sum-closest.cpp ├── NOTES.md └── README.md ├── 160-intersection-of-two-linked-lists ├── 160-intersection-of-two-linked-lists.cpp ├── NOTES.md └── README.md ├── 1602-find-nearest-right-node-in-binary-tree ├── 1602-find-nearest-right-node-in-binary-tree.cpp ├── NOTES.md └── README.md ├── 1603-design-parking-system ├── 1603-design-parking-system.cpp ├── NOTES.md └── README.md ├── 1609-even-odd-tree ├── 1609-even-odd-tree.cpp ├── NOTES.md └── README.md ├── 1614-maximum-nesting-depth-of-the-parentheses ├── 1614-maximum-nesting-depth-of-the-parentheses.cpp ├── NOTES.md └── README.md ├── 1624-largest-substring-between-two-equal-characters ├── 1624-largest-substring-between-two-equal-characters.cpp ├── NOTES.md └── README.md ├── 1628-design-an-expression-tree-with-evaluate-function ├── 1628-design-an-expression-tree-with-evaluate-function.cpp ├── NOTES.md └── README.md ├── 1630-arithmetic-subarrays ├── 1630-arithmetic-subarrays.cpp ├── NOTES.md └── README.md ├── 1631-path-with-minimum-effort ├── 1631-path-with-minimum-effort.cpp ├── NOTES.md └── README.md ├── 1642-furthest-building-you-can-reach ├── 1642-furthest-building-you-can-reach.cpp ├── 1642-furthest-building-you-can-reach.java ├── NOTES.md └── README.md ├── 1644-lowest-common-ancestor-of-a-binary-tree-ii ├── 1644-lowest-common-ancestor-of-a-binary-tree-ii.cpp ├── NOTES.md └── README.md ├── 1650-lowest-common-ancestor-of-a-binary-tree-iii ├── 1650-lowest-common-ancestor-of-a-binary-tree-iii.cpp ├── NOTES.md └── README.md ├── 1656-design-an-ordered-stream ├── 1656-design-an-ordered-stream.cpp ├── NOTES.md └── README.md ├── 1660-correct-a-binary-tree ├── 1660-correct-a-binary-tree.cpp ├── NOTES.md └── README.md ├── 1664-ways-to-make-a-fair-array ├── 1664-ways-to-make-a-fair-array.cpp ├── NOTES.md └── README.md ├── 1668-maximum-repeating-substring ├── 1668-maximum-repeating-substring.cpp ├── NOTES.md └── README.md ├── 1669-merge-in-between-linked-lists ├── 1669-merge-in-between-linked-lists.cpp ├── NOTES.md └── README.md ├── 1676-lowest-common-ancestor-of-a-binary-tree-iv ├── 1676-lowest-common-ancestor-of-a-binary-tree-iv.cpp ├── NOTES.md └── README.md ├── 168-excel-sheet-column-title ├── 168-excel-sheet-column-title.cpp ├── NOTES.md └── README.md ├── 1686-stone-game-vi ├── 1686-stone-game-vi.cpp ├── NOTES.md └── README.md ├── 1688-count-of-matches-in-tournament ├── 1688-count-of-matches-in-tournament.cpp ├── NOTES.md └── README.md ├── 1689-partitioning-into-minimum-number-of-deci-binary-numbers ├── 1689-partitioning-into-minimum-number-of-deci-binary-numbers.cpp ├── NOTES.md └── README.md ├── 169-majority-element ├── 169-majority-element.cpp ├── NOTES.md └── README.md ├── 1694-reformat-phone-number ├── 1694-reformat-phone-number.cpp ├── NOTES.md └── README.md ├── 170-two-sum-iii-data-structure-design ├── 170-two-sum-iii-data-structure-design.cpp ├── NOTES.md └── README.md ├── 1705-maximum-number-of-eaten-apples ├── 1705-maximum-number-of-eaten-apples.cpp ├── NOTES.md └── README.md ├── 1708-largest-subarray-length-k ├── 1708-largest-subarray-length-k.cpp ├── NOTES.md └── README.md ├── 1716-calculate-money-in-leetcode-bank ├── 1716-calculate-money-in-leetcode-bank.cpp ├── NOTES.md └── README.md ├── 1720-decode-xored-array ├── 1720-decode-xored-array.cpp ├── NOTES.md └── README.md ├── 1721-swapping-nodes-in-a-linked-list ├── 1721-swapping-nodes-in-a-linked-list.cpp ├── NOTES.md └── README.md ├── 1725-number-of-rectangles-that-can-form-the-largest-square ├── 1725-number-of-rectangles-that-can-form-the-largest-square.cpp ├── NOTES.md └── README.md ├── 173-binary-search-tree-iterator ├── 173-binary-search-tree-iterator.cpp ├── NOTES.md └── README.md ├── 1732-find-the-highest-altitude ├── 1732-find-the-highest-altitude.cpp ├── NOTES.md └── README.md ├── 1736-latest-time-by-replacing-hidden-digits ├── 1736-latest-time-by-replacing-hidden-digits.cpp ├── NOTES.md └── README.md ├── 1738-find-kth-largest-xor-coordinate-value ├── 1738-find-kth-largest-xor-coordinate-value.cpp ├── NOTES.md └── README.md ├── 1740-find-distance-in-a-binary-tree ├── 1740-find-distance-in-a-binary-tree.cpp ├── NOTES.md └── README.md ├── 175-combine-two-tables ├── 175-combine-two-tables.sql └── README.md ├── 1753-maximum-score-from-removing-stones ├── 1753-maximum-score-from-removing-stones.cpp ├── NOTES.md └── README.md ├── 1756-design-most-recently-used-queue ├── 1756-design-most-recently-used-queue.cpp ├── NOTES.md └── README.md ├── 1762-buildings-with-an-ocean-view ├── 1762-buildings-with-an-ocean-view.cpp ├── NOTES.md └── README.md ├── 1763-longest-nice-substring ├── 1763-longest-nice-substring.cpp ├── NOTES.md └── README.md ├── 1769-minimum-number-of-operations-to-move-all-balls-to-each-box ├── 1769-minimum-number-of-operations-to-move-all-balls-to-each-box.cpp ├── NOTES.md └── README.md ├── 1772-sort-features-by-popularity ├── 1772-sort-features-by-popularity.cpp ├── NOTES.md └── README.md ├── 1784-check-if-binary-string-has-at-most-one-segment-of-ones ├── 1784-check-if-binary-string-has-at-most-one-segment-of-ones.cpp ├── NOTES.md └── README.md ├── 1786-number-of-restricted-paths-from-first-to-last-node ├── NOTES.md └── README.md ├── 1791-find-center-of-star-graph ├── 1791-find-center-of-star-graph.cpp ├── NOTES.md └── README.md ├── 1796-second-largest-digit-in-a-string ├── 1796-second-largest-digit-in-a-string.cpp ├── NOTES.md └── README.md ├── 1800-maximum-ascending-subarray-sum ├── 1800-maximum-ascending-subarray-sum.cpp ├── NOTES.md └── README.md ├── 1805-number-of-different-integers-in-a-string ├── 1805-number-of-different-integers-in-a-string.cpp ├── NOTES.md └── README.md ├── 181-employees-earning-more-than-their-managers ├── 181-employees-earning-more-than-their-managers.sql ├── NOTES.md └── README.md ├── 182-duplicate-emails ├── 182-duplicate-emails.sql ├── NOTES.md └── README.md ├── 1822-sign-of-the-product-of-an-array ├── 1822-sign-of-the-product-of-an-array.cpp ├── NOTES.md └── README.md ├── 1826-faulty-sensor ├── 1826-faulty-sensor.cpp ├── NOTES.md └── README.md ├── 1827-minimum-operations-to-make-the-array-increasing ├── 1827-minimum-operations-to-make-the-array-increasing.cpp ├── NOTES.md └── README.md ├── 183-customers-who-never-order ├── 183-customers-who-never-order.sql ├── NOTES.md └── README.md ├── 1837-sum-of-digits-in-base-k ├── 1837-sum-of-digits-in-base-k.cpp ├── NOTES.md └── README.md ├── 1845-seat-reservation-manager ├── 1845-seat-reservation-manager.cpp ├── NOTES.md └── README.md ├── 1850-minimum-adjacent-swaps-to-reach-the-kth-smallest-number ├── 1850-minimum-adjacent-swaps-to-reach-the-kth-smallest-number.cpp ├── NOTES.md └── README.md ├── 1852-distinct-numbers-in-each-subarray ├── 1852-distinct-numbers-in-each-subarray.cpp ├── NOTES.md └── README.md ├── 1863-sum-of-all-subset-xor-totals ├── 1863-sum-of-all-subset-xor-totals.cpp ├── NOTES.md └── README.md ├── 1874-minimize-product-sum-of-two-arrays ├── 1874-minimize-product-sum-of-two-arrays.cpp ├── NOTES.md └── README.md ├── 1884-egg-drop-with-2-eggs-and-n-floors ├── 1884-egg-drop-with-2-eggs-and-n-floors.cpp ├── NOTES.md └── README.md ├── 1893-check-if-all-the-integers-in-a-range-are-covered ├── 1893-check-if-all-the-integers-in-a-range-are-covered.cpp ├── NOTES.md └── README.md ├── 1897-redistribute-characters-to-make-all-strings-equal ├── 1897-redistribute-characters-to-make-all-strings-equal.cpp ├── NOTES.md └── README.md ├── 19-remove-nth-node-from-end-of-list ├── 19-remove-nth-node-from-end-of-list.cpp ├── NOTES.md └── README.md ├── 1901-find-a-peak-element-ii ├── 1901-find-a-peak-element-ii.cpp ├── NOTES.md └── README.md ├── 1903-largest-odd-number-in-string ├── 1903-largest-odd-number-in-string.cpp ├── NOTES.md └── README.md ├── 191-number-of-1-bits ├── 191-number-of-1-bits.cpp ├── NOTES.md └── README.md ├── 1910-remove-all-occurrences-of-a-substring ├── 1910-remove-all-occurrences-of-a-substring.cpp ├── NOTES.md └── README.md ├── 1913-maximum-product-difference-between-two-pairs ├── 1913-maximum-product-difference-between-two-pairs.cpp ├── NOTES.md └── README.md ├── 1920-build-array-from-permutation ├── 1920-build-array-from-permutation.cpp ├── NOTES.md └── README.md ├── 1925-count-square-sum-triples ├── 1925-count-square-sum-triples.cpp ├── NOTES.md └── README.md ├── 1929-concatenation-of-array ├── 1929-concatenation-of-array.cpp ├── NOTES.md └── README.md ├── 1933-check-if-string-is-decomposable-into-value-equal-substrings ├── 1933-check-if-string-is-decomposable-into-value-equal-substrings.cpp ├── NOTES.md └── README.md ├── 1935-maximum-number-of-words-you-can-type ├── 1935-maximum-number-of-words-you-can-type.cpp ├── NOTES.md └── README.md ├── 1940-longest-common-subsequence-between-sorted-arrays ├── 1940-longest-common-subsequence-between-sorted-arrays.cpp ├── NOTES.md └── README.md ├── 1941-check-if-all-characters-have-equal-number-of-occurrences ├── 1941-check-if-all-characters-have-equal-number-of-occurrences.cpp ├── NOTES.md └── README.md ├── 1945-sum-of-digits-of-string-after-convert ├── 1945-sum-of-digits-of-string-after-convert.cpp ├── NOTES.md └── README.md ├── 1952-three-divisors ├── 1952-three-divisors.cpp ├── NOTES.md └── README.md ├── 1957-delete-characters-to-make-fancy-string ├── 1957-delete-characters-to-make-fancy-string.cpp ├── NOTES.md └── README.md ├── 196-delete-duplicate-emails ├── 196-delete-duplicate-emails.sql ├── NOTES.md └── README.md ├── 1961-check-if-string-is-a-prefix-of-array ├── 1961-check-if-string-is-a-prefix-of-array.cpp ├── NOTES.md └── README.md ├── 1962-remove-stones-to-minimize-the-total ├── 1962-remove-stones-to-minimize-the-total.cpp ├── NOTES.md └── README.md ├── 1963-minimum-number-of-swaps-to-make-the-string-balanced ├── 1963-minimum-number-of-swaps-to-make-the-string-balanced.cpp ├── NOTES.md └── README.md ├── 1967-number-of-strings-that-appear-as-substrings-in-word ├── 1967-number-of-strings-that-appear-as-substrings-in-word.cpp ├── NOTES.md └── README.md ├── 1971-find-if-path-exists-in-graph ├── 1971-find-if-path-exists-in-graph.cpp ├── NOTES.md └── README.md ├── 1973-count-nodes-equal-to-sum-of-descendants ├── 1973-count-nodes-equal-to-sum-of-descendants.cpp ├── NOTES.md └── README.md ├── 1974-minimum-time-to-type-word-using-special-typewriter ├── 1974-minimum-time-to-type-word-using-special-typewriter.cpp ├── NOTES.md └── README.md ├── 1976-number-of-ways-to-arrive-at-destination ├── 1976-number-of-ways-to-arrive-at-destination.cpp ├── NOTES.md └── README.md ├── 1979-find-greatest-common-divisor-of-array ├── 1979-find-greatest-common-divisor-of-array.cpp ├── NOTES.md └── README.md ├── 1984-minimum-difference-between-highest-and-lowest-of-k-scores ├── 1984-minimum-difference-between-highest-and-lowest-of-k-scores.cpp ├── NOTES.md └── README.md ├── 1985-find-the-kth-largest-integer-in-the-array ├── 1985-find-the-kth-largest-integer-in-the-array.cpp ├── NOTES.md └── README.md ├── 199-binary-tree-right-side-view ├── NOTES.md └── README.md ├── 1991-find-the-middle-index-in-array ├── 1991-find-the-middle-index-in-array.cpp ├── NOTES.md └── README.md ├── 2-add-two-numbers ├── 2-add-two-numbers.cpp ├── NOTES.md └── README.md ├── 20-valid-parentheses ├── 20-valid-parentheses.cpp ├── NOTES.md └── README.md ├── 2000-reverse-prefix-of-word ├── 2000-reverse-prefix-of-word.cpp ├── NOTES.md └── README.md ├── 2006-count-number-of-pairs-with-absolute-difference-k ├── 2006-count-number-of-pairs-with-absolute-difference-k.cpp ├── NOTES.md └── README.md ├── 2011-final-value-of-variable-after-performing-operations ├── 2011-final-value-of-variable-after-performing-operations.cpp ├── NOTES.md └── README.md ├── 2016-maximum-difference-between-increasing-elements ├── 2016-maximum-difference-between-increasing-elements.cpp ├── NOTES.md └── README.md ├── 202-happy-number ├── NOTES.md └── README.md ├── 2022-convert-1d-array-into-2d-array ├── 2022-convert-1d-array-into-2d-array.cpp ├── NOTES.md └── README.md ├── 2023-number-of-pairs-of-strings-with-concatenation-equal-to-target ├── 2023-number-of-pairs-of-strings-with-concatenation-equal-to-target.cpp ├── NOTES.md └── README.md ├── 2027-minimum-moves-to-convert-string ├── 2027-minimum-moves-to-convert-string.cpp ├── NOTES.md └── README.md ├── 203-remove-linked-list-elements ├── 203-remove-linked-list-elements.cpp ├── NOTES.md └── README.md ├── 2032-two-out-of-three ├── 2032-two-out-of-three.cpp ├── NOTES.md └── README.md ├── 2033-minimum-operations-to-make-a-uni-value-grid ├── 2033-minimum-operations-to-make-a-uni-value-grid.cpp ├── NOTES.md └── README.md ├── 2037-minimum-number-of-moves-to-seat-everyone ├── 2037-minimum-number-of-moves-to-seat-everyone.cpp ├── NOTES.md └── README.md ├── 2042-check-if-numbers-are-ascending-in-a-sentence ├── 2042-check-if-numbers-are-ascending-in-a-sentence.cpp ├── NOTES.md └── README.md ├── 2047-number-of-valid-words-in-a-sentence ├── 2047-number-of-valid-words-in-a-sentence.cpp ├── NOTES.md └── README.md ├── 2049-count-nodes-with-the-highest-score ├── 2049-count-nodes-with-the-highest-score.cpp ├── NOTES.md └── README.md ├── 2053-kth-distinct-string-in-an-array ├── 2053-kth-distinct-string-in-an-array.cpp ├── NOTES.md └── README.md ├── 2057-smallest-index-with-equal-value ├── 2057-smallest-index-with-equal-value.cpp ├── NOTES.md └── README.md ├── 206-reverse-linked-list ├── 206-reverse-linked-list.cpp ├── NOTES.md └── README.md ├── 2062-count-vowel-substrings-of-a-string ├── 2062-count-vowel-substrings-of-a-string.cpp ├── NOTES.md └── README.md ├── 2068-check-whether-two-strings-are-almost-equivalent ├── 2068-check-whether-two-strings-are-almost-equivalent.cpp ├── NOTES.md └── README.md ├── 207-course-schedule ├── 207-course-schedule.cpp ├── NOTES.md └── README.md ├── 2073-time-needed-to-buy-tickets ├── 2073-time-needed-to-buy-tickets.cpp ├── NOTES.md └── README.md ├── 2074-reverse-nodes-in-even-length-groups ├── 2074-reverse-nodes-in-even-length-groups.cpp ├── NOTES.md └── README.md ├── 2078-two-furthest-houses-with-different-colors ├── 2078-two-furthest-houses-with-different-colors.cpp ├── NOTES.md └── README.md ├── 2083-substrings-that-begin-and-end-with-the-same-letter ├── 2083-substrings-that-begin-and-end-with-the-same-letter.cpp ├── NOTES.md └── README.md ├── 2085-count-common-words-with-one-occurrence ├── 2085-count-common-words-with-one-occurrence.cpp ├── NOTES.md └── README.md ├── 2089-find-target-indices-after-sorting-array ├── 2089-find-target-indices-after-sorting-array.cpp ├── NOTES.md └── README.md ├── 209-minimum-size-subarray-sum ├── 209-minimum-size-subarray-sum.cpp ├── NOTES.md └── README.md ├── 2095-delete-the-middle-node-of-a-linked-list ├── 2095-delete-the-middle-node-of-a-linked-list.cpp ├── NOTES.md └── README.md ├── 2099-find-subsequence-of-length-k-with-the-largest-sum ├── 2099-find-subsequence-of-length-k-with-the-largest-sum.cpp ├── NOTES.md └── README.md ├── 21-merge-two-sorted-lists ├── 21-merge-two-sorted-lists.cpp ├── NOTES.md └── README.md ├── 210-course-schedule-ii ├── 210-course-schedule-ii.cpp ├── NOTES.md └── README.md ├── 2101-detonate-the-maximum-bombs ├── 2101-detonate-the-maximum-bombs.cpp ├── NOTES.md └── README.md ├── 2103-rings-and-rods ├── 2103-rings-and-rods.cpp ├── NOTES.md └── README.md ├── 2108-find-first-palindromic-string-in-the-array ├── 2108-find-first-palindromic-string-in-the-array.cpp ├── NOTES.md └── README.md ├── 2119-a-number-after-a-double-reversal ├── 2119-a-number-after-a-double-reversal.cpp ├── NOTES.md └── README.md ├── 2120-execution-of-all-suffix-instructions-staying-in-a-grid ├── 2120-execution-of-all-suffix-instructions-staying-in-a-grid.cpp ├── NOTES.md └── README.md ├── 2124-check-if-all-as-appears-before-all-bs ├── 2124-check-if-all-as-appears-before-all-bs.cpp ├── NOTES.md └── README.md ├── 2125-number-of-laser-beams-in-a-bank ├── 2125-number-of-laser-beams-in-a-bank.cpp ├── NOTES.md └── README.md ├── 2128-remove-all-ones-with-row-and-column-flips ├── 2128-remove-all-ones-with-row-and-column-flips.cpp ├── NOTES.md └── README.md ├── 2129-capitalize-the-title ├── 2129-capitalize-the-title.cpp ├── NOTES.md └── README.md ├── 2130-maximum-twin-sum-of-a-linked-list ├── 2130-maximum-twin-sum-of-a-linked-list.cpp ├── NOTES.md └── README.md ├── 2133-check-if-every-row-and-column-contains-all-numbers ├── 2133-check-if-every-row-and-column-contains-all-numbers.cpp ├── NOTES.md └── README.md ├── 2138-divide-a-string-into-groups-of-size-k ├── 2138-divide-a-string-into-groups-of-size-k.cpp ├── NOTES.md └── README.md ├── 2144-minimum-cost-of-buying-candies-with-discount ├── 2144-minimum-cost-of-buying-candies-with-discount.cpp ├── NOTES.md └── README.md ├── 2148-count-elements-with-strictly-smaller-and-greater-elements ├── 2148-count-elements-with-strictly-smaller-and-greater-elements.cpp ├── NOTES.md └── README.md ├── 2149-rearrange-array-elements-by-sign ├── 2149-rearrange-array-elements-by-sign.cpp ├── NOTES.md └── README.md ├── 215-kth-largest-element-in-an-array ├── 215-kth-largest-element-in-an-array.cpp ├── NOTES.md └── README.md ├── 2154-keep-multiplying-found-values-by-two ├── 2154-keep-multiplying-found-values-by-two.cpp ├── NOTES.md └── README.md ├── 2160-minimum-sum-of-four-digit-number-after-splitting-digits ├── 2160-minimum-sum-of-four-digit-number-after-splitting-digits.cpp ├── NOTES.md └── README.md ├── 2164-sort-even-and-odd-indices-independently ├── 2164-sort-even-and-odd-indices-independently.cpp ├── NOTES.md └── README.md ├── 2169-count-operations-to-obtain-zero ├── 2169-count-operations-to-obtain-zero.cpp ├── NOTES.md └── README.md ├── 217-contains-duplicate ├── 217-contains-duplicate.cpp ├── NOTES.md └── README.md ├── 2192-all-ancestors-of-a-node-in-a-directed-acyclic-graph ├── 2192-all-ancestors-of-a-node-in-a-directed-acyclic-graph.cpp ├── NOTES.md └── README.md ├── 2196-create-binary-tree-from-descriptions ├── 2196-create-binary-tree-from-descriptions.cpp ├── NOTES.md └── README.md ├── 22-generate-parentheses ├── 22-generate-parentheses.cpp ├── NOTES.md └── README.md ├── 222-count-complete-tree-nodes ├── 222-count-complete-tree-nodes.cpp ├── NOTES.md └── README.md ├── 225-implement-stack-using-queues ├── 225-implement-stack-using-queues.cpp ├── NOTES.md └── README.md ├── 226-invert-binary-tree ├── 226-invert-binary-tree.cpp ├── NOTES.md └── README.md ├── 2265-count-nodes-equal-to-average-of-subtree ├── 2265-count-nodes-equal-to-average-of-subtree.cpp ├── NOTES.md └── README.md ├── 227-basic-calculator-ii ├── 227-basic-calculator-ii.cpp ├── NOTES.md └── README.md ├── 2285-maximum-total-importance-of-roads ├── 2285-maximum-total-importance-of-roads.cpp ├── NOTES.md └── README.md ├── 23-merge-k-sorted-lists ├── 23-merge-k-sorted-lists.cpp ├── NOTES.md └── README.md ├── 230-kth-smallest-element-in-a-bst ├── 230-kth-smallest-element-in-a-bst.cpp ├── NOTES.md └── README.md ├── 231-power-of-two ├── 231-power-of-two.cpp ├── NOTES.md └── README.md ├── 2316-count-unreachable-pairs-of-nodes-in-an-undirected-graph ├── 2316-count-unreachable-pairs-of-nodes-in-an-undirected-graph.cpp ├── NOTES.md └── README.md ├── 232-implement-queue-using-stacks ├── 232-implement-queue-using-stacks.cpp ├── NOTES.md └── README.md ├── 2328-number-of-increasing-paths-in-a-grid ├── 2328-number-of-increasing-paths-in-a-grid.cpp ├── NOTES.md └── README.md ├── 234-palindrome-linked-list ├── 234-palindrome-linked-list.cpp ├── NOTES.md └── README.md ├── 235-lowest-common-ancestor-of-a-binary-search-tree ├── 235-lowest-common-ancestor-of-a-binary-search-tree.cpp ├── NOTES.md └── README.md ├── 2351-first-letter-to-appear-twice ├── 2351-first-letter-to-appear-twice.cpp ├── NOTES.md └── README.md ├── 2359-find-closest-node-to-given-two-nodes ├── 2359-find-closest-node-to-given-two-nodes.cpp ├── NOTES.md └── README.md ├── 236-lowest-common-ancestor-of-a-binary-tree ├── 236-lowest-common-ancestor-of-a-binary-tree.cpp ├── NOTES.md └── README.md ├── 2368-reachable-nodes-with-restrictions ├── 2368-reachable-nodes-with-restrictions.cpp ├── NOTES.md └── README.md ├── 237-delete-node-in-a-linked-list ├── 237-delete-node-in-a-linked-list.cpp ├── NOTES.md └── README.md ├── 2374-node-with-highest-edge-score ├── 2374-node-with-highest-edge-score.cpp ├── NOTES.md └── README.md ├── 2385-amount-of-time-for-binary-tree-to-be-infected ├── 2385-amount-of-time-for-binary-tree-to-be-infected.cpp ├── NOTES.md └── README.md ├── 239-sliding-window-maximum ├── 239-sliding-window-maximum.cpp ├── NOTES.md └── README.md ├── 2390-removing-stars-from-a-string ├── NOTES.md └── README.md ├── 24-swap-nodes-in-pairs ├── 24-swap-nodes-in-pairs.cpp ├── NOTES.md └── README.md ├── 2404-most-frequent-even-element ├── 2404-most-frequent-even-element.cpp ├── NOTES.md └── README.md ├── 2415-reverse-odd-levels-of-binary-tree ├── 2415-reverse-odd-levels-of-binary-tree.cpp ├── NOTES.md └── README.md ├── 242-valid-anagram ├── 242-valid-anagram.cpp ├── NOTES.md └── README.md ├── 243-shortest-word-distance ├── 243-shortest-word-distance.cpp ├── NOTES.md └── README.md ├── 246-strobogrammatic-number ├── 246-strobogrammatic-number.cpp ├── NOTES.md └── README.md ├── 249-group-shifted-strings ├── 249-group-shifted-strings.cpp ├── NOTES.md └── README.md ├── 25-reverse-nodes-in-k-group ├── 25-reverse-nodes-in-k-group.cpp ├── NOTES.md └── README.md ├── 252-meeting-rooms ├── 252-meeting-rooms.cpp ├── NOTES.md └── README.md ├── 257-binary-tree-paths ├── 257-binary-tree-paths.cpp ├── NOTES.md └── README.md ├── 258-add-digits ├── 258-add-digits.cpp ├── NOTES.md └── README.md ├── 263-ugly-number ├── 263-ugly-number.cpp ├── NOTES.md └── README.md ├── 266-palindrome-permutation ├── 266-palindrome-permutation.cpp ├── NOTES.md └── README.md ├── 268-missing-number ├── 268-missing-number.cpp ├── NOTES.md └── README.md ├── 27-remove-element ├── 27-remove-element.cpp ├── NOTES.md └── README.md ├── 270-closest-binary-search-tree-value ├── 270-closest-binary-search-tree-value.cpp ├── NOTES.md └── README.md ├── 283-move-zeroes ├── 283-move-zeroes.cpp └── NOTES.md ├── 290-word-pattern ├── 290-word-pattern.cpp ├── NOTES.md └── README.md ├── 297-serialize-and-deserialize-binary-tree ├── 297-serialize-and-deserialize-binary-tree.cpp └── NOTES.md ├── 3-longest-substring-without-repeating-characters ├── 3-longest-substring-without-repeating-characters.cpp ├── NOTES.md └── README.md ├── 31-next-permutation ├── 31-next-permutation.cpp ├── NOTES.md └── README.md ├── 310-minimum-height-trees ├── 310-minimum-height-trees.cpp ├── NOTES.md └── README.md ├── 314-binary-tree-vertical-order-traversal ├── 314-binary-tree-vertical-order-traversal.cpp ├── NOTES.md └── README.md ├── 326-power-of-three ├── 326-power-of-three.cpp ├── NOTES.md └── README.md ├── 328-odd-even-linked-list ├── 328-odd-even-linked-list.cpp ├── NOTES.md └── README.md ├── 329-longest-increasing-path-in-a-matrix ├── 329-longest-increasing-path-in-a-matrix.cpp ├── NOTES.md └── README.md ├── 331-verify-preorder-serialization-of-a-binary-tree ├── 331-verify-preorder-serialization-of-a-binary-tree.cpp ├── NOTES.md └── README.md ├── 338-counting-bits ├── 338-counting-bits.cpp ├── NOTES.md └── README.md ├── 339-nested-list-weight-sum ├── 339-nested-list-weight-sum.cpp ├── NOTES.md └── README.md ├── 342-power-of-four ├── 342-power-of-four.cpp ├── NOTES.md └── README.md ├── 344-reverse-string ├── 344-reverse-string.cpp ├── NOTES.md └── README.md ├── 345-reverse-vowels-of-a-string ├── 345-reverse-vowels-of-a-string.cpp ├── NOTES.md └── README.md ├── 346-moving-average-from-data-stream ├── 346-moving-average-from-data-stream.cpp ├── NOTES.md └── README.md ├── 347-top-k-frequent-elements ├── NOTES.md └── README.md ├── 350-intersection-of-two-arrays-ii ├── 350-intersection-of-two-arrays-ii.cpp ├── NOTES.md └── README.md ├── 359-logger-rate-limiter ├── 359-logger-rate-limiter.cpp ├── NOTES.md └── README.md ├── 366-find-leaves-of-binary-tree ├── 366-find-leaves-of-binary-tree.cpp ├── NOTES.md └── README.md ├── 367-valid-perfect-square ├── 367-valid-perfect-square.cpp ├── NOTES.md └── README.md ├── 37-sudoku-solver ├── 37-sudoku-solver.cpp ├── NOTES.md └── README.md ├── 373-find-k-pairs-with-smallest-sums ├── 373-find-k-pairs-with-smallest-sums.cpp ├── NOTES.md └── README.md ├── 374-guess-number-higher-or-lower ├── 374-guess-number-higher-or-lower.cpp ├── NOTES.md └── README.md ├── 378-kth-smallest-element-in-a-sorted-matrix ├── 378-kth-smallest-element-in-a-sorted-matrix.cpp ├── NOTES.md └── README.md ├── 382-linked-list-random-node ├── 382-linked-list-random-node.cpp ├── NOTES.md └── README.md ├── 383-ransom-note ├── 383-ransom-note.cpp ├── NOTES.md └── README.md ├── 387-first-unique-character-in-a-string ├── 387-first-unique-character-in-a-string.cpp ├── NOTES.md └── README.md ├── 399-evaluate-division ├── 399-evaluate-division.cpp ├── NOTES.md └── README.md ├── 3sum ├── 3sum.cpp └── README.md ├── 4-median-of-two-sorted-arrays ├── 4-median-of-two-sorted-arrays.cpp ├── NOTES.md └── README.md ├── 404-sum-of-left-leaves ├── 404-sum-of-left-leaves.cpp ├── NOTES.md └── README.md ├── 408-valid-word-abbreviation ├── 408-valid-word-abbreviation.cpp └── NOTES.md ├── 409-longest-palindrome ├── 409-longest-palindrome.cpp ├── NOTES.md └── README.md ├── 412-fizz-buzz ├── 412-fizz-buzz.cpp ├── NOTES.md └── README.md ├── 413-arithmetic-slices ├── 413-arithmetic-slices.cpp ├── NOTES.md └── README.md ├── 414-third-maximum-number ├── 414-third-maximum-number.cpp ├── NOTES.md └── README.md ├── 415-add-strings ├── 415-add-strings.cpp ├── NOTES.md └── README.md ├── 417-pacific-atlantic-water-flow ├── 417-pacific-atlantic-water-flow.cpp ├── NOTES.md └── README.md ├── 42-trapping-rain-water ├── 42-trapping-rain-water.cpp ├── NOTES.md └── README.md ├── 422-valid-word-square ├── 422-valid-word-square.cpp ├── NOTES.md └── README.md ├── 426-convert-binary-search-tree-to-sorted-doubly-linked-list ├── 426-convert-binary-search-tree-to-sorted-doubly-linked-list.cpp ├── NOTES.md └── README.md ├── 43-multiply-strings ├── 43-multiply-strings.cpp ├── NOTES.md └── README.md ├── 434-number-of-segments-in-a-string ├── 434-number-of-segments-in-a-string.cpp ├── NOTES.md └── README.md ├── 437-path-sum-iii ├── 437-path-sum-iii.cpp ├── NOTES.md └── README.md ├── 438-find-all-anagrams-in-a-string ├── 438-find-all-anagrams-in-a-string.cpp ├── NOTES.md └── README.md ├── 442-find-all-duplicates-in-an-array ├── 442-find-all-duplicates-in-an-array.cpp ├── NOTES.md └── README.md ├── 445-add-two-numbers-ii ├── 445-add-two-numbers-ii.cpp ├── NOTES.md └── README.md ├── 451-sort-characters-by-frequency ├── 451-sort-characters-by-frequency.cpp ├── NOTES.md └── README.md ├── 455-assign-cookies ├── 455-assign-cookies.cpp ├── NOTES.md └── README.md ├── 459-repeated-substring-pattern ├── 459-repeated-substring-pattern.cpp ├── NOTES.md └── README.md ├── 461-hamming-distance ├── 461-hamming-distance.cpp ├── NOTES.md └── README.md ├── 463-island-perimeter ├── 463-island-perimeter.cpp ├── NOTES.md └── README.md ├── 476-number-complement ├── 476-number-complement.cpp ├── NOTES.md └── README.md ├── 482-license-key-formatting ├── 482-license-key-formatting.cpp ├── NOTES.md └── README.md ├── 49-group-anagrams ├── 49-group-anagrams.cpp ├── NOTES.md └── README.md ├── 495-teemo-attacking ├── 495-teemo-attacking.cpp ├── NOTES.md └── README.md ├── 496-next-greater-element-i ├── 496-next-greater-element-i.cpp ├── NOTES.md └── README.md ├── 498-diagonal-traverse ├── 498-diagonal-traverse.cpp ├── NOTES.md └── README.md ├── 4sum ├── 4sum.cpp └── README.md ├── 5-longest-palindromic-substring ├── 5-longest-palindromic-substring.cpp ├── NOTES.md └── README.md ├── 50-powx-n ├── 50-powx-n.cpp ├── NOTES.md └── README.md ├── 500-keyboard-row ├── 500-keyboard-row.cpp ├── NOTES.md └── README.md ├── 501-find-mode-in-binary-search-tree ├── 501-find-mode-in-binary-search-tree.cpp ├── NOTES.md └── README.md ├── 503-next-greater-element-ii ├── 503-next-greater-element-ii.cpp ├── NOTES.md └── README.md ├── 506-relative-ranks ├── 506-relative-ranks.cpp ├── NOTES.md └── README.md ├── 507-perfect-number ├── 507-perfect-number.cpp ├── NOTES.md └── README.md ├── 51-n-queens ├── 51-n-queens.cpp ├── NOTES.md └── README.md ├── 513-find-bottom-left-tree-value ├── 513-find-bottom-left-tree-value.cpp ├── NOTES.md └── README.md ├── 515-find-largest-value-in-each-tree-row ├── 515-find-largest-value-in-each-tree-row.cpp ├── NOTES.md └── README.md ├── 520-detect-capital ├── 520-detect-capital.cpp ├── NOTES.md └── README.md ├── 521-longest-uncommon-subsequence-i ├── 521-longest-uncommon-subsequence-i.cpp ├── NOTES.md └── README.md ├── 523-continuous-subarray-sum ├── 523-continuous-subarray-sum.cpp ├── NOTES.md └── README.md ├── 528-random-pick-with-weight ├── 528-random-pick-with-weight.cpp ├── NOTES.md └── README.md ├── 53-maximum-subarray ├── 53-maximum-subarray.cpp ├── NOTES.md └── README.md ├── 530-minimum-absolute-difference-in-bst ├── NOTES.md └── README.md ├── 535-encode-and-decode-tinyurl ├── 535-encode-and-decode-tinyurl.cpp ├── NOTES.md └── README.md ├── 538-convert-bst-to-greater-tree ├── 538-convert-bst-to-greater-tree.cpp ├── NOTES.md └── README.md ├── 543-diameter-of-binary-tree ├── 543-diameter-of-binary-tree.cpp ├── NOTES.md └── README.md ├── 544-output-contest-matches ├── 544-output-contest-matches.cpp ├── NOTES.md └── README.md ├── 547-number-of-provinces ├── 547-number-of-provinces.cpp ├── NOTES.md └── README.md ├── 551-student-attendance-record-i ├── 551-student-attendance-record-i.cpp ├── NOTES.md └── README.md ├── 556-next-greater-element-iii ├── NOTES.md └── README.md ├── 559-maximum-depth-of-n-ary-tree ├── NOTES.md └── README.md ├── 56-merge-intervals ├── 56-merge-intervals.cpp ├── NOTES.md └── README.md ├── 563-binary-tree-tilt ├── 563-binary-tree-tilt.cpp ├── NOTES.md └── README.md ├── 572-subtree-of-another-tree ├── 572-subtree-of-another-tree.cpp ├── NOTES.md └── README.md ├── 58-length-of-last-word ├── 58-length-of-last-word.cpp ├── NOTES.md └── README.md ├── 589-n-ary-tree-preorder-traversal ├── 589-n-ary-tree-preorder-traversal.cpp ├── NOTES.md └── README.md ├── 590-n-ary-tree-postorder-traversal ├── 590-n-ary-tree-postorder-traversal.cpp ├── NOTES.md └── README.md ├── 604-design-compressed-string-iterator ├── 604-design-compressed-string-iterator.cpp ├── NOTES.md └── README.md ├── 605-can-place-flowers ├── 605-can-place-flowers.cpp ├── NOTES.md └── README.md ├── 61-rotate-list ├── 61-rotate-list.cpp ├── NOTES.md └── README.md ├── 617-merge-two-binary-trees ├── 617-merge-two-binary-trees.cpp ├── NOTES.md └── README.md ├── 621-task-scheduler ├── 621-task-scheduler.cpp └── README.md ├── 63-unique-paths-ii ├── 63-unique-paths-ii.cpp ├── NOTES.md └── README.md ├── 637-average-of-levels-in-binary-tree ├── 637-average-of-levels-in-binary-tree.cpp ├── NOTES.md └── README.md ├── 647-palindromic-substrings ├── 647-palindromic-substrings.cpp ├── NOTES.md └── README.md ├── 65-valid-number ├── 65-valid-number.cpp ├── NOTES.md └── README.md ├── 653-two-sum-iv-input-is-a-bst ├── 653-two-sum-iv-input-is-a-bst.cpp ├── NOTES.md └── README.md ├── 654-maximum-binary-tree ├── NOTES.md └── README.md ├── 658-find-k-closest-elements ├── 658-find-k-closest-elements.cpp ├── NOTES.md └── README.md ├── 66-plus-one ├── 66-plus-one.cpp ├── NOTES.md └── README.md ├── 662-maximum-width-of-binary-tree ├── NOTES.md └── README.md ├── 669-trim-a-binary-search-tree ├── NOTES.md └── README.md ├── 67-add-binary ├── 67-add-binary.cpp ├── NOTES.md └── README.md ├── 670-maximum-swap ├── 670-maximum-swap.cpp ├── NOTES.md └── README.md ├── 671-second-minimum-node-in-a-binary-tree ├── 671-second-minimum-node-in-a-binary-tree.cpp └── README.md ├── 678-valid-parenthesis-string ├── 678-valid-parenthesis-string.cpp ├── NOTES.md └── README.md ├── 680-valid-palindrome-ii ├── 680-valid-palindrome-ii.cpp ├── NOTES.md └── README.md ├── 684-redundant-connection ├── 684-redundant-connection.cpp ├── NOTES.md └── README.md ├── 69-sqrtx ├── 69-sqrtx.cpp ├── NOTES.md └── README.md ├── 692-top-k-frequent-words ├── NOTES.md └── README.md ├── 693-binary-number-with-alternating-bits ├── 693-binary-number-with-alternating-bits.cpp ├── NOTES.md └── README.md ├── 694-number-of-distinct-islands ├── 694-number-of-distinct-islands.cpp ├── NOTES.md └── README.md ├── 695-max-area-of-island ├── 695-max-area-of-island.cpp ├── NOTES.md └── README.md ├── 7-reverse-integer ├── 7-reverse-integer.cpp ├── NOTES.md └── README.md ├── 70-climbing-stairs └── README.md ├── 700-search-in-a-binary-search-tree ├── 700-search-in-a-binary-search-tree.cpp ├── NOTES.md └── README.md ├── 701-insert-into-a-binary-search-tree ├── 701-insert-into-a-binary-search-tree.cpp ├── NOTES.md └── README.md ├── 703-kth-largest-element-in-a-stream ├── 703-kth-largest-element-in-a-stream.cpp ├── NOTES.md └── README.md ├── 706-design-hashmap ├── 706-design-hashmap.cpp ├── NOTES.md └── README.md ├── 71-simplify-path ├── 71-simplify-path.cpp ├── NOTES.md └── README.md ├── 711-number-of-distinct-islands-ii ├── 711-number-of-distinct-islands-ii.cpp ├── NOTES.md └── README.md ├── 714-best-time-to-buy-and-sell-stock-with-transaction-fee ├── 714-best-time-to-buy-and-sell-stock-with-transaction-fee.cpp ├── NOTES.md └── README.md ├── 716-max-stack ├── 716-max-stack.cpp ├── NOTES.md └── README.md ├── 718-maximum-length-of-repeated-subarray ├── 718-maximum-length-of-repeated-subarray.cpp ├── NOTES.md └── README.md ├── 719-find-k-th-smallest-pair-distance ├── 719-find-k-th-smallest-pair-distance.cpp ├── NOTES.md └── README.md ├── 728-self-dividing-numbers ├── 728-self-dividing-numbers.cpp ├── NOTES.md └── README.md ├── 733-flood-fill ├── 733-flood-fill.cpp ├── NOTES.md └── README.md ├── 734-sentence-similarity ├── 734-sentence-similarity.cpp ├── NOTES.md └── README.md ├── 739-daily-temperatures └── README.md ├── 742-closest-leaf-in-a-binary-tree ├── 742-closest-leaf-in-a-binary-tree.cpp ├── NOTES.md └── README.md ├── 743-network-delay-time ├── 743-network-delay-time.cpp ├── NOTES.md └── README.md ├── 744-find-smallest-letter-greater-than-target ├── 744-find-smallest-letter-greater-than-target.cpp ├── NOTES.md └── README.md ├── 747-largest-number-at-least-twice-of-others ├── 747-largest-number-at-least-twice-of-others.cpp ├── NOTES.md └── README.md ├── 748-shortest-completing-word ├── 748-shortest-completing-word.cpp ├── NOTES.md └── README.md ├── 754-reach-a-number ├── 754-reach-a-number.cpp ├── NOTES.md └── README.md ├── 76-minimum-window-substring ├── 76-minimum-window-substring.cpp ├── NOTES.md └── README.md ├── 760-find-anagram-mappings ├── 760-find-anagram-mappings.cpp ├── NOTES.md └── README.md ├── 762-prime-number-of-set-bits-in-binary-representation ├── 762-prime-number-of-set-bits-in-binary-representation.cpp ├── NOTES.md └── README.md ├── 763-partition-labels ├── 763-partition-labels.cpp ├── NOTES.md └── README.md ├── 783-minimum-distance-between-bst-nodes ├── 783-minimum-distance-between-bst-nodes.cpp ├── NOTES.md └── README.md ├── 784-letter-case-permutation ├── 784-letter-case-permutation.cpp ├── NOTES.md └── README.md ├── 785-is-graph-bipartite ├── 785-is-graph-bipartite.cpp ├── NOTES.md └── README.md ├── 79-word-search ├── 79-word-search.cpp ├── NOTES.md └── README.md ├── 791-custom-sort-string ├── 791-custom-sort-string.cpp ├── NOTES.md └── README.md ├── 796-rotate-string ├── 796-rotate-string.cpp ├── NOTES.md └── README.md ├── 797-all-paths-from-source-to-target ├── 797-all-paths-from-source-to-target.cpp ├── NOTES.md └── README.md ├── 802-find-eventual-safe-states ├── 802-find-eventual-safe-states.cpp ├── NOTES.md └── README.md ├── 809-expressive-words ├── 809-expressive-words.cpp ├── NOTES.md └── README.md ├── 819-most-common-word ├── 819-most-common-word.cpp ├── NOTES.md └── README.md ├── 82-remove-duplicates-from-sorted-list-ii ├── 82-remove-duplicates-from-sorted-list-ii.cpp ├── NOTES.md └── README.md ├── 824-goat-latin ├── 824-goat-latin.cpp ├── NOTES.md └── README.md ├── 83-remove-duplicates-from-sorted-list ├── 83-remove-duplicates-from-sorted-list.cpp ├── NOTES.md └── README.md ├── 836-rectangle-overlap ├── 836-rectangle-overlap.cpp ├── NOTES.md └── README.md ├── 84-largest-rectangle-in-histogram ├── 84-largest-rectangle-in-histogram.cpp ├── NOTES.md └── README.md ├── 841-keys-and-rooms ├── 841-keys-and-rooms.cpp ├── NOTES.md └── README.md ├── 844-backspace-string-compare ├── 844-backspace-string-compare.cpp ├── NOTES.md └── README.md ├── 85-maximal-rectangle ├── 85-maximal-rectangle.cpp ├── NOTES.md └── README.md ├── 852-peak-index-in-a-mountain-array ├── 852-peak-index-in-a-mountain-array.cpp ├── NOTES.md └── README.md ├── 86-partition-list ├── 86-partition-list.cpp ├── NOTES.md └── README.md ├── 860-lemonade-change ├── 860-lemonade-change.cpp ├── NOTES.md └── README.md ├── 861-score-after-flipping-matrix ├── 861-score-after-flipping-matrix.cpp ├── NOTES.md └── README.md ├── 872-leaf-similar-trees ├── 872-leaf-similar-trees.cpp ├── NOTES.md └── README.md ├── 876-middle-of-the-linked-list ├── 876-middle-of-the-linked-list.cpp ├── NOTES.md └── README.md ├── 877-stone-game ├── 877-stone-game.cpp ├── NOTES.md └── README.md ├── 88-merge-sorted-array ├── 88-merge-sorted-array.cpp ├── NOTES.md └── README.md ├── 886-possible-bipartition ├── 886-possible-bipartition.cpp ├── NOTES.md └── README.md ├── 889-construct-binary-tree-from-preorder-and-postorder-traversal ├── 889-construct-binary-tree-from-preorder-and-postorder-traversal.cpp ├── NOTES.md └── README.md ├── 897-increasing-order-search-tree ├── 897-increasing-order-search-tree.cpp ├── NOTES.md └── README.md ├── 9-palindrome-number ├── NOTES.md └── README.md ├── 904-fruit-into-baskets ├── 904-fruit-into-baskets.cpp ├── NOTES.md └── README.md ├── 912-sort-an-array ├── 912-sort-an-array.cpp ├── NOTES.md └── README.md ├── 92-reverse-linked-list-ii ├── 92-reverse-linked-list-ii.cpp ├── NOTES.md └── README.md ├── 921-minimum-add-to-make-parentheses-valid ├── 921-minimum-add-to-make-parentheses-valid.cpp ├── NOTES.md └── README.md ├── 925-long-pressed-name ├── 925-long-pressed-name.cpp ├── NOTES.md └── README.md ├── 937-reorder-data-in-log-files ├── 937-reorder-data-in-log-files.cpp ├── NOTES.md └── README.md ├── 938-range-sum-of-bst ├── 938-range-sum-of-bst.cpp ├── NOTES.md └── README.md ├── 94-binary-tree-inorder-traversal ├── 94-binary-tree-inorder-traversal.cpp ├── NOTES.md └── README.md ├── 941-valid-mountain-array ├── 941-valid-mountain-array.cpp ├── NOTES.md └── README.md ├── 942-di-string-match ├── 942-di-string-match.cpp ├── NOTES.md └── README.md ├── 946-validate-stack-sequences ├── 946-validate-stack-sequences.cpp ├── NOTES.md └── README.md ├── 947-most-stones-removed-with-same-row-or-column ├── 947-most-stones-removed-with-same-row-or-column.cpp ├── NOTES.md └── README.md ├── 951-flip-equivalent-binary-trees ├── 951-flip-equivalent-binary-trees.cpp ├── NOTES.md └── README.md ├── 965-univalued-binary-tree ├── 965-univalued-binary-tree.cpp ├── NOTES.md └── README.md ├── 973-k-closest-points-to-origin ├── 973-k-closest-points-to-origin.cpp ├── NOTES.md └── README.md ├── 98-validate-binary-search-tree ├── 98-validate-binary-search-tree.cpp ├── NOTES.md └── README.md ├── 980-unique-paths-iii ├── 980-unique-paths-iii.cpp ├── NOTES.md └── README.md ├── 983-minimum-cost-for-tickets ├── 983-minimum-cost-for-tickets.cpp ├── NOTES.md └── README.md ├── 987-vertical-order-traversal-of-a-binary-tree └── README.md ├── 993-cousins-in-binary-tree ├── 993-cousins-in-binary-tree.cpp ├── NOTES.md └── README.md ├── 997-find-the-town-judge ├── 997-find-the-town-judge.cpp ├── NOTES.md └── README.md ├── Boolean Parenthesization - GFG ├── README.md └── boolean-parenthesization.cpp ├── Count Occurences of Anagrams - GFG ├── README.md └── count-occurences-of-anagrams.cpp ├── First negative integer in every window of size k - GFG ├── README.md └── first-negative-integer-in-every-window-of-size-k.cpp ├── Longest Common Substring - GFG ├── README.md └── longest-common-substring.cpp ├── Longest K unique characters substring - GFG ├── README.md └── longest-k-unique-characters-substring.cpp ├── Longest Repeating Subsequence - GFG ├── README.md └── longest-repeating-subsequence.cpp ├── Longest Sub-Array with Sum K - GFG ├── README.md └── longest-sub-array-with-sum-k.cpp ├── Matrix Chain Multiplication - GFG ├── README.md └── matrix-chain-multiplication.cpp ├── Max Sum Subarray of size K - GFG ├── README.md └── max-sum-subarray-of-size-k.cpp ├── Minimum number of deletions and insertions. - GFG └── README.md ├── Minimum sum partition - GFG ├── README.md └── minimum-sum-partition.cpp ├── Nearly sorted - GFG ├── README.md └── nearly-sorted.cpp ├── Partition Equal Subset Sum - GFG ├── README.md └── partition-equal-subset-sum.cpp ├── README.md ├── Subset Sum Problem - GFG ├── README.md └── subset-sum-problem.cpp ├── Subset Sums - GFG ├── README.md └── subset-sums.cpp ├── Sum of elements between k1'th and k2'th smallest elements - GFG ├── README.md └── sum-of-elements-between-k1th-and-k2th-smallest-elements.cpp ├── Target Sum - GFG ├── README.md └── target-sum.cpp ├── add-two-numbers └── README.md ├── all-paths-from-source-to-target ├── README.md └── all-paths-from-source-to-target.cpp ├── all-possible-full-binary-trees ├── README.md └── all-possible-full-binary-trees.cpp ├── balance-a-binary-search-tree ├── README.md └── balance-a-binary-search-tree.cpp ├── cheapest-flights-within-k-stops ├── README.md └── cheapest-flights-within-k-stops.cpp ├── construct-string-from-binary-tree ├── README.md └── construct-string-from-binary-tree.cpp ├── count-number-of-teams ├── README.md └── count-number-of-teams.cpp ├── count-square-submatrices-with-all-ones ├── README.md └── count-square-submatrices-with-all-ones.cpp ├── count-sub-islands ├── README.md └── count-sub-islands.cpp ├── course-schedule-iv ├── README.md └── course-schedule-iv.cpp ├── course-schedule ├── README.md └── course-schedule.cpp ├── evaluate-division ├── README.md └── evaluate-division.cpp ├── even-odd-tree └── README.md ├── find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree ├── README.md └── find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree.cpp ├── find-all-groups-of-farmland ├── README.md └── find-all-groups-of-farmland.cpp ├── find-eventual-safe-states ├── README.md └── find-eventual-safe-states.cpp ├── find-if-path-exists-in-graph ├── README.md └── find-if-path-exists-in-graph.cpp ├── hand-of-straights ├── README.md └── hand-of-straights.cpp ├── increasing-order-search-tree ├── README.md └── increasing-order-search-tree.cpp ├── longest-increasing-path-in-a-matrix ├── README.md └── longest-increasing-path-in-a-matrix.cpp ├── longest-substring-with-at-most-two-distinct-characters └── README.md ├── longest-substring-without-repeating-characters └── README.md ├── max-area-of-island ├── README.md └── max-area-of-island.cpp ├── maximum-length-of-pair-chain ├── README.md └── maximum-length-of-pair-chain.cpp ├── merge-two-binary-trees ├── README.md └── merge-two-binary-trees.cpp ├── merge-two-sorted-lists └── README.md ├── minimum-cost-homecoming-of-a-robot-in-a-grid ├── README.md └── minimum-cost-homecoming-of-a-robot-in-a-grid.cpp ├── minimum-cost-to-make-at-least-one-valid-path-in-a-grid ├── README.md └── minimum-cost-to-make-at-least-one-valid-path-in-a-grid.cpp ├── minimum-distance-between-bst-nodes ├── README.md └── minimum-distance-between-bst-nodes.cpp ├── most-stones-removed-with-same-row-or-column ├── README.md └── most-stones-removed-with-same-row-or-column.cpp ├── n-th-tribonacci-number ├── README.md └── n-th-tribonacci-number.cpp ├── number-of-closed-islands ├── README.md └── number-of-closed-islands.cpp ├── number-of-islands ├── README.md └── number-of-islands.cpp ├── number-of-operations-to-make-network-connected ├── README.md └── number-of-operations-to-make-network-connected.cpp ├── number-of-restricted-paths-from-first-to-last-node ├── README.md └── number-of-restricted-paths-from-first-to-last-node.cpp ├── number-of-ways-to-arrive-at-destination ├── README.md └── number-of-ways-to-arrive-at-destination.cpp ├── path-with-maximum-probability ├── README.md └── path-with-maximum-probability.cpp ├── queries-on-number-of-points-inside-a-circle ├── README.md └── queries-on-number-of-points-inside-a-circle.cpp ├── reachable-nodes-in-subdivided-graph ├── README.md └── reachable-nodes-in-subdivided-graph.cpp ├── reorder-routes-to-make-all-paths-lead-to-the-city-zero ├── README.md └── reorder-routes-to-make-all-paths-lead-to-the-city-zero.cpp ├── search-in-a-binary-search-tree ├── README.md └── search-in-a-binary-search-tree.cpp ├── second-minimum-time-to-reach-destination ├── README.md └── second-minimum-time-to-reach-destination.cpp ├── subtree-of-another-tree ├── README.md └── subtree-of-another-tree.cpp ├── valid-parentheses └── README.md └── validate-binary-tree-nodes ├── README.md └── validate-binary-tree-nodes.cpp /0005-longest-palindromic-substring/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0070-climbing-stairs/0070-climbing-stairs.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int climbStairs(int n) { 5 | 6 | vector dp(n + 1, 0); 7 | 8 | if(n <= 2) return n; 9 | 10 | // Base Condition 11 | dp[0] = 0; 12 | dp[1] = 1; 13 | dp[2] = 2; 14 | 15 | 16 | 17 | for(int i=3; i<=n; i++) { 18 | dp[i] = dp[i-1] + dp[i-2]; 19 | } 20 | 21 | return dp[n]; 22 | } 23 | 24 | }; -------------------------------------------------------------------------------- /0070-climbing-stairs/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0082-remove-duplicates-from-sorted-list-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0086-partition-list/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0095-unique-binary-search-trees-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | Refer https://www.youtube.com/watch?v=mhCJgZWJlSI -------------------------------------------------------------------------------- /0096-unique-binary-search-trees/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0099-recover-binary-search-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0116-populating-next-right-pointers-in-each-node/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0117-populating-next-right-pointers-in-each-node-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | Same as L -------------------------------------------------------------------------------- /0118-pascals-triangle/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0119-pascals-triangle-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0121-best-time-to-buy-and-sell-stock/0121-best-time-to-buy-and-sell-stock.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int maxProfit(vector& prices) { 5 | 6 | int res = INT_MIN; 7 | int n = prices.size(); 8 | 9 | vector maxPrice(n); 10 | int maxi = INT_MIN; 11 | 12 | for(int i=n-1, k=n-1; i>=0; i--) { 13 | maxi = max(maxi, prices[i]); 14 | maxPrice[k--] = maxi; 15 | } 16 | 17 | for(int i=0; i &res) { 5 | 6 | if(i > n) return; 7 | 8 | res.push_back(i); 9 | 10 | for(int j=0; j<=9; j++) { 11 | dfs(10 * i + j, n, res); 12 | } 13 | 14 | return; 15 | } 16 | 17 | vector lexicalOrder(int n) { 18 | 19 | vector res; 20 | 21 | for(int i=1; i<=9; i++) { 22 | dfs(i, n, res); 23 | } 24 | 25 | return res; 26 | } 27 | 28 | }; -------------------------------------------------------------------------------- /0386-lexicographical-numbers/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0392-is-subsequence/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0419-battleships-in-a-board/NOTES.md: -------------------------------------------------------------------------------- 1 | https://www.youtube.com/watch?v=wBG6078g1gE&ab_channel=KevinNaughtonJr. -------------------------------------------------------------------------------- /0429-n-ary-tree-level-order-traversal/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0438-find-all-anagrams-in-a-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0445-add-two-numbers-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0449-serialize-and-deserialize-bst/NOTES.md: -------------------------------------------------------------------------------- 1 | Refer https://www.youtube.com/watch?v=-YbXySKJsX8 -------------------------------------------------------------------------------- /0450-delete-node-in-a-bst/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0508-most-frequent-subtree-sum/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0509-fibonacci-number/0509-fibonacci-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int fib(int n) { 5 | 6 | vector dp(n + 1, 0); 7 | 8 | if(n <= 1) return n; 9 | 10 | dp[0] = 0; 11 | dp[1] = 1; 12 | 13 | for(int i=2; i<=n; i++) dp[i] = dp[i-1] + dp[i-2]; 14 | 15 | return dp[n]; 16 | } 17 | 18 | }; -------------------------------------------------------------------------------- /0509-fibonacci-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0623-add-one-row-to-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0652-find-duplicate-subtrees/NOTES.md: -------------------------------------------------------------------------------- 1 | Refer https://www.youtube.com/watch?v=YsmpR9z9frE&ab_channel=codeExplainer -------------------------------------------------------------------------------- /0701-insert-into-a-binary-search-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0724-find-pivot-index/0724-find-pivot-index.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int pivotIndex(vector& a) { 5 | 6 | int n = a.size(); 7 | 8 | int leftSum = 0, rightSum = 0, sum = 0; 9 | 10 | for(int i=0; i twoSum(vector& v, int tar) { 5 | 6 | vector res; 7 | int n = v.size(); 8 | 9 | for(int i=0; i 0) { 11 | 12 | int rem = n % 2; 13 | rem ^= 1; 14 | 15 | res += rem * mul; 16 | mul *= 2; 17 | 18 | n = n / 2; 19 | } 20 | 21 | return res; 22 | } 23 | 24 | }; -------------------------------------------------------------------------------- /1009-complement-of-base-10-integer/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /101-symmetric-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1019-next-greater-node-in-linked-list/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /102-binary-tree-level-order-traversal/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1022-sum-of-root-to-leaf-binary-numbers/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1026-maximum-difference-between-node-and-ancestor/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /103-binary-tree-zigzag-level-order-traversal/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1030-matrix-cells-in-distance-order/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /104-maximum-depth-of-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1043-partition-array-for-maximum-sum/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1046-last-stone-weight/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1047-remove-all-adjacent-duplicates-in-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /105-construct-binary-tree-from-preorder-and-inorder-traversal/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1054-distant-barcodes/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1056-confusing-number/1056-confusing-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool confusingNumber(int num) { 5 | 6 | string s = to_string(num); 7 | 8 | int n = s.length(); 9 | string res = s; 10 | 11 | for(int i=0; i& a) { 5 | 6 | int res = 0; 7 | int n = a.size(); 8 | 9 | int ele = *min_element(a.begin(), a.end()); 10 | 11 | while(ele > 0) { 12 | res += ele % 10; 13 | ele /= 10; 14 | } 15 | 16 | if(res % 2 == 1) return 0; 17 | else return 1; 18 | } 19 | 20 | }; -------------------------------------------------------------------------------- /1085-sum-of-digits-in-the-minimum-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1086-high-five/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /109-convert-sorted-list-to-binary-search-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1094-car-pooling/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1099-two-sum-less-than-k/1099-two-sum-less-than-k.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int twoSumLessThanK(vector& a, int k) { 5 | 6 | int sum = -1; 7 | int n = a.size(); 8 | 9 | sort(a.begin(), a.end()); 10 | 11 | for(int i=0, j=n-1; i mp; 9 | 10 | mp['a'] = 1; 11 | mp['e'] = 1; 12 | mp['i'] = 1; 13 | mp['o'] = 1; 14 | mp['u'] = 1; 15 | 16 | for(auto &x : s) { 17 | if(mp[x] == 0) res += x; 18 | } 19 | 20 | return res; 21 | } 22 | 23 | }; -------------------------------------------------------------------------------- /1119-remove-vowels-from-a-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /112-path-sum/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1123-lowest-common-ancestor-of-deepest-leaves/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /113-path-sum-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1133-largest-unique-number/1133-largest-unique-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int largestUniqueNumber(vector& a) { 5 | 6 | int res = -1; 7 | 8 | int n = a.size(); 9 | map u; 10 | 11 | for(auto &x : a) u[x]++; 12 | 13 | for(auto it=u.begin(); it!=u.end(); it++) { 14 | 15 | if(it->second == 1) { 16 | res = it->first; 17 | } 18 | } 19 | 20 | return res; 21 | } 22 | 23 | }; -------------------------------------------------------------------------------- /1133-largest-unique-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1134-armstrong-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1137-n-th-tribonacci-number/1137-n-th-tribonacci-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int tribonacci(int n) { 5 | 6 | vector dp(n + 1); 7 | 8 | if(n == 0) return 0; 9 | if(n <= 2) return 1; 10 | 11 | dp[0] = 0, dp[1] = 1, dp[2] = 1; 12 | 13 | for(int i=3; i<=n; i++) dp[i] = dp[i-1] + dp[i-2] + dp[i-3]; 14 | return dp[n]; 15 | } 16 | 17 | }; -------------------------------------------------------------------------------- /1137-n-th-tribonacci-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /114-flatten-binary-tree-to-linked-list/NOTES.md: -------------------------------------------------------------------------------- 1 | Refer https://www.youtube.com/watch?v=NOKVBiJwkD0&ab_channel=AlgorithmsMadeEasy -------------------------------------------------------------------------------- /1140-stone-game-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /115-distinct-subsequences/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1150-check-if-a-number-is-majority-element-in-a-sorted-array/1150-check-if-a-number-is-majority-element-in-a-sorted-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool isMajorityElement(vector& a, int target) { 5 | 6 | int n = a.size(); 7 | int ct = count(a.begin(), a.end(), target); 8 | 9 | return (ct > n/2); 10 | } 11 | 12 | }; -------------------------------------------------------------------------------- /1150-check-if-a-number-is-majority-element-in-a-sorted-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1154-day-of-the-year/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1161-maximum-level-sum-of-a-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1165-single-row-keyboard/1165-single-row-keyboard.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int calculateTime(string keyboard, string word) { 5 | 6 | int res = 0; 7 | 8 | int pre = -1; 9 | 10 | for(int i=0; i& a) { 5 | 6 | int res = 0; 7 | int n = a.size(); 8 | 9 | sort(a.begin(), a.end()); 10 | int sum = 0; 11 | 12 | for(auto &x : a) { 13 | 14 | sum += x; 15 | 16 | if(sum <= 5000) res++; 17 | else break; 18 | } 19 | 20 | return res; 21 | } 22 | 23 | }; -------------------------------------------------------------------------------- /1196-how-many-apples-can-you-put-into-the-basket/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1198-find-smallest-common-element-in-all-rows/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /121-best-time-to-buy-and-sell-stock/121-best-time-to-buy-and-sell-stock.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int maxProfit(vector& prices) { 5 | 6 | int n = prices.size(); 7 | 8 | if(n <= 1) return 0; 9 | 10 | int maxi = 0; 11 | int minLeft = prices[0]; // Min prices from left side 12 | 13 | for(int i=1; i& a, int diff) { 5 | 6 | int res = INT_MIN; 7 | 8 | // mp[i] is the length of Longest Arithmetic Subsequence till index i from index 0 9 | 10 | unordered_map mp; 11 | int n = a.size(); 12 | 13 | for(int i=0; i& a) { 5 | 6 | int n = a.size(); 7 | int sum = 0; 8 | 9 | if(n <= 1) return sum; 10 | 11 | for(int i=1; i& a) { 5 | 6 | int res; 7 | int n = a.size(); 8 | 9 | int diffMax = INT_MIN, d; 10 | int ind; 11 | 12 | for(int i=1; i transformArray(vector& a) { 5 | 6 | vector temp; 7 | int n = a.size(); 8 | 9 | for(int k=1; k<=n-2; k++) { 10 | 11 | temp = a; 12 | 13 | for(int i=1; i<=n-2; i++) { 14 | if(temp[i-1] > temp[i] && temp[i] < temp[i+1]) a[i]++; 15 | else if(temp[i-1] < temp[i] && temp[i] > temp[i+1]) a[i]--; 16 | } 17 | 18 | temp = a; 19 | } 20 | 21 | return temp; 22 | } 23 | 24 | }; -------------------------------------------------------------------------------- /1243-array-transformation/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1245-tree-diameter/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1249-minimum-remove-to-make-valid-parentheses/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /125-valid-palindrome/125-valid-palindrome.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool isPalindrome(string s) { 5 | 6 | string res = ""; 7 | 8 | for(auto &ch : s) { 9 | if(isalpha(ch) || isdigit(ch)) { 10 | res += tolower(ch); 11 | } 12 | } 13 | 14 | string temp = res; 15 | reverse(res.begin(), res.end()); 16 | 17 | return (temp == res); 18 | } 19 | 20 | }; -------------------------------------------------------------------------------- /125-valid-palindrome/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1256-encode-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1261-find-elements-in-a-contaminated-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1265-print-immutable-linked-list-in-reverse/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1276-number-of-burgers-with-no-waste-of-ingredients/1276-number-of-burgers-with-no-waste-of-ingredients.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | 3 | public List numOfBurgers(int t, int c) { 4 | 5 | List ret = new ArrayList<>(); 6 | 7 | if(t%2!=0||((t/2)>2*c)||c>(t/2))return ret; 8 | 9 | ret.add((t/2-c)); 10 | ret.add((2*c-t/2)); 11 | 12 | return ret; 13 | } 14 | } -------------------------------------------------------------------------------- /1276-number-of-burgers-with-no-waste-of-ingredients/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1281-subtract-the-product-and-sum-of-digits-of-an-integer/1281-subtract-the-product-and-sum-of-digits-of-an-integer.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int subtractProductAndSum(int n) { 5 | 6 | int res; 7 | 8 | int sum = 0, pdt = 1; 9 | 10 | while(n > 0) { 11 | 12 | sum += n % 10; 13 | pdt *= (n % 10); 14 | 15 | n = n / 10; 16 | } 17 | 18 | res = pdt - sum; 19 | return res; 20 | } 21 | 22 | }; -------------------------------------------------------------------------------- /1281-subtract-the-product-and-sum-of-digits-of-an-integer/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1286-iterator-for-combination/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /129-sum-root-to-leaf-numbers/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1290-convert-binary-number-in-a-linked-list-to-integer/1290-convert-binary-number-in-a-linked-list-to-integer.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition for singly-linked list. 3 | * struct ListNode { 4 | * int val; 5 | * ListNode *next; 6 | * ListNode() : val(0), next(nullptr) {} 7 | * ListNode(int x) : val(x), next(nullptr) {} 8 | * ListNode(int x, ListNode *next) : val(x), next(next) {} 9 | * }; 10 | */ 11 | class Solution { 12 | public: 13 | 14 | int getDecimalValue(ListNode* head) { 15 | 16 | int sum = 0; 17 | ListNode* temp = head; 18 | 19 | while(temp != NULL) { 20 | sum = (sum * 2) + temp->val; 21 | temp = temp->next; 22 | } 23 | 24 | return sum; 25 | } 26 | 27 | }; -------------------------------------------------------------------------------- /1290-convert-binary-number-in-a-linked-list-to-integer/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /13-roman-to-integer/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1302-deepest-leaves-sum/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1305-all-elements-in-two-binary-search-trees/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1313-decompress-run-length-encoded-list/1313-decompress-run-length-encoded-list.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | vector decompressRLElist(vector& a) { 5 | 6 | vector res; 7 | int n = a.size(); 8 | 9 | for(int i=0; i + 1 < n; i += 2) { 10 | 11 | int freq = a[i]; 12 | int val = a[i + 1]; 13 | 14 | // Push val into res freq times 15 | while(freq--) res.push_back(val); 16 | } 17 | 18 | return res; 19 | } 20 | 21 | }; -------------------------------------------------------------------------------- /1313-decompress-run-length-encoded-list/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1314-matrix-block-sum/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1315-sum-of-nodes-with-even-valued-grandparent/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1317-convert-integer-to-the-sum-of-two-no-zero-integers/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1323-maximum-69-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1325-delete-leaves-with-a-given-value/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /133-clone-graph/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1338-reduce-array-size-to-the-half/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1342-number-of-steps-to-reduce-a-number-to-zero/1342-number-of-steps-to-reduce-a-number-to-zero.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int numberOfSteps(int n) { 5 | 6 | int count = 0; 7 | 8 | while(n > 0) { 9 | 10 | if(n % 2 == 0) n = n / 2; 11 | else n--; 12 | 13 | count++; 14 | } 15 | 16 | return count; 17 | } 18 | 19 | }; -------------------------------------------------------------------------------- /1342-number-of-steps-to-reduce-a-number-to-zero/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1347-minimum-number-of-steps-to-make-two-strings-anagram/1347-minimum-number-of-steps-to-make-two-strings-anagram.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int minSteps(string s, string t) { 5 | 6 | int count = 0; 7 | 8 | int n = s.length(); 9 | int m = t.length(); 10 | 11 | unordered_map u; 12 | 13 | for(auto &x : s) u[x]++; 14 | 15 | int charPresentInS = 0; 16 | 17 | for(auto &x : t) { 18 | 19 | if(u[x] > 0) { 20 | u[x]--; 21 | charPresentInS++; 22 | } 23 | } 24 | 25 | count = m - charPresentInS; 26 | return count; 27 | } 28 | 29 | }; -------------------------------------------------------------------------------- /1347-minimum-number-of-steps-to-make-two-strings-anagram/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1352-product-of-the-last-k-numbers/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /136-single-number/136-single-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int singleNumber(vector& nums) { 5 | 6 | int res = 0; 7 | 8 | for(auto &x : nums) { 9 | res ^= x; 10 | } 11 | 12 | return res; 13 | } 14 | 15 | }; -------------------------------------------------------------------------------- /136-single-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1360-number-of-days-between-two-dates/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1361-validate-binary-tree-nodes/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1367-linked-list-in-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1372-longest-zigzag-path-in-a-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | https://www.youtube.com/watch?v=7aqHhENUbkQ -------------------------------------------------------------------------------- /1376-time-needed-to-inform-all-employees/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /138-copy-list-with-random-pointer/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1381-design-a-stack-with-increment-operation/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1382-balance-a-binary-search-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1396-design-underground-system/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1399-count-largest-group/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /14-longest-common-prefix/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /140-word-break-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | Refer https://www.youtube.com/watch?v=fNVs1J2KCyo -------------------------------------------------------------------------------- /1403-minimum-subsequence-in-non-increasing-order/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1406-stone-game-iii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /141-linked-list-cycle/141-linked-list-cycle.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition for singly-linked list. 3 | * struct ListNode { 4 | * int val; 5 | * ListNode *next; 6 | * ListNode(int x) : val(x), next(NULL) {} 7 | * }; 8 | */ 9 | class Solution { 10 | public: 11 | 12 | bool hasCycle(ListNode *head) { 13 | 14 | set w; 15 | 16 | if(head == NULL) return false; 17 | 18 | w.insert(head); 19 | 20 | while(head->next != NULL) { 21 | 22 | if(w.find(head->next) != w.end()) return true; 23 | 24 | w.insert(head->next); 25 | head = head->next; 26 | } 27 | 28 | return false; 29 | } 30 | 31 | }; -------------------------------------------------------------------------------- /141-linked-list-cycle/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1413-minimum-value-to-get-positive-step-by-step-sum/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1415-the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1418-display-table-of-food-orders-in-a-restaurant/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /142-linked-list-cycle-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1422-maximum-score-after-splitting-a-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1424-diagonal-traverse-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1426-counting-elements/1426-counting-elements.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int countElements(vector& a) { 5 | 6 | int res = 0; 7 | int n = a.size(); 8 | 9 | unordered_set w; 10 | 11 | for(auto &x : a) w.insert(x); 12 | for(auto &x : a) res += w.count(x + 1); 13 | 14 | return res; 15 | } 16 | 17 | }; -------------------------------------------------------------------------------- /1426-counting-elements/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1427-perform-string-shifts/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /143-reorder-list/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1439-find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /144-binary-tree-preorder-traversal/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1443-minimum-time-to-collect-all-apples-in-a-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1446-consecutive-characters/1446-consecutive-characters.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int maxPower(string s) { 5 | 6 | int res = 1; 7 | int n = s.length(); 8 | 9 | for(int i=0; i w; 8 | 9 | for(auto &x : s) { 10 | 11 | if(w.empty() == true) w.push(x); 12 | else if(abs(w.top() - x) == 32) w.pop(); 13 | else w.push(x); 14 | } 15 | 16 | while(w.empty() == false) { 17 | res += w.top(); 18 | w.pop(); 19 | } 20 | 21 | reverse(res.begin(), res.end()); 22 | return res; 23 | } 24 | 25 | }; -------------------------------------------------------------------------------- /1544-make-the-string-great/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /155-min-stack/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1551-minimum-operations-to-make-array-equal/1551-minimum-operations-to-make-array-equal.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int minOperations(int n) { 5 | 6 | // if n is even, then we have to make all elements equal to avg of (n/2 - 1)th and (n/2)th element 7 | // if n is odd, then we have to make all elements qual to (n/2)th element 8 | 9 | // if n is even or odd, we have to make all elements equal to n 10 | 11 | return (n * n) / 4; 12 | } 13 | 14 | }; -------------------------------------------------------------------------------- /1551-minimum-operations-to-make-array-equal/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1556-thousand-separator/1556-thousand-separator.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | string thousandSeparator(int n) { 5 | 6 | string res = ""; 7 | 8 | string temp = to_string(n); 9 | int siz = temp.size(); 10 | 11 | int c = 0; 12 | 13 | for(int i=siz-1; i>=0; i--) { 14 | 15 | res += temp[i]; 16 | 17 | c++; 18 | if(c % 3 == 0 && i > 0) res += '.'; 19 | } 20 | 21 | reverse(res.begin(), res.end()); 22 | return res; 23 | } 24 | 25 | }; -------------------------------------------------------------------------------- /1556-thousand-separator/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1556-thousand-separator/README.md: -------------------------------------------------------------------------------- 1 |

1556. Thousand Separator

Easy


Given an integer n, add a dot (".") as the thousands separator and return it in string format.

2 | 3 |

 

4 |

Example 1:

5 | 6 |
Input: n = 987
 7 | Output: "987"
 8 | 
9 | 10 |

Example 2:

11 | 12 |
Input: n = 1234
13 | Output: "1.234"
14 | 
15 | 16 |

 

17 |

Constraints:

18 | 19 |
    20 |
  • 0 <= n <= 231 - 1
  • 21 |
22 |
-------------------------------------------------------------------------------- /1557-minimum-number-of-vertices-to-reach-all-nodes/1557-minimum-number-of-vertices-to-reach-all-nodes.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | vector findSmallestSetOfVertices(int n, vector>& edges) { 5 | 6 | vector res, indegree(n); 7 | unordered_map> adj; 8 | 9 | for(auto &x : edges) { 10 | adj[x[0]].push_back(x[1]); 11 | indegree[x[1]]++; 12 | } 13 | 14 | for(int i=0; i& a, int m, int k) { 5 | 6 | int count = 0; 7 | int n = a.size(); 8 | 9 | // Subarray of size m should repeat greater or equal to k times consecutively 10 | 11 | for(int i=0; i& neededTime) { 5 | 6 | int time = 0; 7 | int n = a.size(); 8 | 9 | time = neededTime[0]; 10 | int maxCost = neededTime[0]; 11 | 12 | for(int i=1; i& a) { 5 | 6 | int sum = 0; 7 | int n = a.size(); 8 | 9 | int l = 3; 10 | 11 | for(int i=0; i& logs) { 5 | 6 | int count = 0; 7 | int n = logs.size(); 8 | 9 | for(auto &x : logs) { 10 | 11 | if(x[0] != '.') count++; 12 | else if(x.size() == 3 && x[2] == '/') { 13 | if(count > 0) count--; 14 | } 15 | } 16 | 17 | return count; 18 | } 19 | 20 | }; -------------------------------------------------------------------------------- /1598-crawler-log-folder/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /16-3sum-closest/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /160-intersection-of-two-linked-lists/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1602-find-nearest-right-node-in-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1603-design-parking-system/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1609-even-odd-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1614-maximum-nesting-depth-of-the-parentheses/1614-maximum-nesting-depth-of-the-parentheses.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int maxDepth(string s) { 5 | 6 | int res = 0, cur = 0; 7 | int n = s.length(); 8 | 9 | // Ignore digits and signs, only count the current open parentheses cur. 10 | // The depth equals to the maximum open parentheses. 11 | 12 | for(int i=0; i v(26, -1); 8 | 9 | for (int i=0; i& a) { 5 | 6 | int count = 0; 7 | int n = a.size(); 8 | 9 | vector left(2), right(2); 10 | 11 | for(int i=0; i= 0) { 12 | 13 | res += 'A' + (n % 26); 14 | n /= 26; 15 | 16 | n--; 17 | } 18 | 19 | reverse(res.begin(), res.end()); 20 | return res; 21 | } 22 | 23 | }; -------------------------------------------------------------------------------- /168-excel-sheet-column-title/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1686-stone-game-vi/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1688-count-of-matches-in-tournament/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1689-partitioning-into-minimum-number-of-deci-binary-numbers/1689-partitioning-into-minimum-number-of-deci-binary-numbers.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int minPartitions(string n) { 5 | 6 | int res = INT_MIN; 7 | 8 | for(auto &x : n) { 9 | int temp = (int)(x - '0'); 10 | res = max(res, temp); 11 | } 12 | 13 | return res; 14 | } 15 | 16 | }; -------------------------------------------------------------------------------- /1689-partitioning-into-minimum-number-of-deci-binary-numbers/NOTES.md: -------------------------------------------------------------------------------- 1 | Refer https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers/discuss/970318/JavaC%2B%2BPython-Just-return-max-digit -------------------------------------------------------------------------------- /169-majority-element/169-majority-element.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int majorityElement(vector& nums) { 5 | 6 | int res; 7 | int n = nums.size(); 8 | 9 | unordered_map mp; 10 | 11 | for(auto &x : nums) { 12 | mp[x]++; 13 | if(mp[x] > n / 2) return x; 14 | } 15 | 16 | return -1; 17 | } 18 | 19 | }; -------------------------------------------------------------------------------- /169-majority-element/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1694-reformat-phone-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /170-two-sum-iii-data-structure-design/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1705-maximum-number-of-eaten-apples/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1708-largest-subarray-length-k/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1716-calculate-money-in-leetcode-bank/1716-calculate-money-in-leetcode-bank.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int totalMoney(int n) { 5 | 6 | int ans = 0; 7 | vector a(n + 1); 8 | 9 | a[1] = 1; 10 | 11 | for(int i=2; i<=n; i++) { 12 | 13 | if(i >= 8 && i % 7 == 1) a[i] = a[i - 7] + 1; 14 | else a[i] = a[i-1] + 1; 15 | } 16 | 17 | for(auto &x : a) ans += x; 18 | 19 | return ans; 20 | } 21 | 22 | }; -------------------------------------------------------------------------------- /1716-calculate-money-in-leetcode-bank/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1720-decode-xored-array/1720-decode-xored-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | vector decode(vector& encoded, int first) { 5 | 6 | int n = encoded.size(); 7 | vector a(n + 1); 8 | 9 | a[0] = first; 10 | 11 | // Here, encoded[i] = a[i] ^ a[i + 1], so a[i + 1] = encoded[i] * a[i] 12 | 13 | for(int i=0; i>& rect) { 5 | 6 | int count = 0; 7 | unordered_map u; 8 | 9 | int maxLen = INT_MIN; 10 | 11 | for(int i=0; i& a) { 5 | 6 | int maxi = 0; 7 | int n = a.size(); 8 | 9 | int temp = 0; 10 | 11 | for(int i=0; i v; 5 | 6 | MRUQueue(int n) { 7 | 8 | for(int i=1; i<=n; i++) v.push_back(i); 9 | } 10 | 11 | int fetch(int k) { 12 | 13 | // Removes the kth element and moves it to the end (Considering 1-based indexing) 14 | 15 | int temp = v[k-1]; 16 | v.erase(v.begin() + k - 1); 17 | 18 | v.push_back(temp); 19 | return temp; 20 | } 21 | 22 | }; 23 | 24 | /** 25 | * Your MRUQueue object will be instantiated and called as such: 26 | * MRUQueue* obj = new MRUQueue(n); 27 | * int param_1 = obj->fetch(k); 28 | */ -------------------------------------------------------------------------------- /1756-design-most-recently-used-queue/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1762-buildings-with-an-ocean-view/1762-buildings-with-an-ocean-view.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | vector findBuildings(vector& a) { 5 | 6 | vector res, maxR; 7 | int n = a.size(); 8 | 9 | for(int i=n-1; i>=0; i--) { 10 | if(res.empty() == true || a[i] > a[res.back()]) res.push_back(i); 11 | } 12 | 13 | reverse(res.begin(), res.end()); 14 | return res; 15 | } 16 | 17 | }; -------------------------------------------------------------------------------- /1762-buildings-with-an-ocean-view/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1763-longest-nice-substring/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1769-minimum-number-of-operations-to-move-all-balls-to-each-box/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1772-sort-features-by-popularity/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1784-check-if-binary-string-has-at-most-one-segment-of-ones/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1786-number-of-restricted-paths-from-first-to-last-node/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1791-find-center-of-star-graph/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1796-second-largest-digit-in-a-string/1796-second-largest-digit-in-a-string.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int secondHighest(string s) { 5 | 6 | int res = -1; 7 | set dig; 8 | 9 | for(auto &x : s) { 10 | if(x >= '0' && x <= '9') dig.insert((int)(x - '0')); 11 | } 12 | 13 | if(dig.size() >= 2) { 14 | 15 | auto it = dig.end(); 16 | 17 | it--; 18 | it--; 19 | 20 | return *it; 21 | } 22 | 23 | return res; 24 | } 25 | 26 | }; -------------------------------------------------------------------------------- /1796-second-largest-digit-in-a-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1800-maximum-ascending-subarray-sum/1800-maximum-ascending-subarray-sum.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int maxAscendingSum(vector& a) { 5 | 6 | int ans = a[0]; 7 | int n = a.size(); 8 | 9 | int sum = a[0]; 10 | 11 | // Find all ascending subarray 12 | for(int i=1; i b.salary; -------------------------------------------------------------------------------- /181-employees-earning-more-than-their-managers/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /182-duplicate-emails/182-duplicate-emails.sql: -------------------------------------------------------------------------------- 1 | # Write your MySQL query statement below 2 | 3 | # SELECT Email 4 | # FROM ( 5 | # SELECT Person.Email, COUNT(Email) as num 6 | # FROM Person 7 | # GROUP BY Email 8 | # ) AS statistic 9 | # WHERE num > 1; 10 | 11 | 12 | SELECT Person.Email 13 | FROM Person 14 | GROUP BY Email 15 | HAVING COUNT(Email) > 1; 16 | -------------------------------------------------------------------------------- /182-duplicate-emails/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1822-sign-of-the-product-of-an-array/1822-sign-of-the-product-of-an-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int arraySign(vector& v) { 5 | 6 | int noNegative = 0, noZero = 0; 7 | 8 | for(auto &x : v) { 9 | if(x == 0) noZero++; 10 | else if(x < 0) noNegative++; 11 | } 12 | 13 | if(noZero >= 1) return 0; 14 | 15 | else if(noNegative >= 1) { 16 | if(noNegative % 2 == 0) return 1; 17 | else return -1; 18 | } 19 | 20 | return 1; 21 | } 22 | 23 | }; -------------------------------------------------------------------------------- /1822-sign-of-the-product-of-an-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1826-faulty-sensor/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1827-minimum-operations-to-make-the-array-increasing/1827-minimum-operations-to-make-the-array-increasing.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int minOperations(vector& v) { 5 | 6 | int count = 0; 7 | int n = v.size(); 8 | 9 | if(n <= 1) return 0; 10 | 11 | int temp = v[0]; 12 | 13 | for(int i=1; i= v[i]) { 16 | count += (temp - v[i]) + 1; 17 | temp++; 18 | } 19 | 20 | else temp = v[i]; 21 | } 22 | 23 | return count; 24 | } 25 | 26 | }; -------------------------------------------------------------------------------- /1827-minimum-operations-to-make-the-array-increasing/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /183-customers-who-never-order/183-customers-who-never-order.sql: -------------------------------------------------------------------------------- 1 | # Write your MySQL query statement below 2 | 3 | SELECT Customers.name AS Customers 4 | FROM Customers 5 | WHERE Customers.id NOT IN ( 6 | SELECT Orders.customerId 7 | FROM Orders 8 | ); -------------------------------------------------------------------------------- /183-customers-who-never-order/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1837-sum-of-digits-in-base-k/1837-sum-of-digits-in-base-k.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int sumBase(int n, int k) { 5 | 6 | int sum = 0; 7 | vector digits; 8 | 9 | // First, convert the number n from base 10 to base k 10 | while(n > 0) { 11 | 12 | int dig = n % k; 13 | digits.push_back(dig); 14 | 15 | n = n / k; 16 | } 17 | 18 | for(auto &x : digits) sum += x; 19 | 20 | return sum; 21 | } 22 | 23 | }; -------------------------------------------------------------------------------- /1837-sum-of-digits-in-base-k/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1845-seat-reservation-manager/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1850-minimum-adjacent-swaps-to-reach-the-kth-smallest-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1852-distinct-numbers-in-each-subarray/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1863-sum-of-all-subset-xor-totals/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1874-minimize-product-sum-of-two-arrays/1874-minimize-product-sum-of-two-arrays.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int minProductSum(vector& a1, vector& a2) { 5 | 6 | int ans = 0; 7 | 8 | int n = a1.size(); 9 | 10 | sort(a1.begin(), a1.end()); 11 | sort(a2.begin(), a2.end(), greater()); 12 | 13 | for(int i=0; i>& ranges, int left, int right) { 5 | 6 | map mp; 7 | 8 | for(auto &x : ranges) { 9 | 10 | int start = x[0]; 11 | int end = x[1]; 12 | 13 | for(int i=start; i<=end; i++) mp[i] = 1; 14 | } 15 | 16 | for(int i=left; i<=right; i++) { 17 | if(mp[i] == 0) return false; 18 | } 19 | 20 | return true; 21 | } 22 | 23 | }; -------------------------------------------------------------------------------- /1893-check-if-all-the-integers-in-a-range-are-covered/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1897-redistribute-characters-to-make-all-strings-equal/1897-redistribute-characters-to-make-all-strings-equal.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool makeEqual(vector& words) { 5 | 6 | unordered_map u; 7 | int n = words.size(); 8 | 9 | for(auto &x : words) { 10 | for(auto &x1 : x) u[x1]++; 11 | } 12 | 13 | for(auto &x : u) { 14 | int freq = x.second; 15 | if(freq % n != 0) return false; 16 | } 17 | 18 | return true; 19 | } 20 | 21 | }; -------------------------------------------------------------------------------- /1897-redistribute-characters-to-make-all-strings-equal/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /19-remove-nth-node-from-end-of-list/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1901-find-a-peak-element-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1903-largest-odd-number-in-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /191-number-of-1-bits/191-number-of-1-bits.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int hammingWeight(uint32_t n) { 5 | 6 | int count = 0; 7 | 8 | while(n) { 9 | count += (n % 2); 10 | n >>= 1; 11 | } 12 | 13 | return count; 14 | } 15 | 16 | }; -------------------------------------------------------------------------------- /191-number-of-1-bits/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1910-remove-all-occurrences-of-a-substring/1910-remove-all-occurrences-of-a-substring.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | string removeOccurrences(string s, string part) { 5 | 6 | int len = part.length(); 7 | 8 | while(true) { 9 | 10 | auto ind = s.find(part); 11 | 12 | if(ind == string :: npos) return s; 13 | else s.erase(ind, len); 14 | } 15 | 16 | return s; 17 | } 18 | 19 | }; -------------------------------------------------------------------------------- /1910-remove-all-occurrences-of-a-substring/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1913-maximum-product-difference-between-two-pairs/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1920-build-array-from-permutation/1920-build-array-from-permutation.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | vector buildArray(vector& a) { 5 | 6 | int n = a.size(); 7 | vector res(n); 8 | 9 | for(int i=0; i getConcatenation(vector& a) { 5 | 6 | int n = a.size(); 7 | vector res(2*n); 8 | 9 | for(int i=0; i w; 7 | int n = s.length(); 8 | 9 | unordered_map u; 10 | 11 | for(auto &x : s) u[x]++; 12 | for(auto &x : u) w.insert(x.second); 13 | 14 | return (w.size() <= 1); 15 | } 16 | 17 | }; 18 | -------------------------------------------------------------------------------- /1941-check-if-all-characters-have-equal-number-of-occurrences/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1945-sum-of-digits-of-string-after-convert/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1952-three-divisors/1952-three-divisors.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool isThree(int n) { 5 | 6 | int c = 0; 7 | 8 | if(n <= 3) return false; 9 | 10 | for(int i=2; i= 2) return false; 17 | } 18 | 19 | if(c == 0) return false; 20 | 21 | return (c == 1); 22 | } 23 | 24 | }; -------------------------------------------------------------------------------- /1952-three-divisors/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1957-delete-characters-to-make-fancy-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /196-delete-duplicate-emails/196-delete-duplicate-emails.sql: -------------------------------------------------------------------------------- 1 | # Write your MySQL query statement below 2 | 3 | DELETE p1 4 | FROM Person AS p1, Person AS p2 5 | WHERE p1.Email = p2.Email AND p1.Id > p2.Id; 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /196-delete-duplicate-emails/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1961-check-if-string-is-a-prefix-of-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1962-remove-stones-to-minimize-the-total/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1963-minimum-number-of-swaps-to-make-the-string-balanced/NOTES.md: -------------------------------------------------------------------------------- 1 | Refer https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-string-balanced/discuss/1390811/Clear-Explanation-oror-C%2B%2B-oror-Greedy-oror-Detailed-Explanation -------------------------------------------------------------------------------- /1967-number-of-strings-that-appear-as-substrings-in-word/1967-number-of-strings-that-appear-as-substrings-in-word.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int numOfStrings(vector& pat, string word) { 5 | 6 | int count = 0; 7 | int n = pat.size(); 8 | 9 | for(auto &x : pat) { 10 | 11 | // Checks whether x substring exists in string word 12 | if(word.find(x) != string::npos) count++; 13 | } 14 | 15 | return count; 16 | } 17 | 18 | }; -------------------------------------------------------------------------------- /1967-number-of-strings-that-appear-as-substrings-in-word/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1971-find-if-path-exists-in-graph/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1973-count-nodes-equal-to-sum-of-descendants/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1974-minimum-time-to-type-word-using-special-typewriter/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1976-number-of-ways-to-arrive-at-destination/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1979-find-greatest-common-divisor-of-array/1979-find-greatest-common-divisor-of-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | // Here, we assume that a > b 5 | int gcd(int a, int b) { 6 | 7 | int rem; 8 | 9 | while(b > 0) { 10 | 11 | rem = a % b; 12 | 13 | a = b; 14 | b = rem; 15 | } 16 | 17 | return a; 18 | } 19 | 20 | int findGCD(vector& v) { 21 | 22 | int n = v.size(); 23 | sort(v.begin(), v.end()); 24 | 25 | return gcd(v[0], v[n-1]); 26 | } 27 | 28 | }; -------------------------------------------------------------------------------- /1979-find-greatest-common-divisor-of-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1984-minimum-difference-between-highest-and-lowest-of-k-scores/1984-minimum-difference-between-highest-and-lowest-of-k-scores.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int minimumDifference(vector& nums, int k) { 5 | 6 | int res = INT_MAX; 7 | int n = nums.size(); 8 | 9 | sort(nums.begin(), nums.end()); 10 | 11 | for(int i=0; i<=n-k; i++) res = min(res, nums[i + k - 1] - nums[i]); 12 | return res; 13 | } 14 | 15 | }; -------------------------------------------------------------------------------- /1984-minimum-difference-between-highest-and-lowest-of-k-scores/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1985-find-the-kth-largest-integer-in-the-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /199-binary-tree-right-side-view/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1991-find-the-middle-index-in-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2-add-two-numbers/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /20-valid-parentheses/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2000-reverse-prefix-of-word/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2006-count-number-of-pairs-with-absolute-difference-k/2006-count-number-of-pairs-with-absolute-difference-k.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int countKDifference(vector& a, int k) { 5 | 6 | int count = 0; 7 | int n = a.size(); 8 | 9 | for(int i=0; i& v) { 5 | 6 | int res = 0; 7 | int n = v.size(); 8 | 9 | for(int i=0; i& v) { 5 | 6 | int maxi = -1; 7 | int n = v.size(); 8 | 9 | int mn = v[0]; // Minimum element from left side 10 | 11 | for(int i=1; i> construct2DArray(vector& a, int m, int n) { 5 | 6 | vector> res; 7 | 8 | int siz = a.size(); 9 | vector temp; 10 | 11 | if(siz != m * n) return res; 12 | 13 | for(int i=0; i& nums, string target) { 5 | 6 | int count = 0; 7 | int n = nums.size(); 8 | 9 | for(int i=0; i twoOutOfThree(vector& nums1, vector& nums2, vector& nums3) { 5 | 6 | vector res; 7 | int cnt[3][101] = {}; 8 | 9 | for(auto n : nums1) cnt[0][n] = 1; 10 | for(auto n : nums2) cnt[1][n] = 1; 11 | for(auto n : nums3) cnt[2][n] = 1; 12 | 13 | for (int i=1; i<=100; i++) { 14 | if(cnt[0][i] + cnt[1][i] + cnt[2][i] >= 2) res.push_back(i); 15 | } 16 | 17 | return res; 18 | } 19 | 20 | }; -------------------------------------------------------------------------------- /2032-two-out-of-three/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2033-minimum-operations-to-make-a-uni-value-grid/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2037-minimum-number-of-moves-to-seat-everyone/2037-minimum-number-of-moves-to-seat-everyone.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int minMovesToSeat(vector& seats, vector& students) { 5 | 6 | int moves = 0; 7 | 8 | sort(seats.begin(), seats.end()); 9 | sort(students.begin(), students.end()); 10 | 11 | int n = seats.size(); 12 | 13 | for(int i=0; i= cur) return false; 15 | 16 | prev = cur; 17 | cur = 0; 18 | } 19 | } 20 | 21 | return (cur == 0 || prev < cur); 22 | } 23 | 24 | }; -------------------------------------------------------------------------------- /2042-check-if-numbers-are-ascending-in-a-sentence/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2047-number-of-valid-words-in-a-sentence/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2049-count-nodes-with-the-highest-score/NOTES.md: -------------------------------------------------------------------------------- 1 | https://www.youtube.com/watch?v=5wSXA6qn4BI&ab_channel=CodingDecoded -------------------------------------------------------------------------------- /2053-kth-distinct-string-in-an-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2057-smallest-index-with-equal-value/2057-smallest-index-with-equal-value.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int smallestEqual(vector& v) { 5 | 6 | int n = v.size(); 7 | 8 | for(int i=0; i u1, u2; 7 | 8 | for(auto &x : word1) u1[x]++; 9 | for(auto &x : word2) u2[x]++; 10 | 11 | for(int i=0; i<26; i++) { 12 | 13 | char ch = (char)(i + 97); 14 | 15 | if( (u1[ch] > 0 || u2[ch] > 0) && abs(u1[ch] - u2[ch]) > 3) return false; 16 | } 17 | 18 | return true; 19 | } 20 | 21 | }; -------------------------------------------------------------------------------- /2068-check-whether-two-strings-are-almost-equivalent/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /207-course-schedule/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2073-time-needed-to-buy-tickets/2073-time-needed-to-buy-tickets.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int timeRequiredToBuy(vector& v, int k) { 5 | 6 | int time = 0; 7 | int n = v.size(); 8 | 9 | while(v[k] > 0) { 10 | 11 | // Decrease each element of array by 1 12 | 13 | for(int i=0; i 0; i++) { 14 | 15 | if(v[i] > 0) { 16 | v[i]--; 17 | time++; 18 | } 19 | } 20 | } 21 | 22 | return time; 23 | } 24 | 25 | }; -------------------------------------------------------------------------------- /2073-time-needed-to-buy-tickets/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2074-reverse-nodes-in-even-length-groups/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2078-two-furthest-houses-with-different-colors/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2083-substrings-that-begin-and-end-with-the-same-letter/2083-substrings-that-begin-and-end-with-the-same-letter.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | long long numberOfSubstrings(string s) { 5 | 6 | long long res = 0; 7 | int n = s.length(); 8 | 9 | unordered_map mp; 10 | 11 | for(auto &x : s) { 12 | mp[x]++; 13 | res += mp[x]; 14 | } 15 | 16 | return res; 17 | } 18 | 19 | }; -------------------------------------------------------------------------------- /2083-substrings-that-begin-and-end-with-the-same-letter/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2085-count-common-words-with-one-occurrence/2085-count-common-words-with-one-occurrence.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int countWords(vector& words1, vector& words2) { 5 | 6 | int count = 0; 7 | unordered_map u1, u2; 8 | 9 | for(auto &x : words1) u1[x]++; 10 | for(auto &x : words2) u2[x]++; 11 | 12 | for(auto &x : u1) { 13 | if(x.second == 1 && u2[x.first] == 1) count++; 14 | } 15 | 16 | return count; 17 | } 18 | 19 | }; -------------------------------------------------------------------------------- /2085-count-common-words-with-one-occurrence/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2089-find-target-indices-after-sorting-array/2089-find-target-indices-after-sorting-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | vector targetIndices(vector& a, int tar) { 5 | 6 | vector res; 7 | 8 | int n = a.size(); 9 | sort(a.begin(), a.end()); 10 | 11 | for(int i=0; i> u; 8 | 9 | for(int i=0; i temp = x.second; 19 | if(temp.size() == 3) count++; 20 | } 21 | 22 | return count; 23 | } 24 | 25 | 26 | }; -------------------------------------------------------------------------------- /2103-rings-and-rods/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2108-find-first-palindromic-string-in-the-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2119-a-number-after-a-double-reversal/2119-a-number-after-a-double-reversal.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool isSameAfterReversals(int n) { 5 | 6 | if(n == 0) return true; 7 | 8 | int lastDigit = n % 10; 9 | 10 | return (lastDigit != 0); 11 | } 12 | 13 | }; -------------------------------------------------------------------------------- /2119-a-number-after-a-double-reversal/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2120-execution-of-all-suffix-instructions-staying-in-a-grid/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2124-check-if-all-as-appears-before-all-bs/2124-check-if-all-as-appears-before-all-bs.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool checkString(string s) { 5 | 6 | int n = s.length(); 7 | 8 | // Find the rightmost index of A, and leftmost index of B 9 | int maxIndexA = INT_MIN, minIndexB = INT_MAX; 10 | 11 | for(int i=0; i>& grid) { 5 | 6 | int n = grid.size(); 7 | int m = grid[0].size(); 8 | 9 | for(int i=0; i>& mat) { 5 | 6 | int n = mat.size(); 7 | 8 | for(int i=0; i u1, u2; 11 | 12 | for(int j=0; j& nums) { 5 | 6 | int res = 0; 7 | 8 | int n = nums.size(); 9 | sort(nums.begin(), nums.end()); 10 | 11 | for(int i=1; i rearrangeArray(vector& a) { 5 | 6 | vector res; 7 | 8 | int n = a.size(); 9 | res.resize(n); 10 | 11 | int i = 0; 12 | 13 | for(auto &x : a) { 14 | if(x > 0) { 15 | res[i] = x; 16 | i += 2; 17 | } 18 | } 19 | 20 | i = 1; 21 | 22 | for(auto &x : a) { 23 | if(x < 0) { 24 | res[i] = x; 25 | i += 2; 26 | } 27 | } 28 | 29 | return res; 30 | } 31 | 32 | }; -------------------------------------------------------------------------------- /2149-rearrange-array-elements-by-sign/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /215-kth-largest-element-in-an-array/215-kth-largest-element-in-an-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int findKthLargest(vector& nums, int k) { 5 | 6 | sort(nums.begin(), nums.end(), greater()); 7 | return nums[k-1]; 8 | } 9 | 10 | }; -------------------------------------------------------------------------------- /215-kth-largest-element-in-an-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2154-keep-multiplying-found-values-by-two/2154-keep-multiplying-found-values-by-two.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int findFinalValue(vector& a, int orig) { 5 | 6 | int n = a.size(); 7 | 8 | while(true) { 9 | 10 | auto it = find(a.begin(), a.end(), orig); 11 | 12 | if(it != a.end()) orig *= 2; 13 | else break; 14 | } 15 | 16 | return orig; 17 | } 18 | 19 | }; -------------------------------------------------------------------------------- /2154-keep-multiplying-found-values-by-two/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2160-minimum-sum-of-four-digit-number-after-splitting-digits/2160-minimum-sum-of-four-digit-number-after-splitting-digits.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int minimumSum(int num) { 5 | 6 | int res = 0; 7 | 8 | // Split num into min two numbers 9 | 10 | string s = to_string(num); 11 | sort(s.begin(), s.end()); 12 | 13 | res += ( 10 * ( (s[0] - '0') + (s[1] - '0') ) ) + ( (s[2] - '0') + (s[3] - '0') ); 14 | return res; 15 | } 16 | 17 | }; -------------------------------------------------------------------------------- /2160-minimum-sum-of-four-digit-number-after-splitting-digits/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2164-sort-even-and-odd-indices-independently/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2169-count-operations-to-obtain-zero/2169-count-operations-to-obtain-zero.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int countOperations(int n1, int n2) { 5 | 6 | int count = 0; 7 | 8 | while(true) { 9 | 10 | if(n1 == 0 || n2 == 0) break; 11 | 12 | if(n1 >= n2) n1 -= n2; 13 | else n2 -= n1; 14 | 15 | count++; 16 | } 17 | 18 | return count; 19 | } 20 | 21 | }; -------------------------------------------------------------------------------- /2169-count-operations-to-obtain-zero/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /217-contains-duplicate/217-contains-duplicate.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool containsDuplicate(vector& nums) { 5 | 6 | map mp; 7 | 8 | for(auto &x : nums) { 9 | mp[x]++; 10 | if(mp[x] == 2) return true; 11 | } 12 | 13 | return false; 14 | } 15 | 16 | }; -------------------------------------------------------------------------------- /217-contains-duplicate/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2192-all-ancestors-of-a-node-in-a-directed-acyclic-graph/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2196-create-binary-tree-from-descriptions/NOTES.md: -------------------------------------------------------------------------------- 1 | https://www.youtube.com/watch?v=ilS3HSDVvE8&t=407s&ab_channel=CodingDecoded -------------------------------------------------------------------------------- /22-generate-parentheses/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /22-generate-parentheses/README.md: -------------------------------------------------------------------------------- 1 |

22. Generate Parentheses

Medium


Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

2 | 3 |

 

4 |

Example 1:

5 |
Input: n = 3
 6 | Output: ["((()))","(()())","(())()","()(())","()()()"]
 7 | 

Example 2:

8 |
Input: n = 1
 9 | Output: ["()"]
10 | 
11 |

 

12 |

Constraints:

13 | 14 |
    15 |
  • 1 <= n <= 8
  • 16 |
17 |
-------------------------------------------------------------------------------- /222-count-complete-tree-nodes/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /225-implement-stack-using-queues/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /226-invert-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2265-count-nodes-equal-to-average-of-subtree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /227-basic-calculator-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2285-maximum-total-importance-of-roads/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /23-merge-k-sorted-lists/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /230-kth-smallest-element-in-a-bst/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /231-power-of-two/231-power-of-two.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool isPowerOfTwo(int n) { 5 | 6 | if(n == 1) return true; 7 | if(n <= 0) return false; 8 | 9 | if(n % 2 == 0) { 10 | 11 | while(n >= 2 && n % 2 == 0) { 12 | n = n / 2; 13 | } 14 | 15 | return (n <= 2); 16 | } 17 | 18 | else return false; 19 | } 20 | 21 | }; -------------------------------------------------------------------------------- /231-power-of-two/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2316-count-unreachable-pairs-of-nodes-in-an-undirected-graph/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /232-implement-queue-using-stacks/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2328-number-of-increasing-paths-in-a-grid/NOTES.md: -------------------------------------------------------------------------------- 1 | https://www.youtube.com/watch?v=BKhZOTrCa6E -------------------------------------------------------------------------------- /234-palindrome-linked-list/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /235-lowest-common-ancestor-of-a-binary-search-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2351-first-letter-to-appear-twice/2351-first-letter-to-appear-twice.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | char repeatedCharacter(string s) { 5 | 6 | char res = 'a'; 7 | int n = s.length(); 8 | 9 | unordered_map mp; 10 | 11 | for(auto &x : s) { 12 | mp[x]++; 13 | if(mp[x] == 2) return x; 14 | } 15 | 16 | return res; 17 | } 18 | 19 | }; -------------------------------------------------------------------------------- /2351-first-letter-to-appear-twice/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2359-find-closest-node-to-given-two-nodes/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /236-lowest-common-ancestor-of-a-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2368-reachable-nodes-with-restrictions/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /237-delete-node-in-a-linked-list/237-delete-node-in-a-linked-list.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition for singly-linked list. 3 | * struct ListNode { 4 | * int val; 5 | * ListNode *next; 6 | * ListNode(int x) : val(x), next(NULL) {} 7 | * }; 8 | */ 9 | class Solution { 10 | public: 11 | 12 | void deleteNode(ListNode* node) { 13 | 14 | // Storing value of next node into node 15 | node->val = node->next->val; 16 | node->next = node->next->next; 17 | 18 | return; 19 | } 20 | 21 | }; -------------------------------------------------------------------------------- /237-delete-node-in-a-linked-list/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2374-node-with-highest-edge-score/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2385-amount-of-time-for-binary-tree-to-be-infected/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /239-sliding-window-maximum/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2390-removing-stars-from-a-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /24-swap-nodes-in-pairs/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2404-most-frequent-even-element/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2415-reverse-odd-levels-of-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /242-valid-anagram/242-valid-anagram.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool isAnagram(string s, string t) { 5 | 6 | if(s == t) return true; 7 | 8 | map mp; 9 | 10 | for(auto &x : s) mp[x]++; 11 | for(auto &x : t) mp[x]--; 12 | 13 | for(auto &x : mp) { 14 | if(x.second > 0 || x.second < 0) return false; 15 | } 16 | 17 | return true; 18 | } 19 | 20 | }; -------------------------------------------------------------------------------- /242-valid-anagram/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /243-shortest-word-distance/243-shortest-word-distance.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int shortestDistance(vector& wordsDict, string word1, string word2) { 5 | 6 | int res = INT_MAX; 7 | vector v1, v2; 8 | 9 | for(int i=0; i &a, const vector &b) { 5 | if(a[0] == b[0]) return a[1] < b[1]; 6 | else return a[0] < b[0]; 7 | } 8 | 9 | bool canAttendMeetings(vector>& v) { 10 | 11 | int n = v.size(); 12 | 13 | sort(v.begin(), v.end(), cmp); 14 | 15 | for(int i=1; i v[i][0]) return false; 18 | } 19 | 20 | return true; 21 | } 22 | 23 | }; -------------------------------------------------------------------------------- /252-meeting-rooms/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /257-binary-tree-paths/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /258-add-digits/258-add-digits.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int addDigits(int n) { 5 | 6 | int res; 7 | 8 | if(n == 0) return 0; 9 | 10 | int num = n; 11 | 12 | while(true) { 13 | 14 | int sum = 0; 15 | 16 | while(n > 0) { 17 | sum += (n % 10); 18 | n = n / 10; 19 | } 20 | 21 | n = sum; 22 | 23 | if(n <= 9) break; 24 | } 25 | 26 | res = n; 27 | return res; 28 | } 29 | 30 | }; -------------------------------------------------------------------------------- /258-add-digits/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /263-ugly-number/263-ugly-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool isUgly(int n) { 5 | 6 | vector primes = {2, 3, 5}; 7 | 8 | // Find all the prime factors of number 9 | if(n <= 0) return false; 10 | if(n == 1) return true; 11 | 12 | for(auto &x : primes) { 13 | while(n % x == 0) n = n / x; 14 | } 15 | 16 | return (n == 1); 17 | } 18 | 19 | }; -------------------------------------------------------------------------------- /263-ugly-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /266-palindrome-permutation/266-palindrome-permutation.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool canPermutePalindrome(string s) { 5 | 6 | unordered_map u; 7 | int count = 0; 8 | 9 | for(auto &x : s) u[x]++; 10 | 11 | // If more than odd occurence of number exists, then return false 12 | 13 | for(auto &x : u) { 14 | if(x.second % 2 == 1) count++; 15 | if(count >= 2) return false; 16 | } 17 | 18 | return true; 19 | } 20 | 21 | }; -------------------------------------------------------------------------------- /266-palindrome-permutation/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /268-missing-number/268-missing-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int missingNumber(vector& nums) { 5 | 6 | map mp; 7 | int n = nums.size(); 8 | int maxi = INT_MIN; 9 | 10 | for(auto &x : nums) { 11 | mp[x]++; 12 | maxi = max(maxi, x); 13 | } 14 | 15 | for(int i=0; i<=maxi; i++) { 16 | if(mp[i] == 0) return i; 17 | } 18 | 19 | return maxi + 1; 20 | } 21 | 22 | }; -------------------------------------------------------------------------------- /268-missing-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /27-remove-element/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /270-closest-binary-search-tree-value/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /283-move-zeroes/283-move-zeroes.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | void moveZeroes(vector& nums) { 5 | 6 | int n = nums.size(); 7 | int j = 0; 8 | 9 | for(int i=0; i= 3 && n % 3 == 0) { 12 | n = n / 3; 13 | } 14 | 15 | return (n == 1); 16 | } 17 | 18 | else return false; 19 | } 20 | 21 | }; -------------------------------------------------------------------------------- /326-power-of-three/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /328-odd-even-linked-list/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /329-longest-increasing-path-in-a-matrix/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /331-verify-preorder-serialization-of-a-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | https://www.youtube.com/watch?v=RzNYwhSQjHQ -------------------------------------------------------------------------------- /338-counting-bits/338-counting-bits.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int countOnes(int dig) { 5 | 6 | int count = 0; 7 | 8 | while(dig > 0) { 9 | count += (dig % 2); 10 | dig = dig / 2; 11 | } 12 | 13 | return count; 14 | } 15 | 16 | vector countBits(int n) { 17 | 18 | vector res(n + 1); 19 | 20 | for(int i=0; i<=n; i++) { 21 | 22 | int dig = i; 23 | 24 | // res[i] is the no.of 1's in binary representation of dig 25 | res[i] = countOnes(dig); 26 | } 27 | 28 | return res; 29 | } 30 | 31 | }; -------------------------------------------------------------------------------- /338-counting-bits/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /339-nested-list-weight-sum/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /342-power-of-four/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /344-reverse-string/344-reverse-string.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | void reverseString(vector& s) { 5 | 6 | reverse(s.begin(), s.end()); 7 | return; 8 | } 9 | 10 | }; -------------------------------------------------------------------------------- /344-reverse-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /345-reverse-vowels-of-a-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /346-moving-average-from-data-stream/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /347-top-k-frequent-elements/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /350-intersection-of-two-arrays-ii/350-intersection-of-two-arrays-ii.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | vector intersect(vector& nums1, vector& nums2) { 5 | 6 | vector res; 7 | 8 | int n = nums1.size(); 9 | int m = nums2.size(); 10 | 11 | map mp; 12 | 13 | for(auto &x : nums1) mp[x]++; 14 | 15 | for(auto &x : nums2) { 16 | if(mp[x] > 0) { 17 | res.push_back(x); 18 | mp[x]--; 19 | } 20 | } 21 | 22 | return res; 23 | } 24 | 25 | }; -------------------------------------------------------------------------------- /350-intersection-of-two-arrays-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /359-logger-rate-limiter/359-logger-rate-limiter.cpp: -------------------------------------------------------------------------------- 1 | class Logger { 2 | public: 3 | 4 | map u; 5 | 6 | Logger() { 7 | 8 | } 9 | 10 | bool shouldPrintMessage(int timestamp, string message) { 11 | 12 | if(u[message] == 0 || ( u[message] != 0 && timestamp >= u[message]) ) { 13 | u[message] = timestamp + 10; 14 | return true; 15 | } 16 | 17 | return false; 18 | } 19 | 20 | }; 21 | 22 | /** 23 | * Your Logger object will be instantiated and called as such: 24 | * Logger* obj = new Logger(); 25 | * bool param_1 = obj->shouldPrintMessage(timestamp,message); 26 | */ -------------------------------------------------------------------------------- /359-logger-rate-limiter/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /366-find-leaves-of-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /367-valid-perfect-square/367-valid-perfect-square.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool isPerfectSquare(int num) { 5 | 6 | long n = num; 7 | 8 | while(n * n > num) { 9 | n = (n + num / n) / 2; 10 | } 11 | 12 | return (n * n == num); 13 | } 14 | 15 | }; -------------------------------------------------------------------------------- /367-valid-perfect-square/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /37-sudoku-solver/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /373-find-k-pairs-with-smallest-sums/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /374-guess-number-higher-or-lower/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /378-kth-smallest-element-in-a-sorted-matrix/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /382-linked-list-random-node/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /383-ransom-note/383-ransom-note.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool canConstruct(string ransomNote, string magazine) { 5 | 6 | unordered_map u; 7 | 8 | for(auto &x : magazine) u[x]++; 9 | 10 | for(auto &x : ransomNote) { 11 | if(u[x] >= 1) u[x]--; 12 | else return false; 13 | } 14 | 15 | return true; 16 | } 17 | 18 | }; -------------------------------------------------------------------------------- /383-ransom-note/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /387-first-unique-character-in-a-string/387-first-unique-character-in-a-string.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int firstUniqChar(string s) { 5 | 6 | int res = -1; 7 | int n = s.length(); 8 | 9 | unordered_map mp; 10 | 11 | for(auto &x : s) mp[x]++; 12 | 13 | for(int i=0; i fizzBuzz(int n) { 13 | 14 | vector res; 15 | 16 | for(int i=1; i<=n; i++) { 17 | res.push_back(findString(i)); 18 | } 19 | 20 | return res; 21 | } 22 | 23 | }; -------------------------------------------------------------------------------- /412-fizz-buzz/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /413-arithmetic-slices/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /414-third-maximum-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /415-add-strings/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /417-pacific-atlantic-water-flow/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /42-trapping-rain-water/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /422-valid-word-square/422-valid-word-square.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool validWordSquare(vector& words) { 5 | 6 | int n = words.size(); 7 | 8 | for(int i=0; i n) return false; 13 | 14 | for(int j=0; j> word) count++; 14 | 15 | return count; 16 | } 17 | 18 | }; -------------------------------------------------------------------------------- /434-number-of-segments-in-a-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /437-path-sum-iii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /438-find-all-anagrams-in-a-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /442-find-all-duplicates-in-an-array/442-find-all-duplicates-in-an-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | vector findDuplicates(vector& a) { 5 | 6 | vector res; 7 | int n = a.size(); 8 | 9 | unordered_map u; 10 | 11 | for(auto &x : a) u[x]++; 12 | 13 | for(auto &x : u) { 14 | if(x.second >= 2) res.push_back(x.first); 15 | } 16 | 17 | return res; 18 | } 19 | 20 | }; -------------------------------------------------------------------------------- /442-find-all-duplicates-in-an-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /445-add-two-numbers-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /451-sort-characters-by-frequency/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /455-assign-cookies/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /459-repeated-substring-pattern/459-repeated-substring-pattern.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool repeatedSubstringPattern(string s) { 5 | 6 | int n = s.length(); 7 | 8 | // On removing the first and the last characters, if there exists some pattern, we would still be able to find the original string somewhere in the middle, taking some characters from the first half and some from the second half. 9 | 10 | return (s + s).substr(1, 2*n-2).find(s) != -1; 11 | } 12 | 13 | }; -------------------------------------------------------------------------------- /459-repeated-substring-pattern/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /461-hamming-distance/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /463-island-perimeter/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /476-number-complement/476-number-complement.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int findComplement(int n) { 5 | 6 | // Basic idea is to find the smallest power of 2 that is larger than num, and output the difference between powerof2s and num . 7 | 8 | long powerof2s = 2, temp = n; 9 | 10 | while(temp >> 1) { 11 | temp >>= 1; 12 | powerof2s <<= 1; 13 | } 14 | 15 | return (powerof2s - n - 1); 16 | } 17 | 18 | }; -------------------------------------------------------------------------------- /476-number-complement/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /482-license-key-formatting/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /49-group-anagrams/49-group-anagrams.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | vector> groupAnagrams(vector& s) { 5 | 6 | vector> res; 7 | 8 | set w; 9 | unordered_map> mp; 10 | 11 | for(auto &x : s) { 12 | 13 | string temp = x; 14 | sort(temp.begin(), temp.end()); 15 | 16 | w.insert(temp); 17 | mp[temp].push_back(x); 18 | } 19 | 20 | 21 | for(auto &x : w) { 22 | res.push_back(mp[x]); 23 | } 24 | 25 | return res; 26 | } 27 | 28 | }; -------------------------------------------------------------------------------- /49-group-anagrams/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /495-teemo-attacking/495-teemo-attacking.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int findPoisonedDuration(vector& timeSeries, int duration) { 5 | 6 | int time = 0; 7 | int n = timeSeries.size(); 8 | 9 | if(n == 0) return 0; 10 | 11 | int total = 0; 12 | 13 | for(int i=0; i sum; 6 | 7 | Solution(vector& w) { 8 | 9 | n = w.size(); 10 | 11 | for(int i=1; ipickIndex(); 32 | */ -------------------------------------------------------------------------------- /528-random-pick-with-weight/NOTES.md: -------------------------------------------------------------------------------- 1 | Refer https://www.youtube.com/watch?v=_pnWZe44rdo -------------------------------------------------------------------------------- /53-maximum-subarray/53-maximum-subarray.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxSubArray(vector& a) { 4 | 5 | int n = a.size(); 6 | 7 | int o_sum = a[0]; 8 | int cur_sum = a[0]; 9 | 10 | for(int i=1; i 0) cur_sum += a[i]; 13 | else cur_sum = a[i]; 14 | 15 | if(o_sum < cur_sum) o_sum = cur_sum; 16 | } 17 | 18 | return o_sum; 19 | } 20 | 21 | }; -------------------------------------------------------------------------------- /53-maximum-subarray/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /530-minimum-absolute-difference-in-bst/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /535-encode-and-decode-tinyurl/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /538-convert-bst-to-greater-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /543-diameter-of-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /544-output-contest-matches/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /547-number-of-provinces/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /551-student-attendance-record-i/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /556-next-greater-element-iii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /559-maximum-depth-of-n-ary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /56-merge-intervals/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /563-binary-tree-tilt/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /572-subtree-of-another-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /58-length-of-last-word/58-length-of-last-word.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int lengthOfLastWord(string s) { 5 | 6 | int res = 0; 7 | 8 | int n = s.length(); 9 | int i = n - 1; 10 | 11 | while(s[i] == ' ') { 12 | i--; 13 | } 14 | 15 | for( ; i>=0; i--) { 16 | if(s[i] == ' ') return res; 17 | res++; 18 | } 19 | 20 | return res; 21 | } 22 | 23 | }; -------------------------------------------------------------------------------- /58-length-of-last-word/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /589-n-ary-tree-preorder-traversal/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /590-n-ary-tree-postorder-traversal/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /604-design-compressed-string-iterator/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /605-can-place-flowers/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /61-rotate-list/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /617-merge-two-binary-trees/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /63-unique-paths-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /637-average-of-levels-in-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /647-palindromic-substrings/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /65-valid-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /653-two-sum-iv-input-is-a-bst/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /654-maximum-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /658-find-k-closest-elements/658-find-k-closest-elements.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | 5 | vector findClosestElements(vector& v, int k, int x) { 6 | 7 | vector res; 8 | 9 | // Sort the elements of v according to distance from x 10 | 11 | stable_sort(v.begin(), v.end(), [x](const auto a, const auto b) { 12 | return abs(a - x) < abs(b - x); 13 | }); 14 | 15 | v.resize(k); 16 | sort(v.begin(), v.end()); 17 | 18 | return v; 19 | } 20 | 21 | }; -------------------------------------------------------------------------------- /658-find-k-closest-elements/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /66-plus-one/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /662-maximum-width-of-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /669-trim-a-binary-search-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /67-add-binary/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /670-maximum-swap/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /678-valid-parenthesis-string/NOTES.md: -------------------------------------------------------------------------------- 1 | Refer https://www.youtube.com/watch?v=KuE_Cn3xhxI -------------------------------------------------------------------------------- /680-valid-palindrome-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /684-redundant-connection/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /69-sqrtx/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /692-top-k-frequent-words/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /693-binary-number-with-alternating-bits/693-binary-number-with-alternating-bits.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool hasAlternatingBits(int n) { 5 | 6 | string res = ""; 7 | 8 | while(n > 0) { 9 | res.push_back(n % 2); 10 | n = n / 2; 11 | } 12 | 13 | for(int i=1; iput(key,value); 31 | * int param_2 = obj->get(key); 32 | * obj->remove(key); 33 | */ -------------------------------------------------------------------------------- /706-design-hashmap/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /71-simplify-path/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /711-number-of-distinct-islands-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /714-best-time-to-buy-and-sell-stock-with-transaction-fee/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /716-max-stack/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /718-maximum-length-of-repeated-subarray/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /719-find-k-th-smallest-pair-distance/NOTES.md: -------------------------------------------------------------------------------- 1 | Refer https://www.youtube.com/watch?v=ym93rTBR4j8 -------------------------------------------------------------------------------- /728-self-dividing-numbers/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /733-flood-fill/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /734-sentence-similarity/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /742-closest-leaf-in-a-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /743-network-delay-time/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /744-find-smallest-letter-greater-than-target/744-find-smallest-letter-greater-than-target.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | char nextGreatestLetter(vector& letters, char target) { 5 | 6 | for(auto &x : letters) { 7 | if(x > target) return x; 8 | } 9 | 10 | return letters[0]; 11 | } 12 | 13 | }; -------------------------------------------------------------------------------- /744-find-smallest-letter-greater-than-target/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /747-largest-number-at-least-twice-of-others/747-largest-number-at-least-twice-of-others.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int dominantIndex(vector& nums) { 5 | 6 | int res = -1; 7 | 8 | int n = nums.size(); 9 | int maxi = INT_MIN; 10 | 11 | for(int i=0; i maxi) return -1; 21 | } 22 | 23 | return res; 24 | } 25 | 26 | }; -------------------------------------------------------------------------------- /747-largest-number-at-least-twice-of-others/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /748-shortest-completing-word/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /754-reach-a-number/754-reach-a-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int reachNumber(int target) { 5 | 6 | if(target == 0) return 0; 7 | 8 | target = abs(target); 9 | int steps = 0, sum = 0; 10 | 11 | 12 | while(sum < target) { 13 | sum += steps; 14 | steps++; 15 | } 16 | 17 | // Reach till the point when (sum - target) % 2 == 0 18 | while( (sum - target) % 2 == 1 ) { 19 | sum += steps; 20 | steps++; 21 | } 22 | 23 | return (steps - 1); 24 | } 25 | 26 | }; -------------------------------------------------------------------------------- /754-reach-a-number/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /76-minimum-window-substring/NOTES.md: -------------------------------------------------------------------------------- 1 | See Pepcoding -------------------------------------------------------------------------------- /760-find-anagram-mappings/760-find-anagram-mappings.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | vector anagramMappings(vector& a1, vector& a2) { 5 | 6 | vector res; 7 | 8 | // Here, a2 is the anagram of a1 9 | // u[i] = j, means that a1[i] = a2[j] 10 | 11 | for(int i=0; i& a) { 5 | 6 | int n = a.size(); 7 | 8 | if(a[0] > a[1]) return 0; 9 | 10 | for(int i=1; i a[i+1]) return i; 13 | } 14 | 15 | return n - 1; 16 | } 17 | 18 | }; -------------------------------------------------------------------------------- /852-peak-index-in-a-mountain-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /86-partition-list/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /860-lemonade-change/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /861-score-after-flipping-matrix/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /872-leaf-similar-trees/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /876-middle-of-the-linked-list/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /877-stone-game/877-stone-game.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool stoneGame(vector& piles) { 5 | 6 | int n = piles.size(); 7 | 8 | // Finding sum at even and odd indexes, considering 0-based indexing 9 | int sumEven = 0,sumOdd = 0; 10 | 11 | // Alice always starts first 12 | 13 | for(int i=0, j=1; i sortArray(vector& a) { 5 | 6 | vector res; 7 | 8 | // Form Min heap 9 | priority_queue, greater> pq; 10 | 11 | for(auto &x : a) pq.push(x); 12 | 13 | while(pq.empty() == false) { 14 | res.push_back(pq.top()); 15 | pq.pop(); 16 | } 17 | 18 | return res; 19 | } 20 | 21 | }; -------------------------------------------------------------------------------- /912-sort-an-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /912-sort-an-array/README.md: -------------------------------------------------------------------------------- 1 |

912. Sort an Array

Medium


Given an array of integers nums, sort the array in ascending order.

2 | 3 |

 

4 |

Example 1:

5 |
Input: nums = [5,2,3,1]
 6 | Output: [1,2,3,5]
 7 | 

Example 2:

8 |
Input: nums = [5,1,1,2,0,0]
 9 | Output: [0,0,1,1,2,5]
10 | 
11 |

 

12 |

Constraints:

13 | 14 |
    15 |
  • 1 <= nums.length <= 5 * 104
  • 16 |
  • -5 * 104 <= nums[i] <= 5 * 104
  • 17 |
18 |
-------------------------------------------------------------------------------- /92-reverse-linked-list-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /921-minimum-add-to-make-parentheses-valid/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /925-long-pressed-name/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /937-reorder-data-in-log-files/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /938-range-sum-of-bst/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /94-binary-tree-inorder-traversal/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /941-valid-mountain-array/941-valid-mountain-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | bool validMountainArray(vector& a) { 5 | 6 | int n = a.size(); 7 | 8 | int i = 0; 9 | 10 | while(i + 1 < n && a[i] < a[i + 1]) i++; 11 | 12 | // Peak can't be first or last 13 | if(i == 0 || i == n-1) return false; 14 | 15 | while(i + 1 < n && a[i] > a[i + 1]) i++; 16 | 17 | if(i == n-1) return true; 18 | return false; 19 | } 20 | 21 | }; -------------------------------------------------------------------------------- /941-valid-mountain-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /942-di-string-match/942-di-string-match.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | vector diStringMatch(string s) { 5 | 6 | vector res; 7 | 8 | int n = s.length(); 9 | res.resize(n + 1); 10 | 11 | int low = 0, high = n; 12 | 13 | for(int i=0; i& pushed, vector& popped) { 5 | 6 | stack stack; 7 | int i = 0; 8 | 9 | for (int x : pushed) { 10 | 11 | stack.push(x); 12 | 13 | while (stack.size() && stack.top() == popped[i]) { 14 | stack.pop(); 15 | i++; 16 | } 17 | } 18 | 19 | return stack.size() == 0; 20 | } 21 | }; -------------------------------------------------------------------------------- /946-validate-stack-sequences/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /947-most-stones-removed-with-same-row-or-column/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /951-flip-equivalent-binary-trees/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /965-univalued-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /973-k-closest-points-to-origin/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /98-validate-binary-search-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /980-unique-paths-iii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /983-minimum-cost-for-tickets/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /993-cousins-in-binary-tree/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /997-find-the-town-judge/997-find-the-town-judge.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int findJudge(int n, vector>& trust) { 5 | 6 | vector indegree(n + 1), outdegree(n + 1); 7 | 8 | for(auto &x : trust) { 9 | 10 | int u = x[0]; 11 | int v = x[1]; 12 | 13 | // u trust v i.e u -> v 14 | indegree[v]++; 15 | outdegree[u]++; 16 | } 17 | 18 | for(int i=1; i<=n; i++) { 19 | if(indegree[i] == n - 1 && outdegree[i] == 0) return i; 20 | } 21 | 22 | return -1; 23 | } 24 | 25 | }; -------------------------------------------------------------------------------- /997-find-the-town-judge/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Aman's-Leetcode-Solutions 2 | 3 | Collection of LeetCode questions to ace the coding interview! 4 | -------------------------------------------------------------------------------- /n-th-tribonacci-number/n-th-tribonacci-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int tribonacci(int n) { 5 | 6 | if(n == 0) return 0; 7 | else if(n <= 2) return 1; 8 | 9 | int dp[n + 1]; 10 | 11 | dp[0] = 0; 12 | dp[1] = 1; 13 | dp[2] = 1; 14 | 15 | for(int i=3; i<=n; i++) { 16 | dp[i] = dp[i-1] + dp[i-2] + dp[i-3]; 17 | } 18 | 19 | return dp[n]; 20 | } 21 | 22 | }; --------------------------------------------------------------------------------