Skip to content
Shantanu-kaushik-738Public

About

This repository contains my solutions to various problems from the LeetCode platform. Each problem's solution is organized into its own directory, named after the problem's title or number. Within each directory, you'll find the code implementation in the C++ language.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1,894 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leetcode

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

LeetCode Topics

Math

0002-add-two-numbers
0007-reverse-integer
0009-palindrome-number
0013-roman-to-integer
0029-divide-two-integers
0048-rotate-image
0050-powx-n
0062-unique-paths
0069-sqrtx
0171-excel-sheet-column-number
0189-rotate-array
0202-happy-number
0204-count-primes
0231-power-of-two
0268-missing-number
0326-power-of-three
0342-power-of-four
0509-fibonacci-number
0628-maximum-product-of-three-numbers
0836-rectangle-overlap
0877-stone-game
1006-clumsy-factorial
1248-count-number-of-nice-subarrays
1295-find-numbers-with-even-number-of-digits
1344-angle-between-hands-of-a-clock
1401-circle-and-rectangle-overlapping
1510-stone-game-iv
1523-count-odd-numbers-in-an-interval-range
1563-stone-game-v
1621-number-of-sets-of-k-non-overlapping-line-segments
1812-determine-color-of-a-chessboard-square
1837-sum-of-digits-in-base-k
1872-stone-game-viii
1903-largest-odd-number-in-string
1927-sum-game
1979-find-greatest-common-divisor-of-array
2029-stone-game-ix
2235-add-two-integers
2310-sum-of-numbers-with-units-digit-k
2413-smallest-even-multiple
2582-pass-the-pillow
2769-find-the-maximum-achievable-number
2843-count-symmetric-integers
2965-find-missing-and-repeated-values
3014-minimum-number-of-pushes-to-type-word-i
3116-kth-smallest-amount-with-single-denomination-combination
3227-vowels-game-in-a-string
3300-minimum-element-after-replacement-with-digit-sum
3345-smallest-divisible-digit-product-i
3512-minimum-operations-to-make-array-sum-divisible-by-k
3513-number-of-unique-xor-triplets-i
3514-number-of-unique-xor-triplets-ii
3516-find-closest-person
3524-find-x-value-of-array-i
3536-maximum-product-of-two-digits
3550-smallest-index-with-digit-sum-equal-to-index
3622-check-divisibility-by-digit-sum-and-product
3658-gcd-of-odd-and-even-sums
3723-maximize-sum-of-squares-of-digits
3726-remove-zeros-in-decimal-representation
3736-minimum-moves-to-equal-array-elements-iii
3751-total-waviness-of-numbers-in-range-i
3754-concatenate-non-zero-digits-and-multiply-by-sum-i
3783-mirror-distance-of-an-integer
3867-sum-of-gcd-of-formed-pairs
3870-count-commas-in-range
3871-count-commas-in-range-ii
3875-construct-uniform-parity-array-i
3876-construct-uniform-parity-array-ii

Two Pointers

0005-longest-palindromic-substring
0015-3sum
0018-4sum
0019-remove-nth-node-from-end-of-list
0026-remove-duplicates-from-sorted-array
0027-remove-element
0028-find-the-index-of-the-first-occurrence-in-a-string
0031-next-permutation
0042-trapping-rain-water
0075-sort-colors
0088-merge-sorted-array
0125-valid-palindrome
0141-linked-list-cycle
0142-linked-list-cycle-ii
0148-sort-list
0151-reverse-words-in-a-string
0160-intersection-of-two-linked-lists
0189-rotate-array
0202-happy-number
0234-palindrome-linked-list
0283-move-zeroes
0287-find-the-duplicate-number
0295-find-median-from-data-stream
0344-reverse-string
0392-is-subsequence
0443-string-compression
0455-assign-cookies
0567-permutation-in-string
0832-flipping-an-image
0876-middle-of-the-linked-list
0977-squares-of-a-sorted-array
2095-delete-the-middle-node-of-a-linked-list
2108-find-first-palindromic-string-in-the-array
2130-maximum-twin-sum-of-a-linked-list
2149-rearrange-array-elements-by-sign
2161-partition-array-according-to-given-pivot
2472-maximum-number-of-non-overlapping-palindrome-substrings
3633-earliest-finish-time-for-land-and-water-rides-i
3635-earliest-finish-time-for-land-and-water-rides-ii
3734-lexicographically-smallest-palindromic-permutation-greater-than-target
3794-reverse-string-prefix
3867-sum-of-gcd-of-formed-pairs

String

0003-longest-substring-without-repeating-characters
0005-longest-palindromic-substring
0008-string-to-integer-atoi
0013-roman-to-integer
0014-longest-common-prefix
0017-letter-combinations-of-a-phone-number
0020-valid-parentheses
0022-generate-parentheses
0028-find-the-index-of-the-first-occurrence-in-a-string
0032-longest-valid-parentheses
0049-group-anagrams
0076-minimum-window-substring
0079-word-search
0115-distinct-subsequences
0125-valid-palindrome
0131-palindrome-partitioning
0151-reverse-words-in-a-string
0171-excel-sheet-column-number
0179-largest-number
0205-isomorphic-strings
0242-valid-anagram
0301-remove-invalid-parentheses
0344-reverse-string
0387-first-unique-character-in-a-string
0392-is-subsequence
0402-remove-k-digits
0424-longest-repeating-character-replacement
0443-string-compression
0451-sort-characters-by-frequency
0567-permutation-in-string
0657-robot-return-to-origin
0678-valid-parenthesis-string
0709-to-lower-case
0796-rotate-string
0856-score-of-parentheses
0940-distinct-subsequences-ii
1021-remove-outermost-parentheses
1081-smallest-subsequence-of-distinct-characters
1096-brace-expansion-ii
1108-defanging-an-ip-address
1111-maximum-nesting-depth-of-two-valid-parentheses-strings
1189-maximum-number-of-balloons
1358-number-of-substrings-containing-all-three-characters
1487-making-file-names-unique
1520-maximum-number-of-non-overlapping-substrings
1541-minimum-insertions-to-balance-a-parentheses-string
1614-maximum-nesting-depth-of-the-parentheses
1781-sum-of-beauty-of-all-substrings
1784-check-if-binary-string-has-at-most-one-segment-of-ones
1812-determine-color-of-a-chessboard-square
1816-truncate-sentence
1832-check-if-the-sentence-is-pangram
1903-largest-odd-number-in-string
1910-remove-all-occurrences-of-a-substring
1927-sum-game
1967-number-of-strings-that-appear-as-substrings-in-word
1985-find-the-kth-largest-integer-in-the-array
2108-find-first-palindromic-string-in-the-array
2114-maximum-number-of-words-found-in-sentences
2124-check-if-all-as-appears-before-all-bs
2472-maximum-number-of-non-overlapping-palindrome-substrings
2515-shortest-distance-to-target-string-in-a-circular-array
2678-number-of-senior-citizens
2710-remove-trailing-zeros-from-a-string
2716-minimize-string-length
2785-sort-vowels-in-a-string
2833-furthest-point-from-origin
2904-shortest-and-lexicographically-smallest-beautiful-string
2942-find-words-containing-character
3014-minimum-number-of-pushes-to-type-word-i
3016-minimum-number-of-pushes-to-type-word-ii
3043-find-the-length-of-the-longest-common-prefix
3090-maximum-length-substring-with-two-occurrences
3110-score-of-a-string
3120-count-the-number-of-special-characters-i
3121-count-the-number-of-special-characters-ii
3136-valid-word
3174-clear-digits
3227-vowels-game-in-a-string
3498-reverse-degree-of-a-string
3499-maximize-active-section-with-trade-i
3517-smallest-palindromic-rearrangement-i
3541-find-most-frequent-vowel-and-consonant
3612-process-string-with-special-operations-i
3614-process-string-with-special-operations-ii
3720-lexicographically-smallest-permutation-greater-than-target
3734-lexicographically-smallest-palindromic-permutation-greater-than-target
3794-reverse-string-prefix
3813-vowel-consonant-score
3838-weighted-word-mapping
3889-mirror-frequency-distance

Dynamic Programming

0005-longest-palindromic-substring
0022-generate-parentheses
0032-longest-valid-parentheses
0042-trapping-rain-water
0045-jump-game-ii
0053-maximum-subarray
0055-jump-game
0062-unique-paths
0085-maximal-rectangle
0115-distinct-subsequences
0118-pascals-triangle
0121-best-time-to-buy-and-sell-stock
0131-palindrome-partitioning
0152-maximum-product-subarray
0392-is-subsequence
0509-fibonacci-number
0678-valid-parenthesis-string
0877-stone-game
0907-sum-of-subarray-minimums
0940-distinct-subsequences-ii
1477-find-two-non-overlapping-sub-arrays-each-with-target-sum
1510-stone-game-iv
1563-stone-game-v
1621-number-of-sets-of-k-non-overlapping-line-segments
1872-stone-game-viii
2267-check-if-there-is-a-valid-parentheses-string-path
2310-sum-of-numbers-with-units-digit-k
2472-maximum-number-of-non-overlapping-palindrome-substrings
3524-find-x-value-of-array-i
3751-total-waviness-of-numbers-in-range-i

Recursion

0002-add-two-numbers
0021-merge-two-sorted-lists
0025-reverse-nodes-in-k-group
0050-powx-n
0206-reverse-linked-list
0231-power-of-two
0234-palindrome-linked-list
0326-power-of-three
0342-power-of-four
0509-fibonacci-number
3483-unique-3-digit-even-numbers

Memoization

0509-fibonacci-number

Array

0001-two-sum
0004-median-of-two-sorted-arrays
0014-longest-common-prefix
0015-3sum
0018-4sum
0026-remove-duplicates-from-sorted-array
0027-remove-element
0031-next-permutation
0033-search-in-rotated-sorted-array
0034-find-first-and-last-position-of-element-in-sorted-array
0035-search-insert-position
0037-sudoku-solver
0039-combination-sum
0040-combination-sum-ii
0042-trapping-rain-water
0045-jump-game-ii
0048-rotate-image
0049-group-anagrams
0051-n-queens
0053-maximum-subarray
0054-spiral-matrix
0055-jump-game
0056-merge-intervals
0057-insert-interval
0059-spiral-matrix-ii
0073-set-matrix-zeroes
0074-search-a-2d-matrix
0075-sort-colors
0078-subsets
0079-word-search
0081-search-in-rotated-sorted-array-ii
0084-largest-rectangle-in-histogram
0085-maximal-rectangle
0088-merge-sorted-array
0090-subsets-ii
0118-pascals-triangle
0121-best-time-to-buy-and-sell-stock
0128-longest-consecutive-sequence
0134-gas-station
0135-candy
0152-maximum-product-subarray
0153-find-minimum-in-rotated-sorted-array
0154-find-minimum-in-rotated-sorted-array-ii
0162-find-peak-element
0169-majority-element
0179-largest-number
0189-rotate-array
0204-count-primes
0215-kth-largest-element-in-an-array
0216-combination-sum-iii
0217-contains-duplicate
0229-majority-element-ii
0238-product-of-array-except-self
0239-sliding-window-maximum
0240-search-a-2d-matrix-ii
0268-missing-number
0283-move-zeroes
0287-find-the-duplicate-number
0347-top-k-frequent-elements
0455-assign-cookies
0485-max-consecutive-ones
0496-next-greater-element-i
0503-next-greater-element-ii
0560-subarray-sum-equals-k
0621-task-scheduler
0628-maximum-product-of-three-numbers
0704-binary-search
0735-asteroid-collision
0744-find-smallest-letter-greater-than-target
0766-toeplitz-matrix
0832-flipping-an-image
0835-image-overlap
0846-hand-of-straights
0852-peak-index-in-a-mountain-array
0860-lemonade-change
0867-transpose-matrix
0875-koko-eating-bananas
0877-stone-game
0904-fruit-into-baskets
0907-sum-of-subarray-minimums
0912-sort-an-array
0930-binary-subarrays-with-sum
0977-squares-of-a-sorted-array
1004-max-consecutive-ones-iii
1011-capacity-to-ship-packages-within-d-days
1248-count-number-of-nice-subarrays
1260-shift-2d-grid
1283-find-the-smallest-divisor-given-a-threshold
1288-remove-covered-intervals
1295-find-numbers-with-even-number-of-digits
1331-rank-transform-of-an-array
1351-count-negative-numbers-in-a-sorted-matrix
1386-cinema-seat-allocation
1423-maximum-points-you-can-obtain-from-cards
1464-maximum-product-of-two-elements-in-an-array
1470-shuffle-the-array
1477-find-two-non-overlapping-sub-arrays-each-with-target-sum
1482-minimum-number-of-days-to-make-m-bouquets
1487-making-file-names-unique
1502-can-make-arithmetic-progression-from-sequence
1539-kth-missing-positive-number
1563-stone-game-v
1572-matrix-diagonal-sum
1658-minimum-operations-to-reduce-x-to-zero
1672-richest-customer-wealth
1732-find-the-highest-altitude
1748-sum-of-unique-elements
1752-check-if-array-is-sorted-and-rotated
1816-truncate-sentence
1833-maximum-ice-cream-bars
1846-maximum-element-after-decreasing-and-rearranging
1848-minimum-distance-to-the-target-element
1872-stone-game-viii
1901-find-a-peak-element-ii
1920-build-array-from-permutation
1967-number-of-strings-that-appear-as-substrings-in-word
1979-find-greatest-common-divisor-of-array
1985-find-the-kth-largest-integer-in-the-array
1991-find-the-middle-index-in-array
2016-maximum-difference-between-increasing-elements
2022-convert-1d-array-into-2d-array
2029-stone-game-ix
2073-time-needed-to-buy-tickets
2091-removing-minimum-and-maximum-from-array
2104-sum-of-subarray-ranges
2108-find-first-palindromic-string-in-the-array
2114-maximum-number-of-words-found-in-sentences
2126-destroying-asteroids
2144-minimum-cost-of-buying-candies-with-discount
2149-rearrange-array-elements-by-sign
2161-partition-array-according-to-given-pivot
2196-create-binary-tree-from-descriptions
2267-check-if-there-is-a-valid-parentheses-string-path
2333-minimum-sum-of-squared-difference
2515-shortest-distance-to-target-string-in-a-circular-array
2553-separate-the-digits-in-an-array
2574-left-and-right-sum-differences
2596-check-knight-tour-configuration
2657-find-the-prefix-common-array-of-two-arrays
2678-number-of-senior-citizens
2778-sum-of-squares-of-special-elements
2784-check-if-array-is-good
2942-find-words-containing-character
2948-make-lexicographically-smallest-array-by-swapping-elements
2958-length-of-longest-subarray-with-at-most-k-frequency
2965-find-missing-and-repeated-values
2974-minimum-number-game
2996-smallest-missing-integer-greater-than-sequential-prefix-sum
3020-find-the-maximum-number-of-elements-in-subset
3043-find-the-length-of-the-longest-common-prefix
3069-distribute-elements-into-two-arrays-i
3116-kth-smallest-amount-with-single-denomination-combination
3184-count-pairs-that-form-a-complete-day-i
3300-minimum-element-after-replacement-with-digit-sum
3392-count-subarrays-of-length-three-with-a-condition
3423-maximum-difference-between-adjacent-elements-in-a-circular-array
3471-find-the-largest-almost-missing-integer
3477-fruits-into-baskets-ii
3483-unique-3-digit-even-numbers
3512-minimum-operations-to-make-array-sum-divisible-by-k
3513-number-of-unique-xor-triplets-i
3514-number-of-unique-xor-triplets-ii
3523-make-array-non-decreasing
3524-find-x-value-of-array-i
3550-smallest-index-with-digit-sum-equal-to-index
3568-minimum-moves-to-clean-the-classroom
3633-earliest-finish-time-for-land-and-water-rides-i
3635-earliest-finish-time-for-land-and-water-rides-ii
3637-trionic-array-i
3689-maximum-total-subarray-value-i
3702-longest-subsequence-with-non-zero-bitwise-xor
3718-smallest-missing-multiple-of-k
3731-find-missing-elements
3736-minimum-moves-to-equal-array-elements-iii
3737-count-subarrays-with-majority-element-i
3739-count-subarrays-with-majority-element-ii
3838-weighted-word-mapping
3867-sum-of-gcd-of-formed-pairs
3875-construct-uniform-parity-array-i
3876-construct-uniform-parity-array-ii
3903-smallest-stable-index-i
3904-smallest-stable-index-ii

Sorting

0015-3sum
0018-4sum
0049-group-anagrams
0056-merge-intervals
0075-sort-colors
0088-merge-sorted-array
0148-sort-list
0169-majority-element
0179-largest-number
0215-kth-largest-element-in-an-array
0217-contains-duplicate
0229-majority-element-ii
0242-valid-anagram
0268-missing-number
0295-find-median-from-data-stream
0347-top-k-frequent-elements
0451-sort-characters-by-frequency
0455-assign-cookies
0621-task-scheduler
0628-maximum-product-of-three-numbers
0846-hand-of-straights
0912-sort-an-array
0977-squares-of-a-sorted-array
1096-brace-expansion-ii
1288-remove-covered-intervals
1331-rank-transform-of-an-array
1464-maximum-product-of-two-elements-in-an-array
1502-can-make-arithmetic-progression-from-sequence
1520-maximum-number-of-non-overlapping-substrings
1833-maximum-ice-cream-bars
1846-maximum-element-after-decreasing-and-rearranging
1985-find-the-kth-largest-integer-in-the-array
2126-destroying-asteroids
2144-minimum-cost-of-buying-candies-with-discount
2333-minimum-sum-of-squared-difference
2784-check-if-array-is-good
2785-sort-vowels-in-a-string
2948-make-lexicographically-smallest-array-by-swapping-elements
2974-minimum-number-game
2996-smallest-missing-integer-greater-than-sequential-prefix-sum
3016-minimum-number-of-pushes-to-type-word-ii
3517-smallest-palindromic-rearrangement-i
3536-maximum-product-of-two-digits
3633-earliest-finish-time-for-land-and-water-rides-i
3635-earliest-finish-time-for-land-and-water-rides-ii
3731-find-missing-elements
3867-sum-of-gcd-of-formed-pairs

Hash Table

0001-two-sum
0003-longest-substring-without-repeating-characters
0013-roman-to-integer
0017-letter-combinations-of-a-phone-number
0037-sudoku-solver
0049-group-anagrams
0073-set-matrix-zeroes
0076-minimum-window-substring
0128-longest-consecutive-sequence
0141-linked-list-cycle
0142-linked-list-cycle-ii
0146-lru-cache
0160-intersection-of-two-linked-lists
0169-majority-element
0202-happy-number
0205-isomorphic-strings
0217-contains-duplicate
0229-majority-element-ii
0242-valid-anagram
0268-missing-number
0347-top-k-frequent-elements
0387-first-unique-character-in-a-string
0424-longest-repeating-character-replacement
0451-sort-characters-by-frequency
0496-next-greater-element-i
0560-subarray-sum-equals-k
0567-permutation-in-string
0621-task-scheduler
0846-hand-of-straights
0904-fruit-into-baskets
0930-binary-subarrays-with-sum
1096-brace-expansion-ii
1189-maximum-number-of-balloons
1248-count-number-of-nice-subarrays
1331-rank-transform-of-an-array
1358-number-of-substrings-containing-all-three-characters
1386-cinema-seat-allocation
1477-find-two-non-overlapping-sub-arrays-each-with-target-sum
1487-making-file-names-unique
1520-maximum-number-of-non-overlapping-substrings
1658-minimum-operations-to-reduce-x-to-zero
1748-sum-of-unique-elements
1781-sum-of-beauty-of-all-substrings
1832-check-if-the-sentence-is-pangram
2196-create-binary-tree-from-descriptions
2657-find-the-prefix-common-array-of-two-arrays
2716-minimize-string-length
2784-check-if-array-is-good
2958-length-of-longest-subarray-with-at-most-k-frequency
2965-find-missing-and-repeated-values
2996-smallest-missing-integer-greater-than-sequential-prefix-sum
3016-minimum-number-of-pushes-to-type-word-ii
3020-find-the-maximum-number-of-elements-in-subset
3043-find-the-length-of-the-longest-common-prefix
3090-maximum-length-substring-with-two-occurrences
3120-count-the-number-of-special-characters-i
3121-count-the-number-of-special-characters-ii
3184-count-pairs-that-form-a-complete-day-i
3471-find-the-largest-almost-missing-integer
3483-unique-3-digit-even-numbers
3541-find-most-frequent-vowel-and-consonant
3568-minimum-moves-to-clean-the-classroom
3718-smallest-missing-multiple-of-k
3720-lexicographically-smallest-permutation-greater-than-target
3731-find-missing-elements
3737-count-subarrays-with-majority-element-i
3739-count-subarrays-with-majority-element-ii
3889-mirror-frequency-distance

Divide and Conquer

0004-median-of-two-sorted-arrays
0023-merge-k-sorted-lists
0053-maximum-subarray
0148-sort-list
0169-majority-element
0215-kth-largest-element-in-an-array
0240-search-a-2d-matrix-ii
0347-top-k-frequent-elements
0912-sort-an-array
1985-find-the-kth-largest-integer-in-the-array
3737-count-subarrays-with-majority-element-i
3739-count-subarrays-with-majority-element-ii

Counting

0169-majority-element
0229-majority-element-ii
0347-top-k-frequent-elements
0387-first-unique-character-in-a-string
0451-sort-characters-by-frequency
0621-task-scheduler
1189-maximum-number-of-balloons
1748-sum-of-unique-elements
1781-sum-of-beauty-of-all-substrings
2029-stone-game-ix
2833-furthest-point-from-origin
3016-minimum-number-of-pushes-to-type-word-ii
3184-count-pairs-that-form-a-complete-day-i
3541-find-most-frequent-vowel-and-consonant
3720-lexicographically-smallest-permutation-greater-than-target
3737-count-subarrays-with-majority-element-i
3889-mirror-frequency-distance

Simulation

0054-spiral-matrix
0059-spiral-matrix-ii
0657-robot-return-to-origin
0735-asteroid-collision
0832-flipping-an-image
0867-transpose-matrix
1006-clumsy-factorial
1260-shift-2d-grid
1910-remove-all-occurrences-of-a-substring
1920-build-array-from-permutation
2022-convert-1d-array-into-2d-array
2073-time-needed-to-buy-tickets
2149-rearrange-array-elements-by-sign
2161-partition-array-according-to-given-pivot
2553-separate-the-digits-in-an-array
2582-pass-the-pillow
2596-check-knight-tour-configuration
2974-minimum-number-game
3069-distribute-elements-into-two-arrays-i
3174-clear-digits
3477-fruits-into-baskets-ii
3498-reverse-degree-of-a-string
3612-process-string-with-special-operations-i
3614-process-string-with-special-operations-ii
3726-remove-zeros-in-decimal-representation
3813-vowel-consonant-score
3838-weighted-word-mapping
3867-sum-of-gcd-of-formed-pairs

Matrix

0037-sudoku-solver
0048-rotate-image
0054-spiral-matrix
0059-spiral-matrix-ii
0073-set-matrix-zeroes
0074-search-a-2d-matrix
0079-word-search
0085-maximal-rectangle
0240-search-a-2d-matrix-ii
0766-toeplitz-matrix
0832-flipping-an-image
0835-image-overlap
0867-transpose-matrix
1260-shift-2d-grid
1351-count-negative-numbers-in-a-sorted-matrix
1572-matrix-diagonal-sum
1672-richest-customer-wealth
1901-find-a-peak-element-ii
2022-convert-1d-array-into-2d-array
2267-check-if-there-is-a-valid-parentheses-string-path
2596-check-knight-tour-configuration
2965-find-missing-and-repeated-values
3568-minimum-moves-to-clean-the-classroom

Binary Search

0004-median-of-two-sorted-arrays
0033-search-in-rotated-sorted-array
0034-find-first-and-last-position-of-element-in-sorted-array
0035-search-insert-position
0069-sqrtx
0074-search-a-2d-matrix
0081-search-in-rotated-sorted-array-ii
0153-find-minimum-in-rotated-sorted-array
0154-find-minimum-in-rotated-sorted-array-ii
0162-find-peak-element
0240-search-a-2d-matrix-ii
0268-missing-number
0287-find-the-duplicate-number
0704-binary-search
0744-find-smallest-letter-greater-than-target
0852-peak-index-in-a-mountain-array
0875-koko-eating-bananas
1004-max-consecutive-ones-iii
1011-capacity-to-ship-packages-within-d-days
1283-find-the-smallest-divisor-given-a-threshold
1351-count-negative-numbers-in-a-sorted-matrix
1477-find-two-non-overlapping-sub-arrays-each-with-target-sum
1482-minimum-number-of-days-to-make-m-bouquets
1539-kth-missing-positive-number
1658-minimum-operations-to-reduce-x-to-zero
1901-find-a-peak-element-ii
2333-minimum-sum-of-squared-difference
3116-kth-smallest-amount-with-single-denomination-combination
3477-fruits-into-baskets-ii
3633-earliest-finish-time-for-land-and-water-rides-i
3635-earliest-finish-time-for-land-and-water-rides-ii

Union-Find

0128-longest-consecutive-sequence
2948-make-lexicographically-smallest-array-by-swapping-elements

Prefix Sum

0238-product-of-array-except-self
0560-subarray-sum-equals-k
0930-binary-subarrays-with-sum
1004-max-consecutive-ones-iii
1248-count-number-of-nice-subarrays
1423-maximum-points-you-can-obtain-from-cards
1621-number-of-sets-of-k-non-overlapping-line-segments
1658-minimum-operations-to-reduce-x-to-zero
1732-find-the-highest-altitude
1872-stone-game-viii
1991-find-the-middle-index-in-array
2574-left-and-right-sum-differences
3737-count-subarrays-with-majority-element-i
3739-count-subarrays-with-majority-element-ii
3903-smallest-stable-index-i
3904-smallest-stable-index-ii

Bit Manipulation

0029-divide-two-integers
0078-subsets
0090-subsets-ii
0231-power-of-two
0268-missing-number
0287-find-the-duplicate-number
0342-power-of-four
0832-flipping-an-image
1386-cinema-seat-allocation
2220-minimum-bit-flips-to-convert-number
2657-find-the-prefix-common-array-of-two-arrays
3116-kth-smallest-amount-with-single-denomination-combination
3513-number-of-unique-xor-triplets-i
3514-number-of-unique-xor-triplets-ii
3568-minimum-moves-to-clean-the-classroom
3702-longest-subsequence-with-non-zero-bitwise-xor

Stack

0020-valid-parentheses
0032-longest-valid-parentheses
0042-trapping-rain-water
0084-largest-rectangle-in-histogram
0085-maximal-rectangle
0144-binary-tree-preorder-traversal
0155-min-stack
0225-implement-stack-using-queues
0232-implement-queue-using-stacks
0234-palindrome-linked-list
0402-remove-k-digits
0496-next-greater-element-i
0503-next-greater-element-ii
0678-valid-parenthesis-string
0735-asteroid-collision
0856-score-of-parentheses
0901-online-stock-span
0907-sum-of-subarray-minimums
1006-clumsy-factorial
1021-remove-outermost-parentheses
1081-smallest-subsequence-of-distinct-characters
1096-brace-expansion-ii
1111-maximum-nesting-depth-of-two-valid-parentheses-strings
1541-minimum-insertions-to-balance-a-parentheses-string
1614-maximum-nesting-depth-of-the-parentheses
1910-remove-all-occurrences-of-a-substring
2104-sum-of-subarray-ranges
2130-maximum-twin-sum-of-a-linked-list
3174-clear-digits
3523-make-array-non-decreasing

String Matching

0028-find-the-index-of-the-first-occurrence-in-a-string
0796-rotate-string

Segment Tree

3477-fruits-into-baskets-ii
3737-count-subarrays-with-majority-element-i
3739-count-subarrays-with-majority-element-ii

Ordered Set

3477-fruits-into-baskets-ii

Brainteaser

3227-vowels-game-in-a-string

Game Theory

0877-stone-game
1510-stone-game-iv
1563-stone-game-v
1872-stone-game-viii
1927-sum-game
2029-stone-game-ix
3227-vowels-game-in-a-string

Greedy

0045-jump-game-ii
0055-jump-game
0134-gas-station
0135-candy
0179-largest-number
0402-remove-k-digits
0455-assign-cookies
0621-task-scheduler
0678-valid-parenthesis-string
0846-hand-of-straights
0860-lemonade-change
1081-smallest-subsequence-of-distinct-characters
1386-cinema-seat-allocation
1520-maximum-number-of-non-overlapping-substrings
1541-minimum-insertions-to-balance-a-parentheses-string
1833-maximum-ice-cream-bars
1846-maximum-element-after-decreasing-and-rearranging
1903-largest-odd-number-in-string
1927-sum-game
2029-stone-game-ix
2091-removing-minimum-and-maximum-from-array
2126-destroying-asteroids
2144-minimum-cost-of-buying-candies-with-discount
2310-sum-of-numbers-with-units-digit-k
2333-minimum-sum-of-squared-difference
2472-maximum-number-of-non-overlapping-palindrome-substrings
3014-minimum-number-of-pushes-to-type-word-i
3016-minimum-number-of-pushes-to-type-word-ii
3523-make-array-non-decreasing
3633-earliest-finish-time-for-land-and-water-rides-i
3635-earliest-finish-time-for-land-and-water-rides-ii
3689-maximum-total-subarray-value-i
3720-lexicographically-smallest-permutation-greater-than-target
3723-maximize-sum-of-squares-of-digits

Enumeration

0204-count-primes
1291-sequential-digits
2310-sum-of-numbers-with-units-digit-k
2778-sum-of-squares-of-special-elements
2843-count-symmetric-integers
3020-find-the-maximum-number-of-elements-in-subset
3345-smallest-divisible-digit-product-i
3483-unique-3-digit-even-numbers
3499-maximize-active-section-with-trade-i
3514-number-of-unique-xor-triplets-ii
3720-lexicographically-smallest-permutation-greater-than-target
3734-lexicographically-smallest-palindromic-permutation-greater-than-target
3751-total-waviness-of-numbers-in-range-i

Number Theory

0204-count-primes
1979-find-greatest-common-divisor-of-array
2413-smallest-even-multiple
3116-kth-smallest-amount-with-single-denomination-combination
3658-gcd-of-odd-and-even-sums
3867-sum-of-gcd-of-formed-pairs

Linked List

0002-add-two-numbers
0019-remove-nth-node-from-end-of-list
0021-merge-two-sorted-lists
0023-merge-k-sorted-lists
0025-reverse-nodes-in-k-group
0141-linked-list-cycle
0142-linked-list-cycle-ii
0146-lru-cache
0148-sort-list
0160-intersection-of-two-linked-lists
0206-reverse-linked-list
0234-palindrome-linked-list
0237-delete-node-in-a-linked-list
0328-odd-even-linked-list
0430-flatten-a-multilevel-doubly-linked-list
0876-middle-of-the-linked-list
2058-find-the-minimum-and-maximum-number-of-nodes-between-critical-points
2095-delete-the-middle-node-of-a-linked-list
2130-maximum-twin-sum-of-a-linked-list

Trie

0014-longest-common-prefix
3043-find-the-length-of-the-longest-common-prefix

Monotonic Stack

0042-trapping-rain-water
0084-largest-rectangle-in-histogram
0085-maximal-rectangle
0402-remove-k-digits
0496-next-greater-element-i
0503-next-greater-element-ii
0901-online-stock-span
0907-sum-of-subarray-minimums
1081-smallest-subsequence-of-distinct-characters
2104-sum-of-subarray-ranges
3523-make-array-non-decreasing

Combinatorics

0062-unique-paths
1621-number-of-sets-of-k-non-overlapping-line-segments
3116-kth-smallest-amount-with-single-denomination-combination

Merge Sort

0023-merge-k-sorted-lists
0148-sort-list
0912-sort-an-array
3737-count-subarrays-with-majority-element-i
3739-count-subarrays-with-majority-element-ii

Tree

0102-binary-tree-level-order-traversal
0144-binary-tree-preorder-traversal
0703-kth-largest-element-in-a-stream
2196-create-binary-tree-from-descriptions
2265-count-nodes-equal-to-average-of-subtree

Binary Tree

0102-binary-tree-level-order-traversal
0144-binary-tree-preorder-traversal
0703-kth-largest-element-in-a-stream
2196-create-binary-tree-from-descriptions
2265-count-nodes-equal-to-average-of-subtree

Sliding Window

0003-longest-substring-without-repeating-characters
0076-minimum-window-substring
0239-sliding-window-maximum
0424-longest-repeating-character-replacement
0567-permutation-in-string
0904-fruit-into-baskets
0930-binary-subarrays-with-sum
1004-max-consecutive-ones-iii
1248-count-number-of-nice-subarrays
1358-number-of-substrings-containing-all-three-characters
1423-maximum-points-you-can-obtain-from-cards
1477-find-two-non-overlapping-sub-arrays-each-with-target-sum
1658-minimum-operations-to-reduce-x-to-zero
2904-shortest-and-lexicographically-smallest-beautiful-string
2958-length-of-longest-subarray-with-at-most-k-frequency
3090-maximum-length-substring-with-two-occurrences

Depth-First Search

0079-word-search
0144-binary-tree-preorder-traversal
0430-flatten-a-multilevel-doubly-linked-list
2265-count-nodes-equal-to-average-of-subtree
2596-check-knight-tour-configuration

Doubly-Linked List

0146-lru-cache
0430-flatten-a-multilevel-doubly-linked-list

Backtracking

0017-letter-combinations-of-a-phone-number
0022-generate-parentheses
0037-sudoku-solver
0039-combination-sum
0040-combination-sum-ii
0051-n-queens
0078-subsets
0079-word-search
0090-subsets-ii
0131-palindrome-partitioning
0216-combination-sum-iii
0301-remove-invalid-parentheses
1096-brace-expansion-ii

Heap (Priority Queue)

0023-merge-k-sorted-lists
0215-kth-largest-element-in-an-array
0239-sliding-window-maximum
0295-find-median-from-data-stream
0347-top-k-frequent-elements
0451-sort-characters-by-frequency
0621-task-scheduler
0703-kth-largest-element-in-a-stream
0912-sort-an-array
1464-maximum-product-of-two-elements-in-an-array
1985-find-the-kth-largest-integer-in-the-array
2333-minimum-sum-of-squared-difference
2974-minimum-number-game

Bucket Sort

0347-top-k-frequent-elements
0451-sort-characters-by-frequency
0912-sort-an-array

Counting Sort

0912-sort-an-array
1833-maximum-ice-cream-bars
3517-smallest-palindromic-rearrangement-i

Quickselect

0215-kth-largest-element-in-an-array
0347-top-k-frequent-elements
1985-find-the-kth-largest-integer-in-the-array

Breadth-First Search

0102-binary-tree-level-order-traversal
0301-remove-invalid-parentheses
1096-brace-expansion-ii
2596-check-knight-tour-configuration
3568-minimum-moves-to-clean-the-classroom

Radix Sort

0912-sort-an-array

Design

0146-lru-cache
0155-min-stack
0225-implement-stack-using-queues
0232-implement-queue-using-stacks
0295-find-median-from-data-stream
0703-kth-largest-element-in-a-stream
0901-online-stock-span

Queue

0225-implement-stack-using-queues
0232-implement-queue-using-stacks
0239-sliding-window-maximum
0387-first-unique-character-in-a-string
2073-time-needed-to-buy-tickets

Range Minimum/Maximum Query

0084-largest-rectangle-in-histogram
0239-sliding-window-maximum

Monotonic Queue

0239-sliding-window-maximum

Data Stream

0295-find-median-from-data-stream
0703-kth-largest-element-in-a-stream
0901-online-stock-span

Minimax

1510-stone-game-iv
1872-stone-game-viii
2029-stone-game-ix

Nim Game

1510-stone-game-iv
2029-stone-game-ix

Sprague–Grundy Theorem

1510-stone-game-iv

Zero-Sum Game

1510-stone-game-iv
1872-stone-game-viii
2029-stone-game-ix

Tournament Sort

0023-merge-k-sorted-lists

Binary Search Tree

0703-kth-largest-element-in-a-stream

Quicksort

0455-assign-cookies

Bracket Sequences

0020-valid-parentheses
0022-generate-parentheses
0032-longest-valid-parentheses
0678-valid-parenthesis-string
0856-score-of-parentheses
1021-remove-outermost-parentheses
1111-maximum-nesting-depth-of-two-valid-parentheses-strings
1541-minimum-insertions-to-balance-a-parentheses-string
1614-maximum-nesting-depth-of-the-parentheses
2267-check-if-there-is-a-valid-parentheses-string-path

Geometry

0836-rectangle-overlap
1401-circle-and-rectangle-overlapping

Database

0175-combine-two-tables
0176-second-highest-salary
0183-customers-who-never-order
0595-big-countries
1148-article-views-i
1667-fix-names-in-a-table
1683-invalid-tweets
1757-recyclable-and-low-fat-products

Boyer–Moore Majority Vote Algorithm

0169-majority-element

About

This repository contains my solutions to various problems from the LeetCode platform. Each problem's solution is organized into its own directory, named after the problem's title or number. Within each directory, you'll find the code implementation in the C++ language.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages