Skip to content

devasherr/competitive_programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

LeetCode Topics

Array

0011-container-with-most-water
0027-remove-element
0033-search-in-rotated-sorted-array
0034-find-first-and-last-position-of-element-in-sorted-array
0039-combination-sum
0049-group-anagrams
0053-maximum-subarray
0056-merge-intervals
0073-set-matrix-zeroes
0120-triangle
0121-best-time-to-buy-and-sell-stock
0128-longest-consecutive-sequence
0139-word-break
0213-house-robber-ii
0215-kth-largest-element-in-an-array
0238-product-of-array-except-self
0268-missing-number
0283-move-zeroes
0289-game-of-life
0416-partition-equal-subset-sum
0417-pacific-atlantic-water-flow
0435-non-overlapping-intervals
0532-k-diff-pairs-in-an-array
0560-subarray-sum-equals-k
0594-longest-harmonious-subsequence
0605-can-place-flowers
0628-maximum-product-of-three-numbers
0665-non-decreasing-array
0733-flood-fill
0854-making-a-large-island
0875-longest-mountain-in-array
0905-length-of-longest-fibonacci-subsequence
0909-stone-game
0925-construct-binary-tree-from-preorder-and-postorder-traversal
0952-word-subsets
0954-maximum-sum-circular-subarray
1018-largest-perimeter-triangle
1020-longest-turbulent-subarray
1036-rotting-oranges
1056-capacity-to-ship-packages-within-d-days
1095-two-city-scheduling
1147-flip-columns-for-maximum-number-of-equal-rows
1171-shortest-path-in-binary-matrix
1222-remove-covered-intervals
1227-number-of-equivalent-domino-pairs
1335-maximum-candies-allocated-to-k-children
1354-find-players-with-zero-or-one-losses
1364-tuple-with-same-product
1380-number-of-closed-islands
1396-count-servers-that-communicate
1397-search-suggestions-system
1468-check-if-n-and-its-double-exist
1477-product-of-the-last-k-numbers
1539-diagonal-traverse-ii
1748-best-team-with-no-conflicts
1776-minimum-operations-to-reduce-x-to-zero
1927-maximum-ascending-subarray-sum
1951-find-the-winner-of-the-circular-game
1972-rotating-the-box
1993-sum-of-all-subset-xor-totals
2035-count-sub-islands
2048-build-array-from-permutation
2089-maximum-matrix-sum
2094-remove-stones-to-minimize-the-total
2112-minimum-difference-between-highest-and-lowest-of-k-scores
2159-two-out-of-three
2206-detonate-the-maximum-bombs
2220-find-all-possible-recipes-from-given-supplies
2265-partition-array-according-to-given-pivot
2375-minimum-obstacle-removal-to-reach-corner
2392-successful-pairs-of-spells-and-potions
2412-minimum-amount-of-time-to-fill-cups
2465-shifting-letters-ii
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2478-longest-nice-subarray
2533-bitwise-xor-of-all-pairings
2552-maximum-sum-of-distinct-subarrays-with-length-k
2665-minimum-time-to-repair-cars
2692-take-gifts-from-the-richest-pile
2699-count-the-number-of-fair-pairs
2764-maximum-number-of-fish-in-a-grid
2766-find-the-prefix-common-array-of-two-arrays
2868-continuous-subarrays
2888-minimum-index-of-a-valid-split
3152-maximum-value-of-an-ordered-triplet-ii
3194-find-words-containing-character
3219-make-lexicographically-smallest-array-by-swapping-elements
3227-find-missing-and-repeated-values
3427-special-array-ii
3430-count-days-without-meetings
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i
3483-alternating-groups-ii
3581-the-two-sneaky-numbers-of-digitville
3619-adjacent-increasing-subarrays-detection-ii
3621-minimum-operations-to-make-array-values-equal-to-k
3657-check-if-grid-can-be-cut-into-sections
3799-unique-3-digit-even-numbers

Two Pointers

0005-longest-palindromic-substring
0011-container-with-most-water
0027-remove-element
0028-find-the-index-of-the-first-occurrence-in-a-string
0086-partition-list
0142-linked-list-cycle-ii
0283-move-zeroes
0532-k-diff-pairs-in-an-array
0647-palindromic-substrings
0768-partition-labels
0874-backspace-string-compare
0875-longest-mountain-in-array
1468-check-if-n-and-its-double-exist
1972-rotating-the-box
2265-partition-array-according-to-given-pivot
2392-successful-pairs-of-spells-and-potions
2414-move-pieces-to-obtain-a-string
2699-count-the-number-of-fair-pairs
3018-make-string-a-subsequence-using-cyclic-increments

Binary Search

0033-search-in-rotated-sorted-array
0034-find-first-and-last-position-of-element-in-sorted-array
0268-missing-number
0532-k-diff-pairs-in-an-array
1056-capacity-to-ship-packages-within-d-days
1335-maximum-candies-allocated-to-k-children
1397-search-suggestions-system
1468-check-if-n-and-its-double-exist
1776-minimum-operations-to-reduce-x-to-zero
2392-successful-pairs-of-spells-and-potions
2665-minimum-time-to-repair-cars
2699-count-the-number-of-fair-pairs
3427-special-array-ii
3619-adjacent-increasing-subarrays-detection-ii

Sorting

0049-group-anagrams
0056-merge-intervals
0215-kth-largest-element-in-an-array
0268-missing-number
0435-non-overlapping-intervals
0451-sort-characters-by-frequency
0532-k-diff-pairs-in-an-array
0594-longest-harmonious-subsequence
0628-maximum-product-of-three-numbers
1018-largest-perimeter-triangle
1095-two-city-scheduling
1222-remove-covered-intervals
1354-find-players-with-zero-or-one-losses
1397-search-suggestions-system
1468-check-if-n-and-its-double-exist
1539-diagonal-traverse-ii
1748-best-team-with-no-conflicts
2112-minimum-difference-between-highest-and-lowest-of-k-scores
2392-successful-pairs-of-spells-and-potions
2412-minimum-amount-of-time-to-fill-cups
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2699-count-the-number-of-fair-pairs
2888-minimum-index-of-a-valid-split
3219-make-lexicographically-smallest-array-by-swapping-elements
3430-count-days-without-meetings
3657-check-if-grid-can-be-cut-into-sections

Linked List

0021-merge-two-sorted-lists
0024-swap-nodes-in-pairs
0083-remove-duplicates-from-sorted-list
0086-partition-list
0116-populating-next-right-pointers-in-each-node
0142-linked-list-cycle-ii
0203-remove-linked-list-elements
0206-reverse-linked-list
2299-merge-nodes-in-between-zeros

Recursion

0021-merge-two-sorted-lists
0024-swap-nodes-in-pairs
0203-remove-linked-list-elements
0206-reverse-linked-list
0241-different-ways-to-add-parentheses
1951-find-the-winner-of-the-circular-game
2050-count-good-numbers
3600-find-the-k-th-character-in-string-game-i
3799-unique-3-digit-even-numbers

Hash Table

0049-group-anagrams
0073-set-matrix-zeroes
0076-minimum-window-substring
0128-longest-consecutive-sequence
0139-word-break
0142-linked-list-cycle-ii
0205-isomorphic-strings
0208-implement-trie-prefix-tree
0268-missing-number
0451-sort-characters-by-frequency
0532-k-diff-pairs-in-an-array
0560-subarray-sum-equals-k
0594-longest-harmonious-subsequence
0768-partition-labels
0905-length-of-longest-fibonacci-subsequence
0925-construct-binary-tree-from-preorder-and-postorder-traversal
0931-maximum-frequency-stack
0952-word-subsets
1147-flip-columns-for-maximum-number-of-equal-rows
1160-letter-tile-possibilities
1218-lowest-common-ancestor-of-deepest-leaves
1227-number-of-equivalent-domino-pairs
1354-find-players-with-zero-or-one-losses
1364-tuple-with-same-product
1387-find-elements-in-a-contaminated-binary-tree
1468-check-if-n-and-its-double-exist
1502-construct-k-palindrome-strings
1776-minimum-operations-to-reduce-x-to-zero
2159-two-out-of-three
2220-find-all-possible-recipes-from-given-supplies
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
2766-find-the-prefix-common-array-of-two-arrays
2888-minimum-index-of-a-valid-split
3227-find-missing-and-repeated-values
3581-the-two-sneaky-numbers-of-digitville
3621-minimum-operations-to-make-array-values-equal-to-k
3753-maximum-difference-between-even-and-odd-frequency-i
3799-unique-3-digit-even-numbers

Sliding Window

0076-minimum-window-substring
0594-longest-harmonious-subsequence
1020-longest-turbulent-subarray
1776-minimum-operations-to-reduce-x-to-zero
2112-minimum-difference-between-highest-and-lowest-of-k-scores
2478-longest-nice-subarray
2552-maximum-sum-of-distinct-subarrays-with-length-k
2599-take-k-of-each-character-from-left-and-right
2786-find-the-longest-semi-repetitive-substring
2868-continuous-subarrays
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i
3483-alternating-groups-ii

String

0005-longest-palindromic-substring
0022-generate-parentheses
0028-find-the-index-of-the-first-occurrence-in-a-string
0049-group-anagrams
0076-minimum-window-substring
0093-restore-ip-addresses
0139-word-break
0205-isomorphic-strings
0208-implement-trie-prefix-tree
0241-different-ways-to-add-parentheses
0297-serialize-and-deserialize-binary-tree
0415-add-strings
0451-sort-characters-by-frequency
0647-palindromic-substrings
0768-partition-labels
0858-masking-personal-information
0874-backspace-string-compare
0952-word-subsets
1093-recover-a-tree-from-preorder-traversal
1160-letter-tile-possibilities
1250-longest-common-subsequence
1397-search-suggestions-system
1502-construct-k-palindrome-strings
1516-the-k-th-lexicographical-string-of-all-happy-strings-of-length-n
2220-find-all-possible-recipes-from-given-supplies
2414-move-pieces-to-obtain-a-string
2465-shifting-letters-ii
2599-take-k-of-each-character-from-left-and-right
2786-find-the-longest-semi-repetitive-substring
3018-make-string-a-subsequence-using-cyclic-increments
3194-find-words-containing-character
3753-maximum-difference-between-even-and-odd-frequency-i

Matrix

0073-set-matrix-zeroes
0289-game-of-life
0417-pacific-atlantic-water-flow
0733-flood-fill
0854-making-a-large-island
1036-rotting-oranges
1147-flip-columns-for-maximum-number-of-equal-rows
1171-shortest-path-in-binary-matrix
1380-number-of-closed-islands
1396-count-servers-that-communicate
1972-rotating-the-box
2035-count-sub-islands
2089-maximum-matrix-sum
2375-minimum-obstacle-removal-to-reach-corner
2764-maximum-number-of-fish-in-a-grid
3227-find-missing-and-repeated-values

Greedy

0011-container-with-most-water
0435-non-overlapping-intervals
0605-can-place-flowers
0768-partition-labels
1018-largest-perimeter-triangle
1095-two-city-scheduling
1502-construct-k-palindrome-strings
2089-maximum-matrix-sum
2094-remove-stones-to-minimize-the-total
2412-minimum-amount-of-time-to-fill-cups
2509-minimize-xor

Graph

0207-course-schedule
1229-shortest-path-with-alternating-colors
1558-course-schedule-iv
1916-find-center-of-star-graph
2121-find-if-path-exists-in-graph
2206-detonate-the-maximum-bombs
2220-find-all-possible-recipes-from-given-supplies
2375-minimum-obstacle-removal-to-reach-corner
3189-find-champion-ii

Breadth-First Search

0102-binary-tree-level-order-traversal
0116-populating-next-right-pointers-in-each-node
0207-course-schedule
0297-serialize-and-deserialize-binary-tree
0417-pacific-atlantic-water-flow
0637-average-of-levels-in-binary-tree
0733-flood-fill
0774-maximum-depth-of-n-ary-tree
0854-making-a-large-island
1005-univalued-binary-tree
1036-rotting-oranges
1171-shortest-path-in-binary-matrix
1218-lowest-common-ancestor-of-deepest-leaves
1229-shortest-path-with-alternating-colors
1380-number-of-closed-islands
1387-find-elements-in-a-contaminated-binary-tree
1396-count-servers-that-communicate
1492-time-needed-to-inform-all-employees
1558-course-schedule-iv
2035-count-sub-islands
2121-find-if-path-exists-in-graph
2206-detonate-the-maximum-bombs
2375-minimum-obstacle-removal-to-reach-corner
2764-maximum-number-of-fish-in-a-grid

Heap (Priority Queue)

0215-kth-largest-element-in-an-array
0451-sort-characters-by-frequency
1397-search-suggestions-system
1539-diagonal-traverse-ii
2094-remove-stones-to-minimize-the-total
2375-minimum-obstacle-removal-to-reach-corner
2412-minimum-amount-of-time-to-fill-cups
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2692-take-gifts-from-the-richest-pile
2868-continuous-subarrays

Shortest Path

2375-minimum-obstacle-removal-to-reach-corner

Tree

0102-binary-tree-level-order-traversal
0113-path-sum-ii
0116-populating-next-right-pointers-in-each-node
0235-lowest-common-ancestor-of-a-binary-search-tree
0297-serialize-and-deserialize-binary-tree
0637-average-of-levels-in-binary-tree
0774-maximum-depth-of-n-ary-tree
0784-insert-into-a-binary-search-tree
0925-construct-binary-tree-from-preorder-and-postorder-traversal
1005-univalued-binary-tree
1093-recover-a-tree-from-preorder-traversal
1218-lowest-common-ancestor-of-deepest-leaves
1387-find-elements-in-a-contaminated-binary-tree
1492-time-needed-to-inform-all-employees

Depth-First Search

0113-path-sum-ii
0116-populating-next-right-pointers-in-each-node
0207-course-schedule
0235-lowest-common-ancestor-of-a-binary-search-tree
0297-serialize-and-deserialize-binary-tree
0417-pacific-atlantic-water-flow
0637-average-of-levels-in-binary-tree
0733-flood-fill
0774-maximum-depth-of-n-ary-tree
0854-making-a-large-island
1005-univalued-binary-tree
1093-recover-a-tree-from-preorder-traversal
1218-lowest-common-ancestor-of-deepest-leaves
1380-number-of-closed-islands
1387-find-elements-in-a-contaminated-binary-tree
1396-count-servers-that-communicate
1492-time-needed-to-inform-all-employees
1558-course-schedule-iv
2035-count-sub-islands
2121-find-if-path-exists-in-graph
2206-detonate-the-maximum-bombs
2764-maximum-number-of-fish-in-a-grid

Union Find

0128-longest-consecutive-sequence
0854-making-a-large-island
1380-number-of-closed-islands
1396-count-servers-that-communicate
2035-count-sub-islands
2121-find-if-path-exists-in-graph
2764-maximum-number-of-fish-in-a-grid
3219-make-lexicographically-smallest-array-by-swapping-elements

Prefix Sum

0238-product-of-array-except-self
0560-subarray-sum-equals-k
1477-product-of-the-last-k-numbers
1776-minimum-operations-to-reduce-x-to-zero
2465-shifting-letters-ii
3427-special-array-ii
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i

Dynamic Programming

0005-longest-palindromic-substring
0022-generate-parentheses
0053-maximum-subarray
0062-unique-paths
0120-triangle
0121-best-time-to-buy-and-sell-stock
0139-word-break
0213-house-robber-ii
0241-different-ways-to-add-parentheses
0416-partition-equal-subset-sum
0435-non-overlapping-intervals
0647-palindromic-substrings
0875-longest-mountain-in-array
0905-length-of-longest-fibonacci-subsequence
0909-stone-game
0954-maximum-sum-circular-subarray
1020-longest-turbulent-subarray
1250-longest-common-subsequence
1748-best-team-with-no-conflicts

Simulation

0289-game-of-life
0415-add-strings
0874-backspace-string-compare
1708-design-parking-system
1951-find-the-winner-of-the-circular-game
2048-build-array-from-permutation
2265-partition-array-according-to-given-pivot
2299-merge-nodes-in-between-zeros
2645-pass-the-pillow
2692-take-gifts-from-the-richest-pile
3600-find-the-k-th-character-in-string-game-i

Math

0062-unique-paths
0241-different-ways-to-add-parentheses
0268-missing-number
0415-add-strings
0628-maximum-product-of-three-numbers
0909-stone-game
1018-largest-perimeter-triangle
1477-product-of-the-last-k-numbers
1889-check-if-number-is-a-sum-of-powers-of-three
1951-find-the-winner-of-the-circular-game
1993-sum-of-all-subset-xor-totals
2050-count-good-numbers
2206-detonate-the-maximum-bombs
2610-closest-prime-numbers-in-range
2645-pass-the-pillow
2802-find-the-punishment-number-of-an-integer
3227-find-missing-and-repeated-values
3581-the-two-sneaky-numbers-of-digitville
3600-find-the-k-th-character-in-string-game-i

Bit Manipulation

0191-number-of-1-bits
0268-missing-number
1993-sum-of-all-subset-xor-totals
2159-two-out-of-three
2478-longest-nice-subarray
2509-minimize-xor
2533-bitwise-xor-of-all-pairings
2766-find-the-prefix-common-array-of-two-arrays
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i
3600-find-the-k-th-character-in-string-game-i

Queue

0954-maximum-sum-circular-subarray
1951-find-the-winner-of-the-circular-game
2868-continuous-subarrays
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i

Ordered Set

0931-maximum-frequency-stack
2868-continuous-subarrays

Monotonic Queue

0954-maximum-sum-circular-subarray
2868-continuous-subarrays

Topological Sort

0207-course-schedule
1558-course-schedule-iv
2220-find-all-possible-recipes-from-given-supplies

Trie

0139-word-break
0208-implement-trie-prefix-tree
1397-search-suggestions-system

Memoization

0139-word-break
0241-different-ways-to-add-parentheses

Combinatorics

0062-unique-paths
1993-sum-of-all-subset-xor-totals

Divide and Conquer

0053-maximum-subarray
0191-number-of-1-bits
0215-kth-largest-element-in-an-array
0925-construct-binary-tree-from-preorder-and-postorder-traversal
0954-maximum-sum-circular-subarray

Backtracking

0022-generate-parentheses
0039-combination-sum
0093-restore-ip-addresses
0113-path-sum-ii
1160-letter-tile-possibilities
1516-the-k-th-lexicographical-string-of-all-happy-strings-of-length-n
1993-sum-of-all-subset-xor-totals
2802-find-the-punishment-number-of-an-integer

Design

0208-implement-trie-prefix-tree
0297-serialize-and-deserialize-binary-tree
0931-maximum-frequency-stack
1387-find-elements-in-a-contaminated-binary-tree
1477-product-of-the-last-k-numbers
1708-design-parking-system

Binary Tree

0102-binary-tree-level-order-traversal
0113-path-sum-ii
0116-populating-next-right-pointers-in-each-node
0235-lowest-common-ancestor-of-a-binary-search-tree
0297-serialize-and-deserialize-binary-tree
0637-average-of-levels-in-binary-tree
0784-insert-into-a-binary-search-tree
0925-construct-binary-tree-from-preorder-and-postorder-traversal
1005-univalued-binary-tree
1093-recover-a-tree-from-preorder-traversal
1218-lowest-common-ancestor-of-deepest-leaves
1387-find-elements-in-a-contaminated-binary-tree

Binary Search Tree

0235-lowest-common-ancestor-of-a-binary-search-tree
0784-insert-into-a-binary-search-tree

Game Theory

0909-stone-game

Counting

0451-sort-characters-by-frequency
0594-longest-harmonious-subsequence
1160-letter-tile-possibilities
1227-number-of-equivalent-domino-pairs
1354-find-players-with-zero-or-one-losses
1364-tuple-with-same-product
1396-count-servers-that-communicate
1502-construct-k-palindrome-strings
1708-design-parking-system
3753-maximum-difference-between-even-and-odd-frequency-i

Stack

0874-backspace-string-compare
0931-maximum-frequency-stack

Bucket Sort

0451-sort-characters-by-frequency

Brainteaser

2533-bitwise-xor-of-all-pairings

Geometry

2206-detonate-the-maximum-bombs

Data Stream

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

Number Theory

2610-closest-prime-numbers-in-range

Enumeration

0875-longest-mountain-in-array
1993-sum-of-all-subset-xor-totals
3799-unique-3-digit-even-numbers

String Matching

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

Quickselect

0215-kth-largest-element-in-an-array

About

A personal archive of my solutions to problems from LeetCode and Codeforces.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published