/leetcode

My LeetCode Solutions

Primary LanguagePython

My Leetcode solutions categorized by topics.

LeetCode Topics

Stack

0094-binary-tree-inorder-traversal
0143-reorder-list
0145-binary-tree-postorder-traversal
0150-evaluate-reverse-polish-notation
0155-min-stack
0776-n-ary-tree-postorder-traversal
2021-remove-all-occurrences-of-a-substring
2095-minimum-number-of-swaps-to-make-the-string-balanced
2470-removing-stars-from-a-string
2800-minimum-string-length-after-removing-substrings
3447-clear-digits

Design

0155-min-stack

Linked List

0002-add-two-numbers
0019-remove-nth-node-from-end-of-list
0021-merge-two-sorted-lists
0141-linked-list-cycle
0143-reorder-list
0206-reverse-linked-list
0328-odd-even-linked-list
1484-linked-list-in-binary-tree
2216-delete-the-middle-node-of-a-linked-list
3501-delete-nodes-from-linked-list-present-in-array

Recursion

0002-add-two-numbers
0021-merge-two-sorted-lists
0143-reorder-list
0206-reverse-linked-list
0231-power-of-two
0326-power-of-three
0342-power-of-four
3600-find-the-k-th-character-in-string-game-i

Two Pointers

0011-container-with-most-water
0019-remove-nth-node-from-end-of-list
0027-remove-element
0028-find-the-index-of-the-first-occurrence-in-a-string
0088-merge-sorted-array
0141-linked-list-cycle
0143-reorder-list
0151-reverse-words-in-a-string
0283-move-zeroes
0392-is-subsequence
0567-permutation-in-string
1798-max-number-of-k-sum-pairs
2095-minimum-number-of-swaps-to-make-the-string-balanced
2216-delete-the-middle-node-of-a-linked-list
2265-partition-array-according-to-given-pivot
2497-maximum-matching-of-players-with-trainers
2707-merge-two-2d-arrays-by-summing-values

Array

0011-container-with-most-water
0027-remove-element
0036-valid-sudoku
0046-permutations
0049-group-anagrams
0088-merge-sorted-array
0118-pascals-triangle
0128-longest-consecutive-sequence
0150-evaluate-reverse-polish-notation
0215-kth-largest-element-in-an-array
0238-product-of-array-except-self
0283-move-zeroes
0347-top-k-frequent-elements
0378-kth-smallest-element-in-a-sorted-matrix
0435-non-overlapping-intervals
0605-can-place-flowers
0948-sort-an-array
1127-last-stone-weight
1253-sort-the-matrix-diagonally
1319-unique-number-of-occurrences
1329-minimum-cost-to-move-chips-to-the-same-position
1333-sort-the-jumbled-numbers
1392-find-the-difference-of-two-arrays
1396-count-servers-that-communicate
1496-lucky-numbers-in-a-matrix
1510-find-lucky-integer-in-an-array
1556-make-two-arrays-equal-by-reversing-subarrays
1631-number-of-sub-arrays-with-odd-sum
1741-sort-array-by-increasing-frequency
1798-max-number-of-k-sum-pairs
1833-find-the-highest-altitude
1876-map-of-highest-peak
2255-minimum-swaps-to-group-all-1s-together-ii
2265-partition-array-according-to-given-pivot
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2497-maximum-matching-of-players-with-trainers
2502-sort-the-people
2707-merge-two-2d-arrays-by-summing-values
2727-number-of-senior-citizens
3251-maximum-area-of-longest-diagonal-rectangle
3332-minimum-operations-to-exceed-threshold-value-ii
3501-delete-nodes-from-linked-list-present-in-array
3748-sort-matrix-by-diagonals
3788-maximum-unique-subarray-sum-after-deletion
3790-fruits-into-baskets-ii

Hash Table

0036-valid-sudoku
0049-group-anagrams
0128-longest-consecutive-sequence
0141-linked-list-cycle
0290-word-pattern
0347-top-k-frequent-elements
0383-ransom-note
0567-permutation-in-string
1319-unique-number-of-occurrences
1392-find-the-difference-of-two-arrays
1510-find-lucky-integer-in-an-array
1556-make-two-arrays-equal-by-reversing-subarrays
1741-sort-array-by-increasing-frequency
1798-max-number-of-k-sum-pairs
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2502-sort-the-people
2707-merge-two-2d-arrays-by-summing-values
3501-delete-nodes-from-linked-list-present-in-array
3788-maximum-unique-subarray-sum-after-deletion

String

0028-find-the-index-of-the-first-occurrence-in-a-string
0049-group-anagrams
0058-length-of-last-word
0151-reverse-words-in-a-string
0290-word-pattern
0383-ransom-note
0392-is-subsequence
0434-number-of-segments-in-a-string
0567-permutation-in-string
1341-split-a-string-in-balanced-strings
2021-remove-all-occurrences-of-a-substring
2095-minimum-number-of-swaps-to-make-the-string-balanced
2346-largest-3-same-digit-number-in-string
2470-removing-stars-from-a-string
2502-sort-the-people
2727-number-of-senior-citizens
2800-minimum-string-length-after-removing-substrings
3379-score-of-a-string
3396-valid-word
3447-clear-digits

Sorting

0049-group-anagrams
0088-merge-sorted-array
0215-kth-largest-element-in-an-array
0347-top-k-frequent-elements
0378-kth-smallest-element-in-a-sorted-matrix
0435-non-overlapping-intervals
0948-sort-an-array
1253-sort-the-matrix-diagonally
1333-sort-the-jumbled-numbers
1556-make-two-arrays-equal-by-reversing-subarrays
1741-sort-array-by-increasing-frequency
1798-max-number-of-k-sum-pairs
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2497-maximum-matching-of-players-with-trainers
2502-sort-the-people
3748-sort-matrix-by-diagonals

Divide and Conquer

0215-kth-largest-element-in-an-array
0347-top-k-frequent-elements
0948-sort-an-array

Heap (Priority Queue)

0215-kth-largest-element-in-an-array
0347-top-k-frequent-elements
0378-kth-smallest-element-in-a-sorted-matrix
0948-sort-an-array
1127-last-stone-weight
2473-max-sum-of-a-pair-with-equal-sum-of-digits
3332-minimum-operations-to-exceed-threshold-value-ii

Bucket Sort

0347-top-k-frequent-elements
0948-sort-an-array

Counting

0347-top-k-frequent-elements
0383-ransom-note
1341-split-a-string-in-balanced-strings
1396-count-servers-that-communicate
1510-find-lucky-integer-in-an-array

Quickselect

0215-kth-largest-element-in-an-array
0347-top-k-frequent-elements

Math

0002-add-two-numbers
0150-evaluate-reverse-polish-notation
0231-power-of-two
0326-power-of-three
0342-power-of-four
1329-minimum-cost-to-move-chips-to-the-same-position
1362-airplane-seat-assignment-probability
1440-convert-integer-to-the-sum-of-two-no-zero-integers
1448-maximum-69-number
1631-number-of-sub-arrays-with-odd-sum
3600-find-the-k-th-character-in-string-game-i

Tree

0094-binary-tree-inorder-traversal
0098-validate-binary-search-tree
0100-same-tree
0102-binary-tree-level-order-traversal
0104-maximum-depth-of-binary-tree
0110-balanced-binary-tree
0145-binary-tree-postorder-traversal
0226-invert-binary-tree
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0450-delete-node-in-a-bst
0543-diameter-of-binary-tree
0572-subtree-of-another-tree
0776-n-ary-tree-postorder-traversal
0783-search-in-a-binary-search-tree
0904-leaf-similar-trees
1484-linked-list-in-binary-tree
1544-count-good-nodes-in-binary-tree
2493-reverse-odd-levels-of-binary-tree

Depth-First Search

0094-binary-tree-inorder-traversal
0098-validate-binary-search-tree
0100-same-tree
0104-maximum-depth-of-binary-tree
0110-balanced-binary-tree
0145-binary-tree-postorder-traversal
0226-invert-binary-tree
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0386-lexicographical-numbers
0543-diameter-of-binary-tree
0572-subtree-of-another-tree
0684-redundant-connection
0776-n-ary-tree-postorder-traversal
0904-leaf-similar-trees
1396-count-servers-that-communicate
1484-linked-list-in-binary-tree
1544-count-good-nodes-in-binary-tree
2121-find-if-path-exists-in-graph
2493-reverse-odd-levels-of-binary-tree

Breadth-First Search

0100-same-tree
0102-binary-tree-level-order-traversal
0104-maximum-depth-of-binary-tree
0226-invert-binary-tree
0684-redundant-connection
1396-count-servers-that-communicate
1484-linked-list-in-binary-tree
1544-count-good-nodes-in-binary-tree
1876-map-of-highest-peak
2121-find-if-path-exists-in-graph
2493-reverse-odd-levels-of-binary-tree

Binary Tree

0094-binary-tree-inorder-traversal
0098-validate-binary-search-tree
0100-same-tree
0102-binary-tree-level-order-traversal
0104-maximum-depth-of-binary-tree
0110-balanced-binary-tree
0145-binary-tree-postorder-traversal
0226-invert-binary-tree
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0450-delete-node-in-a-bst
0543-diameter-of-binary-tree
0572-subtree-of-another-tree
0783-search-in-a-binary-search-tree
0904-leaf-similar-trees
1484-linked-list-in-binary-tree
1544-count-good-nodes-in-binary-tree
2493-reverse-odd-levels-of-binary-tree

Matrix

0036-valid-sudoku
0378-kth-smallest-element-in-a-sorted-matrix
1253-sort-the-matrix-diagonally
1396-count-servers-that-communicate
1496-lucky-numbers-in-a-matrix
1876-map-of-highest-peak
3748-sort-matrix-by-diagonals

Greedy

0011-container-with-most-water
0435-non-overlapping-intervals
0605-can-place-flowers
1329-minimum-cost-to-move-chips-to-the-same-position
1341-split-a-string-in-balanced-strings
1448-maximum-69-number
2095-minimum-number-of-swaps-to-make-the-string-balanced
2497-maximum-matching-of-players-with-trainers
3788-maximum-unique-subarray-sum-after-deletion

Prefix Sum

0238-product-of-array-except-self
1631-number-of-sub-arrays-with-odd-sum
1833-find-the-highest-altitude

Union Find

0128-longest-consecutive-sequence
0684-redundant-connection
1396-count-servers-that-communicate
2121-find-if-path-exists-in-graph

Merge Sort

0948-sort-an-array

Radix Sort

0948-sort-an-array

Counting Sort

0948-sort-an-array

Dynamic Programming

0118-pascals-triangle
0338-counting-bits
0392-is-subsequence
0435-non-overlapping-intervals
1362-airplane-seat-assignment-probability
1631-number-of-sub-arrays-with-odd-sum

Binary Search Tree

0098-validate-binary-search-tree
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0378-kth-smallest-element-in-a-sorted-matrix
0450-delete-node-in-a-bst
0783-search-in-a-binary-search-tree
3790-fruits-into-baskets-ii

String Matching

0028-find-the-index-of-the-first-occurrence-in-a-string
0572-subtree-of-another-tree

Hash Function

0572-subtree-of-another-tree

Simulation

2021-remove-all-occurrences-of-a-substring
2265-partition-array-according-to-given-pivot
2470-removing-stars-from-a-string
2800-minimum-string-length-after-removing-substrings
3332-minimum-operations-to-exceed-threshold-value-ii
3447-clear-digits
3600-find-the-k-th-character-in-string-game-i
3790-fruits-into-baskets-ii

Backtracking

0046-permutations

Brainteaser

1362-airplane-seat-assignment-probability

Probability and Statistics

1362-airplane-seat-assignment-probability

Sliding Window

0567-permutation-in-string
2255-minimum-swaps-to-group-all-1s-together-ii

Trie

0386-lexicographical-numbers

Bit Manipulation

0201-bitwise-and-of-numbers-range
0231-power-of-two
0338-counting-bits
0342-power-of-four
3600-find-the-k-th-character-in-string-game-i

Database

0197-rising-temperature

Graph

0684-redundant-connection
1916-find-center-of-star-graph
2121-find-if-path-exists-in-graph

Segment Tree

3790-fruits-into-baskets-ii

Ordered Set

3790-fruits-into-baskets-ii