Skip to content

A collection of LeetCode questions to ace the coding interview!

Notifications You must be signed in to change notification settings

krishjha1121/Leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

718 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leetcode

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
0026-remove-duplicates-from-sorted-array
0033-search-in-rotated-sorted-array
0036-valid-sudoku
0037-sudoku-solver
0045-jump-game-ii
0053-maximum-subarray
0064-minimum-path-sum
0074-search-a-2d-matrix
0080-remove-duplicates-from-sorted-array-ii
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0118-pascals-triangle
0120-triangle
0122-best-time-to-buy-and-sell-stock-ii
0128-longest-consecutive-sequence
0137-single-number-ii
0150-evaluate-reverse-polish-notation
0179-largest-number
0189-rotate-array
0209-minimum-size-subarray-sum
0219-contains-duplicate-ii
0238-product-of-array-except-self
0239-sliding-window-maximum
0240-search-a-2d-matrix-ii
0274-h-index
0324-wiggle-sort-ii
0368-largest-divisible-subset
0376-wiggle-subsequence
0380-insert-delete-getrandom-o1
0417-pacific-atlantic-water-flow
0448-find-all-numbers-disappeared-in-an-array
0474-ones-and-zeroes
0498-diagonal-traverse
0611-valid-triangle-number
0636-exclusive-time-of-functions
0645-set-mismatch
0679-24-game
0739-daily-temperatures
0744-find-smallest-letter-greater-than-target
0787-sliding-puzzle
0794-swim-in-rising-water
0797-rabbits-in-forest
0827-making-a-large-island
0848-shifting-letters
0889-construct-binary-tree-from-preorder-and-postorder-traversal
0916-word-subsets
0934-bitwise-ors-of-subarrays
0940-fruit-into-baskets
0944-delete-columns-to-make-sorted
0945-snakes-and-ladders
0954-maximum-sum-circular-subarray
0961-n-repeated-element-in-size-2n-array
1006-vowel-spellchecker
1046-last-stone-weight
1200-minimum-absolute-difference
1351-count-negative-numbers-in-a-sorted-matrix
1354-construct-target-array-with-multiple-sums
1365-how-many-numbers-are-smaller-than-the-current-number
1390-four-divisors
1394-find-lucky-integer-in-an-array
1402-count-square-submatrices-with-all-ones
1426-find-n-unique-integers-sum-up-to-zero
1475-final-prices-with-a-special-discount-in-a-shop
1498-number-of-subsequences-that-satisfy-the-given-sum-condition
1504-count-submatrices-with-all-ones
1580-shuffle-the-array
1586-longest-subarray-of-1s-after-deleting-one-element
1628-count-submatrices-with-all-ones
1700-minimum-time-to-make-rope-colorful
1813-maximum-erasure-value
1834-minimum-number-of-people-to-teach
1877-minimize-maximum-pair-sum-in-array
2047-find-a-peak-element-ii
2058-concatenation-of-array
2229-maximum-fruits-harvested-after-at-most-k-steps
2316-count-hills-and-valleys-in-an-array
2343-count-unguarded-cells-in-the-grid
2392-successful-pairs-of-spells-and-potions
2432-number-of-zero-filled-subarrays
2435-paths-in-matrix-whose-sum-is-divisible-by-k
2498-smallest-subarrays-with-maximum-bitwise-or
2503-longest-subarray-with-maximum-bitwise-and
2529-range-product-queries-of-powers
2618-maximize-the-minimum-powered-city
2661-smallest-missing-non-negative-integer-after-operations
2689-rearranging-fruits
3075-maximize-happiness-of-selected-children
3242-count-elements-with-maximum-frequency
3251-maximum-area-of-longest-diagonal-rectangle
3278-find-the-number-of-ways-to-place-people-i
3314-construct-the-minimum-bitwise-array-i
3383-taking-maximum-energy-from-the-mystic-dungeon
3459-find-the-minimum-area-to-cover-all-ones-ii
3577-count-the-number-of-computer-unlocking-permutations
3583-count-special-triplets
3619-adjacent-increasing-subarrays-detection-ii
3648-find-the-maximum-number-of-fruits-collected
3748-sort-matrix-by-diagonals
3788-maximum-unique-subarray-sum-after-deletion
3791-fruits-into-baskets-iii
3797-design-spreadsheet
3827-implement-router
4078-maximum-alternating-sum-of-squares
4083-stable-subarrays-with-equal-boundary-and-interior-sum

