├── .github └── FUNDING.yml ├── 0001-two-sum ├── 0001-two-sum.cpp ├── 0001-two-sum.py └── README.md ├── 0002-add-two-numbers ├── 0002-add-two-numbers.cpp └── README.md ├── 0003-longest-substring-without-repeating-characters ├── 0003-longest-substring-without-repeating-characters.cpp └── README.md ├── 0004-median-of-two-sorted-arrays ├── 0004-median-of-two-sorted-arrays.cpp └── README.md ├── 0005-longest-palindromic-substring ├── 0005-longest-palindromic-substring.cpp └── README.md ├── 0006-zigzag-conversion ├── 0006-zigzag-conversion.cpp └── README.md ├── 0007-reverse-integer ├── 0007-reverse-integer.cpp └── README.md ├── 0009-palindrome-number ├── 0009-palindrome-number.cpp └── README.md ├── 0011-container-with-most-water ├── 0011-container-with-most-water.cpp ├── 0011-container-with-most-water.py └── README.md ├── 0012-integer-to-roman ├── 0012-integer-to-roman.cpp └── README.md ├── 0013-roman-to-integer ├── 0013-roman-to-integer.py └── README.md ├── 0014-longest-common-prefix ├── 0014-longest-common-prefix.py └── README.md ├── 0015-3sum ├── 0015-3sum.cpp ├── 0015-3sum.py └── README.md ├── 0017-letter-combinations-of-a-phone-number ├── 0017-letter-combinations-of-a-phone-number.py └── README.md ├── 0019-remove-nth-node-from-end-of-list ├── 0019-remove-nth-node-from-end-of-list.cpp └── README.md ├── 0020-valid-parentheses ├── 0020-valid-parentheses.cpp ├── 0020-valid-parentheses.py └── README.md ├── 0021-merge-two-sorted-lists ├── 0021-merge-two-sorted-lists.py └── README.md ├── 0022-generate-parentheses ├── 0022-generate-parentheses.java ├── 0022-generate-parentheses.py └── README.md ├── 0023-merge-k-sorted-lists ├── 0023-merge-k-sorted-lists.cpp └── README.md ├── 0025-reverse-nodes-in-k-group ├── 0025-reverse-nodes-in-k-group.cpp └── README.md ├── 0026-remove-duplicates-from-sorted-array ├── 0026-remove-duplicates-from-sorted-array.cpp └── README.md ├── 0027-remove-element ├── 0027-remove-element.cpp └── README.md ├── 0028-find-the-index-of-the-first-occurrence-in-a-string ├── 0028-find-the-index-of-the-first-occurrence-in-a-string.cpp └── README.md ├── 0030-substring-with-concatenation-of-all-words ├── 0030-substring-with-concatenation-of-all-words.cpp └── README.md ├── 0031-next-permutation ├── 0031-next-permutation.cpp └── README.md ├── 0032-longest-valid-parentheses ├── 0032-longest-valid-parentheses.cpp └── README.md ├── 0033-search-in-rotated-sorted-array ├── 0033-search-in-rotated-sorted-array.cpp └── README.md ├── 0034-find-first-and-last-position-of-element-in-sorted-array ├── 0034-find-first-and-last-position-of-element-in-sorted-array.cpp └── README.md ├── 0035-search-insert-position ├── 0035-search-insert-position.cpp └── README.md ├── 0036-valid-sudoku ├── 0036-valid-sudoku.cpp ├── 0036-valid-sudoku.py └── README.md ├── 0038-count-and-say ├── 0038-count-and-say.go └── README.md ├── 0039-combination-sum ├── 0039-combination-sum.py └── README.md ├── 0041-first-missing-positive ├── 0041-first-missing-positive.cpp └── README.md ├── 0042-trapping-rain-water ├── 0042-trapping-rain-water.cpp ├── 0042-trapping-rain-water.py └── README.md ├── 0045-jump-game-ii ├── 0045-jump-game-ii.cpp └── README.md ├── 0046-permutations ├── 0046-permutations.cpp └── README.md ├── 0048-rotate-image ├── 0048-rotate-image.cpp └── README.md ├── 0049-group-anagrams ├── 0049-group-anagrams.cpp ├── 0049-group-anagrams.py └── README.md ├── 0050-powx-n ├── 0050-powx-n.cpp └── README.md ├── 0051-n-queens ├── 0051-n-queens.cpp └── README.md ├── 0052-n-queens-ii ├── 0052-n-queens-ii.py └── README.md ├── 0053-maximum-subarray ├── 0053-maximum-subarray.cpp ├── 0053-maximum-subarray.go └── README.md ├── 0054-spiral-matrix ├── 0054-spiral-matrix.cpp └── README.md ├── 0055-jump-game ├── 0055-jump-game.cpp └── README.md ├── 0056-merge-intervals ├── 0056-merge-intervals.cpp └── README.md ├── 0057-insert-interval ├── 0057-insert-interval.cpp └── README.md ├── 0058-length-of-last-word ├── 0058-length-of-last-word.cpp └── README.md ├── 0060-permutation-sequence ├── 0060-permutation-sequence.cpp ├── NOTES.md └── README.md ├── 0061-rotate-list ├── 0061-rotate-list.cpp └── README.md ├── 0062-unique-paths ├── 0062-unique-paths.cpp └── README.md ├── 0063-unique-paths-ii ├── 0063-unique-paths-ii.cpp └── README.md ├── 0064-minimum-path-sum ├── 0064-minimum-path-sum.cpp └── README.md ├── 0066-plus-one ├── 0066-plus-one.cpp └── README.md ├── 0067-add-binary ├── 0067-add-binary.js └── README.md ├── 0068-text-justification ├── 0068-text-justification.cpp └── README.md ├── 0069-sqrtx ├── 0069-sqrtx.cpp └── README.md ├── 0070-climbing-stairs ├── 0070-climbing-stairs.cpp └── README.md ├── 0071-simplify-path ├── 0071-simplify-path.cpp └── README.md ├── 0072-edit-distance ├── 0072-edit-distance.cpp └── README.md ├── 0073-set-matrix-zeroes ├── 0073-set-matrix-zeroes.cpp ├── 0073-set-matrix-zeroes.py └── README.md ├── 0074-search-a-2d-matrix ├── 0074-search-a-2d-matrix.cpp └── README.md ├── 0075-sort-colors ├── 0075-sort-colors.cpp ├── 0075-sort-colors.py └── README.md ├── 0076-minimum-window-substring ├── 0076-minimum-window-substring.cpp └── README.md ├── 0077-combinations ├── 0077-combinations.cpp └── README.md ├── 0078-subsets ├── 0078-subsets.cpp └── README.md ├── 0079-word-search ├── 0079-word-search.cpp └── README.md ├── 0080-remove-duplicates-from-sorted-array-ii ├── 0080-remove-duplicates-from-sorted-array-ii.cpp └── README.md ├── 0082-remove-duplicates-from-sorted-list-ii ├── 0082-remove-duplicates-from-sorted-list-ii.cpp └── README.md ├── 0083-remove-duplicates-from-sorted-list ├── 0083-remove-duplicates-from-sorted-list.cpp └── README.md ├── 0084-largest-rectangle-in-histogram ├── 0084-largest-rectangle-in-histogram.cpp ├── 0084-largest-rectangle-in-histogram.py └── README.md ├── 0085-maximal-rectangle ├── 0085-maximal-rectangle.cpp └── README.md ├── 0086-partition-list ├── 0086-partition-list.cpp └── README.md ├── 0087-scramble-string ├── 0087-scramble-string.cpp └── README.md ├── 0088-merge-sorted-array ├── 0088-merge-sorted-array.cpp └── README.md ├── 0091-decode-ways ├── 0091-decode-ways.cpp └── README.md ├── 0092-reverse-linked-list-ii ├── 0092-reverse-linked-list-ii.cpp └── README.md ├── 0093-restore-ip-addresses ├── 0093-restore-ip-addresses.cpp ├── NOTES.md └── README.md ├── 0094-binary-tree-inorder-traversal ├── 0094-binary-tree-inorder-traversal.cpp ├── 0094-binary-tree-inorder-traversal.js └── README.md ├── 0097-interleaving-string ├── 0097-interleaving-string.cpp └── README.md ├── 0098-validate-binary-search-tree ├── 0098-validate-binary-search-tree.cpp └── README.md ├── 0099-recover-binary-search-tree ├── 0099-recover-binary-search-tree.go └── README.md ├── 0100-same-tree ├── 0100-same-tree.cpp ├── 0100-same-tree.py └── README.md ├── 0101-symmetric-tree ├── 0101-symmetric-tree.cpp └── README.md ├── 0102-binary-tree-level-order-traversal ├── 0102-binary-tree-level-order-traversal.rs └── README.md ├── 0103-binary-tree-zigzag-level-order-traversal ├── 0103-binary-tree-zigzag-level-order-traversal.cpp └── README.md ├── 0104-maximum-depth-of-binary-tree ├── 0104-maximum-depth-of-binary-tree.cpp ├── 0104-maximum-depth-of-binary-tree.py └── README.md ├── 0105-construct-binary-tree-from-preorder-and-inorder-traversal ├── 0105-construct-binary-tree-from-preorder-and-inorder-traversal.cpp └── README.md ├── 0106-construct-binary-tree-from-inorder-and-postorder-traversal ├── 0106-construct-binary-tree-from-inorder-and-postorder-traversal.cpp └── README.md ├── 0107-binary-tree-level-order-traversal-ii ├── 0107-binary-tree-level-order-traversal-ii.cpp └── README.md ├── 0108-convert-sorted-array-to-binary-search-tree ├── 0108-convert-sorted-array-to-binary-search-tree.cpp └── README.md ├── 0109-convert-sorted-list-to-binary-search-tree ├── 0109-convert-sorted-list-to-binary-search-tree.cpp └── README.md ├── 0110-balanced-binary-tree ├── 0110-balanced-binary-tree.cpp └── README.md ├── 0112-path-sum ├── 0112-path-sum.cpp └── README.md ├── 0114-flatten-binary-tree-to-linked-list ├── 0114-flatten-binary-tree-to-linked-list.cpp └── README.md ├── 0115-distinct-subsequences ├── 0115-distinct-subsequences.cpp └── README.md ├── 0116-populating-next-right-pointers-in-each-node ├── 0116-populating-next-right-pointers-in-each-node.cpp └── README.md ├── 0117-populating-next-right-pointers-in-each-node-ii ├── 0117-populating-next-right-pointers-in-each-node-ii.cpp └── README.md ├── 0118-pascals-triangle ├── 0118-pascals-triangle.cpp └── README.md ├── 0120-triangle ├── 0120-triangle.cpp └── README.md ├── 0121-best-time-to-buy-and-sell-stock ├── 0121-best-time-to-buy-and-sell-stock.py └── README.md ├── 0123-best-time-to-buy-and-sell-stock-iii ├── 0123-best-time-to-buy-and-sell-stock-iii.cpp └── README.md ├── 0124-binary-tree-maximum-path-sum ├── 0124-binary-tree-maximum-path-sum.cpp └── README.md ├── 0125-valid-palindrome ├── 0125-valid-palindrome.py └── README.md ├── 0127-word-ladder ├── 0127-word-ladder.cpp └── README.md ├── 0128-longest-consecutive-sequence ├── 0128-longest-consecutive-sequence.cpp ├── 0128-longest-consecutive-sequence.py └── README.md ├── 0129-sum-root-to-leaf-numbers ├── 0129-sum-root-to-leaf-numbers.cpp └── README.md ├── 0130-surrounded-regions ├── 0130-surrounded-regions.cpp └── README.md ├── 0131-palindrome-partitioning ├── 0131-palindrome-partitioning.cpp └── README.md ├── 0133-clone-graph ├── 0133-clone-graph.cpp └── README.md ├── 0134-gas-station ├── 0134-gas-station.cpp └── README.md ├── 0135-candy ├── 0135-candy.cpp └── README.md ├── 0136-single-number ├── 0136-single-number.cpp ├── 0136-single-number.py └── README.md ├── 0137-single-number-ii ├── 0137-single-number-ii.cpp └── README.md ├── 0138-copy-list-with-random-pointer ├── 0138-copy-list-with-random-pointer.cpp └── README.md ├── 0139-word-break ├── 0139-word-break.cpp └── README.md ├── 0140-word-break-ii ├── 0140-word-break-ii.cpp └── README.md ├── 0141-linked-list-cycle ├── 0141-linked-list-cycle.cpp └── README.md ├── 0142-linked-list-cycle-ii ├── 0142-linked-list-cycle-ii.cpp └── README.md ├── 0143-reorder-list ├── 0143-reorder-list.cpp └── README.md ├── 0144-binary-tree-preorder-traversal ├── 0144-binary-tree-preorder-traversal.cpp └── README.md ├── 0145-binary-tree-postorder-traversal ├── 0145-binary-tree-postorder-traversal.cpp └── README.md ├── 0146-lru-cache ├── 0146-lru-cache.cpp └── README.md ├── 0148-sort-list ├── 0148-sort-list.cpp └── README.md ├── 0149-max-points-on-a-line ├── 0149-max-points-on-a-line.cpp └── README.md ├── 0150-evaluate-reverse-polish-notation ├── 0150-evaluate-reverse-polish-notation.cpp ├── 0150-evaluate-reverse-polish-notation.py └── README.md ├── 0151-reverse-words-in-a-string ├── 0151-reverse-words-in-a-string.cpp ├── 0151-reverse-words-in-a-string.py └── README.md ├── 0152-maximum-product-subarray ├── 0152-maximum-product-subarray.cpp └── README.md ├── 0153-find-minimum-in-rotated-sorted-array ├── 0153-find-minimum-in-rotated-sorted-array.cpp └── README.md ├── 0154-find-minimum-in-rotated-sorted-array-ii ├── 0154-find-minimum-in-rotated-sorted-array-ii.cpp └── README.md ├── 0155-min-stack ├── 0155-min-stack.cpp ├── 0155-min-stack.py └── README.md ├── 0160-intersection-of-two-linked-lists ├── 0160-intersection-of-two-linked-lists.cpp └── README.md ├── 0162-find-peak-element ├── 0162-find-peak-element.cpp └── README.md ├── 0164-maximum-gap ├── 0164-maximum-gap.py └── README.md ├── 0165-compare-version-numbers ├── 0165-compare-version-numbers.cpp └── README.md ├── 0167-two-sum-ii-input-array-is-sorted ├── 0167-two-sum-ii-input-array-is-sorted.py └── README.md ├── 0168-excel-sheet-column-title ├── 0168-excel-sheet-column-title.py └── README.md ├── 0169-majority-element ├── 0169-majority-element.cpp └── README.md ├── 0171-excel-sheet-column-number ├── 0171-excel-sheet-column-number.cpp └── README.md ├── 0172-factorial-trailing-zeroes ├── 0172-factorial-trailing-zeroes.cpp └── README.md ├── 0179-largest-number ├── 0179-largest-number.py └── README.md ├── 0188-best-time-to-buy-and-sell-stock-iv ├── 0188-best-time-to-buy-and-sell-stock-iv.cpp └── README.md ├── 0189-rotate-array ├── 0189-rotate-array.cpp └── README.md ├── 0190-reverse-bits ├── 0190-reverse-bits.cpp └── README.md ├── 0191-number-of-1-bits ├── 0191-number-of-1-bits.cpp └── README.md ├── 0198-house-robber ├── 0198-house-robber.cpp └── README.md ├── 0199-binary-tree-right-side-view ├── 0199-binary-tree-right-side-view.py └── README.md ├── 0200-number-of-islands ├── 0200-number-of-islands.cpp └── README.md ├── 0201-bitwise-and-of-numbers-range ├── 0201-bitwise-and-of-numbers-range.cpp └── README.md ├── 0203-remove-linked-list-elements ├── 0203-remove-linked-list-elements.cpp └── README.md ├── 0204-count-primes ├── 0204-count-primes.cpp └── README.md ├── 0205-isomorphic-strings ├── 0205-isomorphic-strings.cpp └── README.md ├── 0206-reverse-linked-list ├── 0206-reverse-linked-list.cpp ├── 0206-reverse-linked-list.py └── README.md ├── 0207-course-schedule ├── 0207-course-schedule.cpp └── README.md ├── 0208-implement-trie-prefix-tree ├── 0208-implement-trie-prefix-tree.cpp └── README.md ├── 0210-course-schedule-ii ├── 0210-course-schedule-ii.cpp └── README.md ├── 0211-design-add-and-search-words-data-structure ├── 0211-design-add-and-search-words-data-structure.cpp └── README.md ├── 0212-word-search-ii ├── 0212-word-search-ii.cpp └── README.md ├── 0214-shortest-palindrome ├── 0214-shortest-palindrome.py └── README.md ├── 0215-kth-largest-element-in-an-array ├── 0215-kth-largest-element-in-an-array.cpp ├── 0215-kth-largest-element-in-an-array.py └── README.md ├── 0216-combination-sum-iii ├── 0216-combination-sum-iii.cpp └── README.md ├── 0217-contains-duplicate ├── 0217-contains-duplicate.cpp ├── 0217-contains-duplicate.py └── README.md ├── 0219-contains-duplicate-ii ├── 0219-contains-duplicate-ii.cpp ├── NOTES.md └── README.md ├── 0222-count-complete-tree-nodes ├── 0222-count-complete-tree-nodes.cpp └── README.md ├── 0224-basic-calculator ├── 0224-basic-calculator.cpp └── README.md ├── 0225-implement-stack-using-queues ├── 0225-implement-stack-using-queues.py └── README.md ├── 0226-invert-binary-tree ├── 0226-invert-binary-tree.cpp ├── 0226-invert-binary-tree.py └── README.md ├── 0228-summary-ranges ├── 0228-summary-ranges.cpp └── README.md ├── 0230-kth-smallest-element-in-a-bst ├── 0230-kth-smallest-element-in-a-bst.cpp └── README.md ├── 0231-power-of-two ├── 0231-power-of-two.cpp └── README.md ├── 0234-palindrome-linked-list ├── 0234-palindrome-linked-list.cpp └── README.md ├── 0235-lowest-common-ancestor-of-a-binary-search-tree ├── 0235-lowest-common-ancestor-of-a-binary-search-tree.cpp └── README.md ├── 0236-lowest-common-ancestor-of-a-binary-tree ├── 0236-lowest-common-ancestor-of-a-binary-tree.cpp ├── 0236-lowest-common-ancestor-of-a-binary-tree.py └── README.md ├── 0237-delete-node-in-a-linked-list ├── 0237-delete-node-in-a-linked-list.cpp └── README.md ├── 0238-product-of-array-except-self ├── 0238-product-of-array-except-self.cpp ├── 0238-product-of-array-except-self.go ├── 0238-product-of-array-except-self.py └── README.md ├── 0239-sliding-window-maximum ├── 0239-sliding-window-maximum.cpp └── README.md ├── 0240-search-a-2d-matrix-ii ├── 0240-search-a-2d-matrix-ii.cpp └── README.md ├── 0241-different-ways-to-add-parentheses ├── 0241-different-ways-to-add-parentheses.py └── README.md ├── 0242-valid-anagram ├── 0242-valid-anagram.js ├── 0242-valid-anagram.py └── README.md ├── 0257-binary-tree-paths ├── 0257-binary-tree-paths.py └── README.md ├── 0260-single-number-iii ├── 0260-single-number-iii.cpp └── README.md ├── 0263-ugly-number ├── 0263-ugly-number.py └── README.md ├── 0264-ugly-number-ii ├── 0264-ugly-number-ii.py └── README.md ├── 0268-missing-number ├── 0268-missing-number.cpp └── README.md ├── 0274-h-index ├── 0274-h-index.cpp └── README.md ├── 0278-first-bad-version ├── 0278-first-bad-version.cpp └── README.md ├── 0279-perfect-squares ├── 0279-perfect-squares.cpp └── README.md ├── 0283-move-zeroes ├── 0283-move-zeroes.cpp └── README.md ├── 0287-find-the-duplicate-number ├── 0287-find-the-duplicate-number.cpp └── README.md ├── 0289-game-of-life ├── 0289-game-of-life.cpp └── README.md ├── 0292-nim-game ├── 0292-nim-game.py └── README.md ├── 0295-find-median-from-data-stream ├── 0295-find-median-from-data-stream.cpp ├── 0295-find-median-from-data-stream.py └── README.md ├── 0297-serialize-and-deserialize-binary-tree ├── 0297-serialize-and-deserialize-binary-tree.py └── README.md ├── 0299-bulls-and-cows ├── 0299-bulls-and-cows.cpp └── README.md ├── 0300-longest-increasing-subsequence ├── 0300-longest-increasing-subsequence.cpp └── README.md ├── 0303-range-sum-query-immutable ├── 0303-range-sum-query-immutable.py └── README.md ├── 0310-minimum-height-trees ├── 0310-minimum-height-trees.cpp └── README.md ├── 0313-super-ugly-number ├── 0313-super-ugly-number.py └── README.md ├── 0318-maximum-product-of-word-lengths ├── 0318-maximum-product-of-word-lengths.py └── README.md ├── 0322-coin-change ├── 0322-coin-change.cpp ├── 0322-coin-change.py └── README.md ├── 0324-wiggle-sort-ii ├── 0324-wiggle-sort-ii.py └── README.md ├── 0326-power-of-three ├── 0326-power-of-three.cpp └── README.md ├── 0328-odd-even-linked-list ├── 0328-odd-even-linked-list.cpp └── README.md ├── 0330-patching-array ├── 0330-patching-array.py └── README.md ├── 0344-reverse-string ├── 0344-reverse-string.cpp └── README.md ├── 0347-top-k-frequent-elements ├── 0347-top-k-frequent-elements.cpp ├── 0347-top-k-frequent-elements.py └── README.md ├── 0349-intersection-of-two-arrays ├── 0349-intersection-of-two-arrays.cpp └── README.md ├── 0350-intersection-of-two-arrays-ii ├── 0350-intersection-of-two-arrays-ii.py └── README.md ├── 0365-water-and-jug-problem ├── 0365-water-and-jug-problem.cpp └── README.md ├── 0367-valid-perfect-square ├── 0367-valid-perfect-square.py └── README.md ├── 0368-largest-divisible-subset ├── 0368-largest-divisible-subset.go └── README.md ├── 0373-find-k-pairs-with-smallest-sums ├── 0373-find-k-pairs-with-smallest-sums.cpp ├── 0373-find-k-pairs-with-smallest-sums.py └── README.md ├── 0380-insert-delete-getrandom-o1 ├── 0380-insert-delete-getrandom-o1.cpp └── README.md ├── 0382-linked-list-random-node ├── 0382-linked-list-random-node.cpp └── README.md ├── 0383-ransom-note ├── 0383-ransom-note.py └── README.md ├── 0386-lexicographical-numbers ├── 0386-lexicographical-numbers.py └── README.md ├── 0387-first-unique-character-in-a-string ├── 0387-first-unique-character-in-a-string.cpp └── README.md ├── 0392-is-subsequence ├── 0392-is-subsequence.py └── README.md ├── 0394-decode-string ├── 0394-decode-string.py └── README.md ├── 0398-random-pick-index ├── 0398-random-pick-index.cpp └── README.md ├── 0399-evaluate-division ├── 0399-evaluate-division.cpp └── README.md ├── 0401-binary-watch ├── 0401-binary-watch.py └── README.md ├── 0402-remove-k-digits ├── 0402-remove-k-digits.cpp └── README.md ├── 0404-sum-of-left-leaves ├── 0404-sum-of-left-leaves.cpp └── README.md ├── 0405-convert-a-number-to-hexadecimal ├── 0405-convert-a-number-to-hexadecimal.py └── README.md ├── 0407-trapping-rain-water-ii ├── 0407-trapping-rain-water-ii.go └── README.md ├── 0409-longest-palindrome ├── 0409-longest-palindrome.cpp └── README.md ├── 0410-split-array-largest-sum ├── 0410-split-array-largest-sum.cpp └── README.md ├── 0412-fizz-buzz ├── 0412-fizz-buzz.py └── README.md ├── 0414-third-maximum-number ├── 0414-third-maximum-number.py └── README.md ├── 0416-partition-equal-subset-sum ├── 0416-partition-equal-subset-sum.cpp ├── 0416-partition-equal-subset-sum.go └── README.md ├── 0424-longest-repeating-character-replacement ├── 0424-longest-repeating-character-replacement.cpp └── README.md ├── 0433-minimum-genetic-mutation ├── 0433-minimum-genetic-mutation.cpp └── README.md ├── 0435-non-overlapping-intervals ├── 0435-non-overlapping-intervals.cpp └── README.md ├── 0437-path-sum-iii ├── 0437-path-sum-iii.py └── README.md ├── 0438-find-all-anagrams-in-a-string ├── 0438-find-all-anagrams-in-a-string.cpp └── README.md ├── 0441-arranging-coins ├── 0441-arranging-coins.py └── README.md ├── 0442-find-all-duplicates-in-an-array ├── 0442-find-all-duplicates-in-an-array.cpp └── README.md ├── 0446-arithmetic-slices-ii-subsequence ├── 0446-arithmetic-slices-ii-subsequence.cpp └── README.md ├── 0448-find-all-numbers-disappeared-in-an-array ├── 0448-find-all-numbers-disappeared-in-an-array.py └── README.md ├── 0451-sort-characters-by-frequency ├── 0451-sort-characters-by-frequency.cpp └── README.md ├── 0452-minimum-number-of-arrows-to-burst-balloons ├── 0452-minimum-number-of-arrows-to-burst-balloons.cpp └── README.md ├── 0453-minimum-moves-to-equal-array-elements ├── 0453-minimum-moves-to-equal-array-elements.cpp └── README.md ├── 0455-assign-cookies ├── 0455-assign-cookies.cpp └── README.md ├── 0461-hamming-distance ├── 0461-hamming-distance.py └── README.md ├── 0462-minimum-moves-to-equal-array-elements-ii ├── 0462-minimum-moves-to-equal-array-elements-ii.cpp └── README.md ├── 0463-island-perimeter ├── 0463-island-perimeter.cpp └── README.md ├── 0476-number-complement ├── 0476-number-complement.py └── README.md ├── 0485-max-consecutive-ones ├── 0485-max-consecutive-ones.cpp └── README.md ├── 0494-target-sum ├── 0494-target-sum.py └── README.md ├── 0502-ipo ├── 0502-ipo.cpp ├── 0502-ipo.py └── README.md ├── 0503-next-greater-element-ii ├── 0503-next-greater-element-ii.py └── README.md ├── 0506-relative-ranks ├── 0506-relative-ranks.cpp └── README.md ├── 0507-perfect-number ├── 0507-perfect-number.cpp └── README.md ├── 0508-most-frequent-subtree-sum ├── 0508-most-frequent-subtree-sum.py └── README.md ├── 0509-fibonacci-number ├── 0509-fibonacci-number.py └── README.md ├── 0513-find-bottom-left-tree-value ├── 0513-find-bottom-left-tree-value.cpp └── README.md ├── 0514-freedom-trail ├── 0514-freedom-trail.cpp └── README.md ├── 0515-find-largest-value-in-each-tree-row ├── 0515-find-largest-value-in-each-tree-row.py └── README.md ├── 0518-coin-change-ii ├── 0518-coin-change-ii.py └── README.md ├── 0521-longest-uncommon-subsequence-i ├── 0521-longest-uncommon-subsequence-i.py └── README.md ├── 0523-continuous-subarray-sum ├── 0523-continuous-subarray-sum.cpp └── README.md ├── 0525-contiguous-array ├── 0525-contiguous-array.cpp └── README.md ├── 0530-minimum-absolute-difference-in-bst ├── 0530-minimum-absolute-difference-in-bst.cpp └── README.md ├── 0535-encode-and-decode-tinyurl ├── 0535-encode-and-decode-tinyurl.cpp └── README.md ├── 0538-convert-bst-to-greater-tree ├── 0538-convert-bst-to-greater-tree.cpp └── README.md ├── 0539-minimum-time-difference ├── 0539-minimum-time-difference.py └── README.md ├── 0540-single-element-in-a-sorted-array ├── 0540-single-element-in-a-sorted-array.cpp └── README.md ├── 0543-diameter-of-binary-tree ├── 0543-diameter-of-binary-tree.cpp ├── 0543-diameter-of-binary-tree.py └── README.md ├── 0547-number-of-provinces ├── 0547-number-of-provinces.cpp └── README.md ├── 0559-maximum-depth-of-n-ary-tree ├── 0559-maximum-depth-of-n-ary-tree.py └── README.md ├── 0560-subarray-sum-equals-k ├── 0560-subarray-sum-equals-k.cpp └── README.md ├── 0567-permutation-in-string ├── 0567-permutation-in-string.py └── README.md ├── 0572-subtree-of-another-tree ├── 0572-subtree-of-another-tree.cpp ├── 0572-subtree-of-another-tree.py └── README.md ├── 0590-n-ary-tree-postorder-traversal ├── 0590-n-ary-tree-postorder-traversal.py └── README.md ├── 0594-longest-harmonious-subsequence ├── 0594-longest-harmonious-subsequence.py └── README.md ├── 0599-minimum-index-sum-of-two-lists ├── 0599-minimum-index-sum-of-two-lists.py └── README.md ├── 0606-construct-string-from-binary-tree ├── 0606-construct-string-from-binary-tree.js └── README.md ├── 0617-merge-two-binary-trees ├── 0617-merge-two-binary-trees.py └── README.md ├── 0621-task-scheduler ├── 0621-task-scheduler.py └── README.md ├── 0623-add-one-row-to-tree ├── 0623-add-one-row-to-tree.cpp └── README.md ├── 0624-maximum-distance-in-arrays ├── 0624-maximum-distance-in-arrays.py └── README.md ├── 0629-k-inverse-pairs-array ├── 0629-k-inverse-pairs-array.cpp └── README.md ├── 0632-smallest-range-covering-elements-from-k-lists ├── 0632-smallest-range-covering-elements-from-k-lists.py └── README.md ├── 0633-sum-of-square-numbers ├── 0633-sum-of-square-numbers.cpp └── README.md ├── 0637-average-of-levels-in-binary-tree ├── 0637-average-of-levels-in-binary-tree.js └── README.md ├── 0641-design-circular-deque ├── 0641-design-circular-deque.py └── README.md ├── 0645-set-mismatch ├── 0645-set-mismatch.cpp └── README.md ├── 0647-palindromic-substrings ├── 0647-palindromic-substrings.cpp └── README.md ├── 0648-replace-words ├── 0648-replace-words.cpp └── README.md ├── 0652-find-duplicate-subtrees ├── 0652-find-duplicate-subtrees.cpp └── README.md ├── 0654-maximum-binary-tree ├── 0654-maximum-binary-tree.cpp └── README.md ├── 0657-robot-return-to-origin ├── 0657-robot-return-to-origin.js └── README.md ├── 0661-image-smoother ├── 0661-image-smoother.cpp └── README.md ├── 0669-trim-a-binary-search-tree ├── 0669-trim-a-binary-search-tree.cpp └── README.md ├── 0670-maximum-swap ├── 0670-maximum-swap.py └── README.md ├── 0673-number-of-longest-increasing-subsequence ├── 0673-number-of-longest-increasing-subsequence.py └── README.md ├── 0678-valid-parenthesis-string ├── 0678-valid-parenthesis-string.cpp └── README.md ├── 0682-baseball-game ├── 0682-baseball-game.js └── README.md ├── 0684-redundant-connection ├── 0684-redundant-connection.go └── README.md ├── 0689-maximum-sum-of-3-non-overlapping-subarrays ├── 0689-maximum-sum-of-3-non-overlapping-subarrays.py └── README.md ├── 0695-max-area-of-island ├── 0695-max-area-of-island.cpp └── README.md ├── 0701-insert-into-a-binary-search-tree ├── 0701-insert-into-a-binary-search-tree.cpp └── README.md ├── 0703-kth-largest-element-in-a-stream ├── 0703-kth-largest-element-in-a-stream.py └── README.md ├── 0704-binary-search ├── 0704-binary-search.cpp ├── 0704-binary-search.py └── README.md ├── 0705-design-hashset ├── 0705-design-hashset.py └── README.md ├── 0706-design-hashmap ├── 0706-design-hashmap.py └── README.md ├── 0713-subarray-product-less-than-k ├── 0713-subarray-product-less-than-k.cpp └── README.md ├── 0726-number-of-atoms ├── 0726-number-of-atoms.cpp ├── 0726-number-of-atoms.py └── README.md ├── 0728-self-dividing-numbers ├── 0728-self-dividing-numbers.py └── README.md ├── 0729-my-calendar-i ├── 0729-my-calendar-i.py └── README.md ├── 0731-my-calendar-ii ├── 0731-my-calendar-ii.py └── README.md ├── 0732-my-calendar-iii ├── 0732-my-calendar-iii.py └── README.md ├── 0733-flood-fill ├── 0733-flood-fill.cpp └── README.md ├── 0739-daily-temperatures ├── 0739-daily-temperatures.cpp ├── 0739-daily-temperatures.py └── README.md ├── 0742-to-lower-case ├── 0742-to-lower-case.js └── README.md ├── 0744-find-smallest-letter-greater-than-target ├── 0744-find-smallest-letter-greater-than-target.cpp └── README.md ├── 0747-largest-number-at-least-twice-of-others ├── 0747-largest-number-at-least-twice-of-others.py └── README.md ├── 0748-shortest-completing-word ├── 0748-shortest-completing-word.py └── README.md ├── 0752-open-the-lock ├── 0752-open-the-lock.cpp └── README.md ├── 0763-partition-labels ├── 0763-partition-labels.go └── README.md ├── 0768-partition-labels ├── 0768-partition-labels.cpp └── README.md ├── 0769-max-chunks-to-make-sorted ├── 0769-max-chunks-to-make-sorted.py └── README.md ├── 0771-jewels-and-stones ├── 0771-jewels-and-stones.cpp └── README.md ├── 0772-construct-quad-tree ├── 0772-construct-quad-tree.cpp └── README.md ├── 0773-sliding-puzzle ├── 0773-sliding-puzzle.py └── README.md ├── 0781-rabbits-in-forest ├── 0781-rabbits-in-forest.go └── README.md ├── 0785-is-graph-bipartite ├── 0785-is-graph-bipartite.cpp └── README.md ├── 0786-k-th-smallest-prime-fraction ├── 0786-k-th-smallest-prime-fraction.cpp └── README.md ├── 0787-cheapest-flights-within-k-stops ├── 0787-cheapest-flights-within-k-stops.cpp └── README.md ├── 0790-domino-and-tromino-tiling ├── 0790-domino-and-tromino-tiling.py └── README.md ├── 0791-custom-sort-string ├── 0791-custom-sort-string.cpp └── README.md ├── 0796-rotate-string ├── 0796-rotate-string.py └── README.md ├── 0797-all-paths-from-source-to-target ├── 0797-all-paths-from-source-to-target.py └── README.md ├── 0802-find-eventual-safe-states ├── 0802-find-eventual-safe-states.cpp ├── 0802-find-eventual-safe-states.go └── README.md ├── 0806-domino-and-tromino-tiling ├── 0806-domino-and-tromino-tiling.cpp └── README.md ├── 0807-max-increase-to-keep-city-skyline ├── 0807-max-increase-to-keep-city-skyline.py └── README.md ├── 0826-most-profit-assigning-work ├── 0826-most-profit-assigning-work.py └── README.md ├── 0827-making-a-large-island ├── 0827-making-a-large-island.go └── README.md ├── 0833-bus-routes ├── 0833-bus-routes.cpp └── README.md ├── 0834-sum-of-distances-in-tree ├── 0834-sum-of-distances-in-tree.cpp └── README.md ├── 0838-push-dominoes ├── 0838-push-dominoes.py └── README.md ├── 0846-hand-of-straights ├── 0846-hand-of-straights.cpp └── README.md ├── 0852-peak-index-in-a-mountain-array ├── 0852-peak-index-in-a-mountain-array.py └── README.md ├── 0853-car-fleet ├── 0853-car-fleet.py └── README.md ├── 0857-minimum-cost-to-hire-k-workers ├── 0857-minimum-cost-to-hire-k-workers.cpp └── README.md ├── 0861-score-after-flipping-matrix ├── 0861-score-after-flipping-matrix.cpp └── README.md ├── 0862-shortest-subarray-with-sum-at-least-k ├── 0862-shortest-subarray-with-sum-at-least-k.py └── README.md ├── 0872-leaf-similar-trees ├── 0872-leaf-similar-trees.cpp └── README.md ├── 0873-length-of-longest-fibonacci-subsequence ├── 0873-length-of-longest-fibonacci-subsequence.go └── README.md ├── 0874-walking-robot-simulation ├── 0874-walking-robot-simulation.py └── README.md ├── 0875-koko-eating-bananas ├── 0875-koko-eating-bananas.cpp ├── 0875-koko-eating-bananas.go └── README.md ├── 0876-middle-of-the-linked-list ├── 0876-middle-of-the-linked-list.cpp └── README.md ├── 0877-stone-game ├── 0877-stone-game.rs └── README.md ├── 0881-boats-to-save-people ├── 0881-boats-to-save-people.cpp └── README.md ├── 0884-uncommon-words-from-two-sentences ├── 0884-uncommon-words-from-two-sentences.py └── README.md ├── 0885-spiral-matrix-iii ├── 0885-spiral-matrix-iii.py └── README.md ├── 0889-construct-binary-tree-from-preorder-and-postorder-traversal ├── 0889-construct-binary-tree-from-preorder-and-postorder-traversal.py └── README.md ├── 0890-lemonade-change ├── 0890-lemonade-change.py └── README.md ├── 0894-all-possible-full-binary-trees ├── 0894-all-possible-full-binary-trees.py └── README.md ├── 0895-maximum-frequency-stack ├── 0895-maximum-frequency-stack.go └── README.md ├── 0898-transpose-matrix ├── 0898-transpose-matrix.js └── README.md ├── 0899-orderly-queue ├── 0899-orderly-queue.go └── README.md ├── 0907-koko-eating-bananas ├── 0907-koko-eating-bananas.cpp └── README.md ├── 0907-sum-of-subarray-minimums ├── 0907-sum-of-subarray-minimums.cpp └── README.md ├── 0912-sort-an-array ├── 0912-sort-an-array.py └── README.md ├── 0916-word-subsets ├── 0916-word-subsets.go └── README.md ├── 0917-reverse-only-letters ├── 0917-reverse-only-letters.py └── README.md ├── 0921-minimum-add-to-make-parentheses-valid ├── 0921-minimum-add-to-make-parentheses-valid.cpp ├── 0921-minimum-add-to-make-parentheses-valid.py └── README.md ├── 0922-sort-array-by-parity-ii ├── 0922-sort-array-by-parity-ii.py └── README.md ├── 0929-unique-email-addresses ├── 0929-unique-email-addresses.py └── README.md ├── 0930-binary-subarrays-with-sum ├── 0930-binary-subarrays-with-sum.cpp └── README.md ├── 0931-minimum-falling-path-sum ├── 0931-minimum-falling-path-sum.cpp └── README.md ├── 0938-range-sum-of-bst ├── 0938-range-sum-of-bst.cpp └── README.md ├── 0941-valid-mountain-array ├── 0941-valid-mountain-array.py └── README.md ├── 0942-di-string-match ├── 0942-di-string-match.py └── README.md ├── 0945-minimum-increment-to-make-array-unique ├── 0945-minimum-increment-to-make-array-unique.py └── README.md ├── 0945-snakes-and-ladders ├── 0945-snakes-and-ladders.cpp └── README.md ├── 0950-reveal-cards-in-increasing-order ├── 0950-reveal-cards-in-increasing-order.cpp └── README.md ├── 0951-flip-equivalent-binary-trees ├── 0951-flip-equivalent-binary-trees.py └── README.md ├── 0954-maximum-sum-circular-subarray ├── 0954-maximum-sum-circular-subarray.cpp └── README.md ├── 0961-n-repeated-element-in-size-2n-array ├── 0961-n-repeated-element-in-size-2n-array.py └── README.md ├── 0962-maximum-width-ramp ├── 0962-maximum-width-ramp.py └── README.md ├── 0965-univalued-binary-tree ├── 0965-univalued-binary-tree.py └── README.md ├── 0972-knight-dialer ├── 0972-knight-dialer.cpp └── README.md ├── 0973-k-closest-points-to-origin ├── 0973-k-closest-points-to-origin.py └── README.md ├── 0974-subarray-sums-divisible-by-k ├── 0974-subarray-sums-divisible-by-k.cpp └── README.md ├── 0977-squares-of-a-sorted-array ├── 0977-squares-of-a-sorted-array.cpp └── README.md ├── 0979-distribute-coins-in-binary-tree ├── 0979-distribute-coins-in-binary-tree.cpp └── README.md ├── 0980-unique-paths-iii ├── 0980-unique-paths-iii.cpp └── README.md ├── 0981-time-based-key-value-store ├── 0981-time-based-key-value-store.py └── README.md ├── 0983-minimum-cost-for-tickets ├── 0983-minimum-cost-for-tickets.py └── README.md ├── 0985-sum-of-even-numbers-after-queries ├── 0985-sum-of-even-numbers-after-queries.py └── README.md ├── 0988-smallest-string-starting-from-leaf ├── 0988-smallest-string-starting-from-leaf.cpp └── README.md ├── 0989-add-to-array-form-of-integer ├── 0989-add-to-array-form-of-integer.py └── README.md ├── 0992-subarrays-with-k-different-integers ├── 0992-subarrays-with-k-different-integers.cpp └── README.md ├── 0994-rotting-oranges ├── 0994-rotting-oranges.cpp └── README.md ├── 0995-minimum-number-of-k-consecutive-bit-flips ├── 0995-minimum-number-of-k-consecutive-bit-flips.py └── README.md ├── 0997-find-the-town-judge ├── 0997-find-the-town-judge.cpp └── README.md ├── 1002-find-common-characters ├── 1002-find-common-characters.cpp └── README.md ├── 1007-minimum-domino-rotations-for-equal-row ├── 1007-minimum-domino-rotations-for-equal-row.py └── README.md ├── 1008-construct-binary-search-tree-from-preorder-traversal ├── 1008-construct-binary-search-tree-from-preorder-traversal.py └── README.md ├── 1009-complement-of-base-10-integer ├── 1009-complement-of-base-10-integer.py └── README.md ├── 1010-pairs-of-songs-with-total-durations-divisible-by-60 ├── 1010-pairs-of-songs-with-total-durations-divisible-by-60.py └── README.md ├── 1014-best-sightseeing-pair ├── 1014-best-sightseeing-pair.py └── README.md ├── 1018-largest-perimeter-triangle ├── 1018-largest-perimeter-triangle.py └── README.md ├── 1021-remove-outermost-parentheses ├── 1021-remove-outermost-parentheses.cpp └── README.md ├── 1026-maximum-difference-between-node-and-ancestor ├── 1026-maximum-difference-between-node-and-ancestor.cpp └── README.md ├── 1028-recover-a-tree-from-preorder-traversal ├── 1028-recover-a-tree-from-preorder-traversal.py └── README.md ├── 1036-rotting-oranges ├── 1036-rotting-oranges.cpp └── README.md ├── 1038-binary-search-tree-to-greater-sum-tree ├── 1038-binary-search-tree-to-greater-sum-tree.cpp ├── 1038-binary-search-tree-to-greater-sum-tree.py └── README.md ├── 1046-last-stone-weight ├── 1046-last-stone-weight.py └── README.md ├── 1051-height-checker ├── 1051-height-checker.cpp └── README.md ├── 1052-grumpy-bookstore-owner ├── 1052-grumpy-bookstore-owner.py └── README.md ├── 1072-flip-columns-for-maximum-number-of-equal-rows ├── 1072-flip-columns-for-maximum-number-of-equal-rows.py └── README.md ├── 1079-letter-tile-possibilities ├── 1079-letter-tile-possibilities.go └── README.md ├── 1092-shortest-common-supersequence ├── 1092-shortest-common-supersequence.go └── README.md ├── 1105-filling-bookcase-shelves ├── 1105-filling-bookcase-shelves.cpp ├── 1105-filling-bookcase-shelves.py └── README.md ├── 1106-parsing-a-boolean-expression ├── 1106-parsing-a-boolean-expression.py └── README.md ├── 1108-defanging-an-ip-address ├── 1108-defanging-an-ip-address.cpp └── README.md ├── 1110-delete-nodes-and-return-forest ├── 1110-delete-nodes-and-return-forest.py └── README.md ├── 1112-find-words-that-can-be-formed-by-characters ├── 1112-find-words-that-can-be-formed-by-characters.js └── README.md ├── 1119-robot-bounded-in-circle ├── 1119-robot-bounded-in-circle.py └── README.md ├── 1122-relative-sort-array ├── 1122-relative-sort-array.py └── README.md ├── 1123-lowest-common-ancestor-of-deepest-leaves ├── 1123-lowest-common-ancestor-of-deepest-leaves.go └── README.md ├── 1137-height-checker ├── 1137-height-checker.py └── README.md ├── 1137-n-th-tribonacci-number ├── 1137-n-th-tribonacci-number.cpp └── README.md ├── 1140-stone-game-ii ├── 1140-stone-game-ii.rs └── README.md ├── 1154-day-of-the-year ├── 1154-day-of-the-year.py └── README.md ├── 1189-maximum-number-of-balloons ├── 1189-maximum-number-of-balloons.py └── README.md ├── 1190-reverse-substrings-between-each-pair-of-parentheses ├── 1190-reverse-substrings-between-each-pair-of-parentheses.py └── README.md ├── 1195-distribute-candies-to-people ├── 1195-distribute-candies-to-people.js └── README.md ├── 1200-minimum-absolute-difference ├── 1200-minimum-absolute-difference.py └── README.md ├── 1207-unique-number-of-occurrences ├── 1207-unique-number-of-occurrences.cpp └── README.md ├── 1208-get-equal-substrings-within-budget ├── 1208-get-equal-substrings-within-budget.cpp └── README.md ├── 1219-path-with-maximum-gold ├── 1219-path-with-maximum-gold.cpp └── README.md ├── 1221-element-appearing-more-than-25-in-sorted-array ├── 1221-element-appearing-more-than-25-in-sorted-array.js └── README.md ├── 1221-split-a-string-in-balanced-strings ├── 1221-split-a-string-in-balanced-strings.py └── README.md ├── 1233-remove-sub-folders-from-the-filesystem ├── 1233-remove-sub-folders-from-the-filesystem.py └── README.md ├── 1235-maximum-profit-in-job-scheduling ├── 1235-maximum-profit-in-job-scheduling.cpp └── README.md ├── 1236-n-th-tribonacci-number ├── 1236-n-th-tribonacci-number.cpp └── README.md ├── 1239-maximum-length-of-a-concatenated-string-with-unique-characters ├── 1239-maximum-length-of-a-concatenated-string-with-unique-characters.cpp └── README.md ├── 1248-count-number-of-nice-subarrays ├── 1248-count-number-of-nice-subarrays.cpp ├── 1248-count-number-of-nice-subarrays.py └── README.md ├── 1249-minimum-remove-to-make-valid-parentheses ├── 1249-minimum-remove-to-make-valid-parentheses.cpp └── README.md ├── 1250-check-if-it-is-a-good-array ├── 1250-check-if-it-is-a-good-array.py └── README.md ├── 1250-longest-common-subsequence ├── 1250-longest-common-subsequence.py └── README.md ├── 1254-number-of-closed-islands ├── 1254-number-of-closed-islands.cpp └── README.md ├── 1255-maximum-score-words-formed-by-letters ├── 1255-maximum-score-words-formed-by-letters.cpp └── README.md ├── 1261-find-elements-in-a-contaminated-binary-tree ├── 1261-find-elements-in-a-contaminated-binary-tree.go └── README.md ├── 1263-number-of-dice-rolls-with-target-sum ├── 1263-number-of-dice-rolls-with-target-sum.cpp └── README.md ├── 1267-count-servers-that-communicate ├── 1267-count-servers-that-communicate.go └── README.md ├── 1277-count-square-submatrices-with-all-ones ├── 1277-count-square-submatrices-with-all-ones.py └── README.md ├── 1281-subtract-the-product-and-sum-of-digits-of-an-integer ├── 1281-subtract-the-product-and-sum-of-digits-of-an-integer.py └── README.md ├── 1283-find-the-smallest-divisor-given-a-threshold ├── 1283-find-the-smallest-divisor-given-a-threshold.cpp └── README.md ├── 1284-minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix ├── 1284-minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix.py └── README.md ├── 1289-minimum-falling-path-sum-ii ├── 1289-minimum-falling-path-sum-ii.cpp └── README.md ├── 1290-convert-binary-number-in-a-linked-list-to-integer ├── 1290-convert-binary-number-in-a-linked-list-to-integer.py └── README.md ├── 1291-sequential-digits ├── 1291-sequential-digits.cpp └── README.md ├── 1295-find-numbers-with-even-number-of-digits ├── 1295-find-numbers-with-even-number-of-digits.go ├── 1295-find-numbers-with-even-number-of-digits.py └── README.md ├── 1296-divide-array-in-sets-of-k-consecutive-numbers ├── 1296-divide-array-in-sets-of-k-consecutive-numbers.cpp └── README.md ├── 1299-replace-elements-with-greatest-element-on-right-side ├── 1299-replace-elements-with-greatest-element-on-right-side.py └── README.md ├── 1302-deepest-leaves-sum ├── 1302-deepest-leaves-sum.cpp └── README.md ├── 1304-find-n-unique-integers-sum-up-to-zero ├── 1304-find-n-unique-integers-sum-up-to-zero.py └── README.md ├── 1305-all-elements-in-two-binary-search-trees ├── 1305-all-elements-in-two-binary-search-trees.cpp └── README.md ├── 1310-xor-queries-of-a-subarray ├── 1310-xor-queries-of-a-subarray.py └── README.md ├── 1312-minimum-insertion-steps-to-make-a-string-palindrome ├── 1312-minimum-insertion-steps-to-make-a-string-palindrome.py └── README.md ├── 1315-sum-of-nodes-with-even-valued-grandparent ├── 1315-sum-of-nodes-with-even-valued-grandparent.cpp └── README.md ├── 1319-number-of-operations-to-make-network-connected ├── 1319-number-of-operations-to-make-network-connected.cpp └── README.md ├── 1323-maximum-69-number ├── 1323-maximum-69-number.py └── README.md ├── 1325-delete-leaves-with-a-given-value ├── 1325-delete-leaves-with-a-given-value.cpp └── README.md ├── 1329-sort-the-matrix-diagonally ├── 1329-sort-the-matrix-diagonally.py └── README.md ├── 1331-rank-transform-of-an-array ├── 1331-rank-transform-of-an-array.py └── 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 ├── 1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance.py └── README.md ├── 1342-number-of-steps-to-reduce-a-number-to-zero ├── 1342-number-of-steps-to-reduce-a-number-to-zero.py └── README.md ├── 1346-check-if-n-and-its-double-exist ├── 1346-check-if-n-and-its-double-exist.py └── README.md ├── 1347-minimum-number-of-steps-to-make-two-strings-anagram ├── 1347-minimum-number-of-steps-to-make-two-strings-anagram.cpp └── README.md ├── 1351-count-negative-numbers-in-a-sorted-matrix ├── 1351-count-negative-numbers-in-a-sorted-matrix.py └── README.md ├── 1352-product-of-the-last-k-numbers ├── 1352-product-of-the-last-k-numbers.go └── README.md ├── 1358-number-of-substrings-containing-all-three-characters ├── 1358-number-of-substrings-containing-all-three-characters.go ├── 1358-number-of-substrings-containing-all-three-characters.py └── README.md ├── 1365-how-many-numbers-are-smaller-than-the-current-number ├── 1365-how-many-numbers-are-smaller-than-the-current-number.py └── README.md ├── 1367-linked-list-in-binary-tree ├── 1367-linked-list-in-binary-tree.py └── README.md ├── 1368-minimum-cost-to-make-at-least-one-valid-path-in-a-grid ├── 1368-minimum-cost-to-make-at-least-one-valid-path-in-a-grid.go └── README.md ├── 1374-generate-a-string-with-characters-that-have-odd-counts ├── 1374-generate-a-string-with-characters-that-have-odd-counts.py └── README.md ├── 1380-lucky-numbers-in-a-matrix ├── 1380-lucky-numbers-in-a-matrix.py └── README.md ├── 1381-design-a-stack-with-increment-operation ├── 1381-design-a-stack-with-increment-operation.py └── README.md ├── 1382-balance-a-binary-search-tree ├── 1382-balance-a-binary-search-tree.py └── README.md ├── 1389-create-target-array-in-the-given-order ├── 1389-create-target-array-in-the-given-order.py └── README.md ├── 1394-find-lucky-integer-in-an-array ├── 1394-find-lucky-integer-in-an-array.cpp └── README.md ├── 1395-count-number-of-teams ├── 1395-count-number-of-teams.py └── README.md ├── 1395-minimum-time-visiting-all-points ├── 1395-minimum-time-visiting-all-points.js └── README.md ├── 1397-search-suggestions-system ├── 1397-search-suggestions-system.cpp └── README.md ├── 1399-count-largest-group ├── 1399-count-largest-group.go └── README.md ├── 1400-construct-k-palindrome-strings ├── 1400-construct-k-palindrome-strings.go └── README.md ├── 1400-find-winner-on-a-tic-tac-toe-game ├── 1400-find-winner-on-a-tic-tac-toe-game.py └── README.md ├── 1402-reducing-dishes ├── 1402-reducing-dishes.cpp └── README.md ├── 1404-number-of-steps-to-reduce-a-number-in-binary-representation-to-one ├── 1404-number-of-steps-to-reduce-a-number-in-binary-representation-to-one.cpp └── README.md ├── 1405-longest-happy-string ├── 1405-longest-happy-string.py └── README.md ├── 1408-string-matching-in-an-array ├── 1408-string-matching-in-an-array.py └── README.md ├── 1409-queries-on-a-permutation-with-key ├── 1409-queries-on-a-permutation-with-key.py └── README.md ├── 1413-minimum-value-to-get-positive-step-by-step-sum ├── 1413-minimum-value-to-get-positive-step-by-step-sum.py └── 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.go └── README.md ├── 1422-maximum-score-after-splitting-a-string ├── 1422-maximum-score-after-splitting-a-string.py └── README.md ├── 1423-maximum-points-you-can-obtain-from-cards ├── 1423-maximum-points-you-can-obtain-from-cards.py └── README.md ├── 1437-check-if-all-1s-are-at-least-length-k-places-away ├── 1437-check-if-all-1s-are-at-least-length-k-places-away.py └── README.md ├── 1438-longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit ├── 1438-longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit.cpp ├── 1438-longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit.py └── README.md ├── 1441-build-an-array-with-stack-operations ├── 1441-build-an-array-with-stack-operations.cpp └── README.md ├── 1442-count-triplets-that-can-form-two-arrays-of-equal-xor ├── 1442-count-triplets-that-can-form-two-arrays-of-equal-xor.cpp └── README.md ├── 1446-consecutive-characters ├── 1446-consecutive-characters.py └── README.md ├── 1447-simplified-fractions ├── 1447-simplified-fractions.cpp └── README.md ├── 1450-number-of-students-doing-homework-at-a-given-time ├── 1450-number-of-students-doing-homework-at-a-given-time.py └── 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.py └── README.md ├── 1457-minimum-difficulty-of-a-job-schedule ├── 1457-minimum-difficulty-of-a-job-schedule.cpp └── README.md ├── 1460-make-two-arrays-equal-by-reversing-subarrays ├── 1460-make-two-arrays-equal-by-reversing-subarrays.py └── README.md ├── 1462-course-schedule-iv ├── 1462-course-schedule-iv.go └── README.md ├── 1463-cherry-pickup-ii ├── 1463-cherry-pickup-ii.py └── README.md ├── 1470-shuffle-the-array ├── 1470-shuffle-the-array.py └── README.md ├── 1475-final-prices-with-a-special-discount-in-a-shop ├── 1475-final-prices-with-a-special-discount-in-a-shop.py └── README.md ├── 1476-subrectangle-queries ├── 1476-subrectangle-queries.py └── README.md ├── 1480-running-sum-of-1d-array ├── 1480-running-sum-of-1d-array.cpp └── README.md ├── 1481-least-number-of-unique-integers-after-k-removals ├── 1481-least-number-of-unique-integers-after-k-removals.cpp └── README.md ├── 1482-minimum-number-of-days-to-make-m-bouquets ├── 1482-minimum-number-of-days-to-make-m-bouquets.cpp ├── 1482-minimum-number-of-days-to-make-m-bouquets.py └── README.md ├── 1486-xor-operation-in-an-array ├── 1486-xor-operation-in-an-array.py └── README.md ├── 1489-find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree ├── 1489-find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree.go └── README.md ├── 1492-the-kth-factor-of-n ├── 1492-the-kth-factor-of-n.cpp └── README.md ├── 1497-check-if-array-pairs-are-divisible-by-k ├── 1497-check-if-array-pairs-are-divisible-by-k.py └── README.md ├── 1508-range-sum-of-sorted-subarray-sums ├── 1508-range-sum-of-sorted-subarray-sums.py └── README.md ├── 1509-minimum-difference-between-largest-and-smallest-value-in-three-moves ├── 1509-minimum-difference-between-largest-and-smallest-value-in-three-moves.py └── README.md ├── 1514-path-with-maximum-probability ├── 1514-path-with-maximum-probability.py └── README.md ├── 1518-water-bottles ├── 1518-water-bottles.cpp └── README.md ├── 1524-number-of-sub-arrays-with-odd-sum ├── 1524-number-of-sub-arrays-with-odd-sum.go └── README.md ├── 1526-minimum-number-of-increments-on-subarrays-to-form-a-target-array ├── 1526-minimum-number-of-increments-on-subarrays-to-form-a-target-array.py └── README.md ├── 1528-shuffle-string ├── 1528-shuffle-string.py └── README.md ├── 1530-number-of-good-leaf-nodes-pairs ├── 1530-number-of-good-leaf-nodes-pairs.py └── README.md ├── 1534-count-good-triplets ├── 1534-count-good-triplets.go └── README.md ├── 1537-maximum-score-after-splitting-a-string ├── 1537-maximum-score-after-splitting-a-string.cpp └── README.md ├── 1539-diagonal-traverse-ii ├── 1539-diagonal-traverse-ii.cpp └── README.md ├── 1544-make-the-string-great ├── 1544-make-the-string-great.cpp └── README.md ├── 1545-find-kth-bit-in-nth-binary-string ├── 1545-find-kth-bit-in-nth-binary-string.py └── README.md ├── 1547-destination-city ├── 1547-destination-city.js └── README.md ├── 1550-three-consecutive-odds ├── 1550-three-consecutive-odds.py └── README.md ├── 1551-minimum-operations-to-make-array-equal ├── 1551-minimum-operations-to-make-array-equal.py └── README.md ├── 1552-magnetic-force-between-two-balls ├── 1552-magnetic-force-between-two-balls.py └── README.md ├── 1557-minimum-number-of-vertices-to-reach-all-nodes ├── 1557-minimum-number-of-vertices-to-reach-all-nodes.py └── README.md ├── 1574-maximum-product-of-two-elements-in-an-array ├── 1574-maximum-product-of-two-elements-in-an-array.js └── README.md ├── 1574-shortest-subarray-to-be-removed-to-make-array-sorted ├── 1574-shortest-subarray-to-be-removed-to-make-array-sorted.py └── README.md ├── 1576-reorder-routes-to-make-all-paths-lead-to-the-city-zero ├── 1576-reorder-routes-to-make-all-paths-lead-to-the-city-zero.cpp └── README.md ├── 1579-remove-max-number-of-edges-to-keep-graph-fully-traversable ├── 1579-remove-max-number-of-edges-to-keep-graph-fully-traversable.py └── README.md ├── 1584-average-salary-excluding-the-minimum-and-maximum-salary ├── 1584-average-salary-excluding-the-minimum-and-maximum-salary.py └── README.md ├── 1588-sum-of-all-odd-length-subarrays ├── 1588-sum-of-all-odd-length-subarrays.py └── README.md ├── 1590-make-sum-divisible-by-p ├── 1590-make-sum-divisible-by-p.py └── README.md ├── 1593-split-a-string-into-the-max-number-of-unique-substrings ├── 1593-split-a-string-into-the-max-number-of-unique-substrings.py └── README.md ├── 1598-crawler-log-folder ├── 1598-crawler-log-folder.py └── README.md ├── 1603-design-parking-system ├── 1603-design-parking-system.py └── README.md ├── 1605-find-valid-matrix-given-row-and-column-sums ├── 1605-find-valid-matrix-given-row-and-column-sums.py └── README.md ├── 1608-special-array-with-x-elements-greater-than-or-equal-x ├── 1608-special-array-with-x-elements-greater-than-or-equal-x.cpp └── README.md ├── 1609-even-odd-tree ├── 1609-even-odd-tree.cpp └── README.md ├── 1614-maximum-nesting-depth-of-the-parentheses ├── 1614-maximum-nesting-depth-of-the-parentheses.cpp └── README.md ├── 1617-count-subtrees-with-max-distance-between-cities ├── 1617-count-subtrees-with-max-distance-between-cities.py └── README.md ├── 1619-mean-of-array-after-removing-some-elements ├── 1619-mean-of-array-after-removing-some-elements.py └── README.md ├── 1619-path-crossing ├── 1619-path-crossing.cpp └── README.md ├── 1624-largest-substring-between-two-equal-characters ├── 1624-largest-substring-between-two-equal-characters.cpp └── README.md ├── 1626-can-make-arithmetic-progression-from-sequence ├── 1626-can-make-arithmetic-progression-from-sequence.py └── README.md ├── 1630-count-odd-numbers-in-an-interval-range ├── 1630-count-odd-numbers-in-an-interval-range.py └── README.md ├── 1636-sort-array-by-increasing-frequency ├── 1636-sort-array-by-increasing-frequency.py └── README.md ├── 1637-string-compression-ii ├── 1637-string-compression-ii.cpp └── README.md ├── 1639-number-of-ways-to-form-a-target-string-given-a-dictionary ├── 1639-number-of-ways-to-form-a-target-string-given-a-dictionary.py └── README.md ├── 1642-furthest-building-you-can-reach ├── 1642-furthest-building-you-can-reach.cpp └── README.md ├── 1652-defuse-the-bomb ├── 1652-defuse-the-bomb.py └── README.md ├── 1653-minimum-deletions-to-make-string-balanced ├── 1653-minimum-deletions-to-make-string-balanced.py └── README.md ├── 1657-determine-if-two-strings-are-close ├── 1657-determine-if-two-strings-are-close.cpp └── README.md ├── 1657-find-the-winner-of-an-array-game ├── 1657-find-the-winner-of-an-array-game.cpp └── README.md ├── 1669-merge-in-between-linked-lists ├── 1669-merge-in-between-linked-lists.cpp └── README.md ├── 1671-minimum-number-of-removals-to-make-mountain-array ├── 1671-minimum-number-of-removals-to-make-mountain-array.py └── README.md ├── 1677-matrix-diagonal-sum ├── 1677-matrix-diagonal-sum.py └── README.md ├── 1678-goal-parser-interpretation ├── 1678-goal-parser-interpretation.py └── README.md ├── 1683-maximum-number-of-coins-you-can-get ├── 1683-maximum-number-of-coins-you-can-get.cpp └── README.md ├── 1684-count-the-number-of-consistent-strings ├── 1684-count-the-number-of-consistent-strings.py └── README.md ├── 1686-stone-game-vi ├── 1686-stone-game-vi.rs └── README.md ├── 1689-partitioning-into-minimum-number-of-deci-binary-numbers ├── 1689-partitioning-into-minimum-number-of-deci-binary-numbers.cpp └── README.md ├── 1700-minimum-time-to-make-rope-colorful ├── 1700-minimum-time-to-make-rope-colorful.cpp └── README.md ├── 1700-number-of-students-unable-to-eat-lunch ├── 1700-number-of-students-unable-to-eat-lunch.cpp └── README.md ├── 1701-average-waiting-time ├── 1701-average-waiting-time.py └── README.md ├── 1704-determine-if-string-halves-are-alike ├── 1704-determine-if-string-halves-are-alike.cpp └── README.md ├── 1704-special-positions-in-a-binary-matrix ├── 1704-special-positions-in-a-binary-matrix.js └── README.md ├── 1710-maximum-units-on-a-truck ├── 1710-maximum-units-on-a-truck.py └── README.md ├── 1717-maximum-score-from-removing-substrings ├── 1717-maximum-score-from-removing-substrings.py └── README.md ├── 1718-construct-the-lexicographically-largest-valid-sequence ├── 1718-construct-the-lexicographically-largest-valid-sequence.go └── README.md ├── 1725-number-of-rectangles-that-can-form-the-largest-square ├── 1725-number-of-rectangles-that-can-form-the-largest-square.py └── README.md ├── 1726-tuple-with-same-product ├── 1726-tuple-with-same-product.go └── README.md ├── 1732-find-the-highest-altitude ├── 1732-find-the-highest-altitude.cpp └── README.md ├── 1742-widest-vertical-area-between-two-points-containing-no-points ├── 1742-widest-vertical-area-between-two-points-containing-no-points.cpp └── README.md ├── 1748-sum-of-unique-elements ├── 1748-sum-of-unique-elements.py └── README.md ├── 1749-maximum-absolute-sum-of-any-subarray ├── 1749-maximum-absolute-sum-of-any-subarray.go └── README.md ├── 1752-arithmetic-subarrays ├── 1752-arithmetic-subarrays.cpp └── README.md ├── 1752-check-if-array-is-sorted-and-rotated ├── 1752-check-if-array-is-sorted-and-rotated.go └── README.md ├── 1760-minimum-limit-of-balls-in-a-bag ├── 1760-minimum-limit-of-balls-in-a-bag.py └── README.md ├── 1763-longest-nice-substring ├── 1763-longest-nice-substring.py └── README.md ├── 1765-map-of-highest-peak ├── 1765-map-of-highest-peak.go └── 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 ├── 1769-minimum-number-of-operations-to-move-all-balls-to-each-box.py └── README.md ├── 1773-count-items-matching-a-rule ├── 1773-count-items-matching-a-rule.py └── README.md ├── 1780-check-if-number-is-a-sum-of-powers-of-three ├── 1780-check-if-number-is-a-sum-of-powers-of-three.go └── 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.py └── README.md ├── 1787-sum-of-absolute-differences-in-a-sorted-array ├── 1787-sum-of-absolute-differences-in-a-sorted-array.cpp └── README.md ├── 1790-check-if-one-string-swap-can-make-strings-equal ├── 1790-check-if-one-string-swap-can-make-strings-equal.go └── README.md ├── 1791-find-center-of-star-graph ├── 1791-find-center-of-star-graph.py └── README.md ├── 1791-richest-customer-wealth ├── 1791-richest-customer-wealth.py └── README.md ├── 1792-maximum-average-pass-ratio ├── 1792-maximum-average-pass-ratio.py └── README.md ├── 1800-maximum-ascending-subarray-sum ├── 1800-maximum-ascending-subarray-sum.go ├── 1800-maximum-ascending-subarray-sum.py └── README.md ├── 1806-count-of-matches-in-tournament ├── 1806-count-of-matches-in-tournament.js └── README.md ├── 1813-sentence-similarity-iii ├── 1813-sentence-similarity-iii.py └── README.md ├── 1816-truncate-sentence ├── 1816-truncate-sentence.py └── README.md ├── 1817-calculate-money-in-leetcode-bank ├── 1817-calculate-money-in-leetcode-bank.js └── README.md ├── 1817-finding-the-users-active-minutes ├── 1817-finding-the-users-active-minutes.py └── README.md ├── 1823-find-the-winner-of-the-circular-game ├── 1823-find-the-winner-of-the-circular-game.cpp ├── 1823-find-the-winner-of-the-circular-game.py └── README.md ├── 1828-queries-on-number-of-points-inside-a-circle ├── 1828-queries-on-number-of-points-inside-a-circle.rs └── README.md ├── 1829-maximum-xor-for-each-query ├── 1829-maximum-xor-for-each-query.rs └── README.md ├── 1832-check-if-the-sentence-is-pangram ├── 1832-check-if-the-sentence-is-pangram.py └── README.md ├── 1833-maximum-ice-cream-bars ├── 1833-maximum-ice-cream-bars.cpp └── README.md ├── 1845-largest-submatrix-with-rearrangements ├── 1845-largest-submatrix-with-rearrangements.cpp └── README.md ├── 1846-maximum-element-after-decreasing-and-rearranging ├── 1846-maximum-element-after-decreasing-and-rearranging.cpp ├── NOTES.md └── README.md ├── 1848-minimum-distance-to-the-target-element ├── 1848-minimum-distance-to-the-target-element.py └── README.md ├── 1859-sorting-the-sentence ├── 1859-sorting-the-sentence.py └── README.md ├── 1861-rotating-the-box ├── 1861-rotating-the-box.py └── README.md ├── 1863-sum-of-all-subset-xor-totals ├── 1863-sum-of-all-subset-xor-totals.cpp ├── 1863-sum-of-all-subset-xor-totals.go └── README.md ├── 1866-restore-the-array-from-adjacent-pairs ├── 1866-restore-the-array-from-adjacent-pairs.cpp └── README.md ├── 1869-longer-contiguous-segments-of-ones-than-zeros ├── 1869-longer-contiguous-segments-of-ones-than-zeros.py └── README.md ├── 1876-substrings-of-size-three-with-distinct-characters ├── 1876-substrings-of-size-three-with-distinct-characters.py └── README.md ├── 1877-minimize-maximum-pair-sum-in-array ├── 1877-minimize-maximum-pair-sum-in-array.cpp ├── NOTES.md └── README.md ├── 1880-check-if-word-equals-summation-of-two-words ├── 1880-check-if-word-equals-summation-of-two-words.py └── README.md ├── 1884-minimum-changes-to-make-alternating-binary-string ├── 1884-minimum-changes-to-make-alternating-binary-string.cpp └── README.md ├── 1885-count-number-of-homogenous-substrings ├── 1885-count-number-of-homogenous-substrings.cpp └── README.md ├── 1901-find-a-peak-element-ii ├── 1901-find-a-peak-element-ii.cpp └── README.md ├── 1905-count-sub-islands ├── 1905-count-sub-islands.cpp └── README.md ├── 1910-remove-all-occurrences-of-a-substring ├── 1910-remove-all-occurrences-of-a-substring.cpp ├── 1910-remove-all-occurrences-of-a-substring.go └── README.md ├── 1915-number-of-wonderful-substrings ├── 1915-number-of-wonderful-substrings.cpp └── README.md ├── 1920-build-array-from-permutation ├── 1920-build-array-from-permutation.py └── README.md ├── 1925-count-nice-pairs-in-an-array ├── 1925-count-nice-pairs-in-an-array.cpp └── README.md ├── 1930-unique-length-3-palindromic-subsequences ├── 1930-unique-length-3-palindromic-subsequences.py └── README.md ├── 1935-maximum-number-of-words-you-can-type ├── 1935-maximum-number-of-words-you-can-type.py └── README.md ├── 1942-the-number-of-the-smallest-unoccupied-chair ├── 1942-the-number-of-the-smallest-unoccupied-chair.py └── README.md ├── 1944-number-of-visible-people-in-a-queue ├── 1944-number-of-visible-people-in-a-queue.py └── README.md ├── 1945-sum-of-digits-of-string-after-convert ├── 1945-sum-of-digits-of-string-after-convert.py └── README.md ├── 1952-three-divisors ├── 1952-three-divisors.py └── README.md ├── 1955-seat-reservation-manager ├── 1955-seat-reservation-manager.cpp └── README.md ├── 1957-delete-characters-to-make-fancy-string ├── 1957-delete-characters-to-make-fancy-string.py └── README.md ├── 1961-check-if-string-is-a-prefix-of-array ├── 1961-check-if-string-is-a-prefix-of-array.py └── README.md ├── 1963-minimum-number-of-swaps-to-make-the-string-balanced ├── 1963-minimum-number-of-swaps-to-make-the-string-balanced.py └── README.md ├── 1966-frequency-of-the-most-frequent-element ├── 1966-frequency-of-the-most-frequent-element.cpp └── README.md ├── 1967-number-of-strings-that-appear-as-substrings-in-word ├── 1967-number-of-strings-that-appear-as-substrings-in-word.py └── README.md ├── 1971-find-if-path-exists-in-graph ├── 1971-find-if-path-exists-in-graph.cpp └── README.md ├── 1975-maximum-matrix-sum ├── 1975-maximum-matrix-sum.py └── README.md ├── 1976-number-of-ways-to-arrive-at-destination ├── 1976-number-of-ways-to-arrive-at-destination.py └── README.md ├── 1979-find-greatest-common-divisor-of-array ├── 1979-find-greatest-common-divisor-of-array.py └── README.md ├── 1980-find-unique-binary-string ├── 1980-find-unique-binary-string.cpp ├── 1980-find-unique-binary-string.go ├── NOTES.md └── README.md ├── 1992-find-all-groups-of-farmland ├── 1992-find-all-groups-of-farmland.cpp └── README.md ├── 2000-reverse-prefix-of-word ├── 2000-reverse-prefix-of-word.cpp └── README.md ├── 2011-final-value-of-variable-after-performing-operations ├── 2011-final-value-of-variable-after-performing-operations.py └── README.md ├── 2016-reduction-operations-to-make-the-array-elements-equal ├── 2016-reduction-operations-to-make-the-array-elements-equal.cpp └── README.md ├── 2017-grid-game ├── 2017-grid-game.go └── README.md ├── 2022-convert-1d-array-into-2d-array ├── 2022-convert-1d-array-into-2d-array.py └── README.md ├── 2025-redistribute-characters-to-make-all-strings-equal ├── 2025-redistribute-characters-to-make-all-strings-equal.cpp └── README.md ├── 2032-largest-odd-number-in-string ├── 2032-largest-odd-number-in-string.js └── README.md ├── 2033-minimum-operations-to-make-a-uni-value-grid ├── 2033-minimum-operations-to-make-a-uni-value-grid.go └── README.md ├── 2037-minimum-number-of-moves-to-seat-everyone ├── 2037-minimum-number-of-moves-to-seat-everyone.py └── README.md ├── 2038-nearest-exit-from-entrance-in-maze ├── 2038-nearest-exit-from-entrance-in-maze.cpp └── README.md ├── 2042-maximum-product-difference-between-two-pairs ├── 2042-maximum-product-difference-between-two-pairs.cpp └── README.md ├── 2044-count-number-of-maximum-bitwise-or-subsets ├── 2044-count-number-of-maximum-bitwise-or-subsets.py └── README.md ├── 2045-second-minimum-time-to-reach-destination ├── 2045-second-minimum-time-to-reach-destination.cpp ├── 2045-second-minimum-time-to-reach-destination.py └── README.md ├── 2047-number-of-valid-words-in-a-sentence ├── 2047-number-of-valid-words-in-a-sentence.go └── README.md ├── 2049-eliminate-maximum-number-of-monsters ├── 2049-eliminate-maximum-number-of-monsters.cpp └── README.md ├── 2053-kth-distinct-string-in-an-array ├── 2053-kth-distinct-string-in-an-array.py └── README.md ├── 2054-two-best-non-overlapping-events ├── 2054-two-best-non-overlapping-events.py └── README.md ├── 2057-smallest-index-with-equal-value ├── 2057-smallest-index-with-equal-value.py └── README.md ├── 2058-find-the-minimum-and-maximum-number-of-nodes-between-critical-points ├── 2058-find-the-minimum-and-maximum-number-of-nodes-between-critical-points.py └── README.md ├── 2064-minimized-maximum-of-products-distributed-to-any-store ├── 2064-minimized-maximum-of-products-distributed-to-any-store.py └── README.md ├── 2070-most-beautiful-item-for-each-query ├── 2070-most-beautiful-item-for-each-query.py └── README.md ├── 2073-time-needed-to-buy-tickets ├── 2073-time-needed-to-buy-tickets.cpp └── README.md ├── 2079-watering-plants ├── 2079-watering-plants.cpp └── README.md ├── 2089-find-target-indices-after-sorting-array ├── 2089-find-target-indices-after-sorting-array.cpp └── README.md ├── 2094-finding-3-digit-even-numbers ├── 2094-finding-3-digit-even-numbers.py └── README.md ├── 2095-delete-the-middle-node-of-a-linked-list ├── 2095-delete-the-middle-node-of-a-linked-list.cpp └── README.md ├── 2096-step-by-step-directions-from-a-binary-tree-node-to-another ├── 2096-step-by-step-directions-from-a-binary-tree-node-to-another.py └── README.md ├── 2097-valid-arrangement-of-pairs ├── 2097-valid-arrangement-of-pairs.py └── README.md ├── 2099-find-subsequence-of-length-k-with-the-largest-sum ├── 2099-find-subsequence-of-length-k-with-the-largest-sum.py └── README.md ├── 2104-sum-of-subarray-ranges ├── 2104-sum-of-subarray-ranges.py └── README.md ├── 2108-find-first-palindromic-string-in-the-array ├── 2108-find-first-palindromic-string-in-the-array.cpp └── README.md ├── 2109-adding-spaces-to-a-string ├── 2109-adding-spaces-to-a-string.py └── README.md ├── 2114-maximum-number-of-words-found-in-sentences ├── 2114-maximum-number-of-words-found-in-sentences.go ├── 2114-maximum-number-of-words-found-in-sentences.py └── README.md ├── 2115-find-all-possible-recipes-from-given-supplies ├── 2115-find-all-possible-recipes-from-given-supplies.go └── README.md ├── 2116-check-if-a-parentheses-string-can-be-valid ├── 2116-check-if-a-parentheses-string-can-be-valid.go └── README.md ├── 2119-a-number-after-a-double-reversal ├── 2119-a-number-after-a-double-reversal.py └── README.md ├── 2120-execution-of-all-suffix-instructions-staying-in-a-grid ├── 2120-execution-of-all-suffix-instructions-staying-in-a-grid.py └── README.md ├── 2124-check-if-all-as-appears-before-all-bs ├── 2124-check-if-all-as-appears-before-all-bs.py └── README.md ├── 2125-number-of-laser-beams-in-a-bank ├── 2125-number-of-laser-beams-in-a-bank.cpp └── README.md ├── 2127-maximum-employees-to-be-invited-to-a-meeting ├── 2127-maximum-employees-to-be-invited-to-a-meeting.go └── README.md ├── 2130-maximum-twin-sum-of-a-linked-list ├── 2130-maximum-twin-sum-of-a-linked-list.py └── README.md ├── 2131-longest-palindrome-by-concatenating-two-letter-words ├── 2131-longest-palindrome-by-concatenating-two-letter-words.py └── README.md ├── 2134-minimum-swaps-to-group-all-1s-together-ii ├── 2134-minimum-swaps-to-group-all-1s-together-ii.py └── README.md ├── 2136-earliest-possible-day-of-full-bloom ├── 2136-earliest-possible-day-of-full-bloom.py └── README.md ├── 2140-solving-questions-with-brainpower ├── 2140-solving-questions-with-brainpower.go └── README.md ├── 2144-minimum-cost-of-buying-candies-with-discount ├── 2144-minimum-cost-of-buying-candies-with-discount.py └── README.md ├── 2145-count-the-hidden-sequences ├── 2145-count-the-hidden-sequences.go └── README.md ├── 2148-count-elements-with-strictly-smaller-and-greater-elements ├── 2148-count-elements-with-strictly-smaller-and-greater-elements.py └── README.md ├── 2149-rearrange-array-elements-by-sign ├── 2149-rearrange-array-elements-by-sign.cpp └── README.md ├── 2150-find-all-lonely-numbers-in-the-array ├── 2150-find-all-lonely-numbers-in-the-array.cpp └── README.md ├── 2154-keep-multiplying-found-values-by-two ├── 2154-keep-multiplying-found-values-by-two.py └── README.md ├── 2161-partition-array-according-to-given-pivot ├── 2161-partition-array-according-to-given-pivot.cpp ├── 2161-partition-array-according-to-given-pivot.go └── README.md ├── 2169-count-operations-to-obtain-zero ├── 2169-count-operations-to-obtain-zero.py └── README.md ├── 2176-count-equal-and-divisible-pairs-in-an-array ├── 2176-count-equal-and-divisible-pairs-in-an-array.go ├── 2176-count-equal-and-divisible-pairs-in-an-array.py └── README.md ├── 2177-find-three-consecutive-integers-that-sum-to-a-given-number ├── 2177-find-three-consecutive-integers-that-sum-to-a-given-number.cpp └── README.md ├── 2181-merge-nodes-in-between-zeros ├── 2181-merge-nodes-in-between-zeros.cpp ├── 2181-merge-nodes-in-between-zeros.py └── README.md ├── 2182-construct-string-with-repeat-limit ├── 2182-construct-string-with-repeat-limit.py └── README.md ├── 2185-counting-words-with-a-given-prefix ├── 2185-counting-words-with-a-given-prefix.py └── README.md ├── 2186-minimum-number-of-steps-to-make-two-strings-anagram-ii ├── 2186-minimum-number-of-steps-to-make-two-strings-anagram-ii.cpp └── README.md ├── 2191-sort-the-jumbled-numbers ├── 2191-sort-the-jumbled-numbers.py └── README.md ├── 2192-all-ancestors-of-a-node-in-a-directed-acyclic-graph ├── 2192-all-ancestors-of-a-node-in-a-directed-acyclic-graph.py └── README.md ├── 2196-create-binary-tree-from-descriptions ├── 2196-create-binary-tree-from-descriptions.py └── README.md ├── 2206-divide-array-into-equal-pairs ├── 2206-divide-array-into-equal-pairs.go ├── 2206-divide-array-into-equal-pairs.py └── README.md ├── 2220-minimum-bit-flips-to-convert-number ├── 2220-minimum-bit-flips-to-convert-number.py └── README.md ├── 2221-find-triangular-sum-of-an-array ├── 2221-find-triangular-sum-of-an-array.py └── README.md ├── 2225-find-players-with-zero-or-one-losses ├── 2225-find-players-with-zero-or-one-losses.cpp └── README.md ├── 2226-maximum-candies-allocated-to-k-children ├── 2226-maximum-candies-allocated-to-k-children.go └── README.md ├── 2235-add-two-integers ├── 2235-add-two-integers.py └── README.md ├── 2236-root-equals-sum-of-children ├── 2236-root-equals-sum-of-children.py └── README.md ├── 2251-number-of-ways-to-divide-a-long-corridor ├── 2251-number-of-ways-to-divide-a-long-corridor.py └── README.md ├── 2257-count-unguarded-cells-in-the-grid ├── 2257-count-unguarded-cells-in-the-grid.py └── README.md ├── 2269-find-the-k-beauty-of-a-number ├── 2269-find-the-k-beauty-of-a-number.py └── README.md ├── 2270-number-of-ways-to-split-array ├── 2270-number-of-ways-to-split-array.py └── README.md ├── 2273-find-resultant-array-after-removing-anagrams ├── 2273-find-resultant-array-after-removing-anagrams.cpp └── README.md ├── 2275-largest-combination-with-bitwise-and-greater-than-zero ├── 2275-largest-combination-with-bitwise-and-greater-than-zero.py └── README.md ├── 2278-percentage-of-letter-in-string ├── 2278-percentage-of-letter-in-string.py └── README.md ├── 2279-maximum-bags-with-full-capacity-of-rocks ├── 2279-maximum-bags-with-full-capacity-of-rocks.cpp └── README.md ├── 2285-maximum-total-importance-of-roads ├── 2285-maximum-total-importance-of-roads.py └── README.md ├── 2290-minimum-obstacle-removal-to-reach-corner ├── 2290-minimum-obstacle-removal-to-reach-corner.py └── README.md ├── 2317-maximum-xor-after-operations ├── 2317-maximum-xor-after-operations.py └── README.md ├── 2319-check-if-matrix-is-x-matrix ├── 2319-check-if-matrix-is-x-matrix.py └── README.md ├── 2331-evaluate-boolean-binary-tree ├── 2331-evaluate-boolean-binary-tree.cpp └── README.md ├── 2337-move-pieces-to-obtain-a-string ├── 2337-move-pieces-to-obtain-a-string.py └── README.md ├── 2341-maximum-number-of-pairs-in-array ├── 2341-maximum-number-of-pairs-in-array.py └── README.md ├── 2342-max-sum-of-a-pair-with-equal-sum-of-digits ├── 2342-max-sum-of-a-pair-with-equal-sum-of-digits.go └── README.md ├── 2346-largest-3-same-digit-number-in-string ├── 2346-largest-3-same-digit-number-in-string.js └── README.md ├── 2349-design-a-number-container-system ├── 2349-design-a-number-container-system.py └── README.md ├── 2350-shortest-impossible-sequence-of-rolls ├── 2350-shortest-impossible-sequence-of-rolls.py └── README.md ├── 2351-first-letter-to-appear-twice ├── 2351-first-letter-to-appear-twice.cpp └── README.md ├── 2354-number-of-excellent-pairs ├── 2354-number-of-excellent-pairs.py └── README.md ├── 2357-make-array-zero-by-subtracting-equal-amounts ├── 2357-make-array-zero-by-subtracting-equal-amounts.cpp └── README.md ├── 2364-count-number-of-bad-pairs ├── 2364-count-number-of-bad-pairs.go └── README.md ├── 2367-number-of-arithmetic-triplets ├── 2367-number-of-arithmetic-triplets.py └── README.md ├── 2370-longest-ideal-subsequence ├── 2370-longest-ideal-subsequence.cpp └── README.md ├── 2373-largest-local-values-in-a-matrix ├── 2373-largest-local-values-in-a-matrix.cpp └── README.md ├── 2375-construct-smallest-number-from-di-string ├── 2375-construct-smallest-number-from-di-string.go └── README.md ├── 2379-minimum-recolors-to-get-k-consecutive-black-blocks ├── 2379-minimum-recolors-to-get-k-consecutive-black-blocks.go └── README.md ├── 2381-shifting-letters-ii ├── 2381-shifting-letters-ii.py └── README.md ├── 2385-amount-of-time-for-binary-tree-to-be-infected ├── 2385-amount-of-time-for-binary-tree-to-be-infected.cpp └── README.md ├── 2390-removing-stars-from-a-string ├── 2390-removing-stars-from-a-string.py └── README.md ├── 2392-build-a-matrix-with-conditions ├── 2392-build-a-matrix-with-conditions.py └── README.md ├── 2392-successful-pairs-of-spells-and-potions ├── 2392-successful-pairs-of-spells-and-potions.cpp └── README.md ├── 2396-strictly-palindromic-number ├── 2396-strictly-palindromic-number.rs └── README.md ├── 2401-longest-nice-subarray ├── 2401-longest-nice-subarray.go └── README.md ├── 2404-most-frequent-even-element ├── 2404-most-frequent-even-element.py └── README.md ├── 2405-optimal-partition-of-string ├── 2405-optimal-partition-of-string.py └── README.md ├── 2406-divide-intervals-into-minimum-number-of-groups ├── 2406-divide-intervals-into-minimum-number-of-groups.py └── README.md ├── 2413-smallest-even-multiple ├── 2413-smallest-even-multiple.py └── README.md ├── 2413-smallest-number-in-infinite-set ├── 2413-smallest-number-in-infinite-set.cpp └── README.md ├── 2414-length-of-the-longest-alphabetical-continuous-substring ├── 2414-length-of-the-longest-alphabetical-continuous-substring.cpp └── README.md ├── 2415-reverse-odd-levels-of-binary-tree ├── 2415-reverse-odd-levels-of-binary-tree.py └── README.md ├── 2418-sort-the-people ├── 2418-sort-the-people.py └── README.md ├── 2419-longest-subarray-with-maximum-bitwise-and ├── 2419-longest-subarray-with-maximum-bitwise-and.py └── README.md ├── 2425-bitwise-xor-of-all-pairings ├── 2425-bitwise-xor-of-all-pairings.go └── README.md ├── 2427-number-of-common-factors ├── 2427-number-of-common-factors.py └── README.md ├── 2429-design-a-food-rating-system ├── 2429-design-a-food-rating-system.cpp └── README.md ├── 2429-minimize-xor ├── 2429-minimize-xor.go └── README.md ├── 2439-minimize-maximum-of-array ├── 2439-minimize-maximum-of-array.py └── README.md ├── 2441-largest-positive-integer-that-exists-with-its-negative ├── 2441-largest-positive-integer-that-exists-with-its-negative.cpp └── README.md ├── 2442-count-number-of-distinct-integers-after-reverse-operations ├── 2442-count-number-of-distinct-integers-after-reverse-operations.cpp └── README.md ├── 2444-count-subarrays-with-fixed-bounds ├── 2444-count-subarrays-with-fixed-bounds.cpp └── README.md ├── 2455-average-value-of-even-numbers-that-are-divisible-by-three ├── 2455-average-value-of-even-numbers-that-are-divisible-by-three.py └── README.md ├── 2458-height-of-binary-tree-after-subtree-removal-queries ├── 2458-height-of-binary-tree-after-subtree-removal-queries.py └── README.md ├── 2460-apply-operations-to-an-array ├── 2460-apply-operations-to-an-array.py └── README.md ├── 2461-maximum-sum-of-distinct-subarrays-with-length-k ├── 2461-maximum-sum-of-distinct-subarrays-with-length-k.py └── README.md ├── 2463-minimum-total-distance-traveled ├── 2463-minimum-total-distance-traveled.py └── README.md ├── 2466-count-ways-to-build-good-strings ├── 2466-count-ways-to-build-good-strings.py └── README.md ├── 2467-most-profitable-path-in-a-tree ├── 2467-most-profitable-path-in-a-tree.py └── README.md ├── 2469-convert-the-temperature ├── 2469-convert-the-temperature.py └── README.md ├── 2471-minimum-amount-of-time-to-collect-garbage ├── 2471-minimum-amount-of-time-to-collect-garbage.cpp └── README.md ├── 2471-minimum-number-of-operations-to-sort-a-binary-tree-by-level ├── 2471-minimum-number-of-operations-to-sort-a-binary-tree-by-level.py └── README.md ├── 2485-find-the-pivot-integer ├── 2485-find-the-pivot-integer.cpp └── README.md ├── 2486-append-characters-to-string-to-make-subsequence ├── 2486-append-characters-to-string-to-make-subsequence.cpp └── README.md ├── 2487-remove-nodes-from-linked-list ├── 2487-remove-nodes-from-linked-list.cpp └── README.md ├── 2490-circular-sentence ├── 2490-circular-sentence.py └── README.md ├── 2491-divide-players-into-teams-of-equal-skill ├── 2491-divide-players-into-teams-of-equal-skill.py └── README.md ├── 2493-divide-nodes-into-the-maximum-number-of-groups ├── 2493-divide-nodes-into-the-maximum-number-of-groups.go └── README.md ├── 2501-longest-square-streak-in-an-array ├── 2501-longest-square-streak-in-an-array.py └── README.md ├── 2503-maximum-number-of-points-from-grid-queries ├── 2503-maximum-number-of-points-from-grid-queries.py └── README.md ├── 2506-count-pairs-of-similar-strings ├── 2506-count-pairs-of-similar-strings.py └── README.md ├── 2516-take-k-of-each-character-from-left-and-right ├── 2516-take-k-of-each-character-from-left-and-right.py └── README.md ├── 2523-closest-prime-numbers-in-range ├── 2523-closest-prime-numbers-in-range.go └── README.md ├── 2529-maximum-count-of-positive-integer-and-negative-integer ├── 2529-maximum-count-of-positive-integer-and-negative-integer.go ├── 2529-maximum-count-of-positive-integer-and-negative-integer.py └── README.md ├── 2530-maximal-score-after-applying-k-operations ├── 2530-maximal-score-after-applying-k-operations.py └── README.md ├── 2535-difference-between-element-sum-and-digit-sum-of-an-array ├── 2535-difference-between-element-sum-and-digit-sum-of-an-array.py └── README.md ├── 2537-count-the-number-of-good-subarrays ├── 2537-count-the-number-of-good-subarrays.go └── README.md ├── 2540-minimum-common-value ├── 2540-minimum-common-value.cpp └── README.md ├── 2544-alternating-digit-sum ├── 2544-alternating-digit-sum.py └── README.md ├── 2545-sort-the-students-by-their-kth-score ├── 2545-sort-the-students-by-their-kth-score.py └── README.md ├── 2551-put-marbles-in-bags ├── 2551-put-marbles-in-bags.go └── README.md ├── 2553-separate-the-digits-in-an-array ├── 2553-separate-the-digits-in-an-array.py └── README.md ├── 2553-total-cost-to-hire-k-workers ├── 2553-total-cost-to-hire-k-workers.cpp └── README.md ├── 2554-maximum-number-of-integers-to-choose-from-a-range-i ├── 2554-maximum-number-of-integers-to-choose-from-a-range-i.py └── README.md ├── 2558-take-gifts-from-the-richest-pile ├── 2558-take-gifts-from-the-richest-pile.py └── README.md ├── 2559-count-vowel-strings-in-ranges ├── 2559-count-vowel-strings-in-ranges.py └── README.md ├── 2560-house-robber-iv ├── 2560-house-robber-iv.go └── README.md ├── 2563-count-the-number-of-fair-pairs ├── 2563-count-the-number-of-fair-pairs.py └── README.md ├── 2570-merge-two-2d-arrays-by-summing-values ├── 2570-merge-two-2d-arrays-by-summing-values.go └── README.md ├── 2574-left-and-right-sum-differences ├── 2574-left-and-right-sum-differences.py └── README.md ├── 2577-minimum-time-to-visit-a-cell-in-a-grid ├── 2577-minimum-time-to-visit-a-cell-in-a-grid.py └── README.md ├── 2579-count-total-number-of-colored-cells ├── 2579-count-total-number-of-colored-cells.go └── README.md ├── 2582-pass-the-pillow ├── 2582-pass-the-pillow.py └── README.md ├── 2583-kth-largest-sum-in-a-binary-tree ├── 2583-kth-largest-sum-in-a-binary-tree.py └── README.md ├── 2586-count-the-number-of-vowel-strings-in-range ├── 2586-count-the-number-of-vowel-strings-in-range.py └── README.md ├── 2593-find-score-of-an-array-after-marking-all-elements ├── 2593-find-score-of-an-array-after-marking-all-elements.py └── README.md ├── 2594-minimum-time-to-repair-cars ├── 2594-minimum-time-to-repair-cars.go └── README.md ├── 2595-number-of-even-and-odd-bits ├── 2595-number-of-even-and-odd-bits.py └── README.md ├── 2597-the-number-of-beautiful-subsets ├── 2597-the-number-of-beautiful-subsets.cpp └── README.md ├── 2601-prime-subtraction-operation ├── 2601-prime-subtraction-operation.py └── README.md ├── 2605-form-smallest-number-from-two-digit-arrays ├── 2605-form-smallest-number-from-two-digit-arrays.py └── README.md ├── 2606-difference-between-ones-and-zeros-in-row-and-column ├── 2606-difference-between-ones-and-zeros-in-row-and-column.cpp └── README.md ├── 2610-convert-an-array-into-a-2d-array-with-conditions ├── 2610-convert-an-array-into-a-2d-array-with-conditions.cpp └── README.md ├── 2614-prime-in-diagonal ├── 2614-prime-in-diagonal.py └── README.md ├── 2636-maximum-subsequence-score ├── 2636-maximum-subsequence-score.cpp └── README.md ├── 2639-find-the-width-of-columns-of-a-grid ├── 2639-find-the-width-of-columns-of-a-grid.py └── README.md ├── 2641-cousins-in-binary-tree-ii ├── 2641-cousins-in-binary-tree-ii.py └── README.md ├── 2643-row-with-maximum-ones ├── 2643-row-with-maximum-ones.py └── README.md ├── 2648-generate-fibonacci-sequence ├── 2648-generate-fibonacci-sequence.js └── README.md ├── 2651-calculate-delayed-arrival-time ├── 2651-calculate-delayed-arrival-time.py └── README.md ├── 2652-sum-multiples ├── 2652-sum-multiples.py └── README.md ├── 2656-maximum-sum-with-exactly-k-elements ├── 2656-maximum-sum-with-exactly-k-elements.py └── README.md ├── 2657-find-the-prefix-common-array-of-two-arrays ├── 2657-find-the-prefix-common-array-of-two-arrays.go ├── 2657-find-the-prefix-common-array-of-two-arrays.py └── README.md ├── 2658-maximum-number-of-fish-in-a-grid ├── 2658-maximum-number-of-fish-in-a-grid.cpp ├── 2658-maximum-number-of-fish-in-a-grid.go └── README.md ├── 2661-first-completely-painted-row-or-column ├── 2661-first-completely-painted-row-or-column.go └── README.md ├── 2678-design-graph-with-shortest-path-calculator ├── 2678-design-graph-with-shortest-path-calculator.cpp └── README.md ├── 2678-number-of-senior-citizens ├── 2678-number-of-senior-citizens.py └── README.md ├── 2683-neighboring-bitwise-xor ├── 2683-neighboring-bitwise-xor.go └── README.md ├── 2684-maximum-number-of-moves-in-a-grid ├── 2684-maximum-number-of-moves-in-a-grid.py └── README.md ├── 2685-count-the-number-of-complete-components ├── 2685-count-the-number-of-complete-components.go └── README.md ├── 2696-minimum-string-length-after-removing-substrings ├── 2696-minimum-string-length-after-removing-substrings.py └── README.md ├── 2697-lexicographically-smallest-palindrome ├── 2697-lexicographically-smallest-palindrome.py └── README.md ├── 2698-find-the-punishment-number-of-an-integer ├── 2698-find-the-punishment-number-of-an-integer.go └── README.md ├── 2716-minimize-string-length ├── 2716-minimize-string-length.cpp └── README.md ├── 2729-check-if-the-number-is-fascinating ├── 2729-check-if-the-number-is-fascinating.py └── README.md ├── 2732-counter ├── 2732-counter.js └── README.md ├── 2733-neither-minimum-nor-maximum ├── 2733-neither-minimum-nor-maximum.py └── README.md ├── 2733-sleep ├── 2733-sleep.js └── README.md ├── 2741-function-composition ├── 2741-function-composition.js └── README.md ├── 2746-filter-elements-from-array ├── 2746-filter-elements-from-array.js └── README.md ├── 2747-apply-transform-over-each-element-in-array ├── 2747-apply-transform-over-each-element-in-array.js └── README.md ├── 2751-robot-collisions ├── 2751-robot-collisions.cpp ├── 2751-robot-collisions.py └── README.md ├── 2756-buy-two-chocolates ├── 2756-buy-two-chocolates.cpp └── README.md ├── 2761-array-reduce-transformation ├── 2761-array-reduce-transformation.js └── README.md ├── 2762-continuous-subarrays ├── 2762-continuous-subarrays.py └── README.md ├── 2769-find-the-maximum-achievable-number ├── 2769-find-the-maximum-achievable-number.cpp └── README.md ├── 2778-sum-of-squares-of-special-elements ├── 2778-sum-of-squares-of-special-elements.cpp ├── 2778-sum-of-squares-of-special-elements.py └── README.md ├── 2779-maximum-beauty-of-an-array-after-applying-operation ├── 2779-maximum-beauty-of-an-array-after-applying-operation.py └── README.md ├── 2780-minimum-index-of-a-valid-split ├── 2780-minimum-index-of-a-valid-split.go └── README.md ├── 2788-split-strings-by-separator ├── 2788-split-strings-by-separator.py └── README.md ├── 2789-counter-ii ├── 2789-counter-ii.js └── README.md ├── 2796-allow-one-function-call ├── 2796-allow-one-function-call.js └── README.md ├── 2798-chunk-array ├── 2798-chunk-array.js └── README.md ├── 2798-number-of-employees-who-met-the-target ├── 2798-number-of-employees-who-met-the-target.py └── README.md ├── 2806-account-balance-after-rounded-purchase ├── 2806-account-balance-after-rounded-purchase.py └── README.md ├── 2807-insert-greatest-common-divisors-in-linked-list ├── 2807-insert-greatest-common-divisors-in-linked-list.cpp └── README.md ├── 2809-create-hello-world-function ├── 2809-create-hello-world-function.js └── README.md ├── 2810-faulty-keyboard ├── 2810-faulty-keyboard.py └── README.md ├── 2813-to-be-or-not-to-be ├── 2813-to-be-or-not-to-be.js └── README.md ├── 2816-double-a-number-represented-as-a-linked-list ├── 2816-double-a-number-represented-as-a-linked-list.cpp └── README.md ├── 2818-apply-operations-to-maximize-score ├── 2818-apply-operations-to-maximize-score.py └── README.md ├── 2820-return-length-of-arguments-passed ├── 2820-return-length-of-arguments-passed.js └── README.md ├── 2821-timeout-cancellation ├── 2821-timeout-cancellation.ts └── README.md ├── 2824-count-pairs-whose-sum-is-less-than-target ├── 2824-count-pairs-whose-sum-is-less-than-target.py └── README.md ├── 2825-make-string-a-subsequence-using-cyclic-increments ├── 2825-make-string-a-subsequence-using-cyclic-increments.py └── README.md ├── 2828-check-if-a-string-is-an-acronym-of-words ├── 2828-check-if-a-string-is-an-acronym-of-words.py └── README.md ├── 2843-count-symmetric-integers ├── 2843-count-symmetric-integers.go └── README.md ├── 2848-points-that-intersect-with-cars ├── 2848-points-that-intersect-with-cars.py └── README.md ├── 2859-add-two-promises ├── 2859-add-two-promises.js └── README.md ├── 2862-interval-cancellation ├── 2862-interval-cancellation.js └── README.md ├── 2864-is-object-empty ├── 2864-is-object-empty.js └── README.md ├── 2864-maximum-odd-binary-number ├── 2864-maximum-odd-binary-number.cpp └── README.md ├── 2870-minimum-number-of-operations-to-make-array-empty ├── 2870-minimum-number-of-operations-to-make-array-empty.cpp └── README.md ├── 2872-maximum-number-of-k-divisible-components ├── 2872-maximum-number-of-k-divisible-components.py └── README.md ├── 2873-maximum-value-of-an-ordered-triplet-i ├── 2873-maximum-value-of-an-ordered-triplet-i.go └── README.md ├── 2874-maximum-value-of-an-ordered-triplet-ii ├── 2874-maximum-value-of-an-ordered-triplet-ii.go └── README.md ├── 2887-sort-vowels-in-a-string ├── 2887-sort-vowels-in-a-string.cpp └── README.md ├── 2894-divisible-and-non-divisible-sums-difference ├── 2894-divisible-and-non-divisible-sums-difference.py └── README.md ├── 2903-find-indices-with-index-and-value-difference-i ├── 2903-find-indices-with-index-and-value-difference-i.cpp └── README.md ├── 2914-minimum-number-of-changes-to-make-binary-string-beautiful ├── 2914-minimum-number-of-changes-to-make-binary-string-beautiful.py └── README.md ├── 2918-minimum-equal-sum-of-two-arrays-after-replacing-zeros ├── 2918-minimum-equal-sum-of-two-arrays-after-replacing-zeros.py └── README.md ├── 2923-find-champion-i ├── 2923-find-champion-i.py └── README.md ├── 2924-find-champion-ii ├── 2924-find-champion-ii.py └── README.md ├── 2929-distribute-candies-among-children-ii ├── 2929-distribute-candies-among-children-ii.py └── README.md ├── 2938-separate-black-and-white-balls ├── 2938-separate-black-and-white-balls.py └── README.md ├── 2940-find-building-where-alice-and-bob-can-meet ├── 2940-find-building-where-alice-and-bob-can-meet.py └── README.md ├── 2942-find-words-containing-character ├── 2942-find-words-containing-character.py └── README.md ├── 2948-make-lexicographically-smallest-array-by-swapping-elements ├── 2948-make-lexicographically-smallest-array-by-swapping-elements.go └── README.md ├── 2951-find-the-peaks ├── 2951-find-the-peaks.py └── README.md ├── 2956-find-common-elements-between-two-arrays ├── 2956-find-common-elements-between-two-arrays.py └── README.md ├── 2958-length-of-longest-subarray-with-at-most-k-frequency ├── 2958-length-of-longest-subarray-with-at-most-k-frequency.cpp └── README.md ├── 2960-count-tested-devices-after-test-operations ├── 2960-count-tested-devices-after-test-operations.py └── README.md ├── 2962-count-subarrays-where-max-element-appears-at-least-k-times ├── 2962-count-subarrays-where-max-element-appears-at-least-k-times.cpp └── README.md ├── 2965-find-missing-and-repeated-values ├── 2965-find-missing-and-repeated-values.go └── README.md ├── 2966-divide-array-into-arrays-with-max-difference ├── 2966-divide-array-into-arrays-with-max-difference.cpp └── README.md ├── 2971-find-polygon-with-the-largest-perimeter ├── 2971-find-polygon-with-the-largest-perimeter.cpp └── README.md ├── 2974-minimum-number-game ├── 2974-minimum-number-game.py └── README.md ├── 2976-minimum-cost-to-convert-string-i ├── 2976-minimum-cost-to-convert-string-i.py └── README.md ├── 2980-check-if-bitwise-or-has-trailing-zeros ├── 2980-check-if-bitwise-or-has-trailing-zeros.py └── README.md ├── 2981-find-longest-special-substring-that-occurs-thrice-i ├── 2981-find-longest-special-substring-that-occurs-thrice-i.py └── README.md ├── 2997-minimum-number-of-operations-to-make-array-xor-equal-to-k ├── 2997-minimum-number-of-operations-to-make-array-xor-equal-to-k.cpp └── README.md ├── 3000-maximum-area-of-longest-diagonal-rectangle ├── 3000-maximum-area-of-longest-diagonal-rectangle.cpp └── README.md ├── 3005-count-elements-with-maximum-frequency ├── 3005-count-elements-with-maximum-frequency.cpp └── README.md ├── 3010-divide-an-array-into-subarrays-with-minimum-cost-i ├── 3010-divide-an-array-into-subarrays-with-minimum-cost-i.py └── README.md ├── 3011-find-if-array-can-be-sorted ├── 3011-find-if-array-can-be-sorted.py └── README.md ├── 3014-minimum-number-of-pushes-to-type-word-i ├── 3014-minimum-number-of-pushes-to-type-word-i.cpp └── README.md ├── 3016-minimum-number-of-pushes-to-type-word-ii ├── 3016-minimum-number-of-pushes-to-type-word-ii.py └── README.md ├── 3019-number-of-changing-keys ├── 3019-number-of-changing-keys.cpp └── README.md ├── 3024-type-of-triangle ├── 3024-type-of-triangle.cpp └── README.md ├── 3028-ant-on-the-boundary ├── 3028-ant-on-the-boundary.cpp └── README.md ├── 3033-modify-the-matrix ├── 3033-modify-the-matrix.cpp └── README.md ├── 3038-maximum-number-of-operations-with-the-same-score-i ├── 3038-maximum-number-of-operations-with-the-same-score-i.cpp └── README.md ├── 3042-count-prefix-and-suffix-pairs-i ├── 3042-count-prefix-and-suffix-pairs-i.py ├── 3042-count-prefix-and-suffix-pairs-i.rs └── README.md ├── 3043-find-the-length-of-the-longest-common-prefix ├── 3043-find-the-length-of-the-longest-common-prefix.py └── README.md ├── 3046-split-the-array ├── 3046-split-the-array.cpp └── README.md ├── 3056-determine-if-a-cell-is-reachable-at-a-given-time ├── 3056-determine-if-a-cell-is-reachable-at-a-given-time.cpp └── README.md ├── 3066-minimum-operations-to-exceed-threshold-value-ii ├── 3066-minimum-operations-to-exceed-threshold-value-ii.go └── README.md ├── 3068-find-the-maximum-sum-of-node-values ├── 3068-find-the-maximum-sum-of-node-values.cpp └── README.md ├── 3074-apple-redistribution-into-boxes ├── 3074-apple-redistribution-into-boxes.cpp └── README.md ├── 3075-maximize-happiness-of-selected-children ├── 3075-maximize-happiness-of-selected-children.cpp └── README.md ├── 3079-find-the-sum-of-encrypted-integers ├── 3079-find-the-sum-of-encrypted-integers.cpp └── README.md ├── 3083-existence-of-a-substring-in-a-string-and-its-reverse ├── 3083-existence-of-a-substring-in-a-string-and-its-reverse.cpp └── README.md ├── 3090-maximum-length-substring-with-two-occurrences ├── 3090-maximum-length-substring-with-two-occurrences.cpp └── README.md ├── 3097-shortest-subarray-with-or-at-least-k-ii ├── 3097-shortest-subarray-with-or-at-least-k-ii.py └── README.md ├── 3099-harshad-number ├── 3099-harshad-number.cpp └── README.md ├── 3100-water-bottles-ii ├── 3100-water-bottles-ii.cpp └── README.md ├── 3101-count-alternating-subarrays ├── 3101-count-alternating-subarrays.py └── README.md ├── 3105-longest-strictly-increasing-or-strictly-decreasing-subarray ├── 3105-longest-strictly-increasing-or-strictly-decreasing-subarray.cpp └── README.md ├── 3108-minimum-cost-walk-in-weighted-graph ├── 3108-minimum-cost-walk-in-weighted-graph.go └── README.md ├── 3110-score-of-a-string ├── 3110-score-of-a-string.cpp └── README.md ├── 3111-minimum-rectangles-to-cover-points ├── 3111-minimum-rectangles-to-cover-points.cpp └── README.md ├── 3115-maximum-prime-difference ├── 3115-maximum-prime-difference.py └── README.md ├── 3120-count-the-number-of-special-characters-i ├── 3120-count-the-number-of-special-characters-i.cpp └── README.md ├── 3131-find-the-integer-added-to-array-i ├── 3131-find-the-integer-added-to-array-i.cpp └── README.md ├── 3133-minimum-array-end ├── 3133-minimum-array-end.rs └── README.md ├── 3142-check-if-grid-satisfies-conditions ├── 3142-check-if-grid-satisfies-conditions.cpp └── README.md ├── 3146-permutation-difference-between-two-strings ├── 3146-permutation-difference-between-two-strings.cpp └── README.md ├── 3151-special-array-i ├── 3151-special-array-i.cpp ├── 3151-special-array-i.go └── README.md ├── 3152-special-array-ii ├── 3152-special-array-ii.py └── README.md ├── 3158-find-the-xor-of-numbers-which-appear-twice ├── 3158-find-the-xor-of-numbers-which-appear-twice.cpp └── README.md ├── 3159-find-occurrences-of-an-element-in-an-array ├── 3159-find-occurrences-of-an-element-in-an-array.cpp └── README.md ├── 3160-find-the-number-of-distinct-colors-among-the-balls ├── 3160-find-the-number-of-distinct-colors-among-the-balls.go └── README.md ├── 3162-find-the-number-of-good-pairs-i ├── 3162-find-the-number-of-good-pairs-i.cpp └── README.md ├── 3163-string-compression-iii ├── 3163-string-compression-iii.py └── README.md ├── 3168-minimum-number-of-chairs-in-a-waiting-room ├── 3168-minimum-number-of-chairs-in-a-waiting-room.cpp └── README.md ├── 3169-count-days-without-meetings ├── 3169-count-days-without-meetings.go └── README.md ├── 3174-clear-digits ├── 3174-clear-digits.cpp ├── 3174-clear-digits.go └── README.md ├── 3178-find-the-child-who-has-the-ball-after-k-seconds ├── 3178-find-the-child-who-has-the-ball-after-k-seconds.cpp └── README.md ├── 3179-find-the-n-th-value-after-k-seconds ├── 3179-find-the-n-th-value-after-k-seconds.py └── README.md ├── 3184-count-pairs-that-form-a-complete-day-i ├── 3184-count-pairs-that-form-a-complete-day-i.py └── README.md ├── 3185-count-pairs-that-form-a-complete-day-ii ├── 3185-count-pairs-that-form-a-complete-day-ii.py └── README.md ├── 3190-find-minimum-operations-to-make-all-elements-divisible-by-three ├── 3190-find-minimum-operations-to-make-all-elements-divisible-by-three.py └── README.md ├── 3191-minimum-operations-to-make-binary-array-elements-equal-to-one-i ├── 3191-minimum-operations-to-make-binary-array-elements-equal-to-one-i.go └── README.md ├── 3194-minimum-average-of-smallest-and-largest-elements ├── 3194-minimum-average-of-smallest-and-largest-elements.py └── README.md ├── 3203-find-minimum-diameter-after-merging-two-trees ├── 3203-find-minimum-diameter-after-merging-two-trees.py └── README.md ├── 3206-alternating-groups-i ├── 3206-alternating-groups-i.py └── README.md ├── 3208-alternating-groups-ii ├── 3208-alternating-groups-ii.go └── README.md ├── 3210-find-the-encrypted-string ├── 3210-find-the-encrypted-string.py └── README.md ├── 3211-generate-binary-strings-without-adjacent-zeros ├── 3211-generate-binary-strings-without-adjacent-zeros.rs └── README.md ├── 3217-delete-nodes-from-linked-list-present-in-array ├── 3217-delete-nodes-from-linked-list-present-in-array.py └── README.md ├── 3223-minimum-length-of-string-after-operations ├── 3223-minimum-length-of-string-after-operations.go └── README.md ├── 3227-vowels-game-in-a-string ├── 3227-vowels-game-in-a-string.py └── README.md ├── 3228-maximum-number-of-operations-to-move-ones-to-the-end ├── 3228-maximum-number-of-operations-to-move-ones-to-the-end.py └── README.md ├── 3232-find-if-digit-game-can-be-won ├── 3232-find-if-digit-game-can-be-won.py └── README.md ├── 3243-shortest-distance-after-road-addition-queries-i ├── 3243-shortest-distance-after-road-addition-queries-i.py └── README.md ├── 3248-snake-in-matrix ├── 3248-snake-in-matrix.py └── README.md ├── 3249-count-the-number-of-good-nodes ├── 3249-count-the-number-of-good-nodes.py └── README.md ├── 3254-find-the-power-of-k-size-subarrays-i ├── 3254-find-the-power-of-k-size-subarrays-i.py └── README.md ├── 3255-find-the-power-of-k-size-subarrays-ii ├── 3255-find-the-power-of-k-size-subarrays-ii.py └── README.md ├── 3258-count-substrings-that-satisfy-k-constraint-i ├── 3258-count-substrings-that-satisfy-k-constraint-i.py └── README.md ├── 3264-final-array-state-after-k-multiplication-operations-i ├── 3264-final-array-state-after-k-multiplication-operations-i.py └── README.md ├── 3270-find-the-key-of-the-numbers ├── 3270-find-the-key-of-the-numbers.rs └── README.md ├── 3271-hash-divided-string ├── 3271-hash-divided-string.py └── README.md ├── 3274-check-if-two-chessboard-squares-have-the-same-color ├── 3274-check-if-two-chessboard-squares-have-the-same-color.py └── README.md ├── 3280-convert-date-to-binary ├── 3280-convert-date-to-binary.py └── README.md ├── 3282-reach-end-of-array-with-max-score ├── 3282-reach-end-of-array-with-max-score.py └── README.md ├── 3285-find-indices-of-stable-mountains ├── 3285-find-indices-of-stable-mountains.py └── README.md ├── 3289-the-two-sneaky-numbers-of-digitville ├── 3289-the-two-sneaky-numbers-of-digitville.py └── README.md ├── 3300-minimum-element-after-replacement-with-digit-sum ├── 3300-minimum-element-after-replacement-with-digit-sum.py └── README.md ├── 3304-find-the-k-th-character-in-string-game-i ├── 3304-find-the-k-th-character-in-string-game-i.py └── README.md ├── 3305-count-of-substrings-containing-every-vowel-and-k-consonants-i ├── 3305-count-of-substrings-containing-every-vowel-and-k-consonants-i.py └── README.md ├── 3306-count-of-substrings-containing-every-vowel-and-k-consonants-ii ├── 3306-count-of-substrings-containing-every-vowel-and-k-consonants-ii.go └── README.md ├── 3309-maximum-possible-number-by-binary-concatenation ├── 3309-maximum-possible-number-by-binary-concatenation.py └── README.md ├── 3310-remove-methods-from-project ├── 3310-remove-methods-from-project.py └── README.md ├── 3314-construct-the-minimum-bitwise-array-i ├── 3314-construct-the-minimum-bitwise-array-i.py └── README.md ├── 3324-find-the-sequence-of-strings-appeared-on-the-screen ├── 3324-find-the-sequence-of-strings-appeared-on-the-screen.py └── README.md ├── 3330-find-the-original-typed-string-i ├── 3330-find-the-original-typed-string-i.py └── README.md ├── 3335-total-characters-in-string-after-transformations-i ├── 3335-total-characters-in-string-after-transformations-i.py └── README.md ├── 3340-check-balanced-string ├── 3340-check-balanced-string.py └── README.md ├── 3341-find-minimum-time-to-reach-last-room-i ├── 3341-find-minimum-time-to-reach-last-room-i.py └── README.md ├── 3355-zero-array-transformation-i ├── 3355-zero-array-transformation-i.py └── README.md ├── 3356-zero-array-transformation-ii ├── 3356-zero-array-transformation-ii.go └── README.md ├── 3360-stone-removal-game ├── 3360-stone-removal-game.py └── README.md ├── 3370-smallest-number-with-all-set-bits ├── 3370-smallest-number-with-all-set-bits.py └── README.md ├── 3375-minimum-operations-to-make-array-values-equal-to-k ├── 3375-minimum-operations-to-make-array-values-equal-to-k.go └── README.md ├── 3380-maximum-area-rectangle-with-point-constraints-i ├── 3380-maximum-area-rectangle-with-point-constraints-i.py └── README.md ├── 3392-count-subarrays-of-length-three-with-a-condition ├── 3392-count-subarrays-of-length-three-with-a-condition.go ├── 3392-count-subarrays-of-length-three-with-a-condition.py └── README.md ├── 3394-check-if-grid-can-be-cut-into-sections ├── 3394-check-if-grid-can-be-cut-into-sections.go └── README.md ├── 3396-minimum-number-of-operations-to-make-elements-in-array-distinct ├── 3396-minimum-number-of-operations-to-make-elements-in-array-distinct.go └── README.md ├── 3403-find-the-lexicographically-largest-string-from-the-box-i ├── 3403-find-the-lexicographically-largest-string-from-the-box-i.py └── README.md ├── 3411-maximum-subarray-with-equal-products ├── 3411-maximum-subarray-with-equal-products.go └── README.md └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: m3hu1 4 | -------------------------------------------------------------------------------- /0001-two-sum/0001-two-sum.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | vector twoSum(vector& nums, int target) { 5 | map mpp; 6 | vector ans; 7 | int n=nums.size(); 8 | for (int i=0;i List[int]: 3 | mp = defaultdict(int) 4 | for idx, num in enumerate(nums): 5 | req = target - num 6 | if req in mp: 7 | return [idx, mp[req]] 8 | mp[num] = idx 9 | return [-1, -1] -------------------------------------------------------------------------------- /0007-reverse-integer/0007-reverse-integer.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int reverse(int x) { 4 | long long ans = 0; 5 | while (x) { 6 | int digit = x % 10; 7 | ans = ans * 10 + digit; 8 | x = x / 10; 9 | } 10 | if (ans > INT_MAX || ans < INT_MIN) return 0; 11 | return (int) ans; 12 | } 13 | }; -------------------------------------------------------------------------------- /0009-palindrome-number/0009-palindrome-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isPalindrome(int x) { 4 | if (x < 0 || (x % 10 == 0 && x != 0)) return false; 5 | long long rev = 0; 6 | int copy = x; 7 | while (x) { 8 | int digit = x % 10; 9 | rev = rev * 10 + digit; 10 | x = x / 10; 11 | } 12 | return (int) rev == copy; 13 | } 14 | }; -------------------------------------------------------------------------------- /0011-container-with-most-water/0011-container-with-most-water.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxArea(vector& height) { 4 | int ans = 0; 5 | int l = 0; 6 | int r = height.size() - 1; 7 | 8 | while (l < r) { 9 | const int minHeight = min(height[l], height[r]); 10 | ans = max(ans, minHeight * (r - l)); 11 | if (height[l] <= height[r]) 12 | ++l; 13 | else 14 | --r; 15 | } 16 | 17 | return ans; 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /0011-container-with-most-water/0011-container-with-most-water.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxArea(self, h: List[int]) -> int: 3 | max_area = 0 4 | l = 0 5 | r = len(h) - 1 6 | 7 | while l < r: 8 | min_height = min(h[l], h[r]) 9 | area = min_height * (r - l) 10 | max_area = max(max_area, area) 11 | if h[l] < h[r]: 12 | l += 1 13 | else: 14 | r -= 1 15 | 16 | return max_area -------------------------------------------------------------------------------- /0026-remove-duplicates-from-sorted-array/0026-remove-duplicates-from-sorted-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int removeDuplicates(vector& nums) { 4 | int i = 0; 5 | for(int j=1;j& nums, int val) { 4 | int i = 0; 5 | 6 | for (const int num : nums) 7 | if (num != val) 8 | nums[i++] = num; 9 | 10 | return i; 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /0028-find-the-index-of-the-first-occurrence-in-a-string/0028-find-the-index-of-the-first-occurrence-in-a-string.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int strStr(string haystack, string needle) { 4 | const int m = haystack.length(); 5 | const int n = needle.length(); 6 | 7 | for (int i = 0; i < m - n + 1; i++) 8 | if (haystack.substr(i, n) == needle) 9 | return i; 10 | 11 | return -1; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /0048-rotate-image/0048-rotate-image.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | void rotate(vector>& matrix) { 5 | reverse(matrix.begin(), matrix.end()); 6 | for (int i = 0; i < matrix.size(); ++i) 7 | for (int j = i + 1; j < matrix.size(); ++j) 8 | swap(matrix[i][j], matrix[j][i]); 9 | } 10 | }; -------------------------------------------------------------------------------- /0049-group-anagrams/0049-group-anagrams.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def groupAnagrams(self, strs: List[str]) -> List[List[str]]: 3 | mp = defaultdict(list) 4 | ans = [] 5 | for s in strs: 6 | sorted_s = str(sorted(s)) 7 | mp[sorted_s].append(s) 8 | for i in mp.values(): 9 | ans.append(i) 10 | return ans -------------------------------------------------------------------------------- /0050-powx-n/0050-powx-n.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | double myPow(double x, long n) { 4 | if (n == 0) 5 | return 1; 6 | if (n < 0) 7 | return 1 / myPow(x, -n); 8 | if (n & 1) 9 | return x * myPow(x, n - 1); 10 | return myPow(x * x, n / 2); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /0052-n-queens-ii/0052-n-queens-ii.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def totalNQueens(self, n: int) -> int: 3 | if n == 1: 4 | return 1 5 | if n == 2 or n == 3: 6 | return 0 7 | if n == 4: 8 | return 2 9 | if n == 5: 10 | return 10 11 | if n == 6: 12 | return 4 13 | if n == 7: 14 | return 40 15 | if n == 8: 16 | return 92 17 | if n == 9: 18 | return 352 -------------------------------------------------------------------------------- /0053-maximum-subarray/0053-maximum-subarray.go: -------------------------------------------------------------------------------- 1 | func max(a, b int) int { 2 | if a > b { 3 | return a 4 | } 5 | return b 6 | } 7 | 8 | func maxSubArray(nums []int) int { 9 | sum := 0 10 | res := nums[0] 11 | 12 | for i := range nums { 13 | sum += nums[i] 14 | res = max(res, sum) 15 | if sum < 0 { 16 | sum = 0 17 | } 18 | } 19 | 20 | return res 21 | } -------------------------------------------------------------------------------- /0055-jump-game/0055-jump-game.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool canJump(vector& nums) { 4 | int i = 0; 5 | 6 | for (int reach = 0; i < nums.size() && i <= reach; ++i) 7 | reach = max(reach, i + nums[i]); 8 | 9 | return i == nums.size(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /0056-merge-intervals/0056-merge-intervals.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector> merge(vector>& intervals) { 4 | vector> ans; 5 | 6 | sort(intervals.begin(), intervals.end()); 7 | 8 | for (const vector& interval : intervals) 9 | if (ans.empty() || ans.back()[1] < interval[0]) 10 | ans.push_back(interval); 11 | else 12 | ans.back()[1] = max(ans.back()[1], interval[1]); 13 | 14 | return ans; 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /0058-length-of-last-word/0058-length-of-last-word.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int lengthOfLastWord(string s) { 4 | int ans = 0; 5 | int right = s.size() - 1; 6 | while(right >= 0) { 7 | if(s[right] != ' ') { 8 | ans++; 9 | } else if(ans > 0) return ans; 10 | right--; 11 | } 12 | return ans; 13 | } 14 | }; -------------------------------------------------------------------------------- /0060-permutation-sequence/0060-permutation-sequence.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | string getPermutation(int n, int k) { 5 | string check=""; 6 | char c='1';k--; 7 | for(int i=0;i> dp(m, vector(n, 1)); 5 | for (int i = 1; i < m; ++i) 6 | for (int j = 1; j < n; ++j) 7 | dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; 8 | 9 | return dp[m - 1][n - 1]; 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /0066-plus-one/0066-plus-one.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector plusOne(vector& digits) { 4 | for (int i = digits.size() - 1; i >= 0; --i) { 5 | if (digits[i] < 9) { 6 | ++digits[i]; 7 | return digits; 8 | } 9 | digits[i] = 0; 10 | } 11 | 12 | digits.insert(digits.begin(), 1); 13 | return digits; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /0069-sqrtx/0069-sqrtx.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int mySqrt(int x) { 4 | unsigned l = 1; 5 | unsigned r = x + 1u; 6 | while (l < r) { 7 | const unsigned m = (l + r) / 2; 8 | if (m > x / m) 9 | r = m; 10 | else 11 | l = m + 1; 12 | } 13 | return l - 1; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /0070-climbing-stairs/0070-climbing-stairs.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int climbStairs(int n) { 4 | vector dp(n + 1); 5 | dp[0] = 1; 6 | dp[1] = 1; 7 | for (int i = 2; i <= n; ++i) 8 | dp[i] = dp[i - 1] + dp[i - 2]; 9 | return dp[n]; 10 | } 11 | }; -------------------------------------------------------------------------------- /0073-set-matrix-zeroes/0073-set-matrix-zeroes.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def setZeroes(self, g: List[List[int]]) -> None: 3 | m, n = len(g), len(g[0]) 4 | z = [] 5 | 6 | for i in range(len(g)): 7 | for j in range(len(g[0])): 8 | if g[i][j] == 0: 9 | z.append((i,j)) 10 | 11 | for row, col in z: 12 | for i in range(0, n): 13 | g[row][i] = 0 14 | for j in range(0, m): 15 | g[j][col] = 0 -------------------------------------------------------------------------------- /0075-sort-colors/0075-sort-colors.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | void sortColors(vector& nums) { 4 | int zero = -1; 5 | int one = -1; 6 | int two = -1; 7 | 8 | for (const int num : nums) 9 | if (num == 0) { 10 | nums[++two] = 2; 11 | nums[++one] = 1; 12 | nums[++zero] = 0; 13 | } else if (num == 1) { 14 | nums[++two] = 2; 15 | nums[++one] = 1; 16 | } else { 17 | nums[++two] = 2; 18 | } 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /0080-remove-duplicates-from-sorted-array-ii/0080-remove-duplicates-from-sorted-array-ii.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int removeDuplicates(vector& nums) { 4 | int i = 0; 5 | 6 | for (const int num : nums) 7 | if (i < 2 || num > nums[i - 2]) 8 | nums[i++] = num; 9 | 10 | return i; 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /0088-merge-sorted-array/0088-merge-sorted-array.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | void merge(vector& nums1, int m, vector& nums2, int n) { 5 | int i = 0; 6 | while (i < n) { 7 | nums1.pop_back(); 8 | i++; 9 | } 10 | copy(nums2.begin(), nums2.end(), inserter(nums1, nums1.begin())); 11 | sort(nums1.begin(),nums1.end()); 12 | } 13 | }; -------------------------------------------------------------------------------- /0091-decode-ways/0091-decode-ways.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int numDecodings(string s) { 4 | int m=s.size(); 5 | vectordp(m+1, 0); 6 | dp[m] = 1; 7 | for (int i=m-1;i>=0;--i) 8 | if (s[i]!='0') { 9 | dp[i]=dp[i+1]; 10 | if (i+1val == q->val && // 7 | isSameTree(p->left, q->left) && // 8 | isSameTree(p->right, q->right); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /0101-symmetric-tree/0101-symmetric-tree.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isSymmetric(TreeNode* root) { 4 | return isSymmetric(root, root); 5 | } 6 | 7 | private: 8 | bool isSymmetric(TreeNode* p, TreeNode* q) { 9 | if (!p || !q) 10 | return p == q; 11 | 12 | return p->val == q->val && // 13 | isSymmetric(p->left, q->right) && // 14 | isSymmetric(p->right, q->left); 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /0104-maximum-depth-of-binary-tree/0104-maximum-depth-of-binary-tree.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxDepth(TreeNode* root) { 4 | if (root == nullptr) 5 | return 0; 6 | return 1 + max(maxDepth(root->left), maxDepth(root->right)); 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /0104-maximum-depth-of-binary-tree/0104-maximum-depth-of-binary-tree.py: -------------------------------------------------------------------------------- 1 | # Definition for a binary tree node. 2 | # class TreeNode: 3 | # def __init__(self, val=0, left=None, right=None): 4 | # self.val = val 5 | # self.left = left 6 | # self.right = right 7 | class Solution: 8 | def maxDepth(self, root: Optional[TreeNode]) -> int: 9 | if not root: 10 | return 0 11 | return 1 + max(self.maxDepth(root.left), self.maxDepth(root.right)) -------------------------------------------------------------------------------- /0108-convert-sorted-array-to-binary-search-tree/0108-convert-sorted-array-to-binary-search-tree.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | TreeNode* sortedArrayToBST(vector& nums) { 4 | return build(nums, 0, nums.size() - 1); 5 | } 6 | 7 | private: 8 | TreeNode* build(const vector& nums, int l, int r) { 9 | if (l > r) 10 | return nullptr; 11 | const int m = (l + r) / 2; 12 | return new TreeNode(nums[m], build(nums, l, m - 1), build(nums, m + 1, r)); 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /0112-path-sum/0112-path-sum.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool hasPathSum(TreeNode* root, int sum) { 4 | if (root == nullptr) 5 | return false; 6 | if (root->val == sum && root->left == nullptr && root->right == nullptr) 7 | return true; 8 | return hasPathSum(root->left, sum - root->val) || 9 | hasPathSum(root->right, sum - root->val); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /0118-pascals-triangle/0118-pascals-triangle.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector> generate(int numRows) { 4 | vector> ans; 5 | 6 | for (int i = 0; i < numRows; ++i) 7 | ans.push_back(vector(i + 1, 1)); 8 | 9 | for (int i = 2; i < numRows; ++i) 10 | for (int j = 1; j < ans[i].size() - 1; ++j) 11 | ans[i][j] = ans[i - 1][j - 1] + ans[i - 1][j]; 12 | 13 | return ans; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /0121-best-time-to-buy-and-sell-stock/0121-best-time-to-buy-and-sell-stock.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def maxProfit(self, prices): 3 | l,r=0,1;maxP=0 4 | while r bool: 3 | l = 0 4 | r = len(s) - 1 5 | 6 | while l < r: 7 | if not s[l].isalnum(): 8 | l += 1 9 | elif not s[r].isalnum(): 10 | r -= 1 11 | elif s[l].lower() != s[r].lower(): 12 | return False 13 | else: 14 | l += 1 15 | r -= 1 16 | 17 | return True -------------------------------------------------------------------------------- /0128-longest-consecutive-sequence/0128-longest-consecutive-sequence.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def longestConsecutive(self, nums: List[int]) -> int: 3 | ans = 0 4 | hashset = set(nums) 5 | 6 | for num in hashset: 7 | if num - 1 not in hashset: 8 | curr_length = 1 9 | while num + 1 in hashset: 10 | curr_length += 1 11 | num += 1 12 | ans = max(ans, curr_length) 13 | 14 | return ans -------------------------------------------------------------------------------- /0136-single-number/0136-single-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int singleNumber(vector& nums) { 4 | int x = 0; 5 | for(int i=0;i& nums) { 5 | map visited; 6 | for(int i = 0 ; i < nums.size() ; i++) 7 | { 8 | visited[nums[i]]++; 9 | } 10 | for(int i = 0 ; i < nums.size() ; i++) 11 | { 12 | if(visited[nums[i]] == 1) 13 | return nums[i]; 14 | } 15 | return 0; 16 | 17 | } 18 | }; -------------------------------------------------------------------------------- /0141-linked-list-cycle/0141-linked-list-cycle.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool hasCycle(ListNode* head) { 4 | ListNode* slow = head; 5 | ListNode* fast = head; 6 | 7 | while (fast && fast->next) { 8 | slow = slow->next; 9 | fast = fast->next->next; 10 | if (slow == fast) 11 | return true; 12 | } 13 | 14 | return false; 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /0145-binary-tree-postorder-traversal/0145-binary-tree-postorder-traversal.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | vectorans; 5 | vector postorderTraversal(TreeNode* root) { 6 | if(root == NULL) return ans; 7 | postorderTraversal(root->left); 8 | postorderTraversal(root->right); 9 | ans.push_back(root->val); 10 | return ans; 11 | } 12 | }; -------------------------------------------------------------------------------- /0151-reverse-words-in-a-string/0151-reverse-words-in-a-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def reverseWords(self, s: str) -> str: 3 | return ' '.join(s.split()[::-1]) -------------------------------------------------------------------------------- /0154-find-minimum-in-rotated-sorted-array-ii/0154-find-minimum-in-rotated-sorted-array-ii.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findMin(vector& nums) { 4 | int low = 0; 5 | int high = nums.size() - 1; 6 | while (low < high) { 7 | int mid = (low + high) / 2; 8 | if (nums[mid] > nums[high]) low = mid + 1; 9 | else if (nums[mid] < nums[low]) high = mid; 10 | else high--; 11 | } 12 | return nums[low]; 13 | } 14 | }; -------------------------------------------------------------------------------- /0164-maximum-gap/0164-maximum-gap.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maximumGap(self, nums: List[int]) -> int: 3 | if len(nums) < 2: 4 | return 0 5 | 6 | nums.sort() 7 | maxi = -math.inf 8 | 9 | for i in range(1, len(nums)): 10 | diff = nums[i] - nums[i - 1] 11 | maxi = max(maxi, diff) 12 | 13 | return maxi -------------------------------------------------------------------------------- /0168-excel-sheet-column-title/0168-excel-sheet-column-title.py: -------------------------------------------------------------------------------- 1 | # m3hu1 2 | class Solution: 3 | def convertToTitle(self, columnNumber: int) -> str: 4 | ab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 5 | r = '' 6 | while columnNumber > 0: 7 | columnNumber -= 1 8 | r = ab[(columnNumber) % 26] + r 9 | columnNumber //= 26 10 | return r -------------------------------------------------------------------------------- /0169-majority-element/0169-majority-element.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int majorityElement(vector& nums) { 4 | map mp; 5 | for(int i=0;i (nums.size()/2)) { 10 | return i.first; 11 | } 12 | } 13 | return -1; 14 | } 15 | }; -------------------------------------------------------------------------------- /0171-excel-sheet-column-number/0171-excel-sheet-column-number.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | int titleToNumber(string columnTitle) { 5 | int res = 0; 6 | const size_t n = columnTitle.size(); 7 | for(size_t i = 0; i < n; ++i) 8 | res += (columnTitle[i] - 'A' + 1) * pow(26, n - i - 1); 9 | return res; 10 | } 11 | }; -------------------------------------------------------------------------------- /0172-factorial-trailing-zeroes/0172-factorial-trailing-zeroes.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | int trailingZeroes(int n) { 5 | int count = 0; 6 | while (n >= 5) { 7 | n = n / 5; 8 | count += n; 9 | } 10 | return count; 11 | } 12 | }; -------------------------------------------------------------------------------- /0179-largest-number/0179-largest-number.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def largestNumber(self, nums: List[int]) -> str: 3 | for idx, num in enumerate(nums): 4 | nums[idx] = str(num) 5 | 6 | nums.sort(key = lambda x: x * 10, reverse = True) 7 | 8 | if nums[0] == '0': 9 | return "0" 10 | 11 | return "".join(nums) -------------------------------------------------------------------------------- /0190-reverse-bits/0190-reverse-bits.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | uint32_t reverseBits(uint32_t n) { 5 | uint32_t ret = 0; 6 | int i = 0; 7 | while(i <= 31){ 8 | int b = n & 1; 9 | n = n >> 1; 10 | ret = ret << 1; 11 | ret = ret | b; 12 | i++; 13 | } 14 | return ret; 15 | } 16 | }; -------------------------------------------------------------------------------- /0191-number-of-1-bits/0191-number-of-1-bits.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | int hammingWeight(uint32_t n) { 5 | int count =0; 6 | for(int i=0;i<32;i++){ 7 | if((n&(1<> 1; 7 | right = right >> 1; 8 | cnt++; 9 | } 10 | return right << cnt; 11 | } 12 | }; -------------------------------------------------------------------------------- /0206-reverse-linked-list/0206-reverse-linked-list.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]: 3 | prev = None 4 | curr = head 5 | holder = curr 6 | 7 | while curr: 8 | holder = curr.next 9 | curr.next = prev 10 | prev = curr 11 | curr = holder 12 | 13 | return prev -------------------------------------------------------------------------------- /0214-shortest-palindrome/0214-shortest-palindrome.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def shortestPalindrome(self, s: str) -> str: 3 | rev = s[ :: -1] 4 | 5 | for i in range(len(s)): 6 | if s[ : len(s) - i] == rev[i : ]: 7 | return rev[ : i] + s 8 | 9 | return "" -------------------------------------------------------------------------------- /0215-kth-largest-element-in-an-array/0215-kth-largest-element-in-an-array.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | int findKthLargest(vector& nums, int k) { 5 | sort(nums.begin(), nums.end()); 6 | return nums[nums.size()-1 -k+1]; 7 | } 8 | }; -------------------------------------------------------------------------------- /0215-kth-largest-element-in-an-array/0215-kth-largest-element-in-an-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findKthLargest(self, nums: List[int], k: int) -> int: 3 | heap = [] 4 | 5 | def push(heap, num): 6 | heapq.heappush(heap, num) 7 | 8 | def pop(): 9 | return heapq.heappop(heap) 10 | 11 | for num in nums: 12 | push(heap, num) 13 | while len(heap) > k: 14 | pop() 15 | return pop() -------------------------------------------------------------------------------- /0217-contains-duplicate/0217-contains-duplicate.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool containsDuplicate(vector& nums) { 4 | unordered_map mp; 5 | for(auto i : nums) { 6 | mp[i]++; 7 | } 8 | for(auto i : mp) { 9 | if(i.second > 1) return true; 10 | } 11 | return false; 12 | } 13 | }; -------------------------------------------------------------------------------- /0217-contains-duplicate/0217-contains-duplicate.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def containsDuplicate(self, nums: List[int]) -> bool: 3 | found = set() 4 | for num in nums: 5 | if num in found: 6 | return True 7 | else: 8 | found.add(num) 9 | return False -------------------------------------------------------------------------------- /0219-contains-duplicate-ii/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /0222-count-complete-tree-nodes/0222-count-complete-tree-nodes.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | int countNodes(TreeNode* root) { 5 | if(root==NULL) 6 | return 0; 7 | 8 | return countNodes(root->left)+countNodes(root->right)+1; 9 | } 10 | }; -------------------------------------------------------------------------------- /0231-power-of-two/0231-power-of-two.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isPowerOfTwo(int n) { 4 | return n > 0 && (n & (n - 1)) == 0; 5 | } 6 | }; -------------------------------------------------------------------------------- /0238-product-of-array-except-self/0238-product-of-array-except-self.go: -------------------------------------------------------------------------------- 1 | func productExceptSelf(nums []int) []int { 2 | px := 1 3 | sx := 1 4 | ans := make([]int, len(nums)) 5 | 6 | for i := range nums { 7 | ans[i] = px 8 | px *= nums[i] 9 | } 10 | 11 | for i := len(nums) - 1; i >= 0; i-- { 12 | ans[i] *= sx 13 | sx *= nums[i] 14 | } 15 | 16 | return ans 17 | } -------------------------------------------------------------------------------- /0242-valid-anagram/0242-valid-anagram.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {string} s 3 | * @param {string} t 4 | * @return {boolean} 5 | */ 6 | var isAnagram = function(s, t) { 7 | return s.split("").sort().join("") === t.split("").sort().join("") 8 | }; -------------------------------------------------------------------------------- /0242-valid-anagram/0242-valid-anagram.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isAnagram(self, s: str, t: str) -> bool: 3 | if len(s) != len(t): 4 | return False 5 | mp1 = Counter(s) 6 | mp2 = Counter(t) 7 | return mp1 == mp2 -------------------------------------------------------------------------------- /0260-single-number-iii/0260-single-number-iii.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector singleNumber(vector& nums) { 4 | // not optimal -> come later for bit manipulation soln 5 | unordered_map mp; 6 | for (auto i : nums) mp[i]++; 7 | vector ans; 8 | for (auto i : mp) { 9 | if (i.second != 2) ans.push_back(i.first); 10 | } 11 | return ans; 12 | } 13 | }; -------------------------------------------------------------------------------- /0263-ugly-number/0263-ugly-number.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isUgly(self, n: int) -> bool: 3 | factors = [2, 3, 5] 4 | 5 | for num in factors: 6 | while n > 1 and n % num == 0: 7 | n = n // num 8 | 9 | if n == 1: 10 | return True 11 | 12 | return False -------------------------------------------------------------------------------- /0268-missing-number/0268-missing-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int missingNumber(vector& nums) { 4 | int n = nums.size(); 5 | int sum = (n * (n+1))/2; 6 | int sum2 = 0; 7 | for(int i=0;i& citations) { 5 | int sz=citations.size(); 6 | sort(citations.begin(), citations.end()); 7 | for (int i=0;i=sz-i) { 9 | return sz-i; 10 | } 11 | } 12 | return 0; 13 | } 14 | }; -------------------------------------------------------------------------------- /0287-find-the-duplicate-number/0287-find-the-duplicate-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findDuplicate(vector& nums) { 4 | vector ans(nums.size(), 0); 5 | for(auto i : nums) { 6 | if(ans[i] == 0) ans[i]++; 7 | else return i; 8 | } 9 | return -1; 10 | } 11 | }; -------------------------------------------------------------------------------- /0292-nim-game/0292-nim-game.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def canWinNim(self, n: int) -> bool: 3 | return n % 4 != 0 -------------------------------------------------------------------------------- /0303-range-sum-query-immutable/0303-range-sum-query-immutable.py: -------------------------------------------------------------------------------- 1 | class NumArray: 2 | 3 | def __init__(self, nums: List[int]): 4 | self.nums = nums 5 | 6 | def sumRange(self, left: int, right: int) -> int: 7 | SUM = 0 8 | 9 | for i in range(left, right + 1): 10 | SUM += self.nums[i] 11 | 12 | return SUM 13 | 14 | 15 | # Your NumArray object will be instantiated and called as such: 16 | # obj = NumArray(nums) 17 | # param_1 = obj.sumRange(left,right) -------------------------------------------------------------------------------- /0322-coin-change/0322-coin-change.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def coinChange(self, coins: List[int], amount: int) -> int: 3 | dp = [amount + 1 for _ in range(amount + 1)] 4 | dp[0] = 0 5 | 6 | for a in range(1, amount + 1): 7 | for c in coins: 8 | if a - c >= 0: 9 | dp[a] = min(dp[a], 1+ dp[a - c]) 10 | 11 | if dp[amount] != amount + 1: 12 | return dp[amount] 13 | 14 | return -1 -------------------------------------------------------------------------------- /0326-power-of-three/0326-power-of-three.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isPowerOfThree(int n) { 4 | if(n <= 0) return false; 5 | double logValue = log10(n) / log10(3); 6 | return logValue == (int)logValue; 7 | } 8 | }; -------------------------------------------------------------------------------- /0330-patching-array/0330-patching-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minPatches(self, nums: List[int], n: int) -> int: 3 | ans = 0 4 | i = 0 5 | j = 0 6 | 7 | while j < len(nums): 8 | if i < len(nums) and nums[i] <= j + 1: 9 | j += nums[i] 10 | i += 1 11 | else: 12 | ans += 1 13 | j = j + (j + 1) 14 | 15 | return ans -------------------------------------------------------------------------------- /0344-reverse-string/0344-reverse-string.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | void reverseString(vector& s) { 4 | int left = 0; 5 | int right = s.size() - 1; 6 | while(left < right) { 7 | swap(s[left], s[right]); 8 | left++, right--; 9 | } 10 | } 11 | }; -------------------------------------------------------------------------------- /0365-water-and-jug-problem/0365-water-and-jug-problem.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool canMeasureWater(int x, int y, int target) { 4 | if (x + y < target) return false; 5 | return target % __gcd(x, y) == 0; 6 | } 7 | }; -------------------------------------------------------------------------------- /0367-valid-perfect-square/0367-valid-perfect-square.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isPerfectSquare(self, num: int) -> bool: 3 | low = 1 4 | high = num 5 | 6 | while low <= high: 7 | mid = low + (high - low) // 2 8 | if mid * mid == num: 9 | return True 10 | elif mid * mid > num: 11 | high = mid - 1 12 | else: 13 | low = mid + 1 14 | 15 | return False -------------------------------------------------------------------------------- /0383-ransom-note/0383-ransom-note.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def canConstruct(self, rm: str, mag: str) -> bool: 3 | r = Counter(rm) 4 | m = Counter(mag) 5 | 6 | return r <= m -------------------------------------------------------------------------------- /0386-lexicographical-numbers/0386-lexicographical-numbers.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def dfs(self, c, n, x): 3 | if c > n: 4 | return 5 | else: 6 | x.append(c) 7 | for i in range(10): 8 | if 10 * c > n - i: return 9 | self.dfs(10 * c + i, n, x) 10 | 11 | def lexicalOrder(self, n): 12 | ans = [] 13 | for i in range(1, 10): 14 | self.dfs(i, n, ans) 15 | return ans 16 | -------------------------------------------------------------------------------- /0387-first-unique-character-in-a-string/0387-first-unique-character-in-a-string.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int firstUniqChar(string s) { 4 | int n = s.length(); 5 | unordered_map mp; 6 | for(auto it : s) { 7 | mp[it]++; 8 | } 9 | for(int i=0;i bool: 3 | if len(s) > len(t):return False 4 | if len(s) == 0:return True 5 | subsequence=0 6 | for i in range(0,len(t)): 7 | if subsequence <= len(s) -1: 8 | print(s[subsequence]) 9 | if s[subsequence]==t[i]: 10 | 11 | subsequence+=1 12 | return subsequence == len(s) -------------------------------------------------------------------------------- /0401-binary-watch/0401-binary-watch.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def readBinaryWatch(self, turnedOn: int) -> List[str]: 3 | ans = [] 4 | 5 | for hour in range(12): 6 | for minute in range(60): 7 | m, h = bin(minute), bin(hour) 8 | m1, h1 = m.count('1'), h.count('1') 9 | if m1 + h1 == turnedOn: 10 | ans.append(str(hour) + ':' + str(minute).zfill(2)) 11 | 12 | return ans -------------------------------------------------------------------------------- /0409-longest-palindrome/0409-longest-palindrome.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int longestPalindrome(string s) { 4 | unordered_set vis; 5 | int ans = 0; 6 | for (auto i : s) { 7 | if (vis.find(i) != vis.end()) { 8 | ans = ans + 2; 9 | vis.erase(i); 10 | } else vis.insert(i); 11 | } 12 | return !vis.empty() ? ans + 1 : ans; 13 | } 14 | }; -------------------------------------------------------------------------------- /0412-fizz-buzz/0412-fizz-buzz.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def fizzBuzz(self, n: int) -> List[str]: 3 | ans = [""] * n 4 | 5 | for i in range(1, n + 1): 6 | if i % 3 == 0 and i % 5 == 0: 7 | ans[i - 1] = "FizzBuzz" 8 | elif i % 3 == 0: 9 | ans[i - 1] = "Fizz" 10 | elif i % 5 == 0: 11 | ans[i - 1] = "Buzz" 12 | else: 13 | ans[i - 1] = str(i) 14 | 15 | return ans -------------------------------------------------------------------------------- /0441-arranging-coins/0441-arranging-coins.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def arrangeCoins(self, n: int) -> int: 3 | low = 1 4 | high = n 5 | 6 | while low <= high: 7 | mid = low + (high - low) // 2 8 | if n >= (mid * (mid + 1) / 2): 9 | low = mid + 1 10 | else: 11 | high = mid - 1 12 | 13 | return high -------------------------------------------------------------------------------- /0442-find-all-duplicates-in-an-array/0442-find-all-duplicates-in-an-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector findDuplicates(vector& nums) { 4 | vector ans; 5 | for (auto i : nums) { 6 | if (nums[abs(i) - 1] < 0) ans.push_back(abs(i)); 7 | nums[abs(i) - 1] = -1 * nums[abs(i) - 1]; 8 | } 9 | return ans; 10 | } 11 | }; -------------------------------------------------------------------------------- /0448-find-all-numbers-disappeared-in-an-array/0448-find-all-numbers-disappeared-in-an-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findDisappearedNumbers(self, nums: List[int]) -> List[int]: 3 | count = Counter(nums) 4 | ans = [] 5 | 6 | for i in range(1, len(nums) + 1): 7 | if i not in count: 8 | ans.append(i) 9 | 10 | return ans -------------------------------------------------------------------------------- /0453-minimum-moves-to-equal-array-elements/0453-minimum-moves-to-equal-array-elements.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minMoves(vector& nums) { 4 | int ans = 0; 5 | int smol = INT_MAX; 6 | for (int n : nums) smol = min(smol, n); 7 | for (int n : nums) ans += n - smol; 8 | return ans; 9 | } 10 | }; -------------------------------------------------------------------------------- /0461-hamming-distance/0461-hamming-distance.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def hammingDistance(self, x: int, y: int) -> int: 3 | XOR = x ^ y 4 | ans = 0 5 | 6 | while XOR: 7 | ans += XOR % 2 8 | XOR = XOR >> 1 9 | 10 | return ans -------------------------------------------------------------------------------- /0462-minimum-moves-to-equal-array-elements-ii/0462-minimum-moves-to-equal-array-elements-ii.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minMoves2(vector& nums) { 4 | sort(nums.begin(), nums.end()); 5 | int ans = 0; 6 | for (auto n : nums) ans += abs(n - nums[nums.size() / 2]); 7 | return ans; 8 | } 9 | }; -------------------------------------------------------------------------------- /0476-number-complement/0476-number-complement.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findComplement(self, num: int) -> int: 3 | copy = num 4 | temp = 1 5 | 6 | while copy: 7 | num = num ^ temp 8 | temp = temp << 1 9 | copy = copy >> 1 10 | 11 | return num -------------------------------------------------------------------------------- /0485-max-consecutive-ones/0485-max-consecutive-ones.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findMaxConsecutiveOnes(vector& nums) { 4 | int n = nums.size(); 5 | int cnt = 0; 6 | int max1 = 0; 7 | for(int i=0;i int: 3 | @cache 4 | def helper(a, b): 5 | if a > len(nums) - 1: 6 | return 0 7 | if a == len(nums) - 1: 8 | return int(b == nums[-1]) + int(b == -1 * nums[-1]) 9 | return helper(a + 1, b - nums[a]) + helper(a + 1, b + nums[a]) 10 | 11 | return helper(0, t) -------------------------------------------------------------------------------- /0503-next-greater-element-ii/0503-next-greater-element-ii.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def nextGreaterElements(self, nums: List[int]) -> List[int]: 3 | stack = [] 4 | ans = [-1 for i in nums] 5 | 6 | for _ in range(2): 7 | for idx, num in enumerate(nums): 8 | while stack and num > nums[stack[-1]]: 9 | ans[stack.pop()] = num 10 | stack.append(idx) 11 | 12 | return ans -------------------------------------------------------------------------------- /0507-perfect-number/0507-perfect-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool checkPerfectNumber(int num) { 4 | int temp = num; 5 | for (int i = 1; i <= num / 2; i++) { 6 | if (temp < 0) return false; 7 | else if (num % i == 0) temp = temp - i; 8 | } 9 | return temp == 0; 10 | } 11 | }; -------------------------------------------------------------------------------- /0509-fibonacci-number/0509-fibonacci-number.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | @cache 3 | def fib(self, n: int) -> int: 4 | if n == 0: 5 | return 0 6 | 7 | if n == 1 or n == 2: 8 | return 1 9 | 10 | return self.fib(n - 1) + self.fib(n - 2) -------------------------------------------------------------------------------- /0518-coin-change-ii/0518-coin-change-ii.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def change(self, amount: int, coins: List[int]) -> int: 3 | dp = [0] * (amount + 1) 4 | dp[0] = 1 5 | 6 | for c in coins: 7 | for i in range(c, amount + 1): 8 | dp[i] += dp[i - c] 9 | 10 | return dp[amount] -------------------------------------------------------------------------------- /0521-longest-uncommon-subsequence-i/0521-longest-uncommon-subsequence-i.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findLUSlength(self, a: str, b: str) -> int: 3 | if a == b: 4 | return -1 5 | 6 | n1, n2 = len(a), len(b) 7 | 8 | if n1 > n2: 9 | return n1 10 | 11 | return n2 -------------------------------------------------------------------------------- /0523-continuous-subarray-sum/0523-continuous-subarray-sum.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool checkSubarraySum(vector& nums, int k) { 4 | unordered_map mp; 5 | int ps = 0; 6 | mp[0] = -1; 7 | for (int i = 0; i < nums.size(); i++) { 8 | ps += nums[i]; 9 | if (mp.find(ps % k) == mp.end()) mp[ps % k] = i; 10 | else if (1 < i - mp[ps % k]) return true; 11 | } 12 | return false; 13 | } 14 | }; -------------------------------------------------------------------------------- /0535-encode-and-decode-tinyurl/0535-encode-and-decode-tinyurl.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | // Encodes a URL to a shortened URL. 5 | string encode(string longUrl) { 6 | return longUrl; 7 | } 8 | 9 | // Decodes a shortened URL to its original URL. 10 | string decode(string shortUrl) { 11 | return shortUrl; 12 | } 13 | }; 14 | 15 | // Your Solution object will be instantiated and called as such: 16 | // Solution solution; 17 | // solution.decode(solution.encode(url)); -------------------------------------------------------------------------------- /0594-longest-harmonious-subsequence/0594-longest-harmonious-subsequence.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findLHS(self, nums: List[int]) -> int: 3 | count = Counter(nums) 4 | max_len = 0 5 | 6 | for num in nums: 7 | curr_len = 0 8 | if num + 1 in count: 9 | curr_len = count[num + 1] + count[num] 10 | max_len = max(max_len, curr_len) 11 | 12 | return max_len -------------------------------------------------------------------------------- /0633-sum-of-square-numbers/0633-sum-of-square-numbers.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool judgeSquareSum(int c) { 4 | int low = 0; 5 | int high = sqrt(c); 6 | while (low <= high) { 7 | if ((long long)low * low + (long long)high * high == c) return true; 8 | if (((long long)low * low + (long long)high * high) > c) high--; 9 | else low++; 10 | } 11 | return false; 12 | } 13 | }; -------------------------------------------------------------------------------- /0657-robot-return-to-origin/0657-robot-return-to-origin.js: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | /** 3 | * @param {string} moves 4 | * @return {boolean} 5 | */ 6 | var judgeCircle = function(M) { 7 | return M.replaceAll('R').length == M.replaceAll('L').length && 8 | M.replaceAll('U').length == M.replaceAll('D').length 9 | }; -------------------------------------------------------------------------------- /0704-binary-search/0704-binary-search.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int search(vector& nums, int target) { 4 | int low = 0; 5 | int high = nums.size()-1; 6 | while(low<=high){ 7 | int mid = (low+high)/2; 8 | if(nums[mid]==target) return mid; 9 | else if(target > nums[mid]) low = mid+1; 10 | else high = mid-1; 11 | } 12 | return -1; 13 | } 14 | }; -------------------------------------------------------------------------------- /0704-binary-search/0704-binary-search.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def search(self, nums: List[int], target: int) -> int: 3 | low = 0 4 | high = len(nums) - 1 5 | 6 | while low <= high: 7 | mid = low + (high - low) // 2 8 | if nums[mid] == target: 9 | return mid 10 | elif nums[mid] < target: 11 | low = mid + 1 12 | else: 13 | high = mid - 1 14 | 15 | return -1 -------------------------------------------------------------------------------- /0739-daily-temperatures/0739-daily-temperatures.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def dailyTemperatures(self, t: List[int]) -> List[int]: 3 | ans = [0 for _ in t] 4 | stack = [] # [ [temp, idx] entries ] 5 | 6 | for idx, temp in enumerate(t): 7 | while stack and temp > stack[-1][0]: 8 | curr_temp, curr_idx = stack.pop() 9 | ans[curr_idx] = idx - curr_idx 10 | stack.append([temp, idx]) 11 | 12 | return ans -------------------------------------------------------------------------------- /0742-to-lower-case/0742-to-lower-case.js: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | /** 3 | * @param {string} s 4 | * @return {string} 5 | */ 6 | var toLowerCase = function(s) { 7 | return s.toLowerCase(); 8 | }; -------------------------------------------------------------------------------- /0748-shortest-completing-word/0748-shortest-completing-word.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def shortestCompletingWord(self, lp: str, words: List[str]) -> str: 3 | lic = Counter([i for i in lp.lower() if i.isalpha()]) 4 | ans = [] 5 | 6 | for word in words: 7 | curr = Counter(word) 8 | if len(curr) < len(lic): 9 | continue 10 | if not lic - curr: 11 | ans.append(word) 12 | 13 | return min(ans, key = len) -------------------------------------------------------------------------------- /0763-partition-labels/0763-partition-labels.go: -------------------------------------------------------------------------------- 1 | func partitionLabels(s string) []int { 2 | l := make([]int, 26) 3 | for i, ch := range s { 4 | l[ch-'a'] = i 5 | } 6 | 7 | var ans []int 8 | st, e := 0, 0 9 | 10 | for i, ch := range s { 11 | if l[ch-'a'] > e { 12 | e = l[ch-'a'] 13 | } 14 | if i == e { 15 | ans = append(ans, e-st+1) 16 | st = e + 1 17 | } 18 | } 19 | 20 | return ans 21 | } -------------------------------------------------------------------------------- /0769-max-chunks-to-make-sorted/0769-max-chunks-to-make-sorted.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxChunksToSorted(self, arr: List[int]) -> int: 3 | ans = SUM = pSUM = 0 4 | 5 | for i in range(len(arr)): 6 | pSUM += arr[i] 7 | SUM += i 8 | if pSUM == SUM: 9 | ans += 1 10 | 11 | return ans -------------------------------------------------------------------------------- /0771-jewels-and-stones/0771-jewels-and-stones.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int numJewelsInStones(string jewels, string stones) { 4 | unordered_set st; 5 | int cnt = 0; 6 | for (auto j : jewels) st.insert(j); 7 | for (auto s : stones) { 8 | if (st.find(s) != st.end()) cnt++; 9 | } 10 | return cnt; 11 | } 12 | }; -------------------------------------------------------------------------------- /0781-rabbits-in-forest/0781-rabbits-in-forest.go: -------------------------------------------------------------------------------- 1 | func numRabbits(answers []int) int { 2 | mp := map[int]int{} 3 | for _, ans := range answers { 4 | mp[ans]++ 5 | } 6 | 7 | ans := 0 8 | 9 | for k, cnt := range mp { 10 | r := cnt / (k + 1) 11 | ans += r * (k + 1) 12 | 13 | if 0 != cnt%(k+1) { 14 | ans += (k + 1) 15 | } 16 | } 17 | 18 | return ans 19 | } -------------------------------------------------------------------------------- /0790-domino-and-tromino-tiling/0790-domino-and-tromino-tiling.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def numTilings(self, n: int) -> int: 3 | MOD = 10**9 + 7 4 | arr = [1, 2, 5] 5 | 6 | if n <= 3: 7 | return arr[n-1] 8 | 9 | for i in range(4, n + 1): 10 | ans = arr[-1] * 2 + arr[0] 11 | arr.pop(0) 12 | arr.append(ans) 13 | 14 | return arr[-1] % MOD -------------------------------------------------------------------------------- /0796-rotate-string/0796-rotate-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def rotateString(self, s: str, goal: str) -> bool: 3 | if len(goal) != len(s): 4 | return False 5 | 6 | copy = s * 2 7 | 8 | if goal in copy: 9 | return True 10 | 11 | return False -------------------------------------------------------------------------------- /0806-domino-and-tromino-tiling/0806-domino-and-tromino-tiling.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | const int mod = 1e9+7; 5 | int numTilings(int n) { 6 | if(n==0)return 1; 7 | if(n==1)return 1; 8 | if(n==2)return 2; 9 | vectordp(n+1,0); 10 | dp[0]=1; 11 | dp[1]=1; 12 | dp[2]=2; 13 | for(int i=3;i<=n;i++){ 14 | dp[i]=(2*dp[i-1]+dp[i-3])%mod; 15 | } 16 | return dp[n]%mod; 17 | } 18 | }; -------------------------------------------------------------------------------- /0807-max-increase-to-keep-city-skyline/0807-max-increase-to-keep-city-skyline.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int: 3 | ans = 0 4 | rmax = [max(row) for row in grid] 5 | cmax = [max(col) for col in zip(*grid)] 6 | 7 | for i in range(len(grid)): 8 | for j in range(len(grid)): 9 | ans += min(rmax[i], cmax[j]) - grid[i][j] 10 | 11 | return ans -------------------------------------------------------------------------------- /0853-car-fleet/0853-car-fleet.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def carFleet(self, target: int, position: List[int], speed: List[int]) -> int: 3 | stack = [] 4 | 5 | for pos, speed in sorted(zip(position, speed), reverse = True): 6 | eta = (target - pos) / speed 7 | if not stack or eta > stack[-1]: 8 | stack.append(eta) 9 | 10 | return len(stack) -------------------------------------------------------------------------------- /0877-stone-game/0877-stone-game.rs: -------------------------------------------------------------------------------- 1 | impl Solution { 2 | pub fn stone_game(piles: Vec) -> bool { 3 | true 4 | } 5 | } -------------------------------------------------------------------------------- /0884-uncommon-words-from-two-sentences/0884-uncommon-words-from-two-sentences.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def uncommonFromSentences(self, s1: str, s2: str) -> List[str]: 3 | s1 = s1.split(" ") 4 | c1 = Counter(s1) 5 | s2 = s2.split(" ") 6 | c2 = Counter(s2) 7 | words = c1 + c2 8 | 9 | ans = [w for w, c in words.items() if c == 1] 10 | 11 | return ans -------------------------------------------------------------------------------- /0898-transpose-matrix/0898-transpose-matrix.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number[][]} matrix 3 | * @return {number[][]} 4 | */ 5 | var transpose = function(matrix) { 6 | let transposed = new Array(matrix[0].length).fill(0).map(() => new Array(matrix.length)); 7 | for (let r = 0; r < matrix.length; r++) { 8 | for (let c = 0; c < matrix[0].length; c++) { 9 | transposed[c][r] = matrix[r][c]; 10 | } 11 | } 12 | return transposed; 13 | }; -------------------------------------------------------------------------------- /0899-orderly-queue/0899-orderly-queue.go: -------------------------------------------------------------------------------- 1 | func orderlyQueue(s string, k int) string { 2 | if k > 1 { 3 | r := []rune(s) 4 | sort.Slice(r, func(i int, j int) bool { 5 | return r[i] < r[j] 6 | }) 7 | return string(r) 8 | } 9 | 10 | ans := s 11 | 12 | for i := 1; i < len(s); i++ { 13 | ans = min(ans, s[i:] + s[:i]) 14 | } 15 | 16 | return ans; 17 | } -------------------------------------------------------------------------------- /0912-sort-an-array/0912-sort-an-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def sortArray(self, nums: List[int]) -> List[int]: 3 | temp_arr = [] 4 | 5 | for num in nums: 6 | heapq.heappush(temp_arr, num) 7 | 8 | ans = [0 for _ in range(len(temp_arr))] 9 | 10 | for i in range(len(temp_arr)): 11 | num = heapq.heappop(temp_arr) 12 | ans[i] = num 13 | 14 | return ans -------------------------------------------------------------------------------- /0921-minimum-add-to-make-parentheses-valid/0921-minimum-add-to-make-parentheses-valid.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minAddToMakeValid(string s) { 4 | int close = 0; 5 | int open = 0; 6 | for (auto ch : s) { 7 | if (ch == '(') open++; 8 | else if (open > 0 && ch == ')') open--; 9 | else close++; 10 | } 11 | return open + close; 12 | } 13 | }; -------------------------------------------------------------------------------- /0921-minimum-add-to-make-parentheses-valid/0921-minimum-add-to-make-parentheses-valid.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minAddToMakeValid(self, s: str) -> int: 3 | opened = closed = 0 4 | 5 | for c in s: 6 | if c == '(': 7 | opened += 1 8 | elif opened > 0 and c == ')': 9 | opened -= 1 10 | else: 11 | closed += 1 12 | 13 | return opened + closed -------------------------------------------------------------------------------- /0922-sort-array-by-parity-ii/0922-sort-array-by-parity-ii.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def sortArrayByParityII(self, nums: List[int]) -> List[int]: 3 | e = list(filter(lambda x: x % 2 == 0, nums)) 4 | o = list(filter(lambda x: x % 2 != 0, nums)) 5 | 6 | ans = [] 7 | 8 | for i in range(len(nums) // 2): 9 | ans.append(e[i]) 10 | ans.append(o[i]) 11 | 12 | return ans -------------------------------------------------------------------------------- /0929-unique-email-addresses/0929-unique-email-addresses.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def numUniqueEmails(self, emails: List[str]) -> int: 3 | ans = set() 4 | 5 | for email in emails: 6 | local, domain = email.split('@') 7 | local = local.split('+')[0].replace('.', '') 8 | ans.add((local, domain)) 9 | 10 | return len(ans) -------------------------------------------------------------------------------- /0938-range-sum-of-bst/0938-range-sum-of-bst.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | int sum = 0; 3 | public: 4 | int rangeSumBST(TreeNode* root, int low, int high) { 5 | if (root->left) { 6 | rangeSumBST(root->left, low, high); 7 | } 8 | if (root->right) rangeSumBST(root->right, low, high); 9 | if (root->val >= low && root->val <= high) sum += root->val; 10 | return sum; 11 | } 12 | }; -------------------------------------------------------------------------------- /0942-di-string-match/0942-di-string-match.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def diStringMatch(self, s: str) -> List[int]: 3 | ans = [] 4 | num1 = len(s) 5 | num2 = 0 6 | 7 | for idx, ch in enumerate(s): 8 | if ch == 'D': 9 | ans.append(num1) 10 | num1 -= 1 11 | else: 12 | ans.append(num2) 13 | num2 += 1 14 | 15 | ans.append(num1) 16 | 17 | return ans -------------------------------------------------------------------------------- /0961-n-repeated-element-in-size-2n-array/0961-n-repeated-element-in-size-2n-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def repeatedNTimes(self, nums: List[int]) -> int: 3 | n = len(nums) // 2 4 | print(n) 5 | count = Counter(nums) 6 | print(count) 7 | 8 | for num in nums: 9 | if count[num] == n: 10 | return num 11 | 12 | return -1 -------------------------------------------------------------------------------- /0983-minimum-cost-for-tickets/0983-minimum-cost-for-tickets.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def mincostTickets(self, d: List[int], c: List[int]) -> int: 3 | @cache 4 | def f(idx): 5 | if idx == len(d): 6 | return 0 7 | return min(c[0] + f(bisect_left(d, d[idx] + 1)), c[1] + f(bisect_left(d, d[idx] + 7)), c[2] + f(bisect_left(d, d[idx] + 30))) 8 | 9 | return f(0) -------------------------------------------------------------------------------- /0989-add-to-array-form-of-integer/0989-add-to-array-form-of-integer.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def addToArrayForm(self, num: List[int], k: int) -> List[int]: 3 | ans = [] 4 | number = 0 5 | 6 | for n in num: 7 | number = number * 10 + n 8 | 9 | new = number + k 10 | 11 | while new > 0: 12 | ans.append(new % 10) 13 | new //= 10 14 | 15 | return reversed(ans) -------------------------------------------------------------------------------- /0997-find-the-town-judge/0997-find-the-town-judge.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findJudge(int n, vector>& trust) { 4 | vector trustCnt(n, 0); 5 | for(auto i : trust) { 6 | trustCnt[i[0] - 1]--; 7 | trustCnt[i[1] - 1]++; 8 | } 9 | for(int i=0; i int: 3 | if n == 0: 4 | return 1 5 | 6 | copy = n 7 | temp = 1 8 | 9 | while copy: 10 | n = n ^ temp 11 | copy = copy >> 1 12 | temp = temp << 1 13 | 14 | return n -------------------------------------------------------------------------------- /1010-pairs-of-songs-with-total-durations-divisible-by-60/1010-pairs-of-songs-with-total-durations-divisible-by-60.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def numPairsDivisibleBy60(self, time: List[int]) -> int: 3 | count = Counter() 4 | ans = 0 5 | 6 | for i in time: 7 | mod_i = i % 60 8 | if mod_i == 0: 9 | ans += count[0] 10 | else: 11 | ans += count[60 - mod_i] 12 | count[mod_i] += 1 13 | 14 | return ans -------------------------------------------------------------------------------- /1014-best-sightseeing-pair/1014-best-sightseeing-pair.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxScoreSightseeingPair(self, v: List[int]) -> int: 3 | ans = idx = SUM = 0 4 | temp = v[0] 5 | 6 | for i in range(1, len(v)): 7 | SUM = temp + v[i] + idx - i 8 | ans = max(ans, SUM) 9 | if v[i] + i > temp + idx: 10 | idx = i 11 | temp = v[i] 12 | 13 | return ans -------------------------------------------------------------------------------- /1018-largest-perimeter-triangle/1018-largest-perimeter-triangle.py: -------------------------------------------------------------------------------- 1 | # m3hu1 2 | class Solution: 3 | def largestPerimeter(self, nums: List[int]) -> int: 4 | nums = [-num for num in nums] 5 | heapq.heapify(nums) 6 | c = -heapq.heappop(nums) 7 | b = -heapq.heappop(nums) 8 | a = -heapq.heappop(nums) 9 | while nums and c >= (a + b): 10 | c = b 11 | b = a 12 | a = -heapq.heappop(nums) 13 | 14 | return (a + b + c)*(c < (a + b)) -------------------------------------------------------------------------------- /1051-height-checker/1051-height-checker.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int heightChecker(vector& heights) { 4 | vector expected(heights.begin(), heights.end()); 5 | sort(expected.begin(), expected.end()); 6 | int cnt = 0; 7 | for (int i = 0; i < heights.size(); i++) { 8 | if (heights[i] != expected[i]) cnt++; 9 | } 10 | return cnt; 11 | } 12 | }; -------------------------------------------------------------------------------- /1072-flip-columns-for-maximum-number-of-equal-rows/1072-flip-columns-for-maximum-number-of-equal-rows.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxEqualRowsAfterFlips(self, mat: List[List[int]]) -> int: 3 | arr = defaultdict(int) 4 | 5 | for r in mat: 6 | arr[tuple(r)] += 1 7 | f = [1 - x for x in r] 8 | arr[tuple(f)] += 1 9 | 10 | return max(arr.values()) 11 | -------------------------------------------------------------------------------- /1079-letter-tile-possibilities/1079-letter-tile-possibilities.go: -------------------------------------------------------------------------------- 1 | func helper(arr [26]int) int { 2 | ans := 0 3 | for i := range arr { 4 | if arr[i] > 0 { 5 | ans++ 6 | arr[i]-- 7 | ans += helper(arr) 8 | arr[i]++ 9 | } 10 | } 11 | return ans 12 | } 13 | 14 | func numTilePossibilities(t string) int { 15 | arr := [26]int{} 16 | 17 | for i := range t { 18 | arr[t[i] - 'A']++ 19 | } 20 | 21 | return helper(arr) 22 | } -------------------------------------------------------------------------------- /1108-defanging-an-ip-address/1108-defanging-an-ip-address.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | string defangIPaddr(string address) { 4 | string ans = ""; 5 | for (int i = 0; i < address.size(); i++) { 6 | if (address[i] == '.') ans += "[.]"; 7 | else ans += address[i]; 8 | } 9 | return ans; 10 | } 11 | }; -------------------------------------------------------------------------------- /1137-height-checker/1137-height-checker.py: -------------------------------------------------------------------------------- 1 | # m3hu1 2 | class Solution: 3 | def heightChecker(self, heights: List[int]) -> int: 4 | counter=0 5 | for i in range(len(heights)): 6 | if heights[i]!=sorted(heights)[i]: 7 | counter+=1 8 | return counter -------------------------------------------------------------------------------- /1137-n-th-tribonacci-number/1137-n-th-tribonacci-number.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | int tribonacci(int n) { 5 | int a[3] = {0,n>0,0}; 6 | for(int i = 2; i < n; i++) a[i%3] = a[0] + a[1] + a[2]; 7 | return a[0] + a[1] + a[2]; 8 | } 9 | }; -------------------------------------------------------------------------------- /1189-maximum-number-of-balloons/1189-maximum-number-of-balloons.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxNumberOfBalloons(self, text: str) -> int: 3 | count = Counter(text) 4 | 5 | return min( 6 | count['b'], count['a'], count['l'] // 2, count['o'] // 2, count['n'] 7 | ) -------------------------------------------------------------------------------- /1207-unique-number-of-occurrences/1207-unique-number-of-occurrences.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool uniqueOccurrences(vector& arr) 4 | { 5 | unordered_mapmp; 6 | int n=arr.size(); 7 | for(int i=0;ist; 12 | for(auto it:mp) 13 | { 14 | st.insert(it.second); 15 | } 16 | return st.size()==mp.size()?true:false; 17 | } 18 | }; -------------------------------------------------------------------------------- /1221-element-appearing-more-than-25-in-sorted-array/1221-element-appearing-more-than-25-in-sorted-array.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number[]} arr 3 | * @return {number} 4 | */ 5 | var findSpecialInteger = function(arr) { 6 | let count = 0, gap = Math.floor(arr.length/4)-1, i = 0 7 | while(count<=gap && i int: 3 | ans = 0 4 | l = 0 5 | 6 | for c in s: 7 | if c == 'L': 8 | l += 1 9 | else: 10 | l -= 1 11 | if l == 0: 12 | ans += 1 13 | 14 | return ans -------------------------------------------------------------------------------- /1233-remove-sub-folders-from-the-filesystem/1233-remove-sub-folders-from-the-filesystem.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def removeSubfolders(self, f: List[str]) -> List[str]: 3 | ans = curr = [] 4 | f.sort() 5 | 6 | for i in f: 7 | s = i.split('/') 8 | if not curr or s[:len(curr)] != curr: 9 | ans.append(i) 10 | curr = s 11 | 12 | return ans -------------------------------------------------------------------------------- /1236-n-th-tribonacci-number/1236-n-th-tribonacci-number.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | int tribonacci(int n) { 5 | int a[3] = {0,n>0,0}; 6 | for(int i = 2; i < n; i++) a[i%3] = a[0] + a[1] + a[2]; 7 | return a[0] + a[1] + a[2]; 8 | } 9 | }; -------------------------------------------------------------------------------- /1250-check-if-it-is-a-good-array/1250-check-if-it-is-a-good-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isGoodArray(self, nums: List[int]) -> bool: 3 | ans = 0 4 | 5 | for num in nums: 6 | ans = gcd(ans, num) 7 | 8 | if ans != 1: 9 | return False 10 | 11 | return True -------------------------------------------------------------------------------- /1295-find-numbers-with-even-number-of-digits/1295-find-numbers-with-even-number-of-digits.go: -------------------------------------------------------------------------------- 1 | func findNumbers(nums []int) int { 2 | ans := 0 3 | 4 | for _, num := range nums { 5 | numDigits := int(math.Log10(float64(num))) + 1 6 | if numDigits % 2 == 0 { ans++ } 7 | } 8 | 9 | return ans 10 | } -------------------------------------------------------------------------------- /1304-find-n-unique-integers-sum-up-to-zero/1304-find-n-unique-integers-sum-up-to-zero.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def sumZero(self, n: int) -> List[int]: 3 | ans = [] 4 | 5 | # if n % 2 == 0: 6 | for i in range(1, n // 2 + 1): 7 | ans.append(i) 8 | ans.append(i * -1) 9 | 10 | # else: 11 | if n % 2 != 0: 12 | ans.append(0) 13 | 14 | return ans -------------------------------------------------------------------------------- /1310-xor-queries-of-a-subarray/1310-xor-queries-of-a-subarray.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def xorQueries(self, nums: List[int], q: List[List[int]]) -> List[int]: 3 | ans = [] 4 | p = [0 for _ in range(1 + len(nums))] 5 | 6 | for i in range(len(nums)): 7 | p[i + 1] = nums[i] ^ p[i] 8 | 9 | for a, b in q: 10 | ans.append(p[a] ^ p[b + 1]) 11 | 12 | return ans -------------------------------------------------------------------------------- /1312-minimum-insertion-steps-to-make-a-string-palindrome/1312-minimum-insertion-steps-to-make-a-string-palindrome.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minInsertions(self, s: str) -> int: 3 | @cache 4 | def helper(i, j): 5 | if j < i or j == i: 6 | return 0 7 | if s[i] == s[j]: 8 | return helper(i + 1, j - 1) 9 | return 1 + min(helper(i + 1, j), helper(i, j - 1)) 10 | 11 | return helper(0, len(s) - 1) -------------------------------------------------------------------------------- /1331-rank-transform-of-an-array/1331-rank-transform-of-an-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def arrayRankTransform(self, arr: List[int]) -> List[int]: 3 | nums = sorted(set(arr)) 4 | mp = defaultdict(int) 5 | 6 | for a, b in enumerate(nums): 7 | mp[b] = a + 1 8 | 9 | return [mp[num] for num in arr] -------------------------------------------------------------------------------- /1342-number-of-steps-to-reduce-a-number-to-zero/1342-number-of-steps-to-reduce-a-number-to-zero.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def numberOfSteps(self, num: int) -> int: 3 | cnt = 0 4 | 5 | while num != 0: 6 | cnt += 1 7 | if num % 2 == 0: 8 | num /= 2 9 | else: 10 | num -= 1 11 | 12 | return cnt -------------------------------------------------------------------------------- /1346-check-if-n-and-its-double-exist/1346-check-if-n-and-its-double-exist.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def checkIfExist(self, nums: List[int]) -> bool: 3 | count = Counter(nums) 4 | 5 | for num in nums: 6 | if num == 0 and count[0] < 2: 7 | continue 8 | if num in count and num * 2 in count: 9 | return True 10 | 11 | return False -------------------------------------------------------------------------------- /1351-count-negative-numbers-in-a-sorted-matrix/1351-count-negative-numbers-in-a-sorted-matrix.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countNegatives(self, grid: List[List[int]]) -> int: 3 | ans = 0 4 | 5 | for i in range(len(grid)): 6 | for j in range(len(grid[0])): 7 | if grid[i][j] < 0: 8 | ans += 1 9 | 10 | return ans -------------------------------------------------------------------------------- /1358-number-of-substrings-containing-all-three-characters/1358-number-of-substrings-containing-all-three-characters.go: -------------------------------------------------------------------------------- 1 | func numberOfSubstrings(s string) int { 2 | lastPos := []int{-1, -1, -1} 3 | total := 0 4 | 5 | for pos, char := range s { 6 | lastPos[char-'a'] = pos 7 | total += 1 + min(lastPos[0], lastPos[1], lastPos[2]) 8 | } 9 | 10 | return total 11 | } -------------------------------------------------------------------------------- /1365-how-many-numbers-are-smaller-than-the-current-number/1365-how-many-numbers-are-smaller-than-the-current-number.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]: 3 | ans = [] 4 | sorted_nums = sorted(nums) 5 | 6 | for num in nums: 7 | ans.append(sorted_nums.index(num)) 8 | 9 | return ans -------------------------------------------------------------------------------- /1389-create-target-array-in-the-given-order/1389-create-target-array-in-the-given-order.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def createTargetArray(self, nums: List[int], index: List[int]) -> List[int]: 3 | ans = [] 4 | 5 | for i in range(len(nums)): 6 | ans.insert(index[i], nums[i]) 7 | 8 | return ans -------------------------------------------------------------------------------- /1394-find-lucky-integer-in-an-array/1394-find-lucky-integer-in-an-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findLucky(vector& arr) { 4 | unordered_map mp; 5 | int ans = -1; 6 | for (auto i : arr) mp[i]++; 7 | for (auto i : mp) { 8 | if (i.first == i.second) ans = max(ans, i.first); 9 | } 10 | return ans; 11 | } 12 | }; -------------------------------------------------------------------------------- /1395-minimum-time-visiting-all-points/1395-minimum-time-visiting-all-points.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number[][]} points 3 | * @return {number} 4 | */ 5 | var minTimeToVisitAllPoints = function (points) { 6 | let ans = 0; 7 | const n = points.length; 8 | 9 | for (let i = 0; i < n - 1; i++) { 10 | const [ci, cj] = points[i]; 11 | const [ni, nj] = points[i + 1]; 12 | ans += Math.max(Math.abs(ci - ni), Math.abs(cj - nj)); 13 | } 14 | 15 | return ans; 16 | }; -------------------------------------------------------------------------------- /1400-construct-k-palindrome-strings/1400-construct-k-palindrome-strings.go: -------------------------------------------------------------------------------- 1 | func canConstruct(s string, k int) bool { 2 | if k > len(s) { 3 | return false 4 | } 5 | 6 | mp := make(map[rune]int) 7 | 8 | for _, ch := range s { 9 | mp[ch]++ 10 | } 11 | 12 | o := 0 13 | 14 | for _, cnt := range mp { 15 | if cnt % 2 != 0 { 16 | o++ 17 | } 18 | } 19 | 20 | return o <= k 21 | } -------------------------------------------------------------------------------- /1402-reducing-dishes/1402-reducing-dishes.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxSatisfaction(vector& satisfaction) { 4 | sort(satisfaction.begin(), satisfaction.end()); 5 | int ans = 0; 6 | int sum = 0; 7 | for (int i = satisfaction.size() - 1; i >= 0; i--) { 8 | sum += satisfaction[i]; 9 | if (sum < 0) break; 10 | ans += sum; 11 | } 12 | return ans; 13 | } 14 | }; -------------------------------------------------------------------------------- /1404-number-of-steps-to-reduce-a-number-in-binary-representation-to-one/1404-number-of-steps-to-reduce-a-number-in-binary-representation-to-one.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int numSteps(string s) { 4 | int c = 0; 5 | int ans = 0; 6 | for (int i = s.size() - 1; i >= 1; i--) { 7 | if ((c + s[i] - '0') % 2 == 1) { 8 | c = 1; 9 | ans = ans + 2; 10 | } else ans = ans + 1; 11 | } 12 | return c + ans; 13 | } 14 | }; -------------------------------------------------------------------------------- /1408-string-matching-in-an-array/1408-string-matching-in-an-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def stringMatching(self, w: List[str]) -> List[str]: 3 | temp, ans = "", [] 4 | 5 | for word in w : 6 | temp += word + " " 7 | 8 | for word in w : 9 | if temp.count(word) > 1 : 10 | ans.append(word) 11 | 12 | return ans -------------------------------------------------------------------------------- /1409-queries-on-a-permutation-with-key/1409-queries-on-a-permutation-with-key.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def processQueries(self, qu: List[int], m: int) -> List[int]: 3 | arr = [i for i in range(1, m + 1)] 4 | ans = [] 5 | 6 | for q in qu: 7 | ans.append(arr.index(q)) 8 | arr.insert(0, arr.pop(arr.index(q))) 9 | 10 | return ans -------------------------------------------------------------------------------- /1413-minimum-value-to-get-positive-step-by-step-sum/1413-minimum-value-to-get-positive-step-by-step-sum.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minStartValue(self, nums: List[int]) -> int: 3 | SUM = 0 4 | ans = 0 5 | 6 | for num in nums: 7 | SUM += num 8 | ans = min(ans, SUM) 9 | 10 | return 1 - ans -------------------------------------------------------------------------------- /1422-maximum-score-after-splitting-a-string/1422-maximum-score-after-splitting-a-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxScore(self, s: str) -> int: 3 | z, o, ans = 0, 0, float('-inf') 4 | 5 | for i in range(len(s)): 6 | if s[i] == '0': 7 | z += 1 8 | else: 9 | o += 1 10 | if i != len(s) - 1: 11 | ans = max(ans, z - o) 12 | 13 | return ans + o -------------------------------------------------------------------------------- /1437-check-if-all-1s-are-at-least-length-k-places-away/1437-check-if-all-1s-are-at-least-length-k-places-away.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def kLengthApart(self, nums: List[int], k: int) -> bool: 3 | idx = -1 * (k + 1) 4 | 5 | for i in range(len(nums)): 6 | if nums[i] == 1: 7 | if i - idx <= k: 8 | return False 9 | idx = i 10 | 11 | return True -------------------------------------------------------------------------------- /1446-consecutive-characters/1446-consecutive-characters.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxPower(self, s: str) -> int: 3 | ans = 0 4 | cnt = 0 5 | 6 | for i in range(1, len(s)): 7 | if s[i - 1] == s[i]: 8 | cnt += 1 9 | ans = max(ans, cnt) 10 | else: 11 | cnt = 0 12 | 13 | return ans + 1 -------------------------------------------------------------------------------- /1450-number-of-students-doing-homework-at-a-given-time/1450-number-of-students-doing-homework-at-a-given-time.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def busyStudent(self, st: List[int], et: List[int], qt: int) -> int: 3 | ans = 0 4 | arr = list(zip(st, et)) 5 | 6 | for temp in arr: 7 | if temp[0] <= qt and qt <= temp[1]: 8 | ans += 1 9 | 10 | return ans -------------------------------------------------------------------------------- /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.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isPrefixOfWord(self, sentence: str, searchWord: str) -> int: 3 | new = sentence.split(" ") 4 | 5 | for idx, word in enumerate(new): 6 | if word.startswith(searchWord): 7 | return idx + 1 8 | 9 | return -1 -------------------------------------------------------------------------------- /1460-make-two-arrays-equal-by-reversing-subarrays/1460-make-two-arrays-equal-by-reversing-subarrays.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def canBeEqual(self, target: List[int], arr: List[int]) -> bool: 3 | return sorted(arr) == sorted(target) -------------------------------------------------------------------------------- /1470-shuffle-the-array/1470-shuffle-the-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def shuffle(self, nums: List[int], n: int) -> List[int]: 3 | ans = [] 4 | 5 | for i in range(n): 6 | ans.append(nums[i]) 7 | ans.append(nums[i + n]) 8 | 9 | return ans -------------------------------------------------------------------------------- /1475-final-prices-with-a-special-discount-in-a-shop/1475-final-prices-with-a-special-discount-in-a-shop.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def finalPrices(self, p: List[int]) -> List[int]: 3 | stack = [] 4 | 5 | for i in range(len(p)): 6 | while stack and p[stack[-1]] >= p[i]: 7 | idx = stack.pop() 8 | p[idx] -= p[i] 9 | stack.append(i) 10 | 11 | return p -------------------------------------------------------------------------------- /1480-running-sum-of-1d-array/1480-running-sum-of-1d-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector runningSum(vector& nums) { 4 | for (int i = 1; i < nums.size(); i++) nums[i] = nums[i] + nums[i - 1]; 5 | return nums; 6 | } 7 | }; -------------------------------------------------------------------------------- /1486-xor-operation-in-an-array/1486-xor-operation-in-an-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def xorOperation(self, n: int, start: int) -> int: 3 | nums = [0 for _ in range(n)] 4 | ans = 0 5 | 6 | for i in range(n): 7 | nums[i] = start + 2 * i 8 | ans = ans ^ nums[i] 9 | 10 | return ans -------------------------------------------------------------------------------- /1492-the-kth-factor-of-n/1492-the-kth-factor-of-n.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int kthFactor(int n, int k) { 4 | vector ans; 5 | for (int i = 1; i <= n; i++) { 6 | if (n % i == 0) ans.push_back(i); 7 | } 8 | if (ans.size() < k) return -1; 9 | return ans[k - 1]; 10 | } 11 | }; -------------------------------------------------------------------------------- /1497-check-if-array-pairs-are-divisible-by-k/1497-check-if-array-pairs-are-divisible-by-k.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def canArrange(self, nums: List[int], k: int) -> bool: 3 | if len(nums) % 2 != 0: 4 | return False 5 | 6 | ans = 0 7 | 8 | for num in nums: 9 | rem = num % k 10 | ans ^= (1 << rem) 11 | 12 | return ans == 0 -------------------------------------------------------------------------------- /1509-minimum-difference-between-largest-and-smallest-value-in-three-moves/1509-minimum-difference-between-largest-and-smallest-value-in-three-moves.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minDifference(self, nums: List[int]) -> int: 3 | if len(nums) <= 4: 4 | return 0 5 | 6 | nums.sort() 7 | 8 | return min(nums[-4] - nums[0], nums[-3] - nums[1], nums[-2] - nums[2], nums[-1] - nums[3]) -------------------------------------------------------------------------------- /1518-water-bottles/1518-water-bottles.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int numWaterBottles(int numBottles, int numExchange) { 4 | int ans = numBottles; 5 | while (numBottles >= numExchange) { 6 | // int curr = numBottles / numExchange; 7 | ans += numBottles / numExchange; 8 | numBottles = numBottles % numExchange + numBottles / numExchange; 9 | } 10 | return ans; 11 | } 12 | }; -------------------------------------------------------------------------------- /1526-minimum-number-of-increments-on-subarrays-to-form-a-target-array/1526-minimum-number-of-increments-on-subarrays-to-form-a-target-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minNumberOperations(self, target: List[int]) -> int: 3 | ans = c = 0 4 | 5 | for t in target: 6 | if c >= t: 7 | c = t 8 | continue 9 | ans = ans - c + t 10 | c = t 11 | 12 | return ans -------------------------------------------------------------------------------- /1528-shuffle-string/1528-shuffle-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def restoreString(self, s: str, indices: List[int]) -> str: 3 | ans = ["" for i in range(len(s))] 4 | 5 | for i in range(len(s)): 6 | ans[indices[i]] = s[i] 7 | 8 | return "".join(ans) -------------------------------------------------------------------------------- /1545-find-kth-bit-in-nth-binary-string/1545-find-kth-bit-in-nth-binary-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findKthBit(self, n: int, k: int) -> str: 3 | x = "0" 4 | 5 | for i in range(n): 6 | temp = "" 7 | for i in range(len(x)): 8 | if x[i] == "1": 9 | temp += "0" 10 | else: 11 | temp += "1" 12 | temp = temp[::-1] 13 | x = x + "1" + temp 14 | 15 | return x[k - 1] -------------------------------------------------------------------------------- /1547-destination-city/1547-destination-city.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {string[][]} paths 3 | * @return {string} 4 | */ 5 | var destCity = function(paths) { 6 | const outgoingCities = new Set(paths.map(([src]) => src)); 7 | const destinations = paths.map(([_, dest]) => dest); 8 | return destinations.find((dest) =>!outgoingCities.has(dest)) || ""; 9 | }; -------------------------------------------------------------------------------- /1550-three-consecutive-odds/1550-three-consecutive-odds.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def threeConsecutiveOdds(self, arr: List[int]) -> bool: 3 | cnt = 0 4 | 5 | for num in arr: 6 | if num % 2 == 1: 7 | cnt += 1 8 | if cnt == 3: 9 | return True 10 | else: 11 | cnt = 0 12 | 13 | return False -------------------------------------------------------------------------------- /1551-minimum-operations-to-make-array-equal/1551-minimum-operations-to-make-array-equal.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minOperations(self, n: int) -> int: 3 | arr = [(2 * i) + 1 for i in range(n)] 4 | # print(arr) 5 | ans = 0 6 | 7 | for i in range(n // 2): 8 | ans += n - arr[i] 9 | 10 | return ans -------------------------------------------------------------------------------- /1574-maximum-product-of-two-elements-in-an-array/1574-maximum-product-of-two-elements-in-an-array.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number[]} nums 3 | * @return {number} 4 | */ 5 | var maxProduct = function(nums) { 6 | const n = nums.length; 7 | 8 | nums.sort((a, b) => a - b); 9 | 10 | const first = nums[n - 2] - 1; 11 | 12 | const second = nums[n - 1] - 1; 13 | 14 | return first * second; 15 | }; -------------------------------------------------------------------------------- /1584-average-salary-excluding-the-minimum-and-maximum-salary/1584-average-salary-excluding-the-minimum-and-maximum-salary.py: -------------------------------------------------------------------------------- 1 | # m3hu1 2 | class Solution: 3 | def average(self, salary: List[int]) -> float: 4 | res = [x for x in salary if x != max(salary) and x != min(salary)] 5 | return sum(res) / len(res) -------------------------------------------------------------------------------- /1588-sum-of-all-odd-length-subarrays/1588-sum-of-all-odd-length-subarrays.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def sumOddLengthSubarrays(self, arr: List[int]) -> int: 3 | ans = 0 4 | 5 | for i in range(len(arr)): 6 | tot_sub = (i + 1) * (len(arr) - i) # total no. of subarrays 7 | tot_odd = (tot_sub + 1) // 2 # total odd subarrays 8 | ans += arr[i] * tot_odd 9 | 10 | return ans -------------------------------------------------------------------------------- /1598-crawler-log-folder/1598-crawler-log-folder.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minOperations(self, logs: List[str]) -> int: 3 | stack = [] 4 | 5 | for log in logs: 6 | if log != "./": 7 | if log == "../": 8 | if stack: 9 | stack.pop() 10 | else: 11 | stack.append(log) 12 | 13 | return len(stack) -------------------------------------------------------------------------------- /1614-maximum-nesting-depth-of-the-parentheses/1614-maximum-nesting-depth-of-the-parentheses.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxDepth(string s) { 4 | int ans = INT_MIN; 5 | int cnt = 0; 6 | for (auto ch : s) { 7 | if (ch == '(') cnt++; 8 | else if (ch == ')') cnt--; 9 | ans = max(ans, cnt); 10 | } 11 | return ans; 12 | } 13 | }; -------------------------------------------------------------------------------- /1619-mean-of-array-after-removing-some-elements/1619-mean-of-array-after-removing-some-elements.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def trimMean(self, arr: List[int]) -> float: 3 | arr.sort() 4 | x = len(arr) // 20 5 | SUM = 0 6 | 7 | for i in range(x, len(arr) - x): 8 | SUM += arr[i] 9 | 10 | return SUM / (len(arr) - x - x) -------------------------------------------------------------------------------- /1626-can-make-arithmetic-progression-from-sequence/1626-can-make-arithmetic-progression-from-sequence.py: -------------------------------------------------------------------------------- 1 | # m3hu1 2 | class Solution: 3 | def canMakeArithmeticProgression(self, arr: List[int]) -> bool: 4 | arr=sorted(arr) 5 | diff=arr[1]-arr[0] 6 | for i in range(1,len(arr)): 7 | if i+1>=len(arr): 8 | break 9 | diff1=arr[i+1]-arr[i] 10 | if diff != diff1: 11 | return False 12 | return True -------------------------------------------------------------------------------- /1630-count-odd-numbers-in-an-interval-range/1630-count-odd-numbers-in-an-interval-range.py: -------------------------------------------------------------------------------- 1 | # m3hu1 2 | class Solution: 3 | def countOdds(self, l: int, h: int) -> int: 4 | if l % 2 == 1 or h % 2 == 1: 5 | return (h - l) // 2 + 1 6 | else: 7 | return (h - l) // 2 -------------------------------------------------------------------------------- /1636-sort-array-by-increasing-frequency/1636-sort-array-by-increasing-frequency.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def frequencySort(self, nums: List[int]) -> List[int]: 3 | count = Counter(nums) 4 | sorted_nums = sorted(nums, key = lambda x: (count[x])) 5 | 6 | return sorted_nums -------------------------------------------------------------------------------- /1653-minimum-deletions-to-make-string-balanced/1653-minimum-deletions-to-make-string-balanced.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minimumDeletions(self, s: str) -> int: 3 | stack = [] 4 | ans = 0 5 | 6 | for ch in s: 7 | if ch == 'a': 8 | if stack: 9 | ans += 1 10 | stack.pop() 11 | else: 12 | stack.append(ch) 13 | 14 | return ans -------------------------------------------------------------------------------- /1677-matrix-diagonal-sum/1677-matrix-diagonal-sum.py: -------------------------------------------------------------------------------- 1 | # m3hu1 2 | class Solution: 3 | def diagonalSum(self, mat: List[List[int]]) -> int: 4 | 5 | n=len(mat) 6 | r=[] 7 | 8 | for i in range(n): 9 | for j in range(n): 10 | 11 | if i==j or i+j==n-1: 12 | r.append(mat[i][j]) 13 | return sum(r) -------------------------------------------------------------------------------- /1678-goal-parser-interpretation/1678-goal-parser-interpretation.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def interpret(self, c: str) -> str: 3 | ans = [] 4 | 5 | for i in range(len(c)): 6 | if c[i] == 'G': 7 | ans.append(c[i]) 8 | elif c[i] == '(': 9 | if c[i + 1] == ')': 10 | ans.append("o") 11 | elif c[i + 1] == 'a': 12 | ans.append("al") 13 | 14 | return "".join(ans) -------------------------------------------------------------------------------- /1683-maximum-number-of-coins-you-can-get/1683-maximum-number-of-coins-you-can-get.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | int maxCoins(vector& piles) { 5 | sort(piles.begin(),piles.end()); 6 | int ans=0; 7 | int n=piles.size(); 8 | for(int i=n-2; i>=n/3; i-=2){ 9 | ans+=piles[i]; 10 | } 11 | return ans; 12 | } 13 | }; -------------------------------------------------------------------------------- /1684-count-the-number-of-consistent-strings/1684-count-the-number-of-consistent-strings.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countConsistentStrings(self, allowed: str, words: List[str]) -> int: 3 | SET = set(allowed) 4 | ans = len(words) 5 | 6 | for word in words: 7 | for j in range(len(word)): 8 | if word[j] not in SET: 9 | ans -= 1 10 | break 11 | 12 | return ans -------------------------------------------------------------------------------- /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 | int minPartitions(string n) { 4 | // Upon observing the test cases, the bottleneck is the number of columns, which is the max digit. 5 | return *(max_element(n.begin(), n.end())) - '0'; 6 | } 7 | }; -------------------------------------------------------------------------------- /1701-average-waiting-time/1701-average-waiting-time.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def averageWaitingTime(self, cus: List[List[int]]) -> float: 3 | ans = 0 4 | curr = 0 5 | 6 | for arr, time in cus: 7 | curr = max(arr, curr) 8 | ans += (curr - arr) + time 9 | curr = time + curr 10 | 11 | return ans / len(cus) -------------------------------------------------------------------------------- /1710-maximum-units-on-a-truck/1710-maximum-units-on-a-truck.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maximumUnits(self, bt: List[List[int]], ts: int) -> int: 3 | bt.sort(reverse = True, key = lambda x: x[1]) #sort acc to no. of units/box 4 | ans = 0 5 | 6 | for i in bt: 7 | if ts <= 0: 8 | return ans 9 | ans += min(ts, i[0]) * i[1] 10 | ts -= i[0] 11 | 12 | return ans -------------------------------------------------------------------------------- /1726-tuple-with-same-product/1726-tuple-with-same-product.go: -------------------------------------------------------------------------------- 1 | func tupleSameProduct(nums []int) int { 2 | prod := make(map[int]int) 3 | ans := 0 4 | 5 | for i := 0; i < len(nums) - 1; i++ { 6 | for j := i + 1; j < len(nums); j++ { 7 | ans += 8 * prod[nums[i] * nums[j]] 8 | prod[nums[i] * nums[j]]++ 9 | } 10 | } 11 | 12 | return ans 13 | } -------------------------------------------------------------------------------- /1732-find-the-highest-altitude/1732-find-the-highest-altitude.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int largestAltitude(vector& gain) { 4 | int n = gain.size(); 5 | int sum = 0; 6 | int highest = 0; 7 | for(int i=0;i int: 3 | SUM = 0 4 | count = Counter(nums) 5 | 6 | for num in nums: 7 | if count[num] == 1: 8 | SUM += num 9 | 10 | return SUM -------------------------------------------------------------------------------- /1749-maximum-absolute-sum-of-any-subarray/1749-maximum-absolute-sum-of-any-subarray.go: -------------------------------------------------------------------------------- 1 | func maxAbsoluteSum(nums []int) int { 2 | var minPSum, maxPSum int = 0, 0 3 | var pSum int = 0 4 | 5 | for _, num := range nums { 6 | pSum += num 7 | maxPSum = max(maxPSum, pSum) 8 | minPSum = min(minPSum, pSum) 9 | } 10 | 11 | return maxPSum - minPSum 12 | } -------------------------------------------------------------------------------- /1752-check-if-array-is-sorted-and-rotated/1752-check-if-array-is-sorted-and-rotated.go: -------------------------------------------------------------------------------- 1 | func check(nums []int) bool { 2 | d := 0 3 | 4 | for i, num := range nums { 5 | if num > nums[(i + 1) % len(nums)] { 6 | d++ 7 | } 8 | if d > 1 { 9 | return false 10 | } 11 | } 12 | 13 | return true 14 | } -------------------------------------------------------------------------------- /1763-longest-nice-substring/1763-longest-nice-substring.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def longestNiceSubstring(self, s: str) -> str: 3 | for i in range(len(s)): 4 | if s[i].lower() not in s or s[i].upper() not in s: 5 | l = self.longestNiceSubstring(s[ : i]) 6 | r = self.longestNiceSubstring(s[i + 1 : ]) 7 | return r if len(r) > len(l) else l 8 | 9 | return s -------------------------------------------------------------------------------- /1773-count-items-matching-a-rule/1773-count-items-matching-a-rule.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countMatches(self, items: List[List[str]], rk: str, rv: str) -> int: 3 | cnt = 0 4 | 5 | for item in items: 6 | if ("type" == rk and rv == item[0]) or (rk == "color" and rv == item[1]) or (rk == "name" and rv == item[2]): 7 | cnt += 1 8 | 9 | return cnt -------------------------------------------------------------------------------- /1780-check-if-number-is-a-sum-of-powers-of-three/1780-check-if-number-is-a-sum-of-powers-of-three.go: -------------------------------------------------------------------------------- 1 | func checkPowersOfThree(n int) bool { 2 | var pow int 3 | pow = 1 4 | 5 | for 3 * pow <= n { 6 | pow *= 3 7 | } 8 | 9 | for n > 0 { 10 | if n >= pow { 11 | n -= pow 12 | } 13 | if n >= pow { 14 | return false 15 | } 16 | pow /= 3 17 | } 18 | 19 | return true 20 | } -------------------------------------------------------------------------------- /1784-check-if-binary-string-has-at-most-one-segment-of-ones/1784-check-if-binary-string-has-at-most-one-segment-of-ones.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def checkOnesSegment(self, s: str) -> bool: 3 | for i in range(1, len(s)): 4 | if s[i - 1] == '0' and s[i] == '1': 5 | return False 6 | 7 | return True -------------------------------------------------------------------------------- /1790-check-if-one-string-swap-can-make-strings-equal/1790-check-if-one-string-swap-can-make-strings-equal.go: -------------------------------------------------------------------------------- 1 | func areAlmostEqual(s1 string, s2 string) bool { 2 | if len(s1) != len(s2) { 3 | return false 4 | } 5 | 6 | mp := [26]int{} 7 | x := 0 8 | 9 | for i := 0; i < len(s1); i++ { 10 | mp[s1[i] - 'a']++; mp[s2[i] - 'a']-- 11 | if s1[i] != s2[i] { 12 | x++ 13 | } 14 | } 15 | 16 | return (x < 3 && mp == [26]int{}) 17 | } -------------------------------------------------------------------------------- /1791-find-center-of-star-graph/1791-find-center-of-star-graph.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findCenter(self, edges: List[List[int]]) -> int: 3 | return list(set(edges[0]) & set(edges[1]))[0] -------------------------------------------------------------------------------- /1791-richest-customer-wealth/1791-richest-customer-wealth.py: -------------------------------------------------------------------------------- 1 | # m3hu1 2 | class Solution: 3 | def maximumWealth(self, accounts: List[List[int]]) -> int: 4 | maxx = 0 5 | for i in accounts: 6 | ans = sum(i) 7 | maxx = max(ans,maxx) 8 | return maxx -------------------------------------------------------------------------------- /1800-maximum-ascending-subarray-sum/1800-maximum-ascending-subarray-sum.go: -------------------------------------------------------------------------------- 1 | func maxAscendingSum(nums []int) int { 2 | maxi, x := nums[0], nums[0] 3 | 4 | for i := 1; i < len(nums); i++ { 5 | if nums[i] > nums[i-1] { 6 | x += nums[i] 7 | if x > maxi { 8 | maxi = x 9 | } 10 | } else { 11 | x = nums[i] 12 | } 13 | } 14 | 15 | return maxi 16 | } -------------------------------------------------------------------------------- /1800-maximum-ascending-subarray-sum/1800-maximum-ascending-subarray-sum.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxAscendingSum(self, nums: List[int]) -> int: 3 | maxi = SUM = 0 4 | 5 | for i in range(len(nums)): 6 | if i == 0 or nums[i] > nums[i - 1]: 7 | SUM += nums[i] 8 | else: 9 | maxi = max(maxi, SUM) 10 | SUM = nums[i] 11 | 12 | maxi = max(maxi, SUM) 13 | 14 | return maxi -------------------------------------------------------------------------------- /1806-count-of-matches-in-tournament/1806-count-of-matches-in-tournament.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number} n 3 | * @return {number} 4 | */ 5 | // var numberOfMatches = function(n) { 6 | // const numberOfMatches = n => n-1 7 | // }; 8 | const numberOfMatches = n => n-1 -------------------------------------------------------------------------------- /1816-truncate-sentence/1816-truncate-sentence.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def truncateSentence(self, s: str, k: int) -> str: 3 | words = s.split(' ') 4 | ans = [] 5 | cnt = 0 6 | 7 | for word in words: 8 | cnt += 1 9 | ans.append(word) 10 | if cnt == k: 11 | break 12 | 13 | return ' '.join(ans) -------------------------------------------------------------------------------- /1817-calculate-money-in-leetcode-bank/1817-calculate-money-in-leetcode-bank.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number} n 3 | * @return {number} 4 | */ 5 | var totalMoney = function(n) { 6 | const weekCount = Math.floor(n / 7), 7 | dayLeft = n % 7 8 | return 28 * weekCount + (weekCount * (weekCount - 1) * 3.5) + weekCount * dayLeft + dayLeft * (dayLeft + 1) / 2 9 | }; -------------------------------------------------------------------------------- /1817-finding-the-users-active-minutes/1817-finding-the-users-active-minutes.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findingUsersActiveMinutes(self, logs: List[List[int]], k: int) -> List[int]: 3 | ans = [0] * k 4 | mp = defaultdict(set) 5 | 6 | for idx, log in enumerate(logs): 7 | ID, time = log[0], log[1] 8 | mp[ID].add(time) 9 | 10 | for ID, time in mp.items(): 11 | ans[len(time) - 1] += 1 12 | 13 | return ans -------------------------------------------------------------------------------- /1823-find-the-winner-of-the-circular-game/1823-find-the-winner-of-the-circular-game.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findTheWinner(self, n: int, k: int) -> int: 3 | # q = deque() 4 | 5 | # for i in range(n): 6 | # q.append(i) 7 | 8 | # while q: 9 | 10 | ans = 0 11 | 12 | for i in range(2, 1 + n): 13 | ans = (k + ans) % i 14 | 15 | return ans + 1 -------------------------------------------------------------------------------- /1829-maximum-xor-for-each-query/1829-maximum-xor-for-each-query.rs: -------------------------------------------------------------------------------- 1 | impl Solution { 2 | pub fn get_maximum_xor(nums: Vec, mb: i32) -> Vec { 3 | let mut ans = vec![0; nums.len()]; 4 | let maxi = (1 << mb) - 1; 5 | let mut x = 0; 6 | 7 | for i in 0..nums.len() { 8 | x = x ^ nums[i]; 9 | ans[nums.len() - i - 1] = x ^ maxi; 10 | } 11 | 12 | ans 13 | } 14 | } -------------------------------------------------------------------------------- /1832-check-if-the-sentence-is-pangram/1832-check-if-the-sentence-is-pangram.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def checkIfPangram(self, sentence: str) -> bool: 3 | vis = set() 4 | 5 | for c in sentence: 6 | vis.add(c) 7 | 8 | return len(vis) == 26 -------------------------------------------------------------------------------- /1846-maximum-element-after-decreasing-and-rearranging/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1848-minimum-distance-to-the-target-element/1848-minimum-distance-to-the-target-element.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def getMinDistance(self, nums: List[int], target: int, start: int) -> int: 3 | mini = float('inf') 4 | 5 | for i in range(len(nums)): 6 | if nums[i] == target: 7 | temp = abs(i - start) 8 | mini = min(mini, temp) 9 | # return temp 10 | 11 | return mini -------------------------------------------------------------------------------- /1859-sorting-the-sentence/1859-sorting-the-sentence.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def sortSentence(self, s: str) -> str: 3 | word = s.split(" ") 4 | ans = [""] * (len(word)) 5 | 6 | for w in word: 7 | idx = int(w[-1]) - 1 8 | ans[idx] = w[:-1] 9 | 10 | return ' '.join(ans) -------------------------------------------------------------------------------- /1863-sum-of-all-subset-xor-totals/1863-sum-of-all-subset-xor-totals.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int subsetXORSum(vector& nums) { 4 | int temp = 0; 5 | for (auto i : nums) temp = temp | i; 6 | return temp << nums.size() - 1; 7 | } 8 | }; -------------------------------------------------------------------------------- /1863-sum-of-all-subset-xor-totals/1863-sum-of-all-subset-xor-totals.go: -------------------------------------------------------------------------------- 1 | func subsetXORSum(nums []int) int { 2 | ans := 0 3 | 4 | for _, num := range nums { 5 | ans |= num 6 | } 7 | 8 | return ans << (len(nums)-1) 9 | } -------------------------------------------------------------------------------- /1876-substrings-of-size-three-with-distinct-characters/1876-substrings-of-size-three-with-distinct-characters.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countGoodSubstrings(self, s: str) -> int: 3 | ans = 0 4 | 5 | for i in range(len(s) - 2): 6 | if s[i] != s[i + 1] and s[i + 1] != s[i + 2] and s[i + 2] != s[i]: 7 | ans += 1 8 | 9 | return ans -------------------------------------------------------------------------------- /1877-minimize-maximum-pair-sum-in-array/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /1884-minimum-changes-to-make-alternating-binary-string/1884-minimum-changes-to-make-alternating-binary-string.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minOperations(string s) { 4 | int n=s.size(); 5 | int temp=0; 6 | for(int i=0;i List[int]: 3 | return [nums[nums[i]] for i in range(len(nums))] -------------------------------------------------------------------------------- /1952-three-divisors/1952-three-divisors.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isThree(self, n: int) -> bool: 3 | cnt = 0 4 | 5 | for i in range(1, n + 1): 6 | if n % i == 0: 7 | cnt += 1 8 | 9 | if cnt == 3: 10 | return True 11 | 12 | return False -------------------------------------------------------------------------------- /1957-delete-characters-to-make-fancy-string/1957-delete-characters-to-make-fancy-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def makeFancyString(self, s: str) -> str: 3 | ans = [] 4 | 5 | for i in range(len(s)): 6 | if s[i] == s[-1] == s[-2] and len(ans) >= 2: 7 | continue 8 | ans.append(s[-1]) 9 | 10 | return ''.join(ans) -------------------------------------------------------------------------------- /1961-check-if-string-is-a-prefix-of-array/1961-check-if-string-is-a-prefix-of-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isPrefixString(self, s: str, words: List[str]) -> bool: 3 | string = [] 4 | 5 | for word in words: 6 | string.append(word) 7 | if len(string) >= len(s): 8 | break 9 | 10 | return "".join(string).startswith(s) -------------------------------------------------------------------------------- /1963-minimum-number-of-swaps-to-make-the-string-balanced/1963-minimum-number-of-swaps-to-make-the-string-balanced.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minSwaps(self, s: str) -> int: 3 | opened = 0 4 | 5 | for c in s: 6 | if c == '[': 7 | opened += 1 8 | elif opened > 0: 9 | opened -= 1 10 | 11 | return (opened + 1) // 2 -------------------------------------------------------------------------------- /1967-number-of-strings-that-appear-as-substrings-in-word/1967-number-of-strings-that-appear-as-substrings-in-word.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def numOfStrings(self, patterns: List[str], word: str) -> int: 3 | cnt = 0 4 | 5 | for p in patterns: 6 | if p in word: 7 | cnt += 1 8 | 9 | return cnt -------------------------------------------------------------------------------- /1975-maximum-matrix-sum/1975-maximum-matrix-sum.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxMatrixSum(self, matrix: List[List[int]]) -> int: 3 | ans = ne = 0 4 | mini = float('inf') 5 | 6 | for r in matrix: 7 | for e in r: 8 | ne += e < 0 9 | ans += abs(e) 10 | mini = min(mini, abs(e)) 11 | 12 | return ans if ne % 2 == 0 else ans - 2 * mini -------------------------------------------------------------------------------- /1979-find-greatest-common-divisor-of-array/1979-find-greatest-common-divisor-of-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findGCD(self, nums: List[int]) -> int: 3 | mini = min(nums) 4 | maxi = max(nums) 5 | 6 | ans = float('-inf') 7 | 8 | for i in range(1, min(mini, maxi) + 1): 9 | if mini % i == 0 and maxi % i == 0: 10 | ans = max(ans, i) 11 | 12 | return ans -------------------------------------------------------------------------------- /1980-find-unique-binary-string/1980-find-unique-binary-string.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | string findDifferentBinaryString(vector& nums) { 5 | int i =0; 6 | string ans; 7 | for(string &str: nums){ 8 | ans.push_back(str[i]=='0'?'1':'0'); 9 | i++; 10 | } 11 | return ans; 12 | } 13 | }; -------------------------------------------------------------------------------- /1980-find-unique-binary-string/1980-find-unique-binary-string.go: -------------------------------------------------------------------------------- 1 | func findDifferentBinaryString(nums []string) string { 2 | ans := make([]byte, len(nums)) 3 | 4 | for i := 0; i < len(nums); i++ { 5 | if nums[i][i] == '0' { 6 | ans[i] = '1' 7 | } else { 8 | ans[i] = '0' 9 | } 10 | } 11 | 12 | return string(ans) 13 | } -------------------------------------------------------------------------------- /1980-find-unique-binary-string/NOTES.md: -------------------------------------------------------------------------------- 1 | ​ -------------------------------------------------------------------------------- /2000-reverse-prefix-of-word/2000-reverse-prefix-of-word.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | string reversePrefix(string word, char ch) { 4 | reverse(word.begin(), word.begin() + word.find(ch) + 1); 5 | return word; 6 | } 7 | }; -------------------------------------------------------------------------------- /2011-final-value-of-variable-after-performing-operations/2011-final-value-of-variable-after-performing-operations.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def finalValueAfterOperations(self, operations: List[str]) -> int: 3 | ans = 0 4 | 5 | for string in operations: 6 | if string == "--X" or string == "X--": 7 | ans -= 1 8 | else: 9 | ans += 1 10 | 11 | return ans -------------------------------------------------------------------------------- /2032-largest-odd-number-in-string/2032-largest-odd-number-in-string.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {string} num 3 | * @return {string} 4 | */ 5 | var largestOddNumber = function(num) { 6 | const n=num.length 7 | let odd=-1 8 | for(let i=0;i int: 3 | seats.sort() 4 | stu.sort() 5 | ans = 0 6 | 7 | # for i in range(len(seats)): 8 | # ans += abs(stu[i] - seats[i]) 9 | 10 | for seat, student in zip(seats, stu): 11 | ans += abs(seat - student) 12 | 13 | return ans -------------------------------------------------------------------------------- /2042-maximum-product-difference-between-two-pairs/2042-maximum-product-difference-between-two-pairs.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxProductDifference(vector& nums) { 4 | sort(nums.begin(), nums.end()); 5 | int n = nums.size(); 6 | return nums[n-1]*nums[n-2] - nums[0]*nums[1]; 7 | } 8 | }; -------------------------------------------------------------------------------- /2053-kth-distinct-string-in-an-array/2053-kth-distinct-string-in-an-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def kthDistinct(self, arr: List[str], k: int) -> str: 3 | count = Counter(arr) 4 | ans = [] 5 | 6 | for s in arr: 7 | if count[s] == 1: 8 | ans.append(s) 9 | 10 | if len(ans) < k: 11 | return "" 12 | 13 | return ans[k - 1] -------------------------------------------------------------------------------- /2057-smallest-index-with-equal-value/2057-smallest-index-with-equal-value.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def smallestEqual(self, nums: List[int]) -> int: 3 | for i in range(len(nums)): 4 | if i % 10 == nums[i]: 5 | # ans = min(ans, i) 6 | return i 7 | 8 | return -1 -------------------------------------------------------------------------------- /2073-time-needed-to-buy-tickets/2073-time-needed-to-buy-tickets.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int timeRequiredToBuy(vector& tickets, int k) { 4 | int ans = 0; 5 | for (int i = 0; i < tickets.size(); i++) { 6 | if (i > k) ans += min(tickets[i], tickets[k] - 1); 7 | else ans += min(tickets[i], tickets[k]); 8 | } 9 | return ans; 10 | } 11 | }; -------------------------------------------------------------------------------- /2089-find-target-indices-after-sorting-array/2089-find-target-indices-after-sorting-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector targetIndices(vector& nums, int target) { 4 | sort(nums.begin(), nums.end()); 5 | vector ans; 6 | for (int i = 0; i < nums.size(); i++) { 7 | if (nums[i] == target) ans.push_back(i); 8 | } 9 | return ans; 10 | } 11 | }; -------------------------------------------------------------------------------- /2099-find-subsequence-of-length-k-with-the-largest-sum/2099-find-subsequence-of-length-k-with-the-largest-sum.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxSubsequence(self, nums: List[int], k: int) -> List[int]: 3 | temp = list(enumerate(nums)) 4 | sorted_temp = sorted(temp, key = lambda x: x[1]) 5 | sorted_temp.reverse() 6 | idx = sorted_temp[ : k] 7 | idx = sorted(idx, key = lambda x: x[0]) 8 | 9 | return [x[1] for x in idx] -------------------------------------------------------------------------------- /2104-sum-of-subarray-ranges/2104-sum-of-subarray-ranges.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def subArrayRanges(self, nums: List[int]) -> int: 3 | ans = 0 4 | 5 | for i in range(len(nums)): 6 | mini = float('inf') 7 | maxi = float('-inf') 8 | for j in range(i, len(nums)): 9 | mini = min(mini, nums[j]) 10 | maxi = max(maxi, nums[j]) 11 | ans = ans + (maxi - mini) 12 | 13 | return ans -------------------------------------------------------------------------------- /2114-maximum-number-of-words-found-in-sentences/2114-maximum-number-of-words-found-in-sentences.go: -------------------------------------------------------------------------------- 1 | func mostWordsFound(sentences []string) int { 2 | maxi := 0 3 | 4 | for _, sen := range sentences { 5 | word := strings.Split(sen, " ") 6 | if len(word) > maxi { 7 | maxi = len(word) 8 | } 9 | } 10 | 11 | return maxi 12 | } -------------------------------------------------------------------------------- /2114-maximum-number-of-words-found-in-sentences/2114-maximum-number-of-words-found-in-sentences.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def mostWordsFound(self, sentences: List[str]) -> int: 3 | maxi = 0 4 | 5 | for sen in sentences: 6 | word = sen.split(" ") 7 | if len(word) > maxi: 8 | maxi = len(word) 9 | 10 | return maxi -------------------------------------------------------------------------------- /2119-a-number-after-a-double-reversal/2119-a-number-after-a-double-reversal.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isSameAfterReversals(self, num: int) -> bool: 3 | x = str(num) 4 | x = x[::-1] 5 | # print(int(x)) 6 | new = str(int(x)) 7 | new = new[::-1] 8 | # print(int(new)) 9 | return num == int(new) -------------------------------------------------------------------------------- /2124-check-if-all-as-appears-before-all-bs/2124-check-if-all-as-appears-before-all-bs.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def checkString(self, s: str) -> bool: 3 | for i in range(1, len(s)): 4 | if s[i] == 'a' and s[i - 1] == 'b': 5 | return False 6 | 7 | return True -------------------------------------------------------------------------------- /2134-minimum-swaps-to-group-all-1s-together-ii/2134-minimum-swaps-to-group-all-1s-together-ii.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minSwaps(self, nums: List[int]) -> int: 3 | SUM = sum(nums) 4 | ones = sum(nums[-1 * SUM : ]) 5 | temp = ones 6 | 7 | for i in range(len(nums)): 8 | ones += nums[i] - nums[i - SUM] 9 | if ones > temp: 10 | temp = ones 11 | 12 | return SUM - temp -------------------------------------------------------------------------------- /2136-earliest-possible-day-of-full-bloom/2136-earliest-possible-day-of-full-bloom.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def earliestFullBloom(self, pt: List[int], gt: List[int]) -> int: 3 | nums = sorted(zip(gt, pt)) 4 | nums.reverse() 5 | 6 | ans = 0 7 | t = 0 8 | 9 | for a, b in nums: 10 | t += b 11 | ans = max(ans, t + a) 12 | 13 | return ans -------------------------------------------------------------------------------- /2140-solving-questions-with-brainpower/2140-solving-questions-with-brainpower.go: -------------------------------------------------------------------------------- 1 | func mostPoints(arr [][]int) int64 { 2 | ans, prev := make([]int, len(arr)), 0 3 | 4 | for i := len(arr) - 1; i >= 0; i-- { 5 | x := arr[i] 6 | p, s := x[0], x[1] 7 | pp := 0 8 | if i+s+1 < len(arr) { 9 | pp = ans[i+s+1] 10 | } 11 | if p+pp > prev { 12 | prev = p + pp 13 | } 14 | ans[i] = prev 15 | } 16 | 17 | return int64(ans[0]) 18 | } -------------------------------------------------------------------------------- /2144-minimum-cost-of-buying-candies-with-discount/2144-minimum-cost-of-buying-candies-with-discount.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minimumCost(self, cost: List[int]) -> int: 3 | cost.sort(reverse = True) 4 | ans = 0 5 | cnt = 0 6 | 7 | for candy in cost: 8 | if cnt == 2: 9 | cnt = 0 10 | continue 11 | cnt += 1 12 | ans += candy 13 | 14 | return ans -------------------------------------------------------------------------------- /2145-count-the-hidden-sequences/2145-count-the-hidden-sequences.go: -------------------------------------------------------------------------------- 1 | func numberOfArrays(dx []int, l int, u int) int { 2 | mini, maxi := l, 3 | 4 | for i := range dx { 5 | if dx[i] > 0 { 6 | if mini+dx[i] > u { return 0 } 7 | mini += dx[i] 8 | maxi = min(u, maxi+dx[i]) 9 | } else if dx[i] < 0 { 10 | if maxi+dx[i] < l { return 0 } 11 | maxi += dx[i] 12 | mini = max(mini+dx[i], l) 13 | } 14 | } 15 | 16 | return 1 + maxi - mini 17 | } -------------------------------------------------------------------------------- /2148-count-elements-with-strictly-smaller-and-greater-elements/2148-count-elements-with-strictly-smaller-and-greater-elements.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countElements(self, nums: List[int]) -> int: 3 | mini = min(nums) 4 | maxi = max(nums) 5 | 6 | ans = 0 7 | 8 | for num in nums: 9 | if num > mini and num < maxi: 10 | ans += 1 11 | 12 | return ans -------------------------------------------------------------------------------- /2154-keep-multiplying-found-values-by-two/2154-keep-multiplying-found-values-by-two.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findFinalValue(self, nums: List[int], og: int) -> int: 3 | while og in nums: 4 | og *= 2 5 | 6 | return og -------------------------------------------------------------------------------- /2169-count-operations-to-obtain-zero/2169-count-operations-to-obtain-zero.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countOperations(self, num1: int, num2: int) -> int: 3 | cnt = 0 4 | 5 | while num1 > 0 and num2 > 0: 6 | if num1 >= num2: 7 | num1 -= num2 8 | else: 9 | num2 -= num1 10 | cnt += 1 11 | 12 | return cnt -------------------------------------------------------------------------------- /2176-count-equal-and-divisible-pairs-in-an-array/2176-count-equal-and-divisible-pairs-in-an-array.go: -------------------------------------------------------------------------------- 1 | func countPairs(nums []int, k int) int { 2 | ans := 0 3 | 4 | for i := 0; i < len(nums)-1; i++ { 5 | for j := i + 1; j < len(nums); j++ { 6 | if nums[i] == nums[j] && (i*j)%k == 0 { 7 | ans++ 8 | } 9 | } 10 | } 11 | 12 | return ans 13 | } -------------------------------------------------------------------------------- /2176-count-equal-and-divisible-pairs-in-an-array/2176-count-equal-and-divisible-pairs-in-an-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countPairs(self, nums: List[int], k: int) -> int: 3 | ans = 0 4 | 5 | for i in range(len(nums)): 6 | for j in range(i + 1, len(nums)): 7 | if nums[i] == nums[j] and (i * j) % k == 0: 8 | ans += 1 9 | 10 | return ans -------------------------------------------------------------------------------- /2177-find-three-consecutive-integers-that-sum-to-a-given-number/2177-find-three-consecutive-integers-that-sum-to-a-given-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector sumOfThree(long long num) { 4 | if (num % 3 != 0) return {}; 5 | long long i = num / 3; 6 | return {i - 1, i, i + 1}; 7 | } 8 | }; -------------------------------------------------------------------------------- /2185-counting-words-with-a-given-prefix/2185-counting-words-with-a-given-prefix.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def prefixCount(self, words: List[str], pref: str) -> int: 3 | ans = 0 4 | 5 | for word in words: 6 | if word.startswith(pref): 7 | ans += 1 8 | 9 | return ans -------------------------------------------------------------------------------- /2191-sort-the-jumbled-numbers/2191-sort-the-jumbled-numbers.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def sortJumbled(self, m: List[int], nums: List[int]) -> List[int]: 3 | def compare(num): 4 | ans = 0 5 | for char in str(num): 6 | ans += m[int(char)] 7 | ans = ans * 10 8 | return 9 | 10 | nums.sort(key = lambda x: compare(x)) 11 | 12 | return nums -------------------------------------------------------------------------------- /2206-divide-array-into-equal-pairs/2206-divide-array-into-equal-pairs.go: -------------------------------------------------------------------------------- 1 | func divideArray(nums []int) bool { 2 | mp := make(map[int]int) 3 | 4 | for _, num := range nums { 5 | mp[num]++ 6 | } 7 | 8 | for _, val := range mp { 9 | if val & 1 == 1 { 10 | return false 11 | } 12 | } 13 | 14 | return true 15 | } -------------------------------------------------------------------------------- /2206-divide-array-into-equal-pairs/2206-divide-array-into-equal-pairs.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def divideArray(self, nums: List[int]) -> bool: 3 | # n = len(nums) // 2 4 | 5 | count = Counter(nums) 6 | 7 | for i, j in count.items(): 8 | if j % 2 != 0: 9 | return False 10 | 11 | return True -------------------------------------------------------------------------------- /2220-minimum-bit-flips-to-convert-number/2220-minimum-bit-flips-to-convert-number.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minBitFlips(self, s: int, g: int) -> int: 3 | ans = 0 4 | 5 | while s > 0 or g > 0: 6 | if s % 2 != g % 2: 7 | ans += 1 8 | s = s // 2 9 | g = g // 2 10 | 11 | return ans -------------------------------------------------------------------------------- /2221-find-triangular-sum-of-an-array/2221-find-triangular-sum-of-an-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def triangularSum(self, nums: List[int]) -> int: 3 | while len(nums) > 1: 4 | temp = [] 5 | for i in range(len(nums) - 1): 6 | temp.append((nums[i + 1] + nums[i]) % 10) 7 | nums = temp 8 | 9 | return nums[0] -------------------------------------------------------------------------------- /2235-add-two-integers/2235-add-two-integers.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def sum(self, num1: int, num2: int) -> int: 3 | return num1 + num2 -------------------------------------------------------------------------------- /2236-root-equals-sum-of-children/2236-root-equals-sum-of-children.py: -------------------------------------------------------------------------------- 1 | # Definition for a binary tree node. 2 | # class TreeNode: 3 | # def __init__(self, val=0, left=None, right=None): 4 | # self.val = val 5 | # self.left = left 6 | # self.right = right 7 | class Solution: 8 | def checkTree(self, root: Optional[TreeNode]) -> bool: 9 | root_val = root.val 10 | children_val = root.left.val + root.right.val 11 | 12 | return root_val == children_val -------------------------------------------------------------------------------- /2270-number-of-ways-to-split-array/2270-number-of-ways-to-split-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def waysToSplitArray(self, nums: List[int]) -> int: 3 | lsum, rsum = 0, sum(nums) 4 | ans = 0 5 | 6 | for i in range(len(nums) - 1): 7 | lsum += nums[i]; rsum -= nums[i] 8 | if lsum >= rsum: 9 | ans += 1 10 | 11 | return ans -------------------------------------------------------------------------------- /2275-largest-combination-with-bitwise-and-greater-than-zero/2275-largest-combination-with-bitwise-and-greater-than-zero.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def largestCombination(self, c: List[int]) -> int: 3 | ans = 0 4 | 5 | for i in range(32): 6 | cnt = 0 7 | for n in c: 8 | if n & 1 << i: 9 | cnt += 1 10 | ans = max(ans, cnt) 11 | 12 | return ans -------------------------------------------------------------------------------- /2278-percentage-of-letter-in-string/2278-percentage-of-letter-in-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def percentageLetter(self, s: str, letter: str) -> int: 3 | n = len(s) 4 | count = Counter(s) 5 | print(count[letter]) 6 | 7 | return int((count[letter] / n) * 100) -------------------------------------------------------------------------------- /2285-maximum-total-importance-of-roads/2285-maximum-total-importance-of-roads.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maximumImportance(self, n: int, roads: List[List[int]]) -> int: 3 | edges = [0 for i in range(n)] 4 | 5 | for u, v in roads: 6 | edges[u] += 1 7 | edges[v] += 1 8 | 9 | edges.sort() 10 | val = 1 11 | ans = 0 12 | 13 | for cnt in edges: 14 | ans += cnt * val 15 | val += 1 16 | 17 | return ans -------------------------------------------------------------------------------- /2317-maximum-xor-after-operations/2317-maximum-xor-after-operations.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maximumXOR(self, nums: List[int]) -> int: 3 | ans = 0 4 | 5 | for num in nums: 6 | ans = ans | num 7 | 8 | return ans -------------------------------------------------------------------------------- /2319-check-if-matrix-is-x-matrix/2319-check-if-matrix-is-x-matrix.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def checkXMatrix(self, grid: List[List[int]]) -> bool: 3 | for i in range(len(grid)): 4 | for j in range(len(grid[0])): 5 | if ((i == j) or (i + j == len(grid) - 1)): 6 | if (grid[i][j] == 0): 7 | return False 8 | elif grid[i][j] != 0: 9 | return False 10 | 11 | return True -------------------------------------------------------------------------------- /2342-max-sum-of-a-pair-with-equal-sum-of-digits/2342-max-sum-of-a-pair-with-equal-sum-of-digits.go: -------------------------------------------------------------------------------- 1 | func maximumSum(nums []int) int { 2 | mp := make(map[int]int) 3 | ans := -1 4 | 5 | for _, num := range nums { 6 | x, ds := num, 0 7 | for x > 0 { 8 | ds += x % 10 9 | x /= 10 10 | } 11 | if ele, found := mp[ds]; found { 12 | if ele + num > ans { 13 | ans = ele + num 14 | } 15 | } 16 | if num > mp[ds] { 17 | mp[ds] = num 18 | } 19 | } 20 | 21 | return ans 22 | } -------------------------------------------------------------------------------- /2350-shortest-impossible-sequence-of-rolls/2350-shortest-impossible-sequence-of-rolls.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def shortestSequence(self, r: List[int], k: int) -> int: 3 | x, ans = 0, 1 4 | 5 | while 1: 6 | mp = defaultdict(int) 7 | while len(mp) != k: 8 | if x == len(r): 9 | return ans 10 | mp[r[x]] += 1 11 | x += 1 12 | ans += 1 13 | -------------------------------------------------------------------------------- /2351-first-letter-to-appear-twice/2351-first-letter-to-appear-twice.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | char repeatedCharacter(string s) { 4 | vector freq(26, false); 5 | for (auto ch : s) { 6 | if (freq[ch - 'a'] == true) return ch; 7 | else freq[ch - 'a'] = true; 8 | } 9 | return 'a'; 10 | } 11 | }; -------------------------------------------------------------------------------- /2357-make-array-zero-by-subtracting-equal-amounts/2357-make-array-zero-by-subtracting-equal-amounts.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minimumOperations(vector& nums) { 4 | unordered_map mp; 5 | for (auto num : nums) { 6 | if (num != 0) mp[num]++; 7 | } 8 | return mp.size(); 9 | } 10 | }; -------------------------------------------------------------------------------- /2364-count-number-of-bad-pairs/2364-count-number-of-bad-pairs.go: -------------------------------------------------------------------------------- 1 | type long = int64 2 | 3 | func countBadPairs(nums []int) long { 4 | n := len(nums) 5 | mp := make(map[int]int64) 6 | x := long(0) 7 | 8 | for i, e := range nums { 9 | x += mp[e - i] 10 | mp[e - i]++ 11 | } 12 | 13 | return long(n * (n - 1) / 2) - x 14 | } -------------------------------------------------------------------------------- /2367-number-of-arithmetic-triplets/2367-number-of-arithmetic-triplets.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def arithmeticTriplets(self, nums: List[int], diff: int) -> int: 3 | ans = 0 4 | AP = set(nums) 5 | 6 | for num in nums: 7 | if num - diff in AP and num + diff in AP: 8 | ans += 1 9 | 10 | return ans -------------------------------------------------------------------------------- /2375-construct-smallest-number-from-di-string/2375-construct-smallest-number-from-di-string.go: -------------------------------------------------------------------------------- 1 | func smallestNumber(p string) string { 2 | ans, nums:= "", make([]int, 0) 3 | 4 | for i := 0; i <= len(p); i++ { 5 | nums = append(nums, i + 1) 6 | if i == len(p) || p[i] == 'I' { 7 | for len(nums) > 0 { 8 | ans += strconv.Itoa(nums[len(nums)-1]) 9 | nums = nums[:len(nums) - 1] 10 | } 11 | } 12 | } 13 | 14 | return ans 15 | } -------------------------------------------------------------------------------- /2379-minimum-recolors-to-get-k-consecutive-black-blocks/2379-minimum-recolors-to-get-k-consecutive-black-blocks.go: -------------------------------------------------------------------------------- 1 | func minimumRecolors(blocks string, k int) int { 2 | ans := int(1e9) 3 | 4 | for i := range len(blocks) - (k - 1) { 5 | w := 0 6 | for j := i; j - i < k; j++ { 7 | if blocks[j] == 'W' { 8 | w += 1 9 | } 10 | } 11 | if w < ans { 12 | ans = w 13 | } 14 | } 15 | 16 | return ans 17 | } -------------------------------------------------------------------------------- /2381-shifting-letters-ii/2381-shifting-letters-ii.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def shiftingLetters(self, st: str, sh: List[List[int]]) -> str: 3 | ans, x = [0 for _ in range(len(st))], -97 4 | 5 | for s, e, d in sh: 6 | ans[s] += 1 if d else -1 7 | if e + 1 < len(st): 8 | ans[e + 1] -= 1 if d else -1 9 | 10 | for i in range(len(st)): 11 | x += ans[i] 12 | ans[i] = chr((ord(st[i]) + x) % 26 + 97) 13 | 14 | return "".join(ans) -------------------------------------------------------------------------------- /2390-removing-stars-from-a-string/2390-removing-stars-from-a-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def removeStars(self, s: str) -> str: 3 | ans = [] 4 | for c in s: 5 | if c == '*': 6 | ans.pop() 7 | else: 8 | ans.append(c) 9 | return ''.join(ans) 10 | -------------------------------------------------------------------------------- /2392-successful-pairs-of-spells-and-potions/2392-successful-pairs-of-spells-and-potions.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | vector successfulPairs(vector& spells, vector& potions, long long success) { 5 | ranges::sort(potions); 6 | --success; 7 | for (int& s : spells) 8 | s = end(potions) - ranges::upper_bound(potions, success/s); 9 | return spells; 10 | } 11 | }; -------------------------------------------------------------------------------- /2396-strictly-palindromic-number/2396-strictly-palindromic-number.rs: -------------------------------------------------------------------------------- 1 | impl Solution { 2 | pub fn is_strictly_palindromic(n: i32) -> bool { 3 | false 4 | } 5 | } -------------------------------------------------------------------------------- /2401-longest-nice-subarray/2401-longest-nice-subarray.go: -------------------------------------------------------------------------------- 1 | func longestNiceSubarray(nums []int) int { 2 | var ans int 3 | ans = 1 4 | 5 | for l, r, o := 0, 0, 0; r < len(nums); { 6 | if o & nums[r] == 0 { 7 | o |= nums[r] 8 | curr := r - l + 1 9 | if curr > ans { 10 | ans = curr 11 | } 12 | r++ 13 | } else { 14 | o ^= nums[l] 15 | l++ 16 | } 17 | } 18 | 19 | return ans 20 | } -------------------------------------------------------------------------------- /2404-most-frequent-even-element/2404-most-frequent-even-element.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def mostFrequentEven(self, nums: List[int]) -> int: 3 | count = Counter([i for i in nums if i % 2 == 0]) 4 | 5 | if not count: 6 | return -1 7 | 8 | max_freq = max(count.values()) 9 | 10 | return min([i for i, j in count.items() if j == max_freq]) -------------------------------------------------------------------------------- /2405-optimal-partition-of-string/2405-optimal-partition-of-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def partitionString(self, s: str) -> int: 3 | visited = set() 4 | ans = 0 5 | 6 | for char in s: 7 | if char not in visited: 8 | visited.add(char) 9 | else: 10 | ans += 1 11 | visited = {char} 12 | 13 | return ans + 1 -------------------------------------------------------------------------------- /2406-divide-intervals-into-minimum-number-of-groups/2406-divide-intervals-into-minimum-number-of-groups.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minGroups(self, ii: List[List[int]]) -> int: 3 | ii.sort() 4 | heap = [] 5 | 6 | for i in ii: 7 | if not heap or i[0] <= heap[0]: 8 | heappush(heap, i[1]) 9 | else: 10 | heappop(heap) 11 | heappush(heap, i[1]) 12 | 13 | return len(heap) -------------------------------------------------------------------------------- /2413-smallest-even-multiple/2413-smallest-even-multiple.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def smallestEvenMultiple(self, n: int) -> int: 3 | if n % 2 != 0: 4 | return 2 * n 5 | 6 | return n -------------------------------------------------------------------------------- /2414-length-of-the-longest-alphabetical-continuous-substring/2414-length-of-the-longest-alphabetical-continuous-substring.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int longestContinuousSubstring(string s) { 4 | int cnt = 1; 5 | int ans = 1; 6 | for (int i = 1; i < s.size(); i++) { 7 | if (s[i] == (s[i - 1] + 1)) cnt++; 8 | else cnt = 1; 9 | ans = max(ans, cnt); 10 | } 11 | return ans; 12 | } 13 | }; -------------------------------------------------------------------------------- /2418-sort-the-people/2418-sort-the-people.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def sortPeople(self, names: List[str], heights: List[int]) -> List[str]: 3 | pairs = list(zip(names, heights)) 4 | sorted_pairs = sorted(pairs, key = lambda x: x[1], reverse = True) 5 | 6 | return [name for name, height in sorted_pairs] -------------------------------------------------------------------------------- /2419-longest-subarray-with-maximum-bitwise-and/2419-longest-subarray-with-maximum-bitwise-and.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def longestSubarray(self, nums: List[int]) -> int: 3 | ans = 0 4 | maxi = max(nums) 5 | curr = 0 6 | 7 | for num in nums: 8 | # curr = 0 9 | if num == maxi: 10 | curr += 1 11 | ans = max(ans, curr) 12 | continue 13 | curr = 0 14 | 15 | return ans -------------------------------------------------------------------------------- /2425-bitwise-xor-of-all-pairings/2425-bitwise-xor-of-all-pairings.go: -------------------------------------------------------------------------------- 1 | func xorAllNums(n1 []int, n2 []int) int { 2 | ans := 0 3 | 4 | if len(n2) & 1 == 1 { 5 | for _, x := range n1 { 6 | ans = ans ^ x 7 | } 8 | } 9 | 10 | if len(n1) & 1 == 1 { 11 | for _, x := range n2 { 12 | ans = ans ^ x 13 | } 14 | } 15 | 16 | return ans 17 | } -------------------------------------------------------------------------------- /2427-number-of-common-factors/2427-number-of-common-factors.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def commonFactors(self, a: int, b: int) -> int: 3 | cnt = 0 4 | 5 | # for i in range(1, 1000 + 1): 6 | for i in range(1, min(a, b) + 1): 7 | if a % i == 0 and b % i == 0: 8 | cnt += 1 9 | 10 | return cnt -------------------------------------------------------------------------------- /2439-minimize-maximum-of-array/2439-minimize-maximum-of-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minimizeArrayValue(self, nums: List[int]) -> int: 3 | ans = SUM = nums[0] 4 | 5 | for i in range(1, len(nums)): 6 | SUM += nums[i] 7 | ans = max(ans, (SUM + i) // (i + 1)) 8 | 9 | return ans -------------------------------------------------------------------------------- /2441-largest-positive-integer-that-exists-with-its-negative/2441-largest-positive-integer-that-exists-with-its-negative.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findMaxK(vector& nums) { 4 | unordered_set st(nums.begin(), nums.end()); 5 | int ans = -1; 6 | for (auto n : nums) { 7 | if (st.find(-n) != st.end() && n > ans) ans = n; 8 | } 9 | return ans; 10 | } 11 | }; -------------------------------------------------------------------------------- /2455-average-value-of-even-numbers-that-are-divisible-by-three/2455-average-value-of-even-numbers-that-are-divisible-by-three.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def averageValue(self, nums: List[int]) -> int: 3 | avg = 0 4 | cnt = 0 5 | 6 | for num in nums: 7 | if num % 2 == 0 and num % 3 == 0: 8 | avg += num 9 | cnt += 1 10 | 11 | if cnt == 0: 12 | return 0 13 | 14 | return avg // cnt -------------------------------------------------------------------------------- /2469-convert-the-temperature/2469-convert-the-temperature.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def convertTemperature(self, c: float) -> List[float]: 3 | return [c + 273.15, c * 1.80 + 32.00] -------------------------------------------------------------------------------- /2486-append-characters-to-string-to-make-subsequence/2486-append-characters-to-string-to-make-subsequence.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int appendCharacters(string s, string t) { 4 | int i = 0; 5 | int j = 0; 6 | while (i < s.size()) { 7 | if (s[i] == t[j]) j++; 8 | i++; 9 | } 10 | return t.size() - j; 11 | } 12 | }; -------------------------------------------------------------------------------- /2490-circular-sentence/2490-circular-sentence.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isCircularSentence(self, s: str) -> bool: 3 | if s[0] != s[-1]: 4 | return False 5 | 6 | for i in range(1, len(s) - 1): 7 | if s[i] == ' ': 8 | if s[i - 1] != s[i + 1]: 9 | return False 10 | 11 | return True -------------------------------------------------------------------------------- /2501-longest-square-streak-in-an-array/2501-longest-square-streak-in-an-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def longestSquareStreak(self, nums: List[int]) -> int: 3 | SET = set(nums) 4 | s = 0 5 | 6 | for num in SET: 7 | x = 1 8 | while num**2 in SET: 9 | x += 1 10 | num = num**2 11 | s = max(s, x) 12 | 13 | if s == 1: 14 | return -1 15 | 16 | return s -------------------------------------------------------------------------------- /2506-count-pairs-of-similar-strings/2506-count-pairs-of-similar-strings.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def similarPairs(self, words: List[str]) -> int: 3 | cnt = 0 4 | 5 | for i in range(len(words)): 6 | for j in range(i + 1, len(words)): 7 | if set(words[j]) == set(words[i]): 8 | cnt += 1 9 | 10 | return cnt -------------------------------------------------------------------------------- /2529-maximum-count-of-positive-integer-and-negative-integer/2529-maximum-count-of-positive-integer-and-negative-integer.go: -------------------------------------------------------------------------------- 1 | func maximumCount(nums []int) int { 2 | var n, p int 3 | n, p = 0, 0 4 | 5 | for _, num := range nums { 6 | if num < 0 { 7 | n++ 8 | } else if num > 0 { 9 | p++ 10 | } 11 | } 12 | 13 | return max(n, p) 14 | } -------------------------------------------------------------------------------- /2529-maximum-count-of-positive-integer-and-negative-integer/2529-maximum-count-of-positive-integer-and-negative-integer.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maximumCount(self, nums: List[int]) -> int: 3 | p = 0 4 | n = 0 5 | 6 | for num in nums: 7 | if num > 0: 8 | p += 1 9 | if num < 0: 10 | n += 1 11 | 12 | return max(p, n) -------------------------------------------------------------------------------- /2537-count-the-number-of-good-subarrays/2537-count-the-number-of-good-subarrays.go: -------------------------------------------------------------------------------- 1 | func countGood(nums []int, k int) int64 { 2 | var t, tot int64 = 0, 0 3 | vis := make(map[int]int) 4 | n := int64(len(nums)) 5 | j := 0 6 | 7 | for i := 0; i < len(nums); i++ { 8 | vis[nums[i]]++ 9 | t += int64(vis[nums[i]] - 1) 10 | for j < i && t > int64(k-1) { 11 | t -= int64(vis[nums[j]] - 1) 12 | vis[nums[j]]-- 13 | j++ 14 | } 15 | tot += int64(i - j + 1) 16 | } 17 | 18 | return n*(n+1)/2 - tot 19 | } -------------------------------------------------------------------------------- /2545-sort-the-students-by-their-kth-score/2545-sort-the-students-by-their-kth-score.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def sortTheStudents(self, score: List[List[int]], k: int) -> List[List[int]]: 3 | mp = defaultdict(int) 4 | 5 | for stu in score: 6 | mp[stu[k]] = stu 7 | 8 | mp2 = sorted(mp, reverse = True) 9 | ans = [] 10 | 11 | for marks in mp2: 12 | ans.append(mp[marks]) 13 | 14 | return ans -------------------------------------------------------------------------------- /2551-put-marbles-in-bags/2551-put-marbles-in-bags.go: -------------------------------------------------------------------------------- 1 | func putMarbles(ws []int, k int) int64 { 2 | n := len(ws) 3 | if k == 1 { 4 | return 0 5 | } 6 | 7 | ps := make([]int, n-1) 8 | for i := 0; i < n-1; i++ { 9 | ps[i] = ws[i] + ws[i+1] 10 | } 11 | sort.Ints(ps) 12 | 13 | var mini, maxi int64 = 0, 0 14 | 15 | for i := 0; i < k-1; i++ { 16 | mini += int64(ps[i]) 17 | maxi += int64(ps[n-2-i]) 18 | } 19 | 20 | return maxi - mini 21 | } -------------------------------------------------------------------------------- /2558-take-gifts-from-the-richest-pile/2558-take-gifts-from-the-richest-pile.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def pickGifts(self, g: List[int], k: int) -> int: 3 | g = [-i for i in g] 4 | heapify(g) 5 | 6 | while k > 0: 7 | val = -1 * heappop(g) 8 | heappush(g, -1 * floor(sqrt(val))) 9 | k -= 1 10 | 11 | return -1 * sum(g) -------------------------------------------------------------------------------- /2560-house-robber-iv/2560-house-robber-iv.go: -------------------------------------------------------------------------------- 1 | func minCapability(nums []int, k int) int { 2 | l, r := 1, int(1e9) 3 | 4 | for l <= r { 5 | m := (l+r) >> 1 6 | x := 0 7 | for i := 0; i < len(nums); { 8 | if nums[i] <= m { 9 | i += 2 10 | x++ 11 | if x >= k { 12 | break 13 | } 14 | } else { 15 | i++ 16 | } 17 | } 18 | if x >= k { 19 | r = m - 1 20 | } else { 21 | l = m + 1 22 | } 23 | } 24 | 25 | return r + 1 26 | } -------------------------------------------------------------------------------- /2579-count-total-number-of-colored-cells/2579-count-total-number-of-colored-cells.go: -------------------------------------------------------------------------------- 1 | func coloredCells(n int) int64 { 2 | var ans int64 3 | ans = 1 4 | 5 | var x int64 6 | x = 4 7 | 8 | for n - 1 > 0 { 9 | n-- 10 | ans += x 11 | x += 4 12 | } 13 | 14 | return ans 15 | } -------------------------------------------------------------------------------- /2582-pass-the-pillow/2582-pass-the-pillow.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def passThePillow(self, n: int, time: int) -> int: 3 | cycle = (time - 1) // (n - 1) 4 | position = (time - 1) % (n - 1) 5 | 6 | if cycle % 2 != 0: 7 | return n - position - 1 8 | 9 | return position + -------------------------------------------------------------------------------- /2586-count-the-number-of-vowel-strings-in-range/2586-count-the-number-of-vowel-strings-in-range.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def vowelStrings(self, words: List[str], left: int, right: int) -> int: 3 | cnt = 0 4 | 5 | for i in range(left, right + 1): 6 | if words[i][0] in vowels and words[i][-1] in vowels: 7 | cnt += 1 8 | 9 | return cnt -------------------------------------------------------------------------------- /2594-minimum-time-to-repair-cars/2594-minimum-time-to-repair-cars.go: -------------------------------------------------------------------------------- 1 | func repairCars(rs []int, cars int) int64 { 2 | var low, high int64 = 0, math.MaxInt 3 | 4 | for low < high { 5 | mid := (low + high) / 2 6 | x := 0 7 | for _, r := range rs { 8 | x += int(math.Sqrt(float64(mid/int64(r)))) 9 | } 10 | if x < cars { 11 | low = mid + 1 12 | } else { 13 | high = mid 14 | } 15 | } 16 | 17 | return low 18 | } -------------------------------------------------------------------------------- /2595-number-of-even-and-odd-bits/2595-number-of-even-and-odd-bits.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def evenOddBit(self, n: int) -> List[int]: 3 | odd, even, pos = 0, 0, 0 4 | 5 | while n > 0: 6 | curr = n % 2 7 | if n % 2 == 1: 8 | if pos % 2 != 0: 9 | odd += 1 10 | else: 11 | even += 1 12 | n = n // 2 13 | pos += 1 14 | 15 | return [even, odd] -------------------------------------------------------------------------------- /2648-generate-fibonacci-sequence/2648-generate-fibonacci-sequence.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @return {Generator} 3 | */ 4 | var fibGenerator = function*() { 5 | var sL = 0; 6 | var L = 1; 7 | while(true) { 8 | yield sL; 9 | var sum = sL + L; 10 | sL = L; 11 | L = sum; 12 | } 13 | }; 14 | 15 | /** 16 | * const gen = fibGenerator(); 17 | * gen.next().value; // 0 18 | * gen.next().value; // 1 19 | */ -------------------------------------------------------------------------------- /2651-calculate-delayed-arrival-time/2651-calculate-delayed-arrival-time.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findDelayedArrivalTime(self, at: int, dt: int) -> int: 3 | SUM = at + dt 4 | 5 | if SUM == 24: 6 | return 0 7 | 8 | return SUM if SUM < 24 else SUM - dt -------------------------------------------------------------------------------- /2652-sum-multiples/2652-sum-multiples.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def sumOfMultiples(self, n: int) -> int: 3 | SUM = 0 4 | 5 | for i in range(1, n + 1): 6 | if i % 3 == 0 or i % 5 == 0 or i % 7 == 0: 7 | SUM += i 8 | 9 | return SUM -------------------------------------------------------------------------------- /2656-maximum-sum-with-exactly-k-elements/2656-maximum-sum-with-exactly-k-elements.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maximizeSum(self, nums: List[int], k: int) -> int: 3 | ans = 0 4 | 5 | while k > 0: 6 | maxi = max(nums) 7 | nums.remove(maxi) 8 | nums.append(maxi + 1) 9 | ans += maxi 10 | k -= 1 11 | 12 | return ans -------------------------------------------------------------------------------- /2678-number-of-senior-citizens/2678-number-of-senior-citizens.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countSeniors(self, details: List[str]) -> int: 3 | ans = 0 4 | 5 | for ch in details: 6 | if int(ch[11 : 13]) > 60: 7 | ans += 1 8 | 9 | return ans -------------------------------------------------------------------------------- /2683-neighboring-bitwise-xor/2683-neighboring-bitwise-xor.go: -------------------------------------------------------------------------------- 1 | func doesValidArrayExist(d []int) bool { 2 | e := 0 3 | 4 | for _, n := range d { 5 | if n == 1 { 6 | e = ^e 7 | } 8 | } 9 | 10 | return e == 0 11 | } -------------------------------------------------------------------------------- /2696-minimum-string-length-after-removing-substrings/2696-minimum-string-length-after-removing-substrings.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minLength(self, s: str) -> int: 3 | while "AB" or "CD" in s: 4 | s = s.replace("AB","") 5 | s = s.replace("CD","") 6 | 7 | return len(s) -------------------------------------------------------------------------------- /2697-lexicographically-smallest-palindrome/2697-lexicographically-smallest-palindrome.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def makeSmallestPalindrome(self, s: str) -> str: 3 | ans = list(s) 4 | 5 | for i in range(len(s)): 6 | if ans[i] != ans[len(s) - i - 1]: 7 | lex = min(ans[i], ans[len(s) - i - 1]) 8 | ans[i] = ans[len(s) - i - 1] = lex 9 | 10 | return "".join(ans) -------------------------------------------------------------------------------- /2716-minimize-string-length/2716-minimize-string-length.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minimizedStringLength(string s) { 4 | unordered_map mp; 5 | for (int i = 0; i < s.size(); i++) { 6 | mp[s[i]]++; 7 | } 8 | return mp.size(); 9 | } 10 | }; -------------------------------------------------------------------------------- /2732-counter/2732-counter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number} n 3 | * @return {Function} counter 4 | */ 5 | var createCounter = function(n) { 6 | let v=n; 7 | return function() { 8 | return (v++); 9 | }; 10 | }; 11 | 12 | /** 13 | * const counter = createCounter(10) 14 | * counter() // 10 15 | * counter() // 11 16 | * counter() // 12 17 | */ -------------------------------------------------------------------------------- /2733-neither-minimum-nor-maximum/2733-neither-minimum-nor-maximum.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findNonMinOrMax(self, nums: List[int]) -> int: 3 | maxi = max(nums) 4 | mini = min(nums) 5 | 6 | for num in nums: 7 | if num != maxi and num != mini: 8 | return num 9 | 10 | return -1 -------------------------------------------------------------------------------- /2733-sleep/2733-sleep.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number} millis 3 | */ 4 | const sleep = async (millis) => new Promise( resolve => setTimeout(()=> resolve(millis), millis)) 5 | 6 | /** 7 | * let t = Date.now() 8 | * sleep(100).then(() => console.log(Date.now() - t)) // 100 9 | */ -------------------------------------------------------------------------------- /2741-function-composition/2741-function-composition.js: -------------------------------------------------------------------------------- 1 | var compose = function(functions) { 2 | return function(x) { 3 | let result=x; 4 | for(i=functions.length-1; i>=0; i--) 5 | { 6 | result = functions[i](result) 7 | } 8 | return result; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /2746-filter-elements-from-array/2746-filter-elements-from-array.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number[]} arr 3 | * @param {Function} fn 4 | * @return {number[]} 5 | */ 6 | var filter = function(arr, fn) { 7 | const newArr = []; 8 | for (let i = 0; i < arr.length; i++) 9 | if (fn(arr[i], i)) newArr.push(arr[i]); 10 | return newArr; 11 | }; -------------------------------------------------------------------------------- /2747-apply-transform-over-each-element-in-array/2747-apply-transform-over-each-element-in-array.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number[]} arr 3 | * @param {Function} fn 4 | * @return {number[]} 5 | */ 6 | var map = function(arr, fn) { 7 | var x=[]; 8 | for(let i=0;i& nums) { 4 | int ans = 0; 5 | for (int i = 1; i <= nums.size(); i++) { 6 | if (nums.size() % i == 0) ans = ans + (nums[i - 1] * nums[i - 1]); 7 | } 8 | return ans; 9 | } 10 | }; -------------------------------------------------------------------------------- /2778-sum-of-squares-of-special-elements/2778-sum-of-squares-of-special-elements.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def sumOfSquares(self, nums: List[int]) -> int: 3 | ans = 0 4 | 5 | for i in range(1, len(nums) + 1): 6 | if len(nums) % i == 0: 7 | ans = ans + (nums[i - 1] ** 2) 8 | 9 | return ans -------------------------------------------------------------------------------- /2779-maximum-beauty-of-an-array-after-applying-operation/2779-maximum-beauty-of-an-array-after-applying-operation.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maximumBeauty(self, nums: List[int], k: int) -> int: 3 | nums.sort() 4 | ans = 0 5 | 6 | for i in range(len(nums)): 7 | idx = bisect_right(nums, nums[i] + k * 2) 8 | ans = max(ans, idx - i) 9 | 10 | return ans -------------------------------------------------------------------------------- /2780-minimum-index-of-a-valid-split/2780-minimum-index-of-a-valid-split.go: -------------------------------------------------------------------------------- 1 | func minimumIndex(nums []int) int { 2 | ans := -1 3 | l, r := map[int]int{}, map[int]int{} 4 | 5 | for _, num := range nums { 6 | r[num]++ 7 | } 8 | 9 | for i := 0; i < len(nums); i++ { 10 | l[nums[i]]++ 11 | r[nums[i]]-- 12 | if l[nums[i]]*2 > (i+1) && r[nums[i]]*2 > (len(nums)-i-1) { 13 | return i 14 | } 15 | } 16 | 17 | return ans 18 | } -------------------------------------------------------------------------------- /2788-split-strings-by-separator/2788-split-strings-by-separator.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def splitWordsBySeparator(self, words: List[str], sep: str) -> List[str]: 3 | ans = [] 4 | 5 | for word in words: 6 | new = [i for i in word.split(sep) if i] 7 | ans.extend(new) 8 | 9 | return ans -------------------------------------------------------------------------------- /2796-allow-one-function-call/2796-allow-one-function-call.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {Function} fn 3 | * @return {Function} 4 | */ 5 | var once = function(fn) { 6 | let isExecuted = false; 7 | return (...args) => (isExecuted ? undefined : ((isExecuted = true), fn(...args))); 8 | }; 9 | -------------------------------------------------------------------------------- /2798-chunk-array/2798-chunk-array.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {Array} arr 3 | * @param {number} size 4 | * @return {Array} 5 | */ 6 | var chunk = function(arr, size) { 7 | const chunks = [] 8 | for (let i = 0; i < arr.length; i += size) { 9 | const chunk = arr.slice(i, i + size); 10 | chunks.push(chunk); 11 | } 12 | return chunks 13 | }; -------------------------------------------------------------------------------- /2798-number-of-employees-who-met-the-target/2798-number-of-employees-who-met-the-target.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def numberOfEmployeesWhoMetTarget(self, hours: List[int], target: int) -> int: 3 | ans = 0 4 | 5 | for hour in hours: 6 | if hour >= target: 7 | ans += 1 8 | 9 | return ans -------------------------------------------------------------------------------- /2806-account-balance-after-rounded-purchase/2806-account-balance-after-rounded-purchase.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def accountBalanceAfterPurchase(self, pa: int) -> int: 3 | return 100 - math.floor((pa + 5) / 10) * 10 -------------------------------------------------------------------------------- /2809-create-hello-world-function/2809-create-hello-world-function.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @return {Function} 3 | */ 4 | var createHelloWorld = function() { 5 | 6 | return function(...args) { 7 | return ("Hello World") 8 | } 9 | }; 10 | 11 | /** 12 | * const f = createHelloWorld(); 13 | * f(); // "Hello World" 14 | */ -------------------------------------------------------------------------------- /2810-faulty-keyboard/2810-faulty-keyboard.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def finalString(self, s: str) -> str: 3 | ans = [] 4 | 5 | for c in s: 6 | if c == 'i': 7 | ans.reverse() 8 | continue 9 | ans.append(c) 10 | 11 | return "".join(ans) -------------------------------------------------------------------------------- /2813-to-be-or-not-to-be/2813-to-be-or-not-to-be.js: -------------------------------------------------------------------------------- 1 | var expect = function(val) { 2 | return { 3 | toBe: (val2) => { 4 | if(val === val2) { 5 | return true 6 | } 7 | throw new Error("Not Equal") 8 | }, 9 | notToBe: (val2) => { 10 | if(val !== val2) { 11 | return true 12 | } 13 | throw new Error("Equal") 14 | } 15 | } 16 | }; -------------------------------------------------------------------------------- /2820-return-length-of-arguments-passed/2820-return-length-of-arguments-passed.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {...(null|boolean|number|string|Array|Object)} args 3 | * @return {number} 4 | */ 5 | var argumentsLength = function(...args) { 6 | return args.length 7 | }; 8 | 9 | /** 10 | * argumentsLength(1, 2, 3); // 3 11 | */ -------------------------------------------------------------------------------- /2824-count-pairs-whose-sum-is-less-than-target/2824-count-pairs-whose-sum-is-less-than-target.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countPairs(self, nums: List[int], target: int) -> int: 3 | nums.sort() 4 | l = 0 5 | r = len(nums) - 1 6 | ans = 0 7 | 8 | while l < r: 9 | if nums[l] + nums[r] < target: 10 | ans = r - l + ans 11 | l += 1 12 | else: 13 | r -= 1 14 | 15 | return ans -------------------------------------------------------------------------------- /2828-check-if-a-string-is-an-acronym-of-words/2828-check-if-a-string-is-an-acronym-of-words.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isAcronym(self, words: List[str], s: str) -> bool: 3 | if len(words) != len(s): 4 | return False 5 | 6 | for word in words: 7 | if word[:1] != s[:1]: 8 | return False 9 | 10 | return True -------------------------------------------------------------------------------- /2848-points-that-intersect-with-cars/2848-points-that-intersect-with-cars.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def numberOfPoints(self, nums: List[List[int]]) -> int: 3 | SET = set() 4 | 5 | for s, e in nums: 6 | for i in range(s, e + 1): 7 | SET.add(i) 8 | 9 | return len(SET) -------------------------------------------------------------------------------- /2859-add-two-promises/2859-add-two-promises.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {Promise} promise1 3 | * @param {Promise} promise2 4 | * @return {Promise} 5 | */ 6 | var addTwoPromises = async function(promise1, promise2) { 7 | const [value1, value2] = await Promise.all([promise1, promise2]); 8 | return value1 + value2; 9 | 10 | }; 11 | -------------------------------------------------------------------------------- /2862-interval-cancellation/2862-interval-cancellation.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {Function} fn 3 | * @param {Array} args 4 | * @param {number} t 5 | * @return {Function} 6 | */ 7 | var cancellable = function(fn, args, t) { 8 | fn(...args); 9 | const timeI= setInterval(()=>fn(...args),t); 10 | return ()=> clearInterval(timeI); 11 | }; 12 | -------------------------------------------------------------------------------- /2864-is-object-empty/2864-is-object-empty.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {Object|Array} obj 3 | * @return {boolean} 4 | */ 5 | var isEmpty = function(obj) { 6 | let values = Object.keys(obj) 7 | 8 | if(values.length === 0){ 9 | return true 10 | }else { 11 | return false 12 | } 13 | 14 | }; -------------------------------------------------------------------------------- /2864-maximum-odd-binary-number/2864-maximum-odd-binary-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | string maximumOddBinaryNumber(string s) { 4 | int low = 0; 5 | int high = s.size() - 1; 6 | for(int i = 0; i < s.size(); i++) { 7 | if(s[i] == '1') { 8 | swap(s[i], s[low]); 9 | low++; 10 | } 11 | } 12 | swap(s[low - 1], s[high]); 13 | return s; 14 | } 15 | }; -------------------------------------------------------------------------------- /2873-maximum-value-of-an-ordered-triplet-i/2873-maximum-value-of-an-ordered-triplet-i.go: -------------------------------------------------------------------------------- 1 | func maximumTripletValue(nums []int) int64 { 2 | var ans, b, a int64 = 0, 0, 0 3 | 4 | for i := 0; i < len(nums); i++ { 5 | ans = max(ans, a*int64(nums[i])) 6 | a = max(a, b-int64(nums[i])) 7 | b = max(b, int64(nums[i])) 8 | } 9 | 10 | return ans 11 | } -------------------------------------------------------------------------------- /2874-maximum-value-of-an-ordered-triplet-ii/2874-maximum-value-of-an-ordered-triplet-ii.go: -------------------------------------------------------------------------------- 1 | func maximumTripletValue(nums []int) int64 { 2 | var ans, a, b int64 = 0, 0, 0 3 | 4 | for i := 0; i < len(nums); i++ { 5 | ans = max(ans, b*int64(nums[i])) 6 | b = max(b, a-int64(nums[i])) 7 | a = max(a, int64(nums[i])) 8 | } 9 | 10 | return ans 11 | } -------------------------------------------------------------------------------- /2894-divisible-and-non-divisible-sums-difference/2894-divisible-and-non-divisible-sums-difference.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def differenceOfSums(self, n: int, m: int) -> int: 3 | arr1 = [x for x in range(1, n + 1) if x % m] 4 | arr2 = [x for x in range(1, n + 1) if x % m == False] 5 | 6 | return sum(arr1) - sum(arr2) -------------------------------------------------------------------------------- /2914-minimum-number-of-changes-to-make-binary-string-beautiful/2914-minimum-number-of-changes-to-make-binary-string-beautiful.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minChanges(self, s: str) -> int: 3 | ans = 0 4 | 5 | for i in range(0, len(s), 2): 6 | if s[i + 1] != s[i]: 7 | ans += 1 8 | 9 | return ans -------------------------------------------------------------------------------- /2918-minimum-equal-sum-of-two-arrays-after-replacing-zeros/2918-minimum-equal-sum-of-two-arrays-after-replacing-zeros.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minSum(self, nums1: List[int], nums2: List[int]) -> int: 3 | s1 = sum(num if num != 0 else 1 for num in nums1) 4 | s2 = sum(num if num != 0 else 1 for num in nums2) 5 | 6 | if (s1 <= s2 and 0 in nums1) or s1 == s2: return s2 7 | if s1 > s2 and 0 in nums2: return s1 8 | 9 | return -1 -------------------------------------------------------------------------------- /2923-find-champion-i/2923-find-champion-i.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findChampion(self, grid: List[List[int]]) -> int: 3 | mp = defaultdict(int) 4 | 5 | for i in range(len(grid)): 6 | for j in range(len(grid)): 7 | if grid[i][j] == 1: 8 | mp[i] += 1 9 | 10 | maxi = max(mp.values()) 11 | 12 | for i, j in mp.items(): 13 | if j == maxi: 14 | return i -------------------------------------------------------------------------------- /2924-find-champion-ii/2924-find-champion-ii.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findChampion(self, n: int, e: List[List[int]]) -> int: 3 | a = {x[1] for x in e} 4 | b = {x for x in range(n)} 5 | d = list(b - a) 6 | 7 | if len(d) != 1: 8 | return -1 9 | 10 | return d[0] -------------------------------------------------------------------------------- /2929-distribute-candies-among-children-ii/2929-distribute-candies-among-children-ii.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def distributeCandies(self, n: int, l: int) -> int: 3 | ans = 0 4 | 5 | for i in range(min(l, n) + 1): 6 | if n - i > 2 * l: continue 7 | ans += min(n - i, l) - max(0, n - i - l) + 1 8 | 9 | return ans -------------------------------------------------------------------------------- /2938-separate-black-and-white-balls/2938-separate-black-and-white-balls.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minimumSteps(self, s: str) -> int: 3 | i = len(s) - 1 4 | cnt = z = 0 5 | 6 | while i >= 0: 7 | if s[i] == '1': 8 | cnt += z 9 | else: 10 | z += 1 11 | i -= 1 12 | 13 | return cnt -------------------------------------------------------------------------------- /2942-find-words-containing-character/2942-find-words-containing-character.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findWordsContaining(self, ws: List[str], x: str) -> List[int]: 3 | ans = [] 4 | 5 | for i, w in enumerate(ws): 6 | if x in w: 7 | ans.append(i) 8 | 9 | return ans -------------------------------------------------------------------------------- /2951-find-the-peaks/2951-find-the-peaks.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findPeaks(self, m: List[int]) -> List[int]: 3 | ans = [] 4 | 5 | for i in range(1, len(m) - 1): 6 | if m[i] > m[i - 1] and m[i] > m[i + 1]: 7 | ans.append(i) 8 | 9 | return ans -------------------------------------------------------------------------------- /2960-count-tested-devices-after-test-operations/2960-count-tested-devices-after-test-operations.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countTestedDevices(self, bp: List[int]) -> int: 3 | ans = 0 4 | dec = 0 5 | 6 | for i in range(len(bp)): 7 | bp[i] -= dec 8 | if bp[i] > 0: 9 | dec += 1 10 | ans += 1 11 | 12 | return ans -------------------------------------------------------------------------------- /2971-find-polygon-with-the-largest-perimeter/2971-find-polygon-with-the-largest-perimeter.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | long long largestPerimeter(vector& nums) { 4 | sort(nums.begin(), nums.end()); 5 | long long tot = 0; 6 | long long ans = -1; 7 | for(auto i : nums) { 8 | if(tot > i) { 9 | ans = tot + i; 10 | } 11 | tot += i; 12 | } 13 | return ans; 14 | } 15 | }; -------------------------------------------------------------------------------- /2974-minimum-number-game/2974-minimum-number-game.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def numberGame(self, nums: List[int]) -> List[int]: 3 | ans = [] 4 | # n = len(nums) 5 | 6 | while nums: 7 | alice = min(nums) 8 | nums.remove(alice) 9 | bob = min(nums) 10 | nums.remove(bob) 11 | ans.append(bob) 12 | ans.append(alice) 13 | # n -= 1 14 | 15 | return ans -------------------------------------------------------------------------------- /2980-check-if-bitwise-or-has-trailing-zeros/2980-check-if-bitwise-or-has-trailing-zeros.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def hasTrailingZeros(self, nums: List[int]) -> bool: 3 | ans = [num for num in nums if num % 2 == 0] 4 | 5 | return len(ans) > 1 -------------------------------------------------------------------------------- /3010-divide-an-array-into-subarrays-with-minimum-cost-i/3010-divide-an-array-into-subarrays-with-minimum-cost-i.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minimumCost(self, nums: List[int]) -> int: 3 | heap = [] 4 | 5 | for num in nums[1 : ]: 6 | heapq.heappush(heap, num) 7 | 8 | return nums[0] + heapq.heappop(heap) + heapq.heappop(heap) -------------------------------------------------------------------------------- /3014-minimum-number-of-pushes-to-type-word-i/3014-minimum-number-of-pushes-to-type-word-i.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minimumPushes(string word) { 4 | int n = word.size(); 5 | int cnt = 0; 6 | while (n > 0) { 7 | cnt += n; 8 | n -= 8; 9 | } 10 | return cnt; 11 | } 12 | }; -------------------------------------------------------------------------------- /3016-minimum-number-of-pushes-to-type-word-ii/3016-minimum-number-of-pushes-to-type-word-ii.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minimumPushes(self, word: str) -> int: 3 | count = Counter(word) 4 | sc = sorted(count.values(), reverse=True) 5 | ans = 0 6 | 7 | for i, cnt in enumerate(sc): 8 | ans += cnt * (i // 8 + 1) 9 | 10 | return ans -------------------------------------------------------------------------------- /3019-number-of-changing-keys/3019-number-of-changing-keys.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int countKeyChanges(string s) { 4 | int cnt = 0; 5 | for (int i = 1; i < s.size(); i++) { 6 | if (tolower(s[i]) != tolower(s[i - 1])) cnt++; 7 | } 8 | return cnt; 9 | } 10 | }; -------------------------------------------------------------------------------- /3024-type-of-triangle/3024-type-of-triangle.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | string triangleType(vector& nums) { 4 | sort(nums.begin(), nums.end()); 5 | if (nums[0] + nums[1] <= nums[2]) return "none"; 6 | if (nums[0] == nums[1] && nums[0] == nums[2]) return "equilateral"; 7 | else if (nums[0] == nums[1] || nums[1] == nums[2]) return "isosceles"; 8 | return "scalene"; 9 | } 10 | }; -------------------------------------------------------------------------------- /3028-ant-on-the-boundary/3028-ant-on-the-boundary.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int returnToBoundaryCount(vector& nums) { 4 | int location = 0; 5 | int cnt = 0; 6 | for (int num : nums) { 7 | location += num; 8 | if (location == 0) cnt++; 9 | } 10 | return cnt; 11 | } 12 | }; -------------------------------------------------------------------------------- /3038-maximum-number-of-operations-with-the-same-score-i/3038-maximum-number-of-operations-with-the-same-score-i.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxOperations(vector& nums) { 4 | int cnt = 0; 5 | int score = nums[0] + nums[1]; 6 | for (int i = 0; i < nums.size() - 1; i += 2) { 7 | if (score == nums[i] + nums[i + 1]) cnt++; 8 | else break; 9 | } 10 | return cnt; 11 | } 12 | }; -------------------------------------------------------------------------------- /3046-split-the-array/3046-split-the-array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isPossibleToSplit(vector& nums) { 4 | unordered_map mp; 5 | for (auto i : nums) { 6 | mp[i]++; 7 | } 8 | for (auto i : mp) { 9 | if (i.second > 2) return false; 10 | } 11 | return true; 12 | } 13 | }; -------------------------------------------------------------------------------- /3056-determine-if-a-cell-is-reachable-at-a-given-time/3056-determine-if-a-cell-is-reachable-at-a-given-time.cpp: -------------------------------------------------------------------------------- 1 | // m3hu1 2 | class Solution { 3 | public: 4 | bool isReachableAtTime(int sx, int sy, int fx, int fy, int t) { 5 | int m = max(abs(sx-fx),abs(sy-fy)); 6 | if(m==0 && t==1) return false; 7 | return m<=t; 8 | } 9 | }; -------------------------------------------------------------------------------- /3075-maximize-happiness-of-selected-children/3075-maximize-happiness-of-selected-children.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | long long maximumHappinessSum(vector& happiness, int k) { 4 | sort(happiness.rbegin(), happiness.rend()); 5 | long long ans = 0; 6 | int c = 0; 7 | for (int i = 0; i < k; i++) { 8 | ans += max(happiness[i] - c, 0); 9 | c++; 10 | } 11 | return ans; 12 | } 13 | }; -------------------------------------------------------------------------------- /3099-harshad-number/3099-harshad-number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int sumOfTheDigitsOfHarshadNumber(int x) { 4 | int ans = 0; 5 | int xCopy = x; 6 | while (xCopy > 0) { 7 | ans += xCopy % 10; 8 | xCopy /= 10; 9 | } 10 | if (x % ans == 0) return ans; 11 | else return -1; 12 | } 13 | }; -------------------------------------------------------------------------------- /3100-water-bottles-ii/3100-water-bottles-ii.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxBottlesDrunk(int numBottles, int numExchange) { 4 | int ans = numBottles; 5 | while (numBottles >= numExchange) { 6 | numBottles = numBottles - numExchange + 1; 7 | numExchange++; 8 | ans++; 9 | } 10 | return ans; 11 | } 12 | }; -------------------------------------------------------------------------------- /3101-count-alternating-subarrays/3101-count-alternating-subarrays.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countAlternatingSubarrays(self, nums: List[int]) -> int: 3 | dp = [1] * len(nums) 4 | ans = 0 5 | 6 | for i in range(1, len(nums)): 7 | if nums[i] != nums[i - 1]: 8 | dp[i] += dp[i - 1] 9 | ans += dp[i] 10 | 11 | return ans + 1 -------------------------------------------------------------------------------- /3110-score-of-a-string/3110-score-of-a-string.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int scoreOfString(string s) { 4 | int ans = 0; 5 | for (int i = 0; i < s.size() - 1; i++) { 6 | ans += abs((int)s[i] - (int)s[i + 1]); 7 | } 8 | return ans; 9 | } 10 | }; -------------------------------------------------------------------------------- /3120-count-the-number-of-special-characters-i/3120-count-the-number-of-special-characters-i.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int numberOfSpecialChars(string word) { 4 | unordered_map mp; 5 | for (char c : word) mp[c]++; 6 | int cnt = 0; 7 | for (auto i : mp) { 8 | if (mp.find(tolower(i.first)) != mp.end() && mp.find(toupper(i.first)) != mp.end()) cnt++; 9 | } 10 | return cnt >> 1; 11 | } 12 | }; -------------------------------------------------------------------------------- /3131-find-the-integer-added-to-array-i/3131-find-the-integer-added-to-array-i.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int addedInteger(vector& nums1, vector& nums2) { 4 | // sort(nums1.begin(), nums1.end()); 5 | // sort(nums2.begin(), nums2.end()); 6 | // int ans = nums2[0] - nums1[0]; 7 | // return ans; 8 | int a = *max_element(nums1.begin(), nums1.end()); 9 | int b = *max_element(nums2.begin(), nums2.end()); 10 | return b - a; 11 | } 12 | }; -------------------------------------------------------------------------------- /3151-special-array-i/3151-special-array-i.go: -------------------------------------------------------------------------------- 1 | func isArraySpecial(nums []int) bool { 2 | for i := 1; i < len(nums); i++ { 3 | if nums[i - 1] & 1 == nums[i] & 1 { 4 | return false 5 | } 6 | } 7 | return true 8 | } -------------------------------------------------------------------------------- /3158-find-the-xor-of-numbers-which-appear-twice/3158-find-the-xor-of-numbers-which-appear-twice.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int duplicateNumbersXOR(vector& nums) { 4 | unordered_set st; 5 | int ans = 0; 6 | for (auto i : nums) { 7 | if (st.find(i) != st.end()) ans = ans ^ i; 8 | else st.insert(i); 9 | } 10 | return ans; 11 | } 12 | }; -------------------------------------------------------------------------------- /3162-find-the-number-of-good-pairs-i/3162-find-the-number-of-good-pairs-i.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int numberOfPairs(vector& nums1, vector& nums2, int k) { 4 | int cnt = 0; 5 | // constraints are too small, this is fine 6 | for (int i = 0; i < nums1.size(); i++) { 7 | for (int j = 0; j < nums2.size(); j++) { 8 | if (nums1[i] % (nums2[j] * k) == 0) cnt++; 9 | } 10 | } 11 | return cnt; 12 | } 13 | }; -------------------------------------------------------------------------------- /3163-string-compression-iii/3163-string-compression-iii.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def compressedString(self, word: str) -> str: 3 | comp = [] 4 | i = 0 5 | 6 | while i < len(word): 7 | c = word[i] 8 | curr_len = 0 9 | while i < len(word) and curr_len < 9 and word[i] == c: 10 | curr_len += 1 11 | i += 1 12 | comp += str(curr_len) + c 13 | 14 | return ''.join(comp) -------------------------------------------------------------------------------- /3168-minimum-number-of-chairs-in-a-waiting-room/3168-minimum-number-of-chairs-in-a-waiting-room.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minimumChairs(string s) { 4 | int cnt = 0; 5 | int ans = 0; 6 | for (auto i : s) { 7 | if (i == 'E') { 8 | cnt++; 9 | } else if (i == 'L') cnt--; 10 | ans = max(ans, cnt); 11 | } 12 | return ans; 13 | } 14 | }; -------------------------------------------------------------------------------- /3169-count-days-without-meetings/3169-count-days-without-meetings.go: -------------------------------------------------------------------------------- 1 | func countDays(days int, ms [][]int) int { 2 | sort.Slice(ms, func(i, j int) bool { 3 | return ms[i][0] < ms[j][0] 4 | }) 5 | 6 | maxi := ms[0][1] 7 | bw := 0 8 | 9 | for i := 1; i < len(ms); i++ { 10 | bw += max(ms[i][0] - maxi - 1, 0) 11 | maxi = max(maxi, ms[i][1]) 12 | } 13 | 14 | a, b := days - maxi, ms[0][0] - 1 15 | return b + a + bw 16 | } -------------------------------------------------------------------------------- /3174-clear-digits/3174-clear-digits.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | string clearDigits(string s) { 4 | string ans = ""; 5 | for (int i = 0; i < s.size(); i++) { 6 | if (isdigit(s[i])) { 7 | ans.pop_back(); 8 | } else ans += s[i]; 9 | } 10 | return ans; 11 | } 12 | }; -------------------------------------------------------------------------------- /3174-clear-digits/3174-clear-digits.go: -------------------------------------------------------------------------------- 1 | func clearDigits(s string) string { 2 | st := []rune{} 3 | 4 | for _, v := range s { 5 | if '0' <= v && v <= '9' { 6 | st = st[:len(st) - 1] 7 | continue 8 | } 9 | st = append(st, v) 10 | } 11 | 12 | return string(st) 13 | } -------------------------------------------------------------------------------- /3178-find-the-child-who-has-the-ball-after-k-seconds/3178-find-the-child-who-has-the-ball-after-k-seconds.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int numberOfChild(int n, int k) { 4 | int cycle = 2 * (n - 1); // total cycle time 5 | int Teff = k % cycle; // effective time 6 | if (Teff < n) return Teff; // right dir 7 | return cycle - Teff; // left dir 8 | } 9 | }; -------------------------------------------------------------------------------- /3179-find-the-n-th-value-after-k-seconds/3179-find-the-n-th-value-after-k-seconds.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def valueAfterKSeconds(self, n: int, k: int) -> int: 3 | nums = [1] * n 4 | temp = 0 5 | while k: 6 | for i in range(1, n): 7 | nums[i] = (nums[i] + nums[i - 1]) % (int(1e9) + 7) 8 | k -= 1 9 | 10 | return nums[n - 1] -------------------------------------------------------------------------------- /3184-count-pairs-that-form-a-complete-day-i/3184-count-pairs-that-form-a-complete-day-i.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countCompleteDayPairs(self, hours: List[int]) -> int: 3 | cnt = 0 4 | 5 | for i in range(len(hours)): 6 | for j in range(i + 1, len(hours)): 7 | if (hours[i] + hours[j]) % 24 == 0: 8 | cnt += 1 9 | 10 | return cnt -------------------------------------------------------------------------------- /3185-count-pairs-that-form-a-complete-day-ii/3185-count-pairs-that-form-a-complete-day-ii.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countCompleteDayPairs(self, hours: List[int]) -> int: 3 | count = Counter() 4 | ans = 0 5 | 6 | for i in hours: 7 | mod_i = i % 24 8 | if mod_i == 0: 9 | ans += count[0] 10 | else: 11 | ans += count[24 - mod_i] 12 | count[mod_i] += 1 13 | 14 | return ans -------------------------------------------------------------------------------- /3190-find-minimum-operations-to-make-all-elements-divisible-by-three/3190-find-minimum-operations-to-make-all-elements-divisible-by-three.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minimumOperations(self, nums: List[int]) -> int: 3 | ans = 0 4 | 5 | for i in nums: 6 | if i % 3 != 0: 7 | ans += 1 8 | 9 | return ans -------------------------------------------------------------------------------- /3191-minimum-operations-to-make-binary-array-elements-equal-to-one-i/3191-minimum-operations-to-make-binary-array-elements-equal-to-one-i.go: -------------------------------------------------------------------------------- 1 | func minOperations(nums []int) int { 2 | ans, cur := 0, 0 3 | 4 | for i := 0; i < len(nums); i++ { 5 | if i >= 3 && nums[i-3] == 2 { 6 | curr-- 7 | } 8 | if curr&1 == nums[i] { 9 | if i+3 > len(nums) { 10 | return -1 11 | } 12 | curr++ 13 | ans++ 14 | nums[i] = 2 15 | } 16 | } 17 | 18 | return ans 19 | } -------------------------------------------------------------------------------- /3194-minimum-average-of-smallest-and-largest-elements/3194-minimum-average-of-smallest-and-largest-elements.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minimumAverage(self, nums: List[int]) -> float: 3 | averages = [] 4 | 5 | while nums: 6 | mini = min(nums) 7 | nums.remove(mini) 8 | maxi = max(nums) 9 | nums.remove(maxi) 10 | averages.append((mini + maxi) / 2) 11 | 12 | return min(averages) -------------------------------------------------------------------------------- /3208-alternating-groups-ii/3208-alternating-groups-ii.go: -------------------------------------------------------------------------------- 1 | func numberOfAlternatingGroups(c []int, k int) int { 2 | var l, r int = 0, 0 3 | var ans int = 0 4 | 5 | for l < len(c) { 6 | r++ 7 | if c[r%len(c)] == c[(r-1)%len(c)] { 8 | l = r 9 | } else if r-l+1 == k { 10 | l++ 11 | ans++ 12 | } 13 | } 14 | 15 | return ans 16 | } -------------------------------------------------------------------------------- /3210-find-the-encrypted-string/3210-find-the-encrypted-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def getEncryptedString(self, s: str, k: int) -> str: 3 | n = len(s) 4 | # i = 0 5 | # s = list(s) 6 | ans = ["" for _ in range(n)] 7 | 8 | for i in range(n): 9 | ans[i] = s[(i + k) % n] 10 | 11 | return "".join(ans) -------------------------------------------------------------------------------- /3223-minimum-length-of-string-after-operations/3223-minimum-length-of-string-after-operations.go: -------------------------------------------------------------------------------- 1 | func minimumLength(s string) int { 2 | res := 0 3 | mp := make(map[byte]int) 4 | 5 | for i := range s { 6 | mp[s[i]]++ 7 | } 8 | 9 | for i := range mp { 10 | res += 2 - (mp[i] % 2) 11 | } 12 | 13 | return res 14 | } -------------------------------------------------------------------------------- /3227-vowels-game-in-a-string/3227-vowels-game-in-a-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def doesAliceWin(self, s: str) -> bool: 3 | vowels = ['a', 'e', 'i', 'o', 'u'] 4 | 5 | for ch in s: 6 | if ch in vowels: 7 | return True 8 | 9 | return False -------------------------------------------------------------------------------- /3232-find-if-digit-game-can-be-won/3232-find-if-digit-game-can-be-won.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def canAliceWin(self, nums: List[int]) -> bool: 3 | a = sum(i for i in nums if i < 10) 4 | b = sum(i for i in nums if i >= 10) 5 | 6 | return not(a == b) -------------------------------------------------------------------------------- /3254-find-the-power-of-k-size-subarrays-i/3254-find-the-power-of-k-size-subarrays-i.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def resultsArray(self, nums: List[int], k: int) -> List[int]: 3 | res = [-1] * (len(nums) - k + 1) 4 | cnt = 0 5 | 6 | for i in range(len(nums)): 7 | cnt = cnt + 1 if i and nums[i - 1] + 1 == nums[i] else 0 8 | if cnt >= k - 1: 9 | res[i - k + 1] = nums[i] 10 | 11 | return res -------------------------------------------------------------------------------- /3271-hash-divided-string/3271-hash-divided-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def stringHash(self, s: str, k: int) -> str: 3 | ans = [] 4 | newLen = len(s) // k 5 | 6 | for i in range(newLen): 7 | sub = s[i * k : (i + 1) * k] 8 | hashSum = sum([ord(c) - ord('a') for c in sub]) 9 | h = hashSum % 26 10 | ans.append(chr(h + ord('a'))) 11 | 12 | return ''.join(ans) -------------------------------------------------------------------------------- /3274-check-if-two-chessboard-squares-have-the-same-color/3274-check-if-two-chessboard-squares-have-the-same-color.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def checkTwoChessboards(self, c1: str, c2: str) -> bool: 3 | flag1 = ord(c1[0]) % 2 == int(c1[1]) % 2 4 | flag2 = ord(c2[0]) % 2 == int(c2[1]) % 2 5 | 6 | return flag1 == flag2 -------------------------------------------------------------------------------- /3280-convert-date-to-binary/3280-convert-date-to-binary.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def convertDateToBinary(self, date: str) -> str: 3 | date = date.split("-") 4 | 5 | ans = [bin(int(i))[2 : ] for i in date] 6 | 7 | return '-'.join(ans) -------------------------------------------------------------------------------- /3282-reach-end-of-array-with-max-score/3282-reach-end-of-array-with-max-score.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findMaximumScore(self, nums: List[int]) -> int: 3 | ans = 0 4 | maxi = 0 5 | 6 | for num in nums: 7 | ans += maxi 8 | maxi = max(maxi, num) 9 | 10 | return ans -------------------------------------------------------------------------------- /3285-find-indices-of-stable-mountains/3285-find-indices-of-stable-mountains.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def stableMountains(self, h: List[int], t: int) -> List[int]: 3 | ans = [] 4 | 5 | for i in range(1, len(h)): 6 | if h[i - 1] > t: 7 | ans.append(i) 8 | 9 | return ans -------------------------------------------------------------------------------- /3289-the-two-sneaky-numbers-of-digitville/3289-the-two-sneaky-numbers-of-digitville.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def getSneakyNumbers(self, nums: List[int]) -> List[int]: 3 | count = Counter(nums) 4 | 5 | return [num for num, freq in count.items() if freq == 2] -------------------------------------------------------------------------------- /3304-find-the-k-th-character-in-string-game-i/3304-find-the-k-th-character-in-string-game-i.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def kthCharacter(self, k: int) -> str: 3 | curr = 'a' 4 | 5 | while len(curr) < k: 6 | new = "" 7 | for c in curr: 8 | new += chr(ord(c) + 1) 9 | curr += new 10 | 11 | return curr[k - 1] -------------------------------------------------------------------------------- /3309-maximum-possible-number-by-binary-concatenation/3309-maximum-possible-number-by-binary-concatenation.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxGoodNumber(self, nums: List[int]) -> int: 3 | n = len(nums) 4 | a = [bin(i)[2:] for i in nums] 5 | a.sort(key = lambda x: x * n, reverse=True) 6 | 7 | return int(''.join(a), 2) -------------------------------------------------------------------------------- /3330-find-the-original-typed-string-i/3330-find-the-original-typed-string-i.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def possibleStringCount(self, s: str) -> int: 3 | ans = 0 4 | 5 | for i in range(1, len(s)): 6 | if s[i - 1] == s[i]: 7 | ans += 1 8 | 9 | return ans -------------------------------------------------------------------------------- /3340-check-balanced-string/3340-check-balanced-string.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isBalanced(self, num: str) -> bool: 3 | evenSum = oddSum = 0 4 | 5 | for i in range(len(num)): 6 | if i % 2 == 0: 7 | evenSum += int(num[i]) 8 | else: 9 | oddSum += int(num[i]) 10 | 11 | return evenSum == oddSum -------------------------------------------------------------------------------- /3355-zero-array-transformation-i/3355-zero-array-transformation-i.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isZeroArray(self, nums: List[int], qs: List[List[int]]) -> bool: 3 | x = [0] * (len(nums) + 1) 4 | 5 | for l, r in qs: 6 | x[l] += 1 7 | x[r + 1] -= 1 8 | 9 | temp = 0 10 | 11 | for i in range(len(nums)): 12 | temp += x[i] 13 | if temp < nums[i]: 14 | return False 15 | 16 | return True -------------------------------------------------------------------------------- /3360-stone-removal-game/3360-stone-removal-game.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def canAliceWin(self, n: int) -> bool: 3 | if n < 10: 4 | return False 5 | 6 | alice = True 7 | cnt = 10 8 | 9 | while n > 0: 10 | if cnt > n: 11 | alice = not alice 12 | n -= cnt 13 | cnt -= 1 14 | alice = not alice 15 | 16 | return not alice -------------------------------------------------------------------------------- /3370-smallest-number-with-all-set-bits/3370-smallest-number-with-all-set-bits.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def smallestNumber(self, n: int) -> int: 3 | for i in range(32): 4 | check = 2 ** i - 1 5 | if check >= n: 6 | return check -------------------------------------------------------------------------------- /3392-count-subarrays-of-length-three-with-a-condition/3392-count-subarrays-of-length-three-with-a-condition.go: -------------------------------------------------------------------------------- 1 | func countSubarrays(nums []int) int { 2 | ans := 0 3 | 4 | for i := 0; i < len(nums)-2; i++ { 5 | if (nums[i]+nums[i+2])*2 == nums[i+1] { ans++ } 6 | } 7 | 8 | return ans 9 | } -------------------------------------------------------------------------------- /3392-count-subarrays-of-length-three-with-a-condition/3392-count-subarrays-of-length-three-with-a-condition.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countSubarrays(self, nums: List[int]) -> int: 3 | ans = 0 4 | 5 | for i in range(1, len(nums) - 1): 6 | if nums[i] == (nums[i - 1] + nums[i + 1]) * 2: 7 | ans += 1 8 | 9 | return ans -------------------------------------------------------------------------------- /3403-find-the-lexicographically-largest-string-from-the-box-i/3403-find-the-lexicographically-largest-string-from-the-box-i.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def answerString(self, w, nf): 3 | if nf == 1: 4 | return w 5 | 6 | ans = "" 7 | l = len(w) - nf + 1 8 | maxi = max(w) 9 | 10 | for i in range(len(w)): 11 | if w[i] == maxi: 12 | substr = w[i:i + l] 13 | ans = max(ans, substr) 14 | 15 | return ans -------------------------------------------------------------------------------- /3411-maximum-subarray-with-equal-products/3411-maximum-subarray-with-equal-products.go: -------------------------------------------------------------------------------- 1 | func maxLength(nums []int) int { 2 | l := 0 3 | p := 1 4 | sz := 2 5 | 6 | gcd := func(a, b int) int { 7 | for b != 0 { 8 | a, b = b, a % b 9 | } 10 | return a 11 | } 12 | 13 | for r := 0; r < len(nums); r++ { 14 | for gcd(p, nums[r]) != 1 { 15 | p /= nums[l] 16 | l++ 17 | } 18 | if r - l + 1 > sz { 19 | sz = r - l + 1 20 | } 21 | p *= nums[r] 22 | } 23 | 24 | return sz 25 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LeetCode-Problems 2 | Collection of LeetCode problems that I solved to master Data Structures and Algorithms. 3 | --------------------------------------------------------------------------------