Skip to content

Collection of LeetCode questions to ace the coding interview!

Notifications You must be signed in to change notification settings

aso2001/LeetCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode

Collection of LeetCode questions to ace the coding interview! - Created using LeetHub

LeetCode Topics

String

0179-largest-number
0241-different-ways-to-add-parentheses
0539-minimum-time-difference
0564-find-the-closest-palindrome
0567-permutation-in-string
0592-fraction-addition-and-subtraction
0920-uncommon-words-from-two-sentences
0952-word-subsets
0957-minimum-add-to-make-parentheses-valid
1093-recover-a-tree-from-preorder-traversal
1160-letter-tile-possibilities
1170-shortest-common-supersequence
1460-number-of-substrings-containing-all-three-characters
1473-find-the-longest-substring-containing-vowels-in-even-counts
1502-construct-k-palindrome-strings
1516-the-k-th-lexicographical-string-of-all-happy-strings-of-length-n
1524-string-matching-in-an-array
1537-maximum-score-after-splitting-a-string
1566-check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1756-minimum-deletions-to-make-string-balanced
1786-count-the-number-of-consistent-strings
1915-check-if-one-string-swap-can-make-strings-equal
1923-sentence-similarity-iii
2021-remove-all-occurrences-of-a-substring
2059-unique-length-3-palindromic-subsequences
2107-find-unique-binary-string
2220-find-all-possible-recipes-from-given-supplies
2221-check-if-a-parentheses-string-can-be-valid
2232-adding-spaces-to-a-string
2300-construct-string-with-repeat-limit
2414-move-pieces-to-obtain-a-string
2456-construct-smallest-number-from-di-string
2463-minimum-recolors-to-get-k-consecutive-black-blocks
2465-shifting-letters-ii
2494-sum-of-prefix-scores-of-strings
2691-count-vowel-strings-in-ranges
2755-extra-characters-in-a-string
2800-minimum-string-length-after-removing-substrings
3018-make-string-a-subsequence-using-cyclic-increments
3195-separate-black-and-white-balls
3267-find-longest-special-substring-that-occurs-thrice-i
3329-find-the-length-of-the-longest-common-prefix
3447-clear-digits
3455-minimum-length-of-string-after-operations
3569-count-of-substrings-containing-every-vowel-and-k-consonants-ii

Dynamic Programming

0241-different-ways-to-add-parentheses
0264-ugly-number-ii
0650-2-keys-keyboard
0689-maximum-sum-of-3-non-overlapping-subarrays
0905-length-of-longest-fibonacci-subsequence
1025-minimum-cost-for-tickets
1063-best-sightseeing-pair
1170-shortest-common-supersequence
1511-count-number-of-teams
1631-number-of-sub-arrays-with-odd-sum
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1756-minimum-deletions-to-make-string-balanced
2067-maximum-number-of-points-with-cost
2164-two-best-non-overlapping-events
2562-count-ways-to-build-good-strings
2755-extra-characters-in-a-string

Stack

0145-binary-tree-postorder-traversal
0776-n-ary-tree-postorder-traversal
0780-max-chunks-to-make-sorted
0957-minimum-add-to-make-parentheses-valid
1497-design-a-stack-with-increment-operation
1570-final-prices-with-a-special-discount-in-a-shop
1756-minimum-deletions-to-make-string-balanced
2021-remove-all-occurrences-of-a-substring
2221-check-if-a-parentheses-string-can-be-valid
2456-construct-smallest-number-from-di-string
2800-minimum-string-length-after-removing-substrings
3181-find-building-where-alice-and-bob-can-meet
3447-clear-digits

Array

0040-combination-sum-ii
0179-largest-number
0539-minimum-time-difference
0624-maximum-distance-in-arrays
0632-smallest-range-covering-elements-from-k-lists
0689-maximum-sum-of-3-non-overlapping-subarrays
0719-find-k-th-smallest-pair-distance
0729-my-calendar-i
0780-max-chunks-to-make-sorted
0854-making-a-large-island
0859-design-circular-deque
0890-lemonade-change
0905-length-of-longest-fibonacci-subsequence
0925-construct-binary-tree-from-preorder-and-postorder-traversal
0952-word-subsets
1025-minimum-cost-for-tickets
1063-best-sightseeing-pair
1325-path-with-maximum-probability
1335-maximum-candies-allocated-to-k-children
1435-xor-queries-of-a-subarray
1477-product-of-the-last-k-numbers
1497-design-a-stack-with-increment-operation
1511-count-number-of-teams
1524-string-matching-in-an-array
1570-final-prices-with-a-special-discount-in-a-shop
1620-check-if-array-pairs-are-divisible-by-k
1631-number-of-sub-arrays-with-odd-sum
1694-make-sum-divisible-by-p
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1786-count-the-number-of-consistent-strings
1819-construct-the-lexicographically-largest-valid-sequence
1878-check-if-array-is-sorted-and-rotated
1886-minimum-limit-of-balls-in-a-bag
1917-maximum-average-pass-ratio
1923-sentence-similarity-iii
1927-maximum-ascending-subarray-sum
2035-count-sub-islands
2054-the-number-of-the-smallest-unoccupied-chair
2067-maximum-number-of-points-with-cost
2107-find-unique-binary-string
2164-two-best-non-overlapping-events
2220-find-all-possible-recipes-from-given-supplies
2232-adding-spaces-to-a-string
2265-partition-array-according-to-given-pivot
2308-divide-array-into-equal-pairs
2358-number-of-ways-to-split-array
2375-minimum-obstacle-removal-to-reach-corner
2411-spiral-matrix-iv
2448-count-number-of-bad-pairs
2465-shifting-letters-ii
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2478-longest-nice-subarray
2488-divide-intervals-into-minimum-number-of-groups
2494-sum-of-prefix-scores-of-strings
2503-longest-subarray-with-maximum-bitwise-and
2533-bitwise-xor-of-all-pairings
2616-maximal-score-after-applying-k-operations
2640-maximum-number-of-integers-to-choose-from-a-range-i
2665-minimum-time-to-repair-cars
2690-house-robber-iv
2691-count-vowel-strings-in-ranges
2692-take-gifts-from-the-richest-pile
2695-find-score-of-an-array-after-marking-all-elements
2707-merge-two-2d-arrays-by-summing-values
2711-minimum-time-to-visit-a-cell-in-a-grid
2755-extra-characters-in-a-string
2766-find-the-prefix-common-array-of-two-arrays
2792-neighboring-bitwise-xor
2868-continuous-subarrays
2891-maximum-beauty-of-an-array-after-applying-operation
3181-find-building-where-alice-and-bob-can-meet
3227-find-missing-and-repeated-values
3329-find-the-length-of-the-longest-common-prefix
3348-minimum-cost-walk-in-weighted-graph
3372-longest-strictly-increasing-or-strictly-decreasing-subarray
3427-special-array-ii
3429-special-array-i
3434-find-the-number-of-distinct-colors-among-the-balls
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i
3483-alternating-groups-ii
3501-delete-nodes-from-linked-list-present-in-array
3555-final-array-state-after-k-multiplication-operations-i
3643-zero-array-transformation-ii

Binary Indexed Tree

1511-count-number-of-teams
3181-find-building-where-alice-and-bob-can-meet

Tree

0145-binary-tree-postorder-traversal
0776-n-ary-tree-postorder-traversal
0789-kth-largest-element-in-a-stream
0925-construct-binary-tree-from-preorder-and-postorder-traversal
1093-recover-a-tree-from-preorder-traversal
1387-find-elements-in-a-contaminated-binary-tree
1484-linked-list-in-binary-tree
2493-reverse-odd-levels-of-binary-tree
2558-minimum-number-of-operations-to-sort-a-binary-tree-by-level
3058-maximum-number-of-k-divisible-components
3439-find-minimum-diameter-after-merging-two-trees

Design

0432-all-oone-data-structure
0729-my-calendar-i
0789-kth-largest-element-in-a-stream
0859-design-circular-deque
1387-find-elements-in-a-contaminated-binary-tree
1477-product-of-the-last-k-numbers
1497-design-a-stack-with-increment-operation
2434-design-a-number-container-system

Binary Search Tree

0719-find-k-th-smallest-pair-distance
0729-my-calendar-i
0789-kth-largest-element-in-a-stream
1335-maximum-candies-allocated-to-k-children
1886-minimum-limit-of-balls-in-a-bag
2164-two-best-non-overlapping-events
2640-maximum-number-of-integers-to-choose-from-a-range-i
2665-minimum-time-to-repair-cars
2690-house-robber-iv
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
3643-zero-array-transformation-ii

Heap (Priority Queue)

0264-ugly-number-ii
0632-smallest-range-covering-elements-from-k-lists
0789-kth-largest-element-in-a-stream
1325-path-with-maximum-probability
1917-maximum-average-pass-ratio
2054-the-number-of-the-smallest-unoccupied-chair
2164-two-best-non-overlapping-events
2300-construct-string-with-repeat-limit
2375-minimum-obstacle-removal-to-reach-corner
2434-design-a-number-container-system
2473-max-sum-of-a-pair-with-equal-sum-of-digits
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
2803-modify-graph-edge-weights
2868-continuous-subarrays
3181-find-building-where-alice-and-bob-can-meet
3555-final-array-state-after-k-multiplication-operations-i

Binary Tree

0145-binary-tree-postorder-traversal
0789-kth-largest-element-in-a-stream
0925-construct-binary-tree-from-preorder-and-postorder-traversal
1093-recover-a-tree-from-preorder-traversal
1387-find-elements-in-a-contaminated-binary-tree
1484-linked-list-in-binary-tree
2493-reverse-odd-levels-of-binary-tree
2558-minimum-number-of-operations-to-sort-a-binary-tree-by-level

Data Stream

0789-kth-largest-element-in-a-stream
1477-product-of-the-last-k-numbers

Backtracking

0040-combination-sum-ii
1160-letter-tile-possibilities
1516-the-k-th-lexicographical-string-of-all-happy-strings-of-length-n
1819-construct-the-lexicographically-largest-valid-sequence
2107-find-unique-binary-string
2456-construct-smallest-number-from-di-string
2802-find-the-punishment-number-of-an-integer

Two Pointers

0567-permutation-in-string
0719-find-k-th-smallest-pair-distance
1566-check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence
1923-sentence-similarity-iii
2232-adding-spaces-to-a-string
2265-partition-array-according-to-given-pivot
2414-move-pieces-to-obtain-a-string
2488-divide-intervals-into-minimum-number-of-groups
2707-merge-two-2d-arrays-by-summing-values
3018-make-string-a-subsequence-using-cyclic-increments
3195-separate-black-and-white-balls

Sorting

0179-largest-number
0539-minimum-time-difference
0632-smallest-range-covering-elements-from-k-lists
0719-find-k-th-smallest-pair-distance
0780-max-chunks-to-make-sorted
2164-two-best-non-overlapping-events
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2488-divide-intervals-into-minimum-number-of-groups
2640-maximum-number-of-integers-to-choose-from-a-range-i
2695-find-score-of-an-array-after-marking-all-elements
2891-maximum-beauty-of-an-array-after-applying-operation

Greedy

0179-largest-number
0624-maximum-distance-in-arrays
0632-smallest-range-covering-elements-from-k-lists
0780-max-chunks-to-make-sorted
0890-lemonade-change
0957-minimum-add-to-make-parentheses-valid
1502-construct-k-palindrome-strings
1917-maximum-average-pass-ratio
2221-check-if-a-parentheses-string-can-be-valid
2300-construct-string-with-repeat-limit
2456-construct-smallest-number-from-di-string
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
3195-separate-black-and-white-balls

Hash Table

0264-ugly-number-ii
0432-all-oone-data-structure
0567-permutation-in-string
0632-smallest-range-covering-elements-from-k-lists
0905-length-of-longest-fibonacci-subsequence
0920-uncommon-words-from-two-sentences
0925-construct-binary-tree-from-preorder-and-postorder-traversal
0952-word-subsets
0984-most-stones-removed-with-same-row-or-column
1160-letter-tile-possibilities
1387-find-elements-in-a-contaminated-binary-tree
1460-number-of-substrings-containing-all-three-characters
1473-find-the-longest-substring-containing-vowels-in-even-counts
1502-construct-k-palindrome-strings
1620-check-if-array-pairs-are-divisible-by-k
1694-make-sum-divisible-by-p
1786-count-the-number-of-consistent-strings
1915-check-if-one-string-swap-can-make-strings-equal
2054-the-number-of-the-smallest-unoccupied-chair
2059-unique-length-3-palindromic-subsequences
2107-find-unique-binary-string
2220-find-all-possible-recipes-from-given-supplies
2300-construct-string-with-repeat-limit
2308-divide-array-into-equal-pairs
2434-design-a-number-container-system
2448-count-number-of-bad-pairs
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2640-maximum-number-of-integers-to-choose-from-a-range-i
2695-find-score-of-an-array-after-marking-all-elements
2707-merge-two-2d-arrays-by-summing-values
2755-extra-characters-in-a-string
2766-find-the-prefix-common-array-of-two-arrays
3227-find-missing-and-repeated-values
3267-find-longest-special-substring-that-occurs-thrice-i
3329-find-the-length-of-the-longest-common-prefix
3434-find-the-number-of-distinct-colors-among-the-balls
3455-minimum-length-of-string-after-operations
3501-delete-nodes-from-linked-list-present-in-array
3569-count-of-substrings-containing-every-vowel-and-k-consonants-ii

Math

0241-different-ways-to-add-parentheses
0264-ugly-number-ii
0539-minimum-time-difference
0564-find-the-closest-palindrome
0592-fraction-addition-and-subtraction
0650-2-keys-keyboard
1477-product-of-the-last-k-numbers
1631-number-of-sub-arrays-with-odd-sum
1889-check-if-number-is-a-sum-of-powers-of-three
2448-count-number-of-bad-pairs
2649-count-total-number-of-colored-cells
2802-find-the-punishment-number-of-an-integer
2903-insert-greatest-common-divisors-in-linked-list
3227-find-missing-and-repeated-values
3555-final-array-state-after-k-multiplication-operations-i

Bit Manipulation

0476-number-complement
1435-xor-queries-of-a-subarray
1473-find-the-longest-substring-containing-vowels-in-even-counts
1786-count-the-number-of-consistent-strings
2059-unique-length-3-palindromic-subsequences
2308-divide-array-into-equal-pairs
2323-minimum-bit-flips-to-convert-number
2478-longest-nice-subarray
2503-longest-subarray-with-maximum-bitwise-and
2509-minimize-xor
2533-bitwise-xor-of-all-pairings
2766-find-the-prefix-common-array-of-two-arrays
2792-neighboring-bitwise-xor
3348-minimum-cost-walk-in-weighted-graph
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i

Simulation

0592-fraction-addition-and-subtraction
2021-remove-all-occurrences-of-a-substring
2232-adding-spaces-to-a-string
2265-partition-array-according-to-given-pivot
2411-spiral-matrix-iv
2692-take-gifts-from-the-richest-pile
2695-find-score-of-an-array-after-marking-all-elements
2800-minimum-string-length-after-removing-substrings
3434-find-the-number-of-distinct-colors-among-the-balls
3447-clear-digits
3555-final-array-state-after-k-multiplication-operations-i

Depth-First Search

0145-binary-tree-postorder-traversal
0386-lexicographical-numbers
0776-n-ary-tree-postorder-traversal
0820-find-eventual-safe-states
0854-making-a-large-island
0984-most-stones-removed-with-same-row-or-column
1093-recover-a-tree-from-preorder-traversal
1387-find-elements-in-a-contaminated-binary-tree
1484-linked-list-in-binary-tree
2035-count-sub-islands
2201-valid-arrangement-of-pairs
2246-maximum-employees-to-be-invited-to-a-meeting
2493-reverse-odd-levels-of-binary-tree
2793-count-the-number-of-complete-components
3058-maximum-number-of-k-divisible-components
3439-find-minimum-diameter-after-merging-two-trees

Graph

0820-find-eventual-safe-states
0984-most-stones-removed-with-same-row-or-column
1325-path-with-maximum-probability
2201-valid-arrangement-of-pairs
2220-find-all-possible-recipes-from-given-supplies
2246-maximum-employees-to-be-invited-to-a-meeting
2375-minimum-obstacle-removal-to-reach-corner
2583-divide-nodes-into-the-maximum-number-of-groups
2711-minimum-time-to-visit-a-cell-in-a-grid
2793-count-the-number-of-complete-components
2803-modify-graph-edge-weights
3348-minimum-cost-walk-in-weighted-graph
3439-find-minimum-diameter-after-merging-two-trees

Shortest Path

1325-path-with-maximum-probability
2375-minimum-obstacle-removal-to-reach-corner
2711-minimum-time-to-visit-a-cell-in-a-grid
2803-modify-graph-edge-weights

Union Find

0854-making-a-large-island
0984-most-stones-removed-with-same-row-or-column
2035-count-sub-islands
2583-divide-nodes-into-the-maximum-number-of-groups
2793-count-the-number-of-complete-components
3348-minimum-cost-walk-in-weighted-graph

Breadth-First Search

0820-find-eventual-safe-states
0854-making-a-large-island
1387-find-elements-in-a-contaminated-binary-tree
1484-linked-list-in-binary-tree
2035-count-sub-islands
2375-minimum-obstacle-removal-to-reach-corner
2493-reverse-odd-levels-of-binary-tree
2558-minimum-number-of-operations-to-sort-a-binary-tree-by-level
2583-divide-nodes-into-the-maximum-number-of-groups
2711-minimum-time-to-visit-a-cell-in-a-grid
2793-count-the-number-of-complete-components
3439-find-minimum-diameter-after-merging-two-trees

Matrix

0854-making-a-large-island
2035-count-sub-islands
2375-minimum-obstacle-removal-to-reach-corner
2411-spiral-matrix-iv
2711-minimum-time-to-visit-a-cell-in-a-grid
3227-find-missing-and-repeated-values

Linked List

0432-all-oone-data-structure
0725-split-linked-list-in-parts
0859-design-circular-deque
1484-linked-list-in-binary-tree
2411-spiral-matrix-iv
2903-insert-greatest-common-divisors-in-linked-list
3501-delete-nodes-from-linked-list-present-in-array

Number Theory

2903-insert-greatest-common-divisors-in-linked-list

Counting

0920-uncommon-words-from-two-sentences
1160-letter-tile-possibilities
1502-construct-k-palindrome-strings
1620-check-if-array-pairs-are-divisible-by-k
1786-count-the-number-of-consistent-strings
1915-check-if-one-string-swap-can-make-strings-equal
2300-construct-string-with-repeat-limit
2308-divide-array-into-equal-pairs
2448-count-number-of-bad-pairs
2494-sum-of-prefix-scores-of-strings
3267-find-longest-special-substring-that-occurs-thrice-i
3455-minimum-length-of-string-after-operations

Prefix Sum

1435-xor-queries-of-a-subarray
1473-find-the-longest-substring-containing-vowels-in-even-counts
1477-product-of-the-last-k-numbers
1537-maximum-score-after-splitting-a-string
1631-number-of-sub-arrays-with-odd-sum
1694-make-sum-divisible-by-p
2059-unique-length-3-palindromic-subsequences
2358-number-of-ways-to-split-array
2465-shifting-letters-ii
2488-divide-intervals-into-minimum-number-of-groups
2691-count-vowel-strings-in-ranges
3427-special-array-ii
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i
3643-zero-array-transformation-ii

Brainteaser

2503-longest-subarray-with-maximum-bitwise-and
2533-bitwise-xor-of-all-pairings

Recursion

0241-different-ways-to-add-parentheses

Memoization

0241-different-ways-to-add-parentheses

Trie

0386-lexicographical-numbers
0440-k-th-smallest-in-lexicographical-order
2494-sum-of-prefix-scores-of-strings
2755-extra-characters-in-a-string
3329-find-the-length-of-the-longest-common-prefix

Segment Tree

0729-my-calendar-i
3181-find-building-where-alice-and-bob-can-meet

Ordered Set

0729-my-calendar-i
2434-design-a-number-container-system
2868-continuous-subarrays

Queue

0859-design-circular-deque
2868-continuous-subarrays
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i

Doubly-Linked List

0432-all-oone-data-structure

Sliding Window

0567-permutation-in-string
0632-smallest-range-covering-elements-from-k-lists
1460-number-of-substrings-containing-all-three-characters
2463-minimum-recolors-to-get-k-consecutive-black-blocks
2478-longest-nice-subarray
2868-continuous-subarrays
2891-maximum-beauty-of-an-array-after-applying-operation
3267-find-longest-special-substring-that-occurs-thrice-i
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i
3483-alternating-groups-ii
3569-count-of-substrings-containing-every-vowel-and-k-consonants-ii

Eulerian Circuit

2201-valid-arrangement-of-pairs

String Matching

1524-string-matching-in-an-array
1566-check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence

Monotonic Queue

2868-continuous-subarrays

Monotonic Stack

0780-max-chunks-to-make-sorted
1570-final-prices-with-a-special-discount-in-a-shop
3181-find-building-where-alice-and-bob-can-meet

Topological Sort

0820-find-eventual-safe-states
2220-find-all-possible-recipes-from-given-supplies
2246-maximum-employees-to-be-invited-to-a-meeting

Divide and Conquer

0925-construct-binary-tree-from-preorder-and-postorder-traversal

About

Collection of LeetCode questions to ace the coding interview!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published