Hash Table

0001-two-sum
0013-roman-to-integer
0030-substring-with-concatenation-of-all-words
0036-valid-sudoku
0037-sudoku-solver
0076-minimum-window-substring
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0127-word-ladder
0128-longest-consecutive-sequence
0133-clone-graph
0166-fraction-to-recurring-decimal
0205-isomorphic-strings
0219-contains-duplicate-ii
0242-valid-anagram
0380-insert-delete-getrandom-o1
0383-ransom-note
0424-longest-repeating-character-replacement
0433-minimum-genetic-mutation
0448-find-all-numbers-disappeared-in-an-array
0451-sort-characters-by-frequency
0567-permutation-in-string
0645-set-mismatch
0756-pyramid-transition-matrix
0768-partition-labels
0797-rabbits-in-forest
0889-construct-binary-tree-from-preorder-and-postorder-traversal
0900-reordered-power-of-2
0916-word-subsets
0940-fruit-into-baskets
0961-n-repeated-element-in-size-2n-array
1006-vowel-spellchecker
1264-maximum-number-of-words-you-can-type
1365-how-many-numbers-are-smaller-than-the-current-number
1394-find-lucky-integer-in-an-array
1813-maximum-erasure-value
1834-minimum-number-of-people-to-teach
1890-sum-of-beauty-of-all-substrings
2174-next-greater-numerically-balanced-number
2661-smallest-missing-non-negative-integer-after-operations
2689-rearranging-fruits
3242-count-elements-with-maximum-frequency
3583-count-special-triplets
3678-design-task-manager
3788-maximum-unique-subarray-sum-after-deletion
3797-design-spreadsheet
3827-implement-router
4083-stable-subarrays-with-equal-boundary-and-interior-sum

Sliding Window

0030-substring-with-concatenation-of-all-words
0076-minimum-window-substring
0209-minimum-size-subarray-sum
0219-contains-duplicate-ii
0239-sliding-window-maximum
0424-longest-repeating-character-replacement
0567-permutation-in-string
0940-fruit-into-baskets
1586-longest-subarray-of-1s-after-deleting-one-element
1813-maximum-erasure-value
2229-maximum-fruits-harvested-after-at-most-k-steps
2498-smallest-subarrays-with-maximum-bitwise-or
2618-maximize-the-minimum-powered-city

Greedy

0011-container-with-most-water
0045-jump-game-ii
0122-best-time-to-buy-and-sell-stock-ii
0179-largest-number
0324-wiggle-sort-ii
0376-wiggle-subsequence
0397-integer-replacement
0611-valid-triangle-number
0670-maximum-swap
0768-partition-labels
0797-rabbits-in-forest
1432-max-difference-you-can-get-from-changing-an-integer
1448-maximum-69-number
1700-minimum-time-to-make-rope-colorful
1818-maximum-score-from-removing-substrings
1834-minimum-number-of-people-to-teach
1877-minimize-maximum-pair-sum-in-array
2618-maximize-the-minimum-powered-city
2661-smallest-missing-non-negative-integer-after-operations
2689-rearranging-fruits
3075-maximize-happiness-of-selected-children
3788-maximum-unique-subarray-sum-after-deletion
4078-maximum-alternating-sum-of-squares

String

0008-string-to-integer-atoi
0013-roman-to-integer
0030-substring-with-concatenation-of-all-words
0071-simplify-path
0076-minimum-window-substring
0127-word-ladder
0151-reverse-words-in-a-string
0165-compare-version-numbers
0166-fraction-to-recurring-decimal
0179-largest-number
0205-isomorphic-strings
0224-basic-calculator
0242-valid-anagram
0297-serialize-and-deserialize-binary-tree
0345-reverse-vowels-of-a-string
0383-ransom-note
0394-decode-string
0424-longest-repeating-character-replacement
0433-minimum-genetic-mutation
0451-sort-characters-by-frequency
0474-ones-and-zeroes
0482-license-key-formatting
0520-detect-capital
0567-permutation-in-string
0712-minimum-ascii-delete-sum-for-two-strings
0756-pyramid-transition-matrix
0768-partition-labels
0848-shifting-letters
0916-word-subsets
0944-delete-columns-to-make-sorted
1006-vowel-spellchecker
1078-remove-outermost-parentheses
1264-maximum-number-of-words-you-can-type
1451-rearrange-words-in-a-sentence
1636-number-of-substrings-with-only-1s
1700-minimum-time-to-make-rope-colorful
1818-maximum-score-from-removing-substrings
1890-sum-of-beauty-of-all-substrings
3797-design-spreadsheet

Stack

0071-simplify-path
0150-evaluate-reverse-polish-notation
0224-basic-calculator
0394-decode-string
0636-exclusive-time-of-functions
0739-daily-temperatures
1078-remove-outermost-parentheses
1475-final-prices-with-a-special-discount-in-a-shop
1504-count-submatrices-with-all-ones
1628-count-submatrices-with-all-ones
1818-maximum-score-from-removing-substrings

Dynamic Programming

0045-jump-game-ii
0053-maximum-subarray
0064-minimum-path-sum
0118-pascals-triangle
0120-triangle
0122-best-time-to-buy-and-sell-stock-ii
0368-largest-divisible-subset
0376-wiggle-subsequence
0397-integer-replacement
0474-ones-and-zeroes
0712-minimum-ascii-delete-sum-for-two-strings
0787-sliding-puzzle
0806-domino-and-tromino-tiling
0826-soup-servings
0934-bitwise-ors-of-subarrays
0954-maximum-sum-circular-subarray
1402-count-square-submatrices-with-all-ones
1411-number-of-ways-to-paint-n-3-grid
1504-count-submatrices-with-all-ones
1586-longest-subarray-of-1s-after-deleting-one-element
1628-count-submatrices-with-all-ones
1700-minimum-time-to-make-rope-colorful
2435-paths-in-matrix-whose-sum-is-divisible-by-k
2882-ways-to-express-an-integer-as-sum-of-powers
3648-find-the-maximum-number-of-fruits-collected

Matrix

0036-valid-sudoku
0037-sudoku-solver
0064-minimum-path-sum
0074-search-a-2d-matrix
0240-search-a-2d-matrix-ii
0417-pacific-atlantic-water-flow
0498-diagonal-traverse
0787-sliding-puzzle
0794-swim-in-rising-water
0827-making-a-large-island
0945-snakes-and-ladders
1351-count-negative-numbers-in-a-sorted-matrix
1402-count-square-submatrices-with-all-ones
1504-count-submatrices-with-all-ones
1628-count-submatrices-with-all-ones
2047-find-a-peak-element-ii
2343-count-unguarded-cells-in-the-grid
2435-paths-in-matrix-whose-sum-is-divisible-by-k
3459-find-the-minimum-area-to-cover-all-ones-ii
3648-find-the-maximum-number-of-fruits-collected
3748-sort-matrix-by-diagonals
3797-design-spreadsheet

Binary Search

0033-search-in-rotated-sorted-array
0074-search-a-2d-matrix
0209-minimum-size-subarray-sum
0240-search-a-2d-matrix-ii
0611-valid-triangle-number
0744-find-smallest-letter-greater-than-target
0794-swim-in-rising-water
1351-count-negative-numbers-in-a-sorted-matrix
1498-number-of-subsequences-that-satisfy-the-given-sum-condition
2047-find-a-peak-element-ii
2229-maximum-fruits-harvested-after-at-most-k-steps
2392-successful-pairs-of-spells-and-potions
2498-smallest-subarrays-with-maximum-bitwise-or
2618-maximize-the-minimum-powered-city
3619-adjacent-increasing-subarrays-detection-ii
3791-fruits-into-baskets-iii
3827-implement-router

Bit Manipulation

0137-single-number-ii
0201-bitwise-and-of-numbers-range
0231-power-of-two
0342-power-of-four
0397-integer-replacement
0645-set-mismatch
0756-pyramid-transition-matrix
0934-bitwise-ors-of-subarrays
2498-smallest-subarrays-with-maximum-bitwise-or
2503-longest-subarray-with-maximum-bitwise-and
2529-range-product-queries-of-powers
2837-minimum-operations-to-make-the-integer-zero
3314-construct-the-minimum-bitwise-array-i

Brainteaser

2503-longest-subarray-with-maximum-bitwise-and
2837-minimum-operations-to-make-the-integer-zero
3577-count-the-number-of-computer-unlocking-permutations

Sort

2689-rearranging-fruits

Prefix Sum

0209-minimum-size-subarray-sum
0238-product-of-array-except-self
0848-shifting-letters
2229-maximum-fruits-harvested-after-at-most-k-steps
2529-range-product-queries-of-powers
2618-maximize-the-minimum-powered-city
3383-taking-maximum-energy-from-the-mystic-dungeon
4083-stable-subarrays-with-equal-boundary-and-interior-sum

Two Pointers

0011-container-with-most-water
0026-remove-duplicates-from-sorted-array
0080-remove-duplicates-from-sorted-array-ii
0151-reverse-words-in-a-string
0165-compare-version-numbers
0189-rotate-array
0345-reverse-vowels-of-a-string
0567-permutation-in-string
0611-valid-triangle-number
0768-partition-labels
1498-number-of-subsequences-that-satisfy-the-given-sum-condition
1877-minimize-maximum-pair-sum-in-array
2392-successful-pairs-of-spells-and-potions

Sorting

0179-largest-number
0242-valid-anagram
0274-h-index
0324-wiggle-sort-ii
0368-largest-divisible-subset
0451-sort-characters-by-frequency
0611-valid-triangle-number
0645-set-mismatch
0900-reordered-power-of-2
1200-minimum-absolute-difference
1365-how-many-numbers-are-smaller-than-the-current-number
1451-rearrange-words-in-a-sentence
1498-number-of-subsequences-that-satisfy-the-given-sum-condition
1877-minimize-maximum-pair-sum-in-array
2392-successful-pairs-of-spells-and-potions
3075-maximize-happiness-of-selected-children
3278-find-the-number-of-ways-to-place-people-i
3748-sort-matrix-by-diagonals
4078-maximum-alternating-sum-of-squares

Heap (Priority Queue)

0239-sliding-window-maximum
0451-sort-characters-by-frequency
0794-swim-in-rising-water
1046-last-stone-weight
1354-construct-target-array-with-multiple-sums
3678-design-task-manager

Bucket Sort

0451-sort-characters-by-frequency

Counting

0383-ransom-note
0451-sort-characters-by-frequency
0900-reordered-power-of-2
1394-find-lucky-integer-in-an-array
1890-sum-of-beauty-of-all-substrings
2174-next-greater-numerically-balanced-number
3242-count-elements-with-maximum-frequency
3583-count-special-triplets

Math

0013-roman-to-integer
0150-evaluate-reverse-polish-notation
0166-fraction-to-recurring-decimal
0189-rotate-array
0224-basic-calculator
0231-power-of-two
0326-power-of-three
0342-power-of-four
0368-largest-divisible-subset
0380-insert-delete-getrandom-o1
0670-maximum-swap
0679-24-game
0797-rabbits-in-forest
0826-soup-servings
0900-reordered-power-of-2
1390-four-divisors
1426-find-n-unique-integers-sum-up-to-zero
1432-max-difference-you-can-get-from-changing-an-integer
1440-convert-integer-to-the-sum-of-two-no-zero-integers
1448-maximum-69-number
1492-the-kth-factor-of-n
1636-number-of-substrings-with-only-1s
2174-next-greater-numerically-balanced-number
2288-count-operations-to-obtain-zero
2432-number-of-zero-filled-subarrays
2661-smallest-missing-non-negative-integer-after-operations
3278-find-the-number-of-ways-to-place-people-i
3336-water-bottles-ii
3577-count-the-number-of-computer-unlocking-permutations

Divide and Conquer

0053-maximum-subarray
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0240-search-a-2d-matrix-ii
0324-wiggle-sort-ii
0889-construct-binary-tree-from-preorder-and-postorder-traversal
0954-maximum-sum-circular-subarray

Segment Tree

3791-fruits-into-baskets-iii

Ordered Set

3678-design-task-manager
3791-fruits-into-baskets-iii
3827-implement-router

Probability and Statistics

0826-soup-servings

Recursion

0224-basic-calculator
0231-power-of-two
0326-power-of-three
0342-power-of-four
0394-decode-string

Enumeration

0900-reordered-power-of-2
2174-next-greater-numerically-balanced-number
2837-minimum-operations-to-make-the-integer-zero
3278-find-the-number-of-ways-to-place-people-i
3459-find-the-minimum-area-to-cover-all-ones-ii

Counting Sort

0274-h-index
1365-how-many-numbers-are-smaller-than-the-current-number

Design

0297-serialize-and-deserialize-binary-tree
0380-insert-delete-getrandom-o1
3678-design-task-manager
3797-design-spreadsheet
3827-implement-router

Randomized

0380-insert-delete-getrandom-o1

Depth-First Search

0098-validate-binary-search-tree
0129-sum-root-to-leaf-numbers
0133-clone-graph
0207-course-schedule
0210-course-schedule-ii
0297-serialize-and-deserialize-binary-tree
0386-lexicographical-numbers
0417-pacific-atlantic-water-flow
0530-minimum-absolute-difference-in-bst
0794-swim-in-rising-water
0820-find-eventual-safe-states
0827-making-a-large-island
1462-course-schedule-iv

Breadth-First Search

0127-word-ladder
0133-clone-graph
0207-course-schedule
0210-course-schedule-ii
0297-serialize-and-deserialize-binary-tree
0417-pacific-atlantic-water-flow
0433-minimum-genetic-mutation
0530-minimum-absolute-difference-in-bst
0787-sliding-puzzle
0794-swim-in-rising-water
0820-find-eventual-safe-states
0827-making-a-large-island
0945-snakes-and-ladders
1462-course-schedule-iv

Graph

0133-clone-graph
0207-course-schedule
0210-course-schedule-ii
0820-find-eventual-safe-states
1462-course-schedule-iv

Topological Sort

0207-course-schedule
0210-course-schedule-ii
0820-find-eventual-safe-states
1462-course-schedule-iv

Backtracking

0037-sudoku-solver
0679-24-game
0756-pyramid-transition-matrix
0787-sliding-puzzle
2174-next-greater-numerically-balanced-number

Queue

0239-sliding-window-maximum
0954-maximum-sum-circular-subarray
2618-maximize-the-minimum-powered-city
3827-implement-router

Monotonic Queue

0239-sliding-window-maximum
0954-maximum-sum-circular-subarray

Tree

0098-validate-binary-search-tree
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0129-sum-root-to-leaf-numbers
0297-serialize-and-deserialize-binary-tree
0530-minimum-absolute-difference-in-bst
0889-construct-binary-tree-from-preorder-and-postorder-traversal

Binary Search Tree

0098-validate-binary-search-tree
0530-minimum-absolute-difference-in-bst

Binary Tree

0098-validate-binary-search-tree
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0129-sum-root-to-leaf-numbers
0297-serialize-and-deserialize-binary-tree
0530-minimum-absolute-difference-in-bst
0889-construct-binary-tree-from-preorder-and-postorder-traversal

Monotonic Stack

0739-daily-temperatures
1475-final-prices-with-a-special-discount-in-a-shop
1504-count-submatrices-with-all-ones
1628-count-submatrices-with-all-ones

Simulation

0498-diagonal-traverse
2058-concatenation-of-array
2288-count-operations-to-obtain-zero
2343-count-unguarded-cells-in-the-grid
3336-water-bottles-ii

Geometry

3278-find-the-number-of-ways-to-place-people-i

Union Find

0128-longest-consecutive-sequence
0794-swim-in-rising-water
0827-making-a-large-island

Quickselect

0324-wiggle-sort-ii

Trie

0386-lexicographical-numbers

Memoization

0397-integer-replacement
0787-sliding-puzzle

Combinatorics

3577-count-the-number-of-computer-unlocking-permutations

Number Theory

1492-the-kth-factor-of-n

About

A collection of LeetCode questions to ace the coding interview!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages