Skip to content

About

430+ LeetCode solutions in Java | Knight Badge | Top 5.69% Globally

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1,100 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏆 LeetCode Solutions

✨ Milestone Achieved: Knight Badge | Top 5.69% Globally | 430+ Java Solutions

LeetCode Problems Solved Contest Rating

My solutions to LeetCode problems, primarily in Java. Automatically synced via LeetHub v2.


📊 Stats

Metric Value
Total Solved 430+
Primary Language Java
Global Rank Top 5.69%
Achievement Knight Badge

🗂️ Algorithm Pattern Index

Mastering algorithm patterns is critical for writing clean, optimized Java solutions. By identifying the underlying pattern, you avoid brittle ad-hoc logic, reduce time complexity, and produce readable, idiomatic code.

Pattern Why It Matters for Java Implementations Key Problems
Sliding Window Avoids nested loops (O(n²) -> O(n)) for subarray/substring problems. Perfect for optimizing String or char[] manipulations in Java. Longest Substring Without Repeating, Minimum Window Substring
Two Pointers Minimizes space complexity (O(1)) and provides elegant solutions for sorted arrays and linked lists without extra collections overhead. 3Sum, Container With Most Water, Trapping Rain Water
Monotonic Stack Essential for O(n) solutions to "next greater element" problems. Java's ArrayDeque is the ideal non-synchronized, performant choice here. Next Greater Element, Stock Span, Trapping Rain Water
Dynamic Programming Trades space for time by memoizing subproblems. Crucial for optimizing recursive tree explorations into efficient tabulated arrays. Climbing Stairs, Longest Common Subsequence, Edit Distance
Graph BFS/DFS Forms the backbone of connectivity and traversal problems. Leveraging Java's Queue for BFS and recursion/Stack for DFS handles complex topologies efficiently. Number of Islands, Course Schedule, Word Ladder
Binary Search Drops O(n) to O(log n) for sorted data. Mastering off-by-one errors and loop invariants here is key to robust Java algorithms. Search in Rotated Array, Median of Two Sorted Arrays

🚀 How This Repo Works

Every accepted LeetCode submission is automatically pushed to this repository using the LeetHub v2 Chrome Extension. Each solution includes:

  • ✅ Clean, optimized Java code
  • 📁 Organized by problem number and title
  • 🏷️ Tagged with difficulty level

📈 LeetCode Profile

Himanshu's LeetCode Stats


Solutions by Himanshu Yadav • Built with consistency and caffeine ☕

LeetCode Topics

Array

0001-two-sum
0015-3sum
0018-4sum
0026-remove-duplicates-from-sorted-array
0031-next-permutation
0034-find-first-and-last-position-of-element-in-sorted-array
0036-valid-sudoku
0039-combination-sum
0048-rotate-image
0053-maximum-subarray
0056-merge-intervals
0063-unique-paths-ii
0073-set-matrix-zeroes
0074-search-a-2d-matrix
0075-sort-colors
0081-search-in-rotated-sorted-array-ii
0088-merge-sorted-array
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0118-pascals-triangle
0120-triangle
0121-best-time-to-buy-and-sell-stock
0122-best-time-to-buy-and-sell-stock-ii
0123-best-time-to-buy-and-sell-stock-iii
0128-longest-consecutive-sequence
0130-surrounded-regions
0136-single-number
0152-maximum-product-subarray
0153-find-minimum-in-rotated-sorted-array
0169-majority-element
0188-best-time-to-buy-and-sell-stock-iv
0189-rotate-array
0198-house-robber
0200-number-of-islands
0213-house-robber-ii
0229-majority-element-ii
0283-move-zeroes
0287-find-the-duplicate-number
0300-longest-increasing-subsequence
0309-best-time-to-buy-and-sell-stock-with-cooldown
0312-burst-balloons
0322-coin-change
0368-largest-divisible-subset
0377-combination-sum-iv
0410-split-array-largest-sum
0416-partition-equal-subset-sum
0455-assign-cookies
0485-max-consecutive-ones
0486-predict-the-winner
0493-reverse-pairs
0494-target-sum
0518-coin-change-ii
0542-01-matrix
0560-subarray-sum-equals-k
0628-maximum-product-of-three-numbers
0673-number-of-longest-increasing-subsequence
0704-binary-search
0714-best-time-to-buy-and-sell-stock-with-transaction-fee
0733-flood-fill
0778-swim-in-rising-water
0827-making-a-large-island
0835-image-overlap
0875-koko-eating-bananas
0877-stone-game
0992-subarrays-with-k-different-integers
0994-rotting-oranges
1004-max-consecutive-ones-iii
1008-construct-binary-search-tree-from-preorder-traversal
1011-capacity-to-ship-packages-within-d-days
1020-number-of-enclaves
1043-partition-array-for-maximum-sum
1048-longest-string-chain
1091-shortest-path-in-binary-matrix
1140-stone-game-ii
1248-count-number-of-nice-subarrays
1260-shift-2d-grid
1277-count-square-submatrices-with-all-ones
1283-find-the-smallest-divisor-given-a-threshold
1288-remove-covered-intervals
1301-number-of-paths-with-max-score
1331-rank-transform-of-an-array
1386-cinema-seat-allocation
1406-stone-game-iii
1423-maximum-points-you-can-obtain-from-cards
1464-maximum-product-of-two-elements-in-an-array
1477-find-two-non-overlapping-sub-arrays-each-with-target-sum
1482-minimum-number-of-days-to-make-m-bouquets
1497-check-if-array-pairs-are-divisible-by-k
1539-kth-missing-positive-number
1547-minimum-cost-to-cut-a-stick
1563-stone-game-v
1631-path-with-minimum-effort
1658-minimum-operations-to-reduce-x-to-zero
1752-check-if-array-is-sorted-and-rotated
1807-evaluate-the-bracket-pairs-of-a-string
1833-maximum-ice-cream-bars
1840-maximum-building-height
1846-maximum-element-after-decreasing-and-rearranging
1872-stone-game-viii
1967-number-of-strings-that-appear-as-substrings-in-word
1979-find-greatest-common-divisor-of-array
2029-stone-game-ix
2091-removing-minimum-and-maximum-from-array
2149-rearrange-array-elements-by-sign
2213-longest-substring-of-one-repeating-character
2498-frog-jump-ii
2778-sum-of-squares-of-special-elements
2812-find-the-safest-path-in-a-grid
2948-make-lexicographically-smallest-array-by-swapping-elements
2958-length-of-longest-subarray-with-at-most-k-frequency
2996-smallest-missing-integer-greater-than-sequential-prefix-sum
3020-find-the-maximum-number-of-elements-in-subset
3069-distribute-elements-into-two-arrays-i
3116-kth-smallest-amount-with-single-denomination-combination
3312-sorted-gcd-pair-queries
3336-find-the-number-of-subsequences-with-equal-gcd
3414-maximum-score-of-non-overlapping-intervals
3471-find-the-largest-almost-missing-integer
3483-unique-3-digit-even-numbers
3513-number-of-unique-xor-triplets-i
3514-number-of-unique-xor-triplets-ii
3524-find-x-value-of-array-i
3525-find-x-value-of-array-ii
3532-path-existence-queries-in-a-graph-i
3534-path-existence-queries-in-a-graph-ii
3550-smallest-index-with-digit-sum-equal-to-index
3568-minimum-moves-to-clean-the-classroom
3620-network-recovery-pathways
3702-longest-subsequence-with-non-zero-bitwise-xor
3718-smallest-missing-multiple-of-k
3731-find-missing-elements
3737-count-subarrays-with-majority-element-i
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

Hash Table

0001-two-sum
0003-longest-substring-without-repeating-characters
0036-valid-sudoku
0073-set-matrix-zeroes
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
0169-majority-element
0229-majority-element-ii
0560-subarray-sum-equals-k
0653-two-sum-iv-input-is-a-bst
0863-all-nodes-distance-k-in-binary-tree
0947-most-stones-removed-with-same-row-or-column
0987-vertical-order-traversal-of-a-binary-tree
0992-subarrays-with-k-different-integers
1048-longest-string-chain
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
1497-check-if-array-pairs-are-divisible-by-k
1520-maximum-number-of-non-overlapping-substrings
1658-minimum-operations-to-reduce-x-to-zero
1807-evaluate-the-bracket-pairs-of-a-string
2958-length-of-longest-subarray-with-at-most-k-frequency
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
3090-maximum-length-substring-with-two-occurrences
3312-sorted-gcd-pair-queries
3471-find-the-largest-almost-missing-integer
3483-unique-3-digit-even-numbers
3518-smallest-palindromic-rearrangement-ii
3532-path-existence-queries-in-a-graph-i
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

Math

0009-palindrome-number
0048-rotate-image
0062-unique-paths
0070-climbing-stairs
0189-rotate-array
0223-rectangle-area
0368-largest-divisible-subset
0486-predict-the-winner
0628-maximum-product-of-three-numbers
0836-rectangle-overlap
0877-stone-game
1140-stone-game-ii
1248-count-number-of-nice-subarrays
1401-circle-and-rectangle-overlapping
1406-stone-game-iii
1510-stone-game-iv
1563-stone-game-v
1621-number-of-sets-of-k-non-overlapping-line-segments
1840-maximum-building-height
1872-stone-game-viii
1927-sum-game
1979-find-greatest-common-divisor-of-array
2029-stone-game-ix
3014-minimum-number-of-pushes-to-type-word-i
3116-kth-smallest-amount-with-single-denomination-combination
3312-sorted-gcd-pair-queries
3336-find-the-number-of-subsequences-with-equal-gcd
3345-smallest-divisible-digit-product-i
3348-smallest-divisible-digit-product-ii
3513-number-of-unique-xor-triplets-i
3514-number-of-unique-xor-triplets-ii
3518-smallest-palindromic-rearrangement-ii
3524-find-x-value-of-array-i
3525-find-x-value-of-array-ii
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
3700-number-of-zigzag-arrays-ii
3754-concatenate-non-zero-digits-and-multiply-by-sum-i
3756-concatenate-non-zero-digits-and-multiply-by-sum-ii
3867-sum-of-gcd-of-formed-pairs
3870-count-commas-in-range
3875-construct-uniform-parity-array-i
3876-construct-uniform-parity-array-ii

Sliding Window

0003-longest-substring-without-repeating-characters
0076-minimum-window-substring
0992-subarrays-with-k-different-integers
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

Prefix Sum

0410-split-array-largest-sum
0560-subarray-sum-equals-k
1004-max-consecutive-ones-iii
1140-stone-game-ii
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
1872-stone-game-viii
3312-sorted-gcd-pair-queries
3737-count-subarrays-with-majority-element-i
3756-concatenate-non-zero-digits-and-multiply-by-sum-ii
3903-smallest-stable-index-i
3904-smallest-stable-index-ii

String

0003-longest-substring-without-repeating-characters
0022-generate-parentheses
0044-wildcard-matching
0072-edit-distance
0076-minimum-window-substring
0115-distinct-subsequences
0127-word-ladder
0132-palindrome-partitioning-ii
0316-remove-duplicate-letters
0516-longest-palindromic-subsequence
0940-distinct-subsequences-ii
1048-longest-string-chain
1081-smallest-subsequence-of-distinct-characters
1092-shortest-common-supersequence
1106-parsing-a-boolean-expression
1143-longest-common-subsequence
1189-maximum-number-of-balloons
1190-reverse-substrings-between-each-pair-of-parentheses
1312-minimum-insertion-steps-to-make-a-string-palindrome
1358-number-of-substrings-containing-all-three-characters
1520-maximum-number-of-non-overlapping-substrings
1807-evaluate-the-bracket-pairs-of-a-string
1927-sum-game
1967-number-of-strings-that-appear-as-substrings-in-word
2213-longest-substring-of-one-repeating-character
2472-maximum-number-of-non-overlapping-palindrome-substrings
2904-shortest-and-lexicographically-smallest-beautiful-string
3014-minimum-number-of-pushes-to-type-word-i
3016-minimum-number-of-pushes-to-type-word-ii
3090-maximum-length-substring-with-two-occurrences
3302-find-the-lexicographically-smallest-valid-sequence
3348-smallest-divisible-digit-product-ii
3498-reverse-degree-of-a-string
3499-maximize-active-section-with-trade-i
3517-smallest-palindromic-rearrangement-i
3518-smallest-palindromic-rearrangement-ii
3720-lexicographically-smallest-permutation-greater-than-target
3756-concatenate-non-zero-digits-and-multiply-by-sum-ii

Counting

0169-majority-element
0229-majority-element-ii
0992-subarrays-with-k-different-integers
1189-maximum-number-of-balloons
1497-check-if-array-pairs-are-divisible-by-k
2029-stone-game-ix
3016-minimum-number-of-pushes-to-type-word-ii
3312-sorted-gcd-pair-queries
3518-smallest-palindromic-rearrangement-ii
3720-lexicographically-smallest-permutation-greater-than-target
3737-count-subarrays-with-majority-element-i

Sorting

0015-3sum
0018-4sum
0056-merge-intervals
0075-sort-colors
0088-merge-sorted-array
0169-majority-element
0229-majority-element-ii
0368-largest-divisible-subset
0455-assign-cookies
0628-maximum-product-of-three-numbers
0987-vertical-order-traversal-of-a-binary-tree
1048-longest-string-chain
1288-remove-covered-intervals
1331-rank-transform-of-an-array
1464-maximum-product-of-two-elements-in-an-array
1520-maximum-number-of-non-overlapping-substrings
1547-minimum-cost-to-cut-a-stick
1833-maximum-ice-cream-bars
1840-maximum-building-height
1846-maximum-element-after-decreasing-and-rearranging
2948-make-lexicographically-smallest-array-by-swapping-elements
2996-smallest-missing-integer-greater-than-sequential-prefix-sum
3016-minimum-number-of-pushes-to-type-word-ii
3414-maximum-score-of-non-overlapping-intervals
3517-smallest-palindromic-rearrangement-i
3534-path-existence-queries-in-a-graph-ii
3536-maximum-product-of-two-digits
3731-find-missing-elements
3867-sum-of-gcd-of-formed-pairs

Greedy

0044-wildcard-matching
0122-best-time-to-buy-and-sell-stock-ii
0316-remove-duplicate-letters
0410-split-array-largest-sum
0455-assign-cookies
0714-best-time-to-buy-and-sell-stock-with-transaction-fee
1081-smallest-subsequence-of-distinct-characters
1386-cinema-seat-allocation
1520-maximum-number-of-non-overlapping-substrings
1833-maximum-ice-cream-bars
1846-maximum-element-after-decreasing-and-rearranging
1927-sum-game
2029-stone-game-ix
2091-removing-minimum-and-maximum-from-array
2472-maximum-number-of-non-overlapping-palindrome-substrings
2498-frog-jump-ii
3014-minimum-number-of-pushes-to-type-word-i
3016-minimum-number-of-pushes-to-type-word-ii
3302-find-the-lexicographically-smallest-valid-sequence
3348-smallest-divisible-digit-product-ii
3534-path-existence-queries-in-a-graph-ii
3720-lexicographically-smallest-permutation-greater-than-target

Counting Sort

1833-maximum-ice-cream-bars
3517-smallest-palindromic-rearrangement-i

Tree

0098-validate-binary-search-tree
0100-same-tree
0101-symmetric-tree
0102-binary-tree-level-order-traversal
0103-binary-tree-zigzag-level-order-traversal
0104-maximum-depth-of-binary-tree
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0110-balanced-binary-tree
0124-binary-tree-maximum-path-sum
0199-binary-tree-right-side-view
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0236-lowest-common-ancestor-of-a-binary-tree
0450-delete-node-in-a-bst
0543-diameter-of-binary-tree
0653-two-sum-iv-input-is-a-bst
0662-maximum-width-of-binary-tree
0700-search-in-a-binary-search-tree
0701-insert-into-a-binary-search-tree
0863-all-nodes-distance-k-in-binary-tree
0987-vertical-order-traversal-of-a-binary-tree
1008-construct-binary-search-tree-from-preorder-traversal
1376-time-needed-to-inform-all-employees
2265-count-nodes-equal-to-average-of-subtree

Depth-First Search

0098-validate-binary-search-tree
0100-same-tree
0101-symmetric-tree
0104-maximum-depth-of-binary-tree
0110-balanced-binary-tree
0124-binary-tree-maximum-path-sum
0130-surrounded-regions
0199-binary-tree-right-side-view
0200-number-of-islands
0207-course-schedule
0210-course-schedule-ii
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0236-lowest-common-ancestor-of-a-binary-tree
0543-diameter-of-binary-tree
0547-number-of-provinces
0653-two-sum-iv-input-is-a-bst
0662-maximum-width-of-binary-tree
0733-flood-fill
0743-network-delay-time
0778-swim-in-rising-water
0785-is-graph-bipartite
0802-find-eventual-safe-states
0827-making-a-large-island
0863-all-nodes-distance-k-in-binary-tree
0947-most-stones-removed-with-same-row-or-column
0987-vertical-order-traversal-of-a-binary-tree
1020-number-of-enclaves
1319-number-of-operations-to-make-network-connected
1376-time-needed-to-inform-all-employees
1631-path-with-minimum-effort
2265-count-nodes-equal-to-average-of-subtree
2492-minimum-score-of-a-path-between-two-cities
2685-count-the-number-of-complete-components

Breadth-First Search

0100-same-tree
0101-symmetric-tree
0102-binary-tree-level-order-traversal
0103-binary-tree-zigzag-level-order-traversal
0104-maximum-depth-of-binary-tree
0127-word-ladder
0130-surrounded-regions
0199-binary-tree-right-side-view
0200-number-of-islands
0207-course-schedule
0210-course-schedule-ii
0322-coin-change
0542-01-matrix
0547-number-of-provinces
0653-two-sum-iv-input-is-a-bst
0662-maximum-width-of-binary-tree
0733-flood-fill
0743-network-delay-time
0778-swim-in-rising-water
0785-is-graph-bipartite
0802-find-eventual-safe-states
0827-making-a-large-island
0863-all-nodes-distance-k-in-binary-tree
0987-vertical-order-traversal-of-a-binary-tree
0994-rotting-oranges
1020-number-of-enclaves
1091-shortest-path-in-binary-matrix
1319-number-of-operations-to-make-network-connected
1376-time-needed-to-inform-all-employees
1631-path-with-minimum-effort
2492-minimum-score-of-a-path-between-two-cities
2685-count-the-number-of-complete-components
2812-find-the-safest-path-in-a-grid
3568-minimum-moves-to-clean-the-classroom

Binary Tree

0098-validate-binary-search-tree
0100-same-tree
0101-symmetric-tree
0102-binary-tree-level-order-traversal
0103-binary-tree-zigzag-level-order-traversal
0104-maximum-depth-of-binary-tree
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0110-balanced-binary-tree
0124-binary-tree-maximum-path-sum
0199-binary-tree-right-side-view
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0236-lowest-common-ancestor-of-a-binary-tree
0450-delete-node-in-a-bst
0543-diameter-of-binary-tree
0653-two-sum-iv-input-is-a-bst
0662-maximum-width-of-binary-tree
0700-search-in-a-binary-search-tree
0701-insert-into-a-binary-search-tree
0863-all-nodes-distance-k-in-binary-tree
0987-vertical-order-traversal-of-a-binary-tree
1008-construct-binary-search-tree-from-preorder-traversal
2265-count-nodes-equal-to-average-of-subtree

Dynamic Programming

0022-generate-parentheses
0044-wildcard-matching
0053-maximum-subarray
0062-unique-paths
0063-unique-paths-ii
0070-climbing-stairs
0072-edit-distance
0115-distinct-subsequences
0118-pascals-triangle
0120-triangle
0121-best-time-to-buy-and-sell-stock
0122-best-time-to-buy-and-sell-stock-ii
0123-best-time-to-buy-and-sell-stock-iii
0124-binary-tree-maximum-path-sum
0132-palindrome-partitioning-ii
0152-maximum-product-subarray
0188-best-time-to-buy-and-sell-stock-iv
0198-house-robber
0213-house-robber-ii
0300-longest-increasing-subsequence
0309-best-time-to-buy-and-sell-stock-with-cooldown
0312-burst-balloons
0322-coin-change
0368-largest-divisible-subset
0377-combination-sum-iv
0410-split-array-largest-sum
0416-partition-equal-subset-sum
0486-predict-the-winner
0494-target-sum
0516-longest-palindromic-subsequence
0518-coin-change-ii
0542-01-matrix
0673-number-of-longest-increasing-subsequence
0714-best-time-to-buy-and-sell-stock-with-transaction-fee
0877-stone-game
0940-distinct-subsequences-ii
1043-partition-array-for-maximum-sum
1048-longest-string-chain
1092-shortest-common-supersequence
1140-stone-game-ii
1143-longest-common-subsequence
1277-count-square-submatrices-with-all-ones
1301-number-of-paths-with-max-score
1312-minimum-insertion-steps-to-make-a-string-palindrome
1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance
1406-stone-game-iii
1477-find-two-non-overlapping-sub-arrays-each-with-target-sum
1510-stone-game-iv
1547-minimum-cost-to-cut-a-stick
1563-stone-game-v
1621-number-of-sets-of-k-non-overlapping-line-segments
1872-stone-game-viii
1976-number-of-ways-to-arrive-at-destination
2472-maximum-number-of-non-overlapping-palindrome-substrings
3302-find-the-lexicographically-smallest-valid-sequence
3336-find-the-number-of-subsequences-with-equal-gcd
3414-maximum-score-of-non-overlapping-intervals
3524-find-x-value-of-array-i
3534-path-existence-queries-in-a-graph-ii
3620-network-recovery-pathways
3700-number-of-zigzag-arrays-ii

Divide and Conquer

0053-maximum-subarray
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0169-majority-element
0493-reverse-pairs
3737-count-subarrays-with-majority-element-i

Segment Tree

0493-reverse-pairs
0673-number-of-longest-increasing-subsequence
2213-longest-substring-of-one-repeating-character
3525-find-x-value-of-array-ii
3737-count-subarrays-with-majority-element-i

Merge Sort

0493-reverse-pairs
3737-count-subarrays-with-majority-element-i

Backtracking

0022-generate-parentheses
0039-combination-sum
0494-target-sum
3348-smallest-divisible-digit-product-ii

Enumeration

1291-sequential-digits
2778-sum-of-squares-of-special-elements
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

Matrix

0036-valid-sudoku
0048-rotate-image
0063-unique-paths-ii
0073-set-matrix-zeroes
0074-search-a-2d-matrix
0130-surrounded-regions
0200-number-of-islands
0542-01-matrix
0733-flood-fill
0778-swim-in-rising-water
0827-making-a-large-island
0835-image-overlap
0994-rotting-oranges
1020-number-of-enclaves
1091-shortest-path-in-binary-matrix
1260-shift-2d-grid
1277-count-square-submatrices-with-all-ones
1301-number-of-paths-with-max-score
1631-path-with-minimum-effort
2812-find-the-safest-path-in-a-grid
3568-minimum-moves-to-clean-the-classroom

Database

0197-rising-temperature
0570-managers-with-at-least-5-direct-reports
0577-employee-bonus
0584-find-customer-referee
0595-big-countries
0620-not-boring-movies
1068-product-sales-analysis-i
1075-project-employees-i
1148-article-views-i
1193-monthly-transactions-i
1211-queries-quality-and-percentage
1251-average-selling-price
1280-students-and-examinations
1378-replace-employee-id-with-the-unique-identifier
1581-customer-who-visited-but-did-not-make-any-transactions
1633-percentage-of-users-attended-a-contest
1661-average-time-of-process-per-machine
1757-recyclable-and-low-fat-products
1934-confirmation-rate

Binary Search Tree

0034-find-first-and-last-position-of-element-in-sorted-array
0074-search-a-2d-matrix
0081-search-in-rotated-sorted-array-ii
0098-validate-binary-search-tree
0153-find-minimum-in-rotated-sorted-array
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0287-find-the-duplicate-number
0300-longest-increasing-subsequence
0410-split-array-largest-sum
0450-delete-node-in-a-bst
0493-reverse-pairs
0653-two-sum-iv-input-is-a-bst
0700-search-in-a-binary-search-tree
0701-insert-into-a-binary-search-tree
0704-binary-search
0778-swim-in-rising-water
0875-koko-eating-bananas
1004-max-consecutive-ones-iii
1008-construct-binary-search-tree-from-preorder-traversal
1011-capacity-to-ship-packages-within-d-days
1283-find-the-smallest-divisor-given-a-threshold
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
1631-path-with-minimum-effort
1658-minimum-operations-to-reduce-x-to-zero
2498-frog-jump-ii
2812-find-the-safest-path-in-a-grid
3116-kth-smallest-amount-with-single-denomination-combination
3312-sorted-gcd-pair-queries
3414-maximum-score-of-non-overlapping-intervals
3532-path-existence-queries-in-a-graph-i
3534-path-existence-queries-in-a-graph-ii
3620-network-recovery-pathways

Stack

0316-remove-duplicate-letters
1008-construct-binary-search-tree-from-preorder-traversal
1081-smallest-subsequence-of-distinct-characters
1106-parsing-a-boolean-expression
1190-reverse-substrings-between-each-pair-of-parentheses

Monotonic Stack

0316-remove-duplicate-letters
1008-construct-binary-search-tree-from-preorder-traversal
1081-smallest-subsequence-of-distinct-characters

Two Pointers

0015-3sum
0018-4sum
0026-remove-duplicates-from-sorted-array
0031-next-permutation
0075-sort-colors
0088-merge-sorted-array
0189-rotate-array
0283-move-zeroes
0287-find-the-duplicate-number
0455-assign-cookies
0653-two-sum-iv-input-is-a-bst
1048-longest-string-chain
2149-rearrange-array-elements-by-sign
2472-maximum-number-of-non-overlapping-palindrome-substrings
3302-find-the-lexicographically-smallest-valid-sequence
3534-path-existence-queries-in-a-graph-ii
3867-sum-of-gcd-of-formed-pairs

Union-Find

0128-longest-consecutive-sequence
0130-surrounded-regions
0200-number-of-islands
0547-number-of-provinces
0778-swim-in-rising-water
0785-is-graph-bipartite
0827-making-a-large-island
0947-most-stones-removed-with-same-row-or-column
1020-number-of-enclaves
1319-number-of-operations-to-make-network-connected
1631-path-with-minimum-effort
2492-minimum-score-of-a-path-between-two-cities
2685-count-the-number-of-complete-components
2812-find-the-safest-path-in-a-grid
2948-make-lexicographically-smallest-array-by-swapping-elements
3532-path-existence-queries-in-a-graph-i

Heap (Priority Queue)

0743-network-delay-time
0778-swim-in-rising-water
1464-maximum-product-of-two-elements-in-an-array
1631-path-with-minimum-effort
2812-find-the-safest-path-in-a-grid
3620-network-recovery-pathways

Graph Theory

0207-course-schedule
0210-course-schedule-ii
0547-number-of-provinces
0743-network-delay-time
0785-is-graph-bipartite
0802-find-eventual-safe-states
0947-most-stones-removed-with-same-row-or-column
1319-number-of-operations-to-make-network-connected
1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance
1976-number-of-ways-to-arrive-at-destination
2492-minimum-score-of-a-path-between-two-cities
2685-count-the-number-of-complete-components
3532-path-existence-queries-in-a-graph-i
3534-path-existence-queries-in-a-graph-ii
3620-network-recovery-pathways

Topological Sort

0207-course-schedule
0210-course-schedule-ii
0802-find-eventual-safe-states
1976-number-of-ways-to-arrive-at-destination
3620-network-recovery-pathways

Shortest Path

0743-network-delay-time
1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance
1976-number-of-ways-to-arrive-at-destination
3620-network-recovery-pathways

Bit Manipulation

0136-single-number
0287-find-the-duplicate-number
1386-cinema-seat-allocation
3116-kth-smallest-amount-with-single-denomination-combination
3513-number-of-unique-xor-triplets-i
3514-number-of-unique-xor-triplets-ii
3534-path-existence-queries-in-a-graph-ii
3568-minimum-moves-to-clean-the-classroom
3702-longest-subsequence-with-non-zero-bitwise-xor

Memoization

0070-climbing-stairs

Combinatorics

0062-unique-paths
1621-number-of-sets-of-k-non-overlapping-line-segments
3116-kth-smallest-amount-with-single-denomination-combination
3312-sorted-gcd-pair-queries
3518-smallest-palindromic-rearrangement-ii

Number Theory

1979-find-greatest-common-divisor-of-array
3116-kth-smallest-amount-with-single-denomination-combination
3312-sorted-gcd-pair-queries
3336-find-the-number-of-subsequences-with-equal-gcd
3348-smallest-divisible-digit-product-ii
3658-gcd-of-odd-and-even-sums
3867-sum-of-gcd-of-formed-pairs

Recursion

0044-wildcard-matching
0486-predict-the-winner
1106-parsing-a-boolean-expression
3483-unique-3-digit-even-numbers

Simulation

1260-shift-2d-grid
2149-rearrange-array-elements-by-sign
3069-distribute-elements-into-two-arrays-i
3498-reverse-degree-of-a-string
3867-sum-of-gcd-of-formed-pairs

Binary Indexed Tree

0493-reverse-pairs
0673-number-of-longest-increasing-subsequence

Ordered Set

0493-reverse-pairs
2213-longest-substring-of-one-repeating-character

Game Theory

0486-predict-the-winner
0877-stone-game
1140-stone-game-ii
1406-stone-game-iii
1510-stone-game-iv
1563-stone-game-v
1872-stone-game-viii
1927-sum-game
2029-stone-game-ix

Binary Lifting

0236-lowest-common-ancestor-of-a-binary-tree

Lowest Common Ancestor

0236-lowest-common-ancestor-of-a-binary-tree

Directed Acyclic Graph

0207-course-schedule

Minimax

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

Zero-Sum Game

1140-stone-game-ii
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

Linked List

2058-find-the-minimum-and-maximum-number-of-nodes-between-critical-points

Quicksort

0056-merge-intervals
0075-sort-colors

Bubble Sort

0075-sort-colors

Pigeonhole Principle

0287-find-the-duplicate-number

Floyd's Cycle Finding Algorithm

0287-find-the-duplicate-number

Boyer–Moore Majority Vote Algorithm

0169-majority-element
0229-majority-element-ii

Geometry

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

Bracket Sequences

1190-reverse-substrings-between-each-pair-of-parentheses

About

430+ LeetCode solutions in Java | Knight Badge | Top 5.69% Globally

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages