Skip to content

vinhlq2512/Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

829 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A collection of LeetCode questions to ace the coding interview! - Created using LeetHub v2

LeetCode Topics

Array

0001-two-sum
0011-container-with-most-water
0027-remove-element
0042-trapping-rain-water
0049-group-anagrams
0053-maximum-subarray
0118-pascals-triangle
0121-best-time-to-buy-and-sell-stock
0200-number-of-islands
0217-contains-duplicate
0283-move-zeroes
0303-range-sum-query-immutable
0407-trapping-rain-water-ii
0494-target-sum
0605-can-place-flowers
0643-maximum-average-subarray-i
0689-maximum-sum-of-3-non-overlapping-subarrays
0724-find-pivot-index
0787-sliding-puzzle
0892-shortest-subarray-with-sum-at-least-k
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
1147-flip-columns-for-maximum-number-of-equal-rows
1319-unique-number-of-occurrences
1335-maximum-candies-allocated-to-k-children
1392-find-the-difference-of-two-arrays
1396-count-servers-that-communicate
1413-minimum-value-to-get-positive-step-by-step-sum
1468-check-if-n-and-its-double-exist
1477-product-of-the-last-k-numbers
1480-running-sum-of-1d-array
1524-string-matching-in-an-array
1528-kids-with-the-greatest-number-of-candies
1570-final-prices-with-a-special-discount-in-a-shop
1679-shortest-subarray-to-be-removed-to-make-array-sorted
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1755-defuse-the-bomb
1833-find-the-highest-altitude
1849-maximum-absolute-sum-of-any-subarray
1876-map-of-highest-peak
1878-check-if-array-is-sorted-and-rotated
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
1927-maximum-ascending-subarray-sum
1929-concatenation-of-array
1972-rotating-the-box
1993-sum-of-all-subset-xor-totals
2054-two-best-non-overlapping-events
2089-maximum-matrix-sum
2107-find-unique-binary-string
2145-grid-game
2160-minimum-operations-to-make-a-uni-value-grid
2164-two-best-non-overlapping-events
2188-minimized-maximum-of-products-distributed-to-any-store
2232-adding-spaces-to-a-string
2265-partition-array-according-to-given-pivot
2292-counting-words-with-a-given-prefix
2343-count-unguarded-cells-in-the-grid
2358-number-of-ways-to-split-array
2375-minimum-obstacle-removal-to-reach-corner
2448-count-number-of-bad-pairs
2465-shifting-letters-ii
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2533-bitwise-xor-of-all-pairings
2551-apply-operations-to-an-array
2552-maximum-sum-of-distinct-subarrays-with-length-k
2564-most-profitable-path-in-a-tree
2614-maximum-count-of-positive-integer-and-negative-integer
2640-maximum-number-of-integers-to-choose-from-a-range-i
2665-minimum-time-to-repair-cars
2681-put-marbles-in-bags
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
2707-merge-two-2d-arrays-by-summing-values
2711-minimum-time-to-visit-a-cell-in-a-grid
2764-maximum-number-of-fish-in-a-grid
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
2906-construct-product-matrix
3152-maximum-value-of-an-ordered-triplet-ii
3154-maximum-value-of-an-ordered-triplet-i
3181-find-building-where-alice-and-bob-can-meet
3227-find-missing-and-repeated-values
3309-count-prefix-and-suffix-pairs-i
3332-minimum-operations-to-exceed-threshold-value-ii
3372-longest-strictly-increasing-or-strictly-decreasing-subarray
3427-special-array-ii
3429-special-array-i
3430-count-days-without-meetings
3434-find-the-number-of-distinct-colors-among-the-balls
3483-alternating-groups-ii
3517-shortest-distance-after-road-addition-queries-i
3522-find-the-power-of-k-size-subarrays-i
3555-final-array-state-after-k-multiplication-operations-i

Binary Search

0069-sqrtx
0374-guess-number-higher-or-lower
0892-shortest-subarray-with-sum-at-least-k
1335-maximum-candies-allocated-to-k-children
1468-check-if-n-and-its-double-exist
1679-shortest-subarray-to-be-removed-to-make-array-sorted
1886-minimum-limit-of-balls-in-a-bag
2054-two-best-non-overlapping-events
2164-two-best-non-overlapping-events
2188-minimized-maximum-of-products-distributed-to-any-store
2614-maximum-count-of-positive-integer-and-negative-integer
2640-maximum-number-of-integers-to-choose-from-a-range-i
2665-minimum-time-to-repair-cars
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

Two Pointers

0011-container-with-most-water
0027-remove-element
0042-trapping-rain-water
0125-valid-palindrome
0151-reverse-words-in-a-string
0283-move-zeroes
0345-reverse-vowels-of-a-string
0392-is-subsequence
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
1894-merge-strings-alternately
1972-rotating-the-box
2232-adding-spaces-to-a-string
2265-partition-array-according-to-given-pivot
2414-move-pieces-to-obtain-a-string
2551-apply-operations-to-an-array
2707-merge-two-2d-arrays-by-summing-values
3018-make-string-a-subsequence-using-cyclic-increments

Stack

0042-trapping-rain-water
0225-implement-stack-using-queues
1570-final-prices-with-a-special-discount-in-a-shop
1679-shortest-subarray-to-be-removed-to-make-array-sorted
2021-remove-all-occurrences-of-a-substring
2221-check-if-a-parentheses-string-can-be-valid
2456-construct-smallest-number-from-di-string
3181-find-building-where-alice-and-bob-can-meet
3447-clear-digits

Monotonic Stack

0042-trapping-rain-water
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

Database

0175-combine-two-tables
0176-second-highest-salary
0181-employees-earning-more-than-their-managers
0182-duplicate-emails
0183-customers-who-never-order
0196-delete-duplicate-emails
0577-employee-bonus
0584-find-customer-referee

Hash Table

0001-two-sum
0003-longest-substring-without-repeating-characters
0049-group-anagrams
0217-contains-duplicate
0900-reordered-power-of-2
0905-length-of-longest-fibonacci-subsequence
0925-construct-binary-tree-from-preorder-and-postorder-traversal
0952-word-subsets
1147-flip-columns-for-maximum-number-of-equal-rows
1218-lowest-common-ancestor-of-deepest-leaves
1319-unique-number-of-occurrences
1392-find-the-difference-of-two-arrays
1460-number-of-substrings-containing-all-three-characters
1468-check-if-n-and-its-double-exist
1502-construct-k-palindrome-strings
1915-check-if-one-string-swap-can-make-strings-equal
2059-unique-length-3-palindromic-subsequences
2107-find-unique-binary-string
2300-construct-string-with-repeat-limit
2434-design-a-number-container-system
2448-count-number-of-bad-pairs
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2552-maximum-sum-of-distinct-subarrays-with-length-k
2599-take-k-of-each-character-from-left-and-right
2640-maximum-number-of-integers-to-choose-from-a-range-i
2685-first-completely-painted-row-or-column
2695-find-score-of-an-array-after-marking-all-elements
2707-merge-two-2d-arrays-by-summing-values
2766-find-the-prefix-common-array-of-two-arrays
3227-find-missing-and-repeated-values
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
3569-count-of-substrings-containing-every-vowel-and-k-consonants-ii

Linked List

0002-add-two-numbers
0083-remove-duplicates-from-sorted-list
0203-remove-linked-list-elements

Math

0002-add-two-numbers
0009-palindrome-number
0069-sqrtx
0900-reordered-power-of-2
1477-product-of-the-last-k-numbers
1993-sum-of-all-subset-xor-totals
2160-minimum-operations-to-make-a-uni-value-grid
2448-count-number-of-bad-pairs
2610-closest-prime-numbers-in-range
2649-count-total-number-of-colored-cells
3227-find-missing-and-repeated-values
3555-final-array-state-after-k-multiplication-operations-i

Recursion

0002-add-two-numbers
0203-remove-linked-list-elements

String

0003-longest-substring-without-repeating-characters
0014-longest-common-prefix
0049-group-anagrams
0125-valid-palindrome
0151-reverse-words-in-a-string
0345-reverse-vowels-of-a-string
0392-is-subsequence
0952-word-subsets
1093-recover-a-tree-from-preorder-traversal
1170-shortest-common-supersequence
1460-number-of-substrings-containing-all-three-characters
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
1894-merge-strings-alternately
1895-minimum-number-of-operations-to-move-all-balls-to-each-box
1915-check-if-one-string-swap-can-make-strings-equal
2021-remove-all-occurrences-of-a-substring
2059-unique-length-3-palindromic-subsequences
2107-find-unique-binary-string
2221-check-if-a-parentheses-string-can-be-valid
2232-adding-spaces-to-a-string
2292-counting-words-with-a-given-prefix
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
2599-take-k-of-each-character-from-left-and-right
2691-count-vowel-strings-in-ranges
3018-make-string-a-subsequence-using-cyclic-increments
3267-find-longest-special-substring-that-occurs-thrice-i
3309-count-prefix-and-suffix-pairs-i
3447-clear-digits
3455-minimum-length-of-string-after-operations
3569-count-of-substrings-containing-every-vowel-and-k-consonants-ii

Sliding Window

0003-longest-substring-without-repeating-characters
0643-maximum-average-subarray-i
0892-shortest-subarray-with-sum-at-least-k
1460-number-of-substrings-containing-all-three-characters
1755-defuse-the-bomb
2463-minimum-recolors-to-get-k-consecutive-black-blocks
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
3483-alternating-groups-ii
3522-find-the-power-of-k-size-subarrays-i
3569-count-of-substrings-containing-every-vowel-and-k-consonants-ii

Greedy

0011-container-with-most-water
0605-can-place-flowers
1502-construct-k-palindrome-strings
1917-maximum-average-pass-ratio
2089-maximum-matrix-sum
2221-check-if-a-parentheses-string-can-be-valid
2300-construct-string-with-repeat-limit
2456-construct-smallest-number-from-di-string
2509-minimize-xor
2640-maximum-number-of-integers-to-choose-from-a-range-i
2681-put-marbles-in-bags

Dynamic Programming

0042-trapping-rain-water
0053-maximum-subarray
0118-pascals-triangle
0121-best-time-to-buy-and-sell-stock
0392-is-subsequence
0494-target-sum
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
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1849-maximum-absolute-sum-of-any-subarray
2054-two-best-non-overlapping-events
2164-two-best-non-overlapping-events
2562-count-ways-to-build-good-strings

Divide and Conquer

0053-maximum-subarray
0925-construct-binary-tree-from-preorder-and-postorder-traversal

Queue

0225-implement-stack-using-queues
0892-shortest-subarray-with-sum-at-least-k
2868-continuous-subarrays

Heap (Priority Queue)

0407-trapping-rain-water-ii
0892-shortest-subarray-with-sum-at-least-k
1917-maximum-average-pass-ratio
2054-two-best-non-overlapping-events
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
2681-put-marbles-in-bags
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

Prefix Sum

0303-range-sum-query-immutable
0724-find-pivot-index
0892-shortest-subarray-with-sum-at-least-k
1413-minimum-value-to-get-positive-step-by-step-sum
1477-product-of-the-last-k-numbers
1480-running-sum-of-1d-array
1537-maximum-score-after-splitting-a-string
1833-find-the-highest-altitude
1895-minimum-number-of-operations-to-move-all-balls-to-each-box
2059-unique-length-3-palindromic-subsequences
2145-grid-game
2358-number-of-ways-to-split-array
2465-shifting-letters-ii
2691-count-vowel-strings-in-ranges
2906-construct-product-matrix
3427-special-array-ii

Monotonic Queue

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

Matrix

0200-number-of-islands
0407-trapping-rain-water-ii
0787-sliding-puzzle
1147-flip-columns-for-maximum-number-of-equal-rows
1396-count-servers-that-communicate
1876-map-of-highest-peak
1972-rotating-the-box
2089-maximum-matrix-sum
2145-grid-game
2160-minimum-operations-to-make-a-uni-value-grid
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
2906-construct-product-matrix
3227-find-missing-and-repeated-values

Simulation

1929-concatenation-of-array
2021-remove-all-occurrences-of-a-substring
2232-adding-spaces-to-a-string
2265-partition-array-according-to-given-pivot
2343-count-unguarded-cells-in-the-grid
2551-apply-operations-to-an-array
2692-take-gifts-from-the-richest-pile
2695-find-score-of-an-array-after-marking-all-elements
3332-minimum-operations-to-exceed-threshold-value-ii
3434-find-the-number-of-distinct-colors-among-the-balls
3447-clear-digits
3555-final-array-state-after-k-multiplication-operations-i

Breadth-First Search

0200-number-of-islands
0407-trapping-rain-water-ii
0515-find-largest-value-in-each-tree-row
0787-sliding-puzzle
0820-find-eventual-safe-states
1218-lowest-common-ancestor-of-deepest-leaves
1396-count-servers-that-communicate
1558-course-schedule-iv
1876-map-of-highest-peak
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
2564-most-profitable-path-in-a-tree
2583-divide-nodes-into-the-maximum-number-of-groups
2711-minimum-time-to-visit-a-cell-in-a-grid
2764-maximum-number-of-fish-in-a-grid
2793-count-the-number-of-complete-components
3439-find-minimum-diameter-after-merging-two-trees
3517-shortest-distance-after-road-addition-queries-i

Graph

0820-find-eventual-safe-states
1558-course-schedule-iv
2201-valid-arrangement-of-pairs
2375-minimum-obstacle-removal-to-reach-corner
2564-most-profitable-path-in-a-tree
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
3189-find-champion-ii
3439-find-minimum-diameter-after-merging-two-trees
3517-shortest-distance-after-road-addition-queries-i

Shortest Path

2375-minimum-obstacle-removal-to-reach-corner
2711-minimum-time-to-visit-a-cell-in-a-grid

Sorting

0049-group-anagrams
0217-contains-duplicate
0900-reordered-power-of-2
1468-check-if-n-and-its-double-exist
2054-two-best-non-overlapping-events
2160-minimum-operations-to-make-a-uni-value-grid
2164-two-best-non-overlapping-events
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2640-maximum-number-of-integers-to-choose-from-a-range-i
2681-put-marbles-in-bags
2695-find-score-of-an-array-after-marking-all-elements
2891-maximum-beauty-of-an-array-after-applying-operation
3430-count-days-without-meetings

String Matching

1524-string-matching-in-an-array
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

Trie

0014-longest-common-prefix
3309-count-prefix-and-suffix-pairs-i

Counting

0900-reordered-power-of-2
1396-count-servers-that-communicate
1502-construct-k-palindrome-strings
1915-check-if-one-string-swap-can-make-strings-equal
2300-construct-string-with-repeat-limit
2448-count-number-of-bad-pairs
2614-maximum-count-of-positive-integer-and-negative-integer
3267-find-longest-special-substring-that-occurs-thrice-i
3455-minimum-length-of-string-after-operations

Ordered Set

2434-design-a-number-container-system
2868-continuous-subarrays

Depth-First Search

0200-number-of-islands
0515-find-largest-value-in-each-tree-row
0820-find-eventual-safe-states
1093-recover-a-tree-from-preorder-traversal
1218-lowest-common-ancestor-of-deepest-leaves
1396-count-servers-that-communicate
1558-course-schedule-iv
2201-valid-arrangement-of-pairs
2493-reverse-odd-levels-of-binary-tree
2564-most-profitable-path-in-a-tree
2764-maximum-number-of-fish-in-a-grid
2793-count-the-number-of-complete-components
3058-maximum-number-of-k-divisible-components
3439-find-minimum-diameter-after-merging-two-trees

Eulerian Circuit

2201-valid-arrangement-of-pairs

Tree

0515-find-largest-value-in-each-tree-row
0925-construct-binary-tree-from-preorder-and-postorder-traversal
1093-recover-a-tree-from-preorder-traversal
1218-lowest-common-ancestor-of-deepest-leaves
2493-reverse-odd-levels-of-binary-tree
2558-minimum-number-of-operations-to-sort-a-binary-tree-by-level
2564-most-profitable-path-in-a-tree
3058-maximum-number-of-k-divisible-components
3439-find-minimum-diameter-after-merging-two-trees

Binary Tree

0515-find-largest-value-in-each-tree-row
0925-construct-binary-tree-from-preorder-and-postorder-traversal
1093-recover-a-tree-from-preorder-traversal
1218-lowest-common-ancestor-of-deepest-leaves
2493-reverse-odd-levels-of-binary-tree
2558-minimum-number-of-operations-to-sort-a-binary-tree-by-level

Binary Indexed Tree

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

Segment Tree

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

Backtracking

0494-target-sum
1516-the-k-th-lexicographical-string-of-all-happy-strings-of-length-n
1993-sum-of-all-subset-xor-totals
2107-find-unique-binary-string
2456-construct-smallest-number-from-di-string

Bit Manipulation

1993-sum-of-all-subset-xor-totals
2059-unique-length-3-palindromic-subsequences
2509-minimize-xor
2533-bitwise-xor-of-all-pairings
2766-find-the-prefix-common-array-of-two-arrays
2792-neighboring-bitwise-xor

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

0200-number-of-islands
1396-count-servers-that-communicate
2583-divide-nodes-into-the-maximum-number-of-groups
2764-maximum-number-of-fish-in-a-grid
2793-count-the-number-of-complete-components

Topological Sort

0820-find-eventual-safe-states
1558-course-schedule-iv

Design

0225-implement-stack-using-queues
0303-range-sum-query-immutable
1477-product-of-the-last-k-numbers
2434-design-a-number-container-system

Data Stream

1477-product-of-the-last-k-numbers

Number Theory

2610-closest-prime-numbers-in-range

Combinatorics

1993-sum-of-all-subset-xor-totals

Enumeration

0900-reordered-power-of-2
1993-sum-of-all-subset-xor-totals

Interactive

0374-guess-number-higher-or-lower

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors