Skip to content

Welcome to my collection of LeetCode solutions! I started uploading my solutions on July 28th, 2024. Each solution is crafted with care, and I'm always more than happy to discuss my approach and thought process. Feel free to reach out if you have any questions or would like to have a discussion about any of the solutions. Happy coding!

Notifications You must be signed in to change notification settings

Medoriku/LeetCode-Solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Created using LeetHub v2

LeetCode Topics

String

0005-longest-palindromic-substring
0006-zigzag-conversion
0008-string-to-integer-atoi
0010-regular-expression-matching
0012-integer-to-roman
0067-add-binary
0165-compare-version-numbers
0171-excel-sheet-column-number
0214-shortest-palindrome
0241-different-ways-to-add-parentheses
0242-valid-anagram
0344-reverse-string
0409-longest-palindrome
0412-fizz-buzz
0564-find-the-closest-palindrome
0567-permutation-in-string
0592-fraction-addition-and-subtraction
0812-rotate-string
0920-uncommon-words-from-two-sentences
0952-word-subsets
1044-find-common-characters
1112-find-words-that-can-be-formed-by-characters
1197-parsing-a-boolean-expression
1302-delete-characters-to-make-fancy-string
1304-longest-happy-string
1524-string-matching-in-an-array
1667-find-kth-bit-in-nth-binary-string
1715-split-a-string-into-the-max-number-of-unique-substrings
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1786-count-the-number-of-consistent-strings
1895-minimum-number-of-operations-to-move-all-balls-to-each-box
1923-sentence-similarity-iii
2059-unique-length-3-palindromic-subsequences
2095-minimum-number-of-swaps-to-make-the-string-balanced
2163-kth-distinct-string-in-an-array
2232-adding-spaces-to-a-string
2300-construct-string-with-repeat-limit
2414-move-pieces-to-obtain-a-string
2465-shifting-letters-ii
2502-sort-the-people
2580-circular-sentence
2599-take-k-of-each-character-from-left-and-right
2800-minimum-string-length-after-removing-substrings
3018-make-string-a-subsequence-using-cyclic-increments
3309-count-prefix-and-suffix-pairs-i
3379-score-of-a-string

Linked List

0002-add-two-numbers
0021-merge-two-sorted-lists
0141-linked-list-cycle
0206-reverse-linked-list
0859-design-circular-deque
2411-spiral-matrix-iv
2903-insert-greatest-common-divisors-in-linked-list

Math

0002-add-two-numbers
0012-integer-to-roman
0067-add-binary
0171-excel-sheet-column-number
0202-happy-number
0231-power-of-two
0241-different-ways-to-add-parentheses
0264-ugly-number-ii
0412-fizz-buzz
0564-find-the-closest-palindrome
0592-fraction-addition-and-subtraction
0633-sum-of-square-numbers
0650-2-keys-keyboard
1240-stone-game-ii
1951-find-the-winner-of-the-circular-game
2903-insert-greatest-common-divisors-in-linked-list
3555-final-array-state-after-k-multiplication-operations-i

Recursion

0002-add-two-numbers
0010-regular-expression-matching
0021-merge-two-sorted-lists
0206-reverse-linked-list
0231-power-of-two
0241-different-ways-to-add-parentheses
1197-parsing-a-boolean-expression
1667-find-kth-bit-in-nth-binary-string
1951-find-the-winner-of-the-circular-game

Two Pointers

0005-longest-palindromic-substring
0011-container-with-most-water
0015-3sum
0016-3sum-closest
0141-linked-list-cycle
0165-compare-version-numbers
0202-happy-number
0344-reverse-string
0349-intersection-of-two-arrays
0567-permutation-in-string
0633-sum-of-square-numbers
0719-find-k-th-smallest-pair-distance
1468-check-if-n-and-its-double-exist
1679-shortest-subarray-to-be-removed-to-make-array-sorted
1923-sentence-similarity-iii
1972-rotating-the-box
2095-minimum-number-of-swaps-to-make-the-string-balanced
2232-adding-spaces-to-a-string
2414-move-pieces-to-obtain-a-string
2488-divide-intervals-into-minimum-number-of-groups
2524-largest-positive-integer-that-exists-with-its-negative
2699-count-the-number-of-fair-pairs
3018-make-string-a-subsequence-using-cyclic-increments

Dynamic Programming

0005-longest-palindromic-substring
0010-regular-expression-matching
0241-different-ways-to-add-parentheses
0264-ugly-number-ii
0650-2-keys-keyboard
1025-minimum-cost-for-tickets
1196-filling-bookcase-shelves
1240-stone-game-ii
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1766-minimum-number-of-removals-to-make-mountain-array
2067-maximum-number-of-points-with-cost
2562-count-ways-to-build-good-strings
2794-maximum-number-of-moves-in-a-grid

Tree

0112-path-sum
0515-find-largest-value-in-each-tree-row
0789-kth-largest-element-in-a-stream
0988-flip-equivalent-binary-trees
1116-maximum-level-sum-of-a-binary-tree
2493-reverse-odd-levels-of-binary-tree
2558-minimum-number-of-operations-to-sort-a-binary-tree-by-level
2646-kth-largest-sum-in-a-binary-tree

Design

0731-my-calendar-ii
0789-kth-largest-element-in-a-stream
0859-design-circular-deque
1497-design-a-stack-with-increment-operation

Binary Search Tree

0004-median-of-two-sorted-arrays
0349-intersection-of-two-arrays
0633-sum-of-square-numbers
0719-find-k-th-smallest-pair-distance
0731-my-calendar-ii
0789-kth-largest-element-in-a-stream
0892-shortest-subarray-with-sum-at-least-k
1468-check-if-n-and-its-double-exist
1679-shortest-subarray-to-be-removed-to-make-array-sorted
1730-special-array-with-x-elements-greater-than-or-equal-x
1766-minimum-number-of-removals-to-make-mountain-array
1886-minimum-limit-of-balls-in-a-bag
2640-maximum-number-of-integers-to-choose-from-a-range-i
2699-count-the-number-of-fair-pairs

Heap (Priority Queue)

0264-ugly-number-ii
0506-relative-ranks
0789-kth-largest-element-in-a-stream
0892-shortest-subarray-with-sum-at-least-k
1304-longest-happy-string
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
2300-construct-string-with-repeat-limit
2375-minimum-obstacle-removal-to-reach-corner
2488-divide-intervals-into-minimum-number-of-groups
2616-maximal-score-after-applying-k-operations
2692-take-gifts-from-the-richest-pile
2868-continuous-subarrays
3555-final-array-state-after-k-multiplication-operations-i

Binary Tree

0112-path-sum
0515-find-largest-value-in-each-tree-row
0789-kth-largest-element-in-a-stream
0988-flip-equivalent-binary-trees
1116-maximum-level-sum-of-a-binary-tree
2493-reverse-odd-levels-of-binary-tree
2558-minimum-number-of-operations-to-sort-a-binary-tree-by-level
2646-kth-largest-sum-in-a-binary-tree

Data Stream

0789-kth-largest-element-in-a-stream

Array

0004-median-of-two-sorted-arrays
0011-container-with-most-water
0015-3sum
0016-3sum-closest
0136-single-number
0169-majority-element
0217-contains-duplicate
0349-intersection-of-two-arrays
0506-relative-ranks
0624-maximum-distance-in-arrays
0719-find-k-th-smallest-pair-distance
0731-my-calendar-ii
0780-max-chunks-to-make-sorted
0859-design-circular-deque
0890-lemonade-change
0892-shortest-subarray-with-sum-at-least-k
0906-walking-robot-simulation
0952-word-subsets
1002-maximum-width-ramp
1025-minimum-cost-for-tickets
1044-find-common-characters
1112-find-words-that-can-be-formed-by-characters
1147-flip-columns-for-maximum-number-of-equal-rows
1196-filling-bookcase-shelves
1240-stone-game-ii
1256-rank-transform-of-an-array
1468-check-if-n-and-its-double-exist
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1497-design-a-stack-with-increment-operation
1524-string-matching-in-an-array
1570-final-prices-with-a-special-discount-in-a-shop
1679-shortest-subarray-to-be-removed-to-make-array-sorted
1694-make-sum-divisible-by-p
1730-special-array-with-x-elements-greater-than-or-equal-x
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1755-defuse-the-bomb
1766-minimum-number-of-removals-to-make-mountain-array
1786-count-the-number-of-consistent-strings
1876-map-of-highest-peak
1886-minimum-limit-of-balls-in-a-bag
1895-minimum-number-of-operations-to-move-all-balls-to-each-box
1923-sentence-similarity-iii
1940-maximum-xor-for-each-query
1951-find-the-winner-of-the-circular-game
1972-rotating-the-box
2067-maximum-number-of-points-with-cost
2089-maximum-matrix-sum
2132-convert-1d-array-into-2d-array
2145-grid-game
2163-kth-distinct-string-in-an-array
2232-adding-spaces-to-a-string
2356-largest-combination-with-bitwise-and-greater-than-zero
2358-number-of-ways-to-split-array
2375-minimum-obstacle-removal-to-reach-corner
2411-spiral-matrix-iv
2465-shifting-letters-ii
2488-divide-intervals-into-minimum-number-of-groups
2502-sort-the-people
2524-largest-positive-integer-that-exists-with-its-negative
2552-maximum-sum-of-distinct-subarrays-with-length-k
2616-maximal-score-after-applying-k-operations
2640-maximum-number-of-integers-to-choose-from-a-range-i
2692-take-gifts-from-the-richest-pile
2699-count-the-number-of-fair-pairs
2794-maximum-number-of-moves-in-a-grid
2868-continuous-subarrays
3309-count-prefix-and-suffix-pairs-i
3522-find-the-power-of-k-size-subarrays-i
3555-final-array-state-after-k-multiplication-operations-i

Sorting

0015-3sum
0016-3sum-closest
0169-majority-element
0217-contains-duplicate
0242-valid-anagram
0349-intersection-of-two-arrays
0506-relative-ranks
0719-find-k-th-smallest-pair-distance
0780-max-chunks-to-make-sorted
1256-rank-transform-of-an-array
1468-check-if-n-and-its-double-exist
1730-special-array-with-x-elements-greater-than-or-equal-x
2488-divide-intervals-into-minimum-number-of-groups
2502-sort-the-people
2524-largest-positive-integer-that-exists-with-its-negative
2640-maximum-number-of-integers-to-choose-from-a-range-i
2646-kth-largest-sum-in-a-binary-tree
2699-count-the-number-of-fair-pairs

Hash Table

0012-integer-to-roman
0141-linked-list-cycle
0169-majority-element
0202-happy-number
0217-contains-duplicate
0242-valid-anagram
0264-ugly-number-ii
0349-intersection-of-two-arrays
0409-longest-palindrome
0567-permutation-in-string
0906-walking-robot-simulation
0920-uncommon-words-from-two-sentences
0952-word-subsets
1044-find-common-characters
1112-find-words-that-can-be-formed-by-characters
1147-flip-columns-for-maximum-number-of-equal-rows
1256-rank-transform-of-an-array
1468-check-if-n-and-its-double-exist
1694-make-sum-divisible-by-p
1715-split-a-string-into-the-max-number-of-unique-substrings
1786-count-the-number-of-consistent-strings
2059-unique-length-3-palindromic-subsequences
2163-kth-distinct-string-in-an-array
2300-construct-string-with-repeat-limit
2356-largest-combination-with-bitwise-and-greater-than-zero
2502-sort-the-people
2524-largest-positive-integer-that-exists-with-its-negative
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

Greedy

0011-container-with-most-water
0409-longest-palindrome
0624-maximum-distance-in-arrays
0780-max-chunks-to-make-sorted
0890-lemonade-change
1304-longest-happy-string
1766-minimum-number-of-removals-to-make-mountain-array
2089-maximum-matrix-sum
2095-minimum-number-of-swaps-to-make-the-string-balanced
2300-construct-string-with-repeat-limit
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

Bit Manipulation

0067-add-binary
0136-single-number
0231-power-of-two
1786-count-the-number-of-consistent-strings
1940-maximum-xor-for-each-query
2059-unique-length-3-palindromic-subsequences
2323-minimum-bit-flips-to-convert-number
2356-largest-combination-with-bitwise-and-greater-than-zero
2509-minimize-xor
3394-minimum-array-end

Divide and Conquer

0004-median-of-two-sorted-arrays
0169-majority-element

Counting

0169-majority-element
0920-uncommon-words-from-two-sentences
1112-find-words-that-can-be-formed-by-characters
1786-count-the-number-of-consistent-strings
2163-kth-distinct-string-in-an-array
2300-construct-string-with-repeat-limit
2356-largest-combination-with-bitwise-and-greater-than-zero

Simulation

0067-add-binary
0412-fizz-buzz
0592-fraction-addition-and-subtraction
0906-walking-robot-simulation
1667-find-kth-bit-in-nth-binary-string
1951-find-the-winner-of-the-circular-game
2132-convert-1d-array-into-2d-array
2232-adding-spaces-to-a-string
2411-spiral-matrix-iv
2692-take-gifts-from-the-richest-pile
2800-minimum-string-length-after-removing-substrings
3555-final-array-state-after-k-multiplication-operations-i

Depth-First Search

0112-path-sum
0515-find-largest-value-in-each-tree-row
0988-flip-equivalent-binary-trees
1116-maximum-level-sum-of-a-binary-tree
2201-valid-arrangement-of-pairs
2493-reverse-odd-levels-of-binary-tree

Breadth-First Search

0112-path-sum
0515-find-largest-value-in-each-tree-row
1116-maximum-level-sum-of-a-binary-tree
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
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
2646-kth-largest-sum-in-a-binary-tree

Trie

0440-k-th-smallest-in-lexicographical-order
3309-count-prefix-and-suffix-pairs-i

Matrix

1147-flip-columns-for-maximum-number-of-equal-rows
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1876-map-of-highest-peak
1972-rotating-the-box
2067-maximum-number-of-points-with-cost
2089-maximum-matrix-sum
2132-convert-1d-array-into-2d-array
2145-grid-game
2375-minimum-obstacle-removal-to-reach-corner
2411-spiral-matrix-iv
2794-maximum-number-of-moves-in-a-grid

Segment Tree

0731-my-calendar-ii

Prefix Sum

0731-my-calendar-ii
0892-shortest-subarray-with-sum-at-least-k
1240-stone-game-ii
1694-make-sum-divisible-by-p
1895-minimum-number-of-operations-to-move-all-balls-to-each-box
1940-maximum-xor-for-each-query
2059-unique-length-3-palindromic-subsequences
2145-grid-game
2358-number-of-ways-to-split-array
2465-shifting-letters-ii
2488-divide-intervals-into-minimum-number-of-groups

Ordered Set

0731-my-calendar-ii
2868-continuous-subarrays

Rolling Hash

0214-shortest-palindrome
3309-count-prefix-and-suffix-pairs-i

String Matching

0214-shortest-palindrome
0812-rotate-string
1524-string-matching-in-an-array
3309-count-prefix-and-suffix-pairs-i

Hash Function

0214-shortest-palindrome
3309-count-prefix-and-suffix-pairs-i

Stack

0780-max-chunks-to-make-sorted
1002-maximum-width-ramp
1197-parsing-a-boolean-expression
1497-design-a-stack-with-increment-operation
1570-final-prices-with-a-special-discount-in-a-shop
1679-shortest-subarray-to-be-removed-to-make-array-sorted
2095-minimum-number-of-swaps-to-make-the-string-balanced
2800-minimum-string-length-after-removing-substrings

Sliding Window

0567-permutation-in-string
0892-shortest-subarray-with-sum-at-least-k
1755-defuse-the-bomb
2552-maximum-sum-of-distinct-subarrays-with-length-k
2599-take-k-of-each-character-from-left-and-right
2868-continuous-subarrays
3522-find-the-power-of-k-size-subarrays-i

Memoization

0241-different-ways-to-add-parentheses

Backtracking

1715-split-a-string-into-the-max-number-of-unique-substrings

Number Theory

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

Monotonic Stack

0780-max-chunks-to-make-sorted
1002-maximum-width-ramp
1570-final-prices-with-a-special-discount-in-a-shop
1679-shortest-subarray-to-be-removed-to-make-array-sorted

Queue

0859-design-circular-deque
0892-shortest-subarray-with-sum-at-least-k
1951-find-the-winner-of-the-circular-game
2868-continuous-subarrays

Monotonic Queue

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

Graph

1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
2201-valid-arrangement-of-pairs
2375-minimum-obstacle-removal-to-reach-corner

Shortest Path

1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
2375-minimum-obstacle-removal-to-reach-corner

Eulerian Circuit

2201-valid-arrangement-of-pairs

Game Theory

1240-stone-game-ii

About

Welcome to my collection of LeetCode solutions! I started uploading my solutions on July 28th, 2024. Each solution is crafted with care, and I'm always more than happy to discuss my approach and thought process. Feel free to reach out if you have any questions or would like to have a discussion about any of the solutions. Happy coding!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages