Skip to content

nerdylua/Leetcode-solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leetcode-solutions

My solutions to leetcode problems.

LeetCode Topics

Math

0009-palindrome-number
0013-roman-to-integer
0670-maximum-swap
0679-24-game
0867-new-21-game
1448-maximum-69-number
2202-sum-of-k-mirror-numbers
2716-prime-subtraction-operation
3555-final-array-state-after-k-multiplication-operations-i
3581-the-two-sneaky-numbers-of-digitville
3830-find-closest-person

Array

0001-two-sum
0004-median-of-two-sorted-arrays
0217-contains-duplicate
0494-target-sum
0632-smallest-range-covering-elements-from-k-lists
0679-24-game
0689-maximum-sum-of-3-non-overlapping-subarrays
0780-max-chunks-to-make-sorted
0787-sliding-puzzle
0891-score-after-flipping-matrix
0892-shortest-subarray-with-sum-at-least-k
0925-construct-binary-tree-from-preorder-and-postorder-traversal
0952-word-subsets
1002-maximum-width-ramp
1063-best-sightseeing-pair
1147-flip-columns-for-maximum-number-of-equal-rows
1256-rank-transform-of-an-array
1350-remove-sub-folders-from-the-filesystem
1396-count-servers-that-communicate
1402-count-square-submatrices-with-all-ones
1468-check-if-n-and-its-double-exist
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1570-final-prices-with-a-special-discount-in-a-shop
1620-check-if-array-pairs-are-divisible-by-k
1679-shortest-subarray-to-be-removed-to-make-array-sorted
1694-make-sum-divisible-by-p
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1755-defuse-the-bomb
1766-minimum-number-of-removals-to-make-mountain-array
1813-maximum-erasure-value
1876-map-of-highest-peak
1886-minimum-limit-of-balls-in-a-bag
1895-minimum-number-of-operations-to-move-all-balls-to-each-box
1917-maximum-average-pass-ratio
1923-sentence-similarity-iii
1940-maximum-xor-for-each-query
1972-rotating-the-box
2054-the-number-of-the-smallest-unoccupied-chair
2089-maximum-matrix-sum
2145-grid-game
2164-two-best-non-overlapping-events
2170-count-number-of-maximum-bitwise-or-subsets
2179-most-beautiful-item-for-each-query
2188-minimized-maximum-of-products-distributed-to-any-store
2204-find-subsequence-of-length-k-with-the-largest-sum
2274-keep-multiplying-found-values-by-two
2292-counting-words-with-a-given-prefix
2320-find-all-k-distant-indices-in-an-array
2343-count-unguarded-cells-in-the-grid
2356-largest-combination-with-bitwise-and-greater-than-zero
2375-minimum-obstacle-removal-to-reach-corner
2465-shifting-letters-ii
2479-meeting-rooms-iii
2488-divide-intervals-into-minimum-number-of-groups
2533-bitwise-xor-of-all-pairings
2545-height-of-binary-tree-after-subtree-removal-queries
2552-maximum-sum-of-distinct-subarrays-with-length-k
2554-minimum-total-distance-traveled
2581-divide-players-into-teams-of-equal-skill
2586-longest-square-streak-in-an-array
2616-maximal-score-after-applying-k-operations
2640-maximum-number-of-integers-to-choose-from-a-range-i
2685-first-completely-painted-row-or-column
2691-count-vowel-strings-in-ranges
2692-take-gifts-from-the-richest-pile
2695-find-score-of-an-array-after-marking-all-elements
2699-count-the-number-of-fair-pairs
2711-minimum-time-to-visit-a-cell-in-a-grid
2716-prime-subtraction-operation
2764-maximum-number-of-fish-in-a-grid
2792-neighboring-bitwise-xor
2794-maximum-number-of-moves-in-a-grid
2868-continuous-subarrays
2891-maximum-beauty-of-an-array-after-applying-operation
3181-find-building-where-alice-and-bob-can-meet
3291-find-if-array-can-be-sorted
3309-count-prefix-and-suffix-pairs-i
3332-minimum-operations-to-exceed-threshold-value-ii
3380-shortest-subarray-with-or-at-least-k-ii
3427-special-array-ii
3429-special-array-i
3434-find-the-number-of-distinct-colors-among-the-balls
3522-find-the-power-of-k-size-subarrays-i
3555-final-array-state-after-k-multiplication-operations-i
3581-the-two-sneaky-numbers-of-digitville
3587-maximum-points-tourist-can-earn
3605-construct-the-minimum-bitwise-array-i

Hash Table

0001-two-sum
0003-longest-substring-without-repeating-characters
0013-roman-to-integer
0217-contains-duplicate
0242-valid-anagram
0355-design-twitter
0567-permutation-in-string
0632-smallest-range-covering-elements-from-k-lists
0925-construct-binary-tree-from-preorder-and-postorder-traversal
0952-word-subsets
1147-flip-columns-for-maximum-number-of-equal-rows
1256-rank-transform-of-an-array
1468-check-if-n-and-its-double-exist
1502-construct-k-palindrome-strings
1620-check-if-array-pairs-are-divisible-by-k
1694-make-sum-divisible-by-p
1715-split-a-string-into-the-max-number-of-unique-substrings
1813-maximum-erasure-value
2054-the-number-of-the-smallest-unoccupied-chair
2204-find-subsequence-of-length-k-with-the-largest-sum
2274-keep-multiplying-found-values-by-two
2300-construct-string-with-repeat-limit
2356-largest-combination-with-bitwise-and-greater-than-zero
2479-meeting-rooms-iii
2552-maximum-sum-of-distinct-subarrays-with-length-k
2581-divide-players-into-teams-of-equal-skill
2586-longest-square-streak-in-an-array
2599-take-k-of-each-character-from-left-and-right
2640-maximum-number-of-integers-to-choose-from-a-range-i
2677-cousins-in-binary-tree-ii
2685-first-completely-painted-row-or-column
2695-find-score-of-an-array-after-marking-all-elements
3267-find-longest-special-substring-that-occurs-thrice-i
3434-find-the-number-of-distinct-colors-among-the-balls
3455-minimum-length-of-string-after-operations
3581-the-two-sneaky-numbers-of-digitville

Sorting

0217-contains-duplicate
0242-valid-anagram
0632-smallest-range-covering-elements-from-k-lists
0780-max-chunks-to-make-sorted
1256-rank-transform-of-an-array
1468-check-if-n-and-its-double-exist
2164-two-best-non-overlapping-events
2179-most-beautiful-item-for-each-query
2204-find-subsequence-of-length-k-with-the-largest-sum
2274-keep-multiplying-found-values-by-two
2479-meeting-rooms-iii
2488-divide-intervals-into-minimum-number-of-groups
2554-minimum-total-distance-traveled
2581-divide-players-into-teams-of-equal-skill
2586-longest-square-streak-in-an-array
2640-maximum-number-of-integers-to-choose-from-a-range-i
2646-kth-largest-sum-in-a-binary-tree
2695-find-score-of-an-array-after-marking-all-elements
2699-count-the-number-of-fair-pairs
2891-maximum-beauty-of-an-array-after-applying-operation
3291-find-if-array-can-be-sorted

Two Pointers

0567-permutation-in-string
1468-check-if-n-and-its-double-exist
1566-check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence
1679-shortest-subarray-to-be-removed-to-make-array-sorted
1923-sentence-similarity-iii
1972-rotating-the-box
2095-minimum-number-of-swaps-to-make-the-string-balanced
2320-find-all-k-distant-indices-in-an-array
2414-move-pieces-to-obtain-a-string
2488-divide-intervals-into-minimum-number-of-groups
2581-divide-players-into-teams-of-equal-skill
2699-count-the-number-of-fair-pairs
3018-make-string-a-subsequence-using-cyclic-increments
3195-separate-black-and-white-balls

String

0003-longest-substring-without-repeating-characters
0006-zigzag-conversion
0013-roman-to-integer
0242-valid-anagram
0567-permutation-in-string
0812-rotate-string
0952-word-subsets
0957-minimum-add-to-make-parentheses-valid
1197-parsing-a-boolean-expression
1302-delete-characters-to-make-fancy-string
1304-longest-happy-string
1350-remove-sub-folders-from-the-filesystem
1502-construct-k-palindrome-strings
1566-check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence
1667-find-kth-bit-in-nth-binary-string
1715-split-a-string-into-the-max-number-of-unique-substrings
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1895-minimum-number-of-operations-to-move-all-balls-to-each-box
1923-sentence-similarity-iii
2095-minimum-number-of-swaps-to-make-the-string-balanced
2221-check-if-a-parentheses-string-can-be-valid
2260-divide-a-string-into-groups-of-size-k
2292-counting-words-with-a-given-prefix
2300-construct-string-with-repeat-limit
2414-move-pieces-to-obtain-a-string
2465-shifting-letters-ii
2580-circular-sentence
2599-take-k-of-each-character-from-left-and-right
2691-count-vowel-strings-in-ranges
2800-minimum-string-length-after-removing-substrings
3018-make-string-a-subsequence-using-cyclic-increments
3174-minimum-number-of-changes-to-make-binary-string-beautiful
3195-separate-black-and-white-balls
3267-find-longest-special-substring-that-occurs-thrice-i
3309-count-prefix-and-suffix-pairs-i
3451-string-compression-iii
3455-minimum-length-of-string-after-operations
3617-find-the-original-typed-string-i

Greedy

0632-smallest-range-covering-elements-from-k-lists
0670-maximum-swap
0780-max-chunks-to-make-sorted
0891-score-after-flipping-matrix
0957-minimum-add-to-make-parentheses-valid
1304-longest-happy-string
1448-maximum-69-number
1502-construct-k-palindrome-strings
1766-minimum-number-of-removals-to-make-mountain-array
1917-maximum-average-pass-ratio
2089-maximum-matrix-sum
2095-minimum-number-of-swaps-to-make-the-string-balanced
2221-check-if-a-parentheses-string-can-be-valid
2300-construct-string-with-repeat-limit
2488-divide-intervals-into-minimum-number-of-groups
2509-minimize-xor
2616-maximal-score-after-applying-k-operations
2640-maximum-number-of-integers-to-choose-from-a-range-i
2716-prime-subtraction-operation
3195-separate-black-and-white-balls

Heap (Priority Queue)

0355-design-twitter
0632-smallest-range-covering-elements-from-k-lists
0892-shortest-subarray-with-sum-at-least-k
1304-longest-happy-string
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1917-maximum-average-pass-ratio
2054-the-number-of-the-smallest-unoccupied-chair
2164-two-best-non-overlapping-events
2204-find-subsequence-of-length-k-with-the-largest-sum
2300-construct-string-with-repeat-limit
2375-minimum-obstacle-removal-to-reach-corner
2479-meeting-rooms-iii
2488-divide-intervals-into-minimum-number-of-groups
2616-maximal-score-after-applying-k-operations
2692-take-gifts-from-the-richest-pile
2695-find-score-of-an-array-after-marking-all-elements
2711-minimum-time-to-visit-a-cell-in-a-grid
2868-continuous-subarrays
3181-find-building-where-alice-and-bob-can-meet
3332-minimum-operations-to-exceed-threshold-value-ii
3555-final-array-state-after-k-multiplication-operations-i

Sliding Window

0003-longest-substring-without-repeating-characters
0567-permutation-in-string
0632-smallest-range-covering-elements-from-k-lists
0867-new-21-game
0892-shortest-subarray-with-sum-at-least-k
1755-defuse-the-bomb
1813-maximum-erasure-value
2552-maximum-sum-of-distinct-subarrays-with-length-k
2599-take-k-of-each-character-from-left-and-right
2868-continuous-subarrays
2891-maximum-beauty-of-an-array-after-applying-operation
3267-find-longest-special-substring-that-occurs-thrice-i
3380-shortest-subarray-with-or-at-least-k-ii
3522-find-the-power-of-k-size-subarrays-i

Bit Manipulation

0891-score-after-flipping-matrix
1940-maximum-xor-for-each-query
2170-count-number-of-maximum-bitwise-or-subsets
2356-largest-combination-with-bitwise-and-greater-than-zero
2509-minimize-xor
2533-bitwise-xor-of-all-pairings
2792-neighboring-bitwise-xor
3291-find-if-array-can-be-sorted
3380-shortest-subarray-with-or-at-least-k-ii
3394-minimum-array-end
3605-construct-the-minimum-bitwise-array-i

Matrix

0787-sliding-puzzle
0891-score-after-flipping-matrix
1147-flip-columns-for-maximum-number-of-equal-rows
1396-count-servers-that-communicate
1402-count-square-submatrices-with-all-ones
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1876-map-of-highest-peak
1972-rotating-the-box
2089-maximum-matrix-sum
2145-grid-game
2343-count-unguarded-cells-in-the-grid
2375-minimum-obstacle-removal-to-reach-corner
2685-first-completely-painted-row-or-column
2711-minimum-time-to-visit-a-cell-in-a-grid
2764-maximum-number-of-fish-in-a-grid
2794-maximum-number-of-moves-in-a-grid
3587-maximum-points-tourist-can-earn

Backtracking

0494-target-sum
0679-24-game
1715-split-a-string-into-the-max-number-of-unique-substrings
2170-count-number-of-maximum-bitwise-or-subsets

Enumeration

2170-count-number-of-maximum-bitwise-or-subsets
2202-sum-of-k-mirror-numbers

Stack

0780-max-chunks-to-make-sorted
0957-minimum-add-to-make-parentheses-valid
1002-maximum-width-ramp
1197-parsing-a-boolean-expression
1570-final-prices-with-a-special-discount-in-a-shop
1679-shortest-subarray-to-be-removed-to-make-array-sorted
2095-minimum-number-of-swaps-to-make-the-string-balanced
2221-check-if-a-parentheses-string-can-be-valid
2800-minimum-string-length-after-removing-substrings
3181-find-building-where-alice-and-bob-can-meet

Simulation

1667-find-kth-bit-in-nth-binary-string
2260-divide-a-string-into-groups-of-size-k
2274-keep-multiplying-found-values-by-two
2343-count-unguarded-cells-in-the-grid
2479-meeting-rooms-iii
2692-take-gifts-from-the-richest-pile
2695-find-score-of-an-array-after-marking-all-elements
2800-minimum-string-length-after-removing-substrings
3332-minimum-operations-to-exceed-threshold-value-ii
3434-find-the-number-of-distinct-colors-among-the-balls
3555-final-array-state-after-k-multiplication-operations-i

Recursion

1197-parsing-a-boolean-expression
1667-find-kth-bit-in-nth-binary-string

Tree

0925-construct-binary-tree-from-preorder-and-postorder-traversal
2493-reverse-odd-levels-of-binary-tree
2545-height-of-binary-tree-after-subtree-removal-queries
2558-minimum-number-of-operations-to-sort-a-binary-tree-by-level
2646-kth-largest-sum-in-a-binary-tree
2677-cousins-in-binary-tree-ii
3058-maximum-number-of-k-divisible-components
3439-find-minimum-diameter-after-merging-two-trees

Breadth-First Search

0684-redundant-connection
0787-sliding-puzzle
0820-find-eventual-safe-states
1396-count-servers-that-communicate
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1876-map-of-highest-peak
2375-minimum-obstacle-removal-to-reach-corner
2493-reverse-odd-levels-of-binary-tree
2545-height-of-binary-tree-after-subtree-removal-queries
2558-minimum-number-of-operations-to-sort-a-binary-tree-by-level
2646-kth-largest-sum-in-a-binary-tree
2677-cousins-in-binary-tree-ii
2711-minimum-time-to-visit-a-cell-in-a-grid
2764-maximum-number-of-fish-in-a-grid
3439-find-minimum-diameter-after-merging-two-trees

Binary Tree

0925-construct-binary-tree-from-preorder-and-postorder-traversal
2493-reverse-odd-levels-of-binary-tree
2545-height-of-binary-tree-after-subtree-removal-queries
2558-minimum-number-of-operations-to-sort-a-binary-tree-by-level
2646-kth-largest-sum-in-a-binary-tree
2677-cousins-in-binary-tree-ii

Counting

1396-count-servers-that-communicate
1502-construct-k-palindrome-strings
1620-check-if-array-pairs-are-divisible-by-k
2300-construct-string-with-repeat-limit
2356-largest-combination-with-bitwise-and-greater-than-zero
3267-find-longest-special-substring-that-occurs-thrice-i
3455-minimum-length-of-string-after-operations

Depth-First Search

0684-redundant-connection
0820-find-eventual-safe-states
1350-remove-sub-folders-from-the-filesystem
1396-count-servers-that-communicate
2201-valid-arrangement-of-pairs
2493-reverse-odd-levels-of-binary-tree
2545-height-of-binary-tree-after-subtree-removal-queries
2677-cousins-in-binary-tree-ii
2764-maximum-number-of-fish-in-a-grid
3058-maximum-number-of-k-divisible-components
3439-find-minimum-diameter-after-merging-two-trees

Trie

1350-remove-sub-folders-from-the-filesystem
3309-count-prefix-and-suffix-pairs-i

Dynamic Programming

0494-target-sum
0689-maximum-sum-of-3-non-overlapping-subarrays
0867-new-21-game
1063-best-sightseeing-pair
1402-count-square-submatrices-with-all-ones
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1766-minimum-number-of-removals-to-make-mountain-array
2164-two-best-non-overlapping-events
2554-minimum-total-distance-traveled
2562-count-ways-to-build-good-strings
2586-longest-square-streak-in-an-array
2794-maximum-number-of-moves-in-a-grid
3587-maximum-points-tourist-can-earn

Binary Search

0004-median-of-two-sorted-arrays
0892-shortest-subarray-with-sum-at-least-k
1468-check-if-n-and-its-double-exist
1679-shortest-subarray-to-be-removed-to-make-array-sorted
1766-minimum-number-of-removals-to-make-mountain-array
1886-minimum-limit-of-balls-in-a-bag
2164-two-best-non-overlapping-events
2179-most-beautiful-item-for-each-query
2188-minimized-maximum-of-products-distributed-to-any-store
2586-longest-square-streak-in-an-array
2640-maximum-number-of-integers-to-choose-from-a-range-i
2699-count-the-number-of-fair-pairs
2716-prime-subtraction-operation
2891-maximum-beauty-of-an-array-after-applying-operation
3181-find-building-where-alice-and-bob-can-meet
3267-find-longest-special-substring-that-occurs-thrice-i
3427-special-array-ii

String Matching

0812-rotate-string
1566-check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence
2292-counting-words-with-a-given-prefix
3309-count-prefix-and-suffix-pairs-i

Prefix Sum

0892-shortest-subarray-with-sum-at-least-k
1694-make-sum-divisible-by-p
1895-minimum-number-of-operations-to-move-all-balls-to-each-box
1940-maximum-xor-for-each-query
2145-grid-game
2465-shifting-letters-ii
2488-divide-intervals-into-minimum-number-of-groups
2691-count-vowel-strings-in-ranges
3427-special-array-ii

Number Theory

2716-prime-subtraction-operation

Monotonic Stack

0780-max-chunks-to-make-sorted
1002-maximum-width-ramp
1570-final-prices-with-a-special-discount-in-a-shop
1679-shortest-subarray-to-be-removed-to-make-array-sorted
3181-find-building-where-alice-and-bob-can-meet

Queue

0892-shortest-subarray-with-sum-at-least-k
2868-continuous-subarrays

Monotonic Queue

0892-shortest-subarray-with-sum-at-least-k
2868-continuous-subarrays

Graph

0684-redundant-connection
0820-find-eventual-safe-states
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
2201-valid-arrangement-of-pairs
2375-minimum-obstacle-removal-to-reach-corner
2711-minimum-time-to-visit-a-cell-in-a-grid
3189-find-champion-ii
3439-find-minimum-diameter-after-merging-two-trees

Shortest Path

1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
2375-minimum-obstacle-removal-to-reach-corner
2711-minimum-time-to-visit-a-cell-in-a-grid

Eulerian Circuit

2201-valid-arrangement-of-pairs

Ordered Set

2868-continuous-subarrays

Binary Indexed Tree

3181-find-building-where-alice-and-bob-can-meet

Segment Tree

3181-find-building-where-alice-and-bob-can-meet

Rolling Hash

3309-count-prefix-and-suffix-pairs-i

Hash Function

3309-count-prefix-and-suffix-pairs-i

Brainteaser

2533-bitwise-xor-of-all-pairings

Union Find

0684-redundant-connection
1396-count-servers-that-communicate
2764-maximum-number-of-fish-in-a-grid

Topological Sort

0820-find-eventual-safe-states

Divide and Conquer

0004-median-of-two-sorted-arrays
0925-construct-binary-tree-from-preorder-and-postorder-traversal

Linked List

0355-design-twitter

Design

0355-design-twitter

Probability and Statistics

0867-new-21-game

About

Pushing my leetcode solutions to this repo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published