Skip to content

Solved 100+ LeetCode DSA problems in Java — organized by topic, covering Arrays, Strings, Dynamic Programming, Trees, Two Pointers, Stack, Sorting, and more.

Notifications You must be signed in to change notification settings

ayyaz-khira/leetcode-dsa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💻 LeetCode DSA Solutions in Java

Solved 100+ LeetCode Data Structures & Algorithms problems in Java, organized by topic.
This repository reflects my consistent problem-solving practice and preparation for coding interviews.


🧠 Topics Covered

  • Arrays
  • Strings
  • Two Pointers
  • Stack
  • Queue
  • Linked List
  • Sorting
  • Binary Search
  • Hash Table
  • Matrix
  • Tree & Binary Tree
  • DFS & Backtracking
  • Bit Manipulation
  • Dynamic Programming (DP)
  • Monotonic Stack / Queue
  • Divide and Conquer
  • Trie

LeetCode Topics

Stack

0020-valid-parentheses
0042-trapping-rain-water
0084-largest-rectangle-in-histogram
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0225-implement-stack-using-queues
0232-implement-queue-using-stacks
0402-remove-k-digits
0496-next-greater-element-i
0503-next-greater-element-ii

Design

0225-implement-stack-using-queues
0232-implement-queue-using-stacks

Queue

0225-implement-stack-using-queues
0232-implement-queue-using-stacks
0239-sliding-window-maximum
0387-first-unique-character-in-a-string

String

0003-longest-substring-without-repeating-characters
0005-longest-palindromic-substring
0014-longest-common-prefix
0020-valid-parentheses
0028-find-the-index-of-the-first-occurrence-in-a-string
0049-group-anagrams
0072-edit-distance
0076-minimum-window-substring
0079-word-search
0115-distinct-subsequences
0125-valid-palindrome
0139-word-break
0151-reverse-words-in-a-string
0242-valid-anagram
0344-reverse-string
0383-ransom-note
0387-first-unique-character-in-a-string
0392-is-subsequence
0402-remove-k-digits
0424-longest-repeating-character-replacement
0438-find-all-anagrams-in-a-string
0516-longest-palindromic-subsequence
0742-to-lower-case
0782-jewels-and-stones
0812-rotate-string
1250-longest-common-subsequence
1781-check-if-two-string-arrays-are-equivalent
1823-determine-if-string-halves-are-alike
1894-merge-strings-alternately
1944-truncate-sentence
1960-check-if-the-sentence-is-pangram
2032-largest-odd-number-in-string
2099-number-of-strings-that-appear-as-substrings-in-word
2219-maximum-number-of-words-found-in-sentences
2231-find-first-palindromic-string-in-the-array
3194-find-words-containing-character

Array

0001-two-sum
0004-median-of-two-sorted-arrays
0011-container-with-most-water
0014-longest-common-prefix
0015-3sum
0026-remove-duplicates-from-sorted-array
0027-remove-element
0034-find-first-and-last-position-of-element-in-sorted-array
0039-combination-sum
0042-trapping-rain-water
0046-permutations
0047-permutations-ii
0048-rotate-image
0049-group-anagrams
0053-maximum-subarray
0054-spiral-matrix
0056-merge-intervals
0064-minimum-path-sum
0075-sort-colors
0079-word-search
0084-largest-rectangle-in-histogram
0121-best-time-to-buy-and-sell-stock
0128-longest-consecutive-sequence
0136-single-number
0137-single-number-ii
0139-word-break
0162-find-peak-element
0169-majority-element
0189-rotate-array
0198-house-robber
0200-number-of-islands
0209-minimum-size-subarray-sum
0213-house-robber-ii
0215-kth-largest-element-in-an-array
0217-contains-duplicate
0229-majority-element-ii
0238-product-of-array-except-self
0239-sliding-window-maximum
0260-single-number-iii
0268-missing-number
0283-move-zeroes
0287-find-the-duplicate-number
0300-longest-increasing-subsequence
0322-coin-change
0347-top-k-frequent-elements
0349-intersection-of-two-arrays
0442-find-all-duplicates-in-an-array
0485-max-consecutive-ones
0496-next-greater-element-i
0503-next-greater-element-ii
0518-coin-change-ii
0525-contiguous-array
0560-subarray-sum-equals-k
0643-maximum-average-subarray-i
0724-find-pivot-index
0898-transpose-matrix
0940-fruit-into-baskets
0966-binary-subarrays-with-sum
1019-squares-of-a-sorted-array
1046-max-consecutive-ones-iii
1137-height-checker
1293-three-consecutive-odds
1482-how-many-numbers-are-smaller-than-the-current-number
1580-shuffle-the-array
1603-running-sum-of-1d-array
1677-matrix-diagonal-sum
1781-check-if-two-string-arrays-are-equivalent
1791-richest-customer-wealth
1878-check-if-array-is-sorted-and-rotated
1944-truncate-sentence
2099-number-of-strings-that-appear-as-substrings-in-word
2219-maximum-number-of-words-found-in-sentences
2231-find-first-palindromic-string-in-the-array
2255-minimum-swaps-to-group-all-1s-together-ii
2876-number-of-employees-who-met-the-target
3194-find-words-containing-character
3321-type-of-triangle
3372-longest-strictly-increasing-or-strictly-decreasing-subarray

Hash Table

0001-two-sum
0003-longest-substring-without-repeating-characters
0049-group-anagrams
0076-minimum-window-substring
0128-longest-consecutive-sequence
0139-word-break
0141-linked-list-cycle
0169-majority-element
0217-contains-duplicate
0229-majority-element-ii
0242-valid-anagram
0268-missing-number
0347-top-k-frequent-elements
0349-intersection-of-two-arrays
0383-ransom-note
0387-first-unique-character-in-a-string
0424-longest-repeating-character-replacement
0438-find-all-anagrams-in-a-string
0442-find-all-duplicates-in-an-array
0496-next-greater-element-i
0525-contiguous-array
0560-subarray-sum-equals-k
0653-two-sum-iv-input-is-a-bst
0782-jewels-and-stones
0940-fruit-into-baskets
0966-binary-subarrays-with-sum
1482-how-many-numbers-are-smaller-than-the-current-number
1960-check-if-the-sentence-is-pangram

Monotonic Stack

0042-trapping-rain-water
0084-largest-rectangle-in-histogram
0402-remove-k-digits
0496-next-greater-element-i
0503-next-greater-element-ii

Greedy

0011-container-with-most-water
0402-remove-k-digits
2032-largest-odd-number-in-string

Two Pointers

0005-longest-palindromic-substring
0011-container-with-most-water
0015-3sum
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
0042-trapping-rain-water
0061-rotate-list
0075-sort-colors
0125-valid-palindrome
0141-linked-list-cycle
0151-reverse-words-in-a-string
0189-rotate-array
0283-move-zeroes
0287-find-the-duplicate-number
0344-reverse-string
0349-intersection-of-two-arrays
0392-is-subsequence
0653-two-sum-iv-input-is-a-bst
0908-middle-of-the-linked-list
1019-squares-of-a-sorted-array
1894-merge-strings-alternately
2231-find-first-palindromic-string-in-the-array

Dynamic Programming

0005-longest-palindromic-substring
0042-trapping-rain-water
0053-maximum-subarray
0064-minimum-path-sum
0072-edit-distance
0115-distinct-subsequences
0121-best-time-to-buy-and-sell-stock
0139-word-break
0198-house-robber
0213-house-robber-ii
0300-longest-increasing-subsequence
0322-coin-change
0392-is-subsequence
0516-longest-palindromic-subsequence
0518-coin-change-ii
1013-fibonacci-number
1250-longest-common-subsequence
1263-number-of-dice-rolls-with-target-sum

Sorting

0015-3sum
0047-permutations-ii
0049-group-anagrams
0056-merge-intervals
0075-sort-colors
0169-majority-element
0215-kth-largest-element-in-an-array
0217-contains-duplicate
0229-majority-element-ii
0242-valid-anagram
0268-missing-number
0347-top-k-frequent-elements
0349-intersection-of-two-arrays
1019-squares-of-a-sorted-array
1137-height-checker
1482-how-many-numbers-are-smaller-than-the-current-number
3321-type-of-triangle

Prefix Sum

0209-minimum-size-subarray-sum
0238-product-of-array-except-self
0525-contiguous-array
0560-subarray-sum-equals-k
0724-find-pivot-index
0966-binary-subarrays-with-sum
1046-max-consecutive-ones-iii
1603-running-sum-of-1d-array

Linked List

0019-remove-nth-node-from-end-of-list
0021-merge-two-sorted-lists
0024-swap-nodes-in-pairs
0061-rotate-list
0141-linked-list-cycle
0206-reverse-linked-list
0908-middle-of-the-linked-list

Recursion

0021-merge-two-sorted-lists
0024-swap-nodes-in-pairs
0206-reverse-linked-list
1013-fibonacci-number

Breadth-First Search

0100-same-tree
0101-symmetric-tree
0104-maximum-depth-of-binary-tree
0112-path-sum
0200-number-of-islands
0226-invert-binary-tree
0322-coin-change
0404-sum-of-left-leaves
0653-two-sum-iv-input-is-a-bst

Tree

0100-same-tree
0101-symmetric-tree
0104-maximum-depth-of-binary-tree
0110-balanced-binary-tree
0112-path-sum
0113-path-sum-ii
0144-binary-tree-preorder-traversal
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
0236-lowest-common-ancestor-of-a-binary-tree
0404-sum-of-left-leaves
0450-delete-node-in-a-bst
0543-diameter-of-binary-tree
0653-two-sum-iv-input-is-a-bst
0783-search-in-a-binary-search-tree
0784-insert-into-a-binary-search-tree

Depth-First Search

0079-word-search
0100-same-tree
0101-symmetric-tree
0104-maximum-depth-of-binary-tree
0110-balanced-binary-tree
0112-path-sum
0113-path-sum-ii
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0200-number-of-islands
0226-invert-binary-tree
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0236-lowest-common-ancestor-of-a-binary-tree
0404-sum-of-left-leaves
0543-diameter-of-binary-tree
0653-two-sum-iv-input-is-a-bst

Binary Tree

0100-same-tree
0101-symmetric-tree
0104-maximum-depth-of-binary-tree
0110-balanced-binary-tree
0112-path-sum
0113-path-sum-ii
0144-binary-tree-preorder-traversal
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
0236-lowest-common-ancestor-of-a-binary-tree
0404-sum-of-left-leaves
0450-delete-node-in-a-bst
0543-diameter-of-binary-tree
0653-two-sum-iv-input-is-a-bst
0783-search-in-a-binary-search-tree
0784-insert-into-a-binary-search-tree

Binary Search Tree

0004-median-of-two-sorted-arrays
0034-find-first-and-last-position-of-element-in-sorted-array
0162-find-peak-element
0209-minimum-size-subarray-sum
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0268-missing-number
0287-find-the-duplicate-number
0300-longest-increasing-subsequence
0349-intersection-of-two-arrays
0450-delete-node-in-a-bst
0653-two-sum-iv-input-is-a-bst
0783-search-in-a-binary-search-tree
0784-insert-into-a-binary-search-tree
1046-max-consecutive-ones-iii

Matrix

0048-rotate-image
0054-spiral-matrix
0064-minimum-path-sum
0079-word-search
0200-number-of-islands
0898-transpose-matrix
1677-matrix-diagonal-sum
1791-richest-customer-wealth

Math

0009-palindrome-number
0048-rotate-image
0189-rotate-array
0258-add-digits
0268-missing-number
1013-fibonacci-number
1406-subtract-the-product-and-sum-of-digits-of-an-integer
2032-largest-odd-number-in-string
2608-count-the-digits-that-divide-a-number
2752-sum-multiples
3172-divisible-and-non-divisible-sums-difference
3321-type-of-triangle

Simulation

0054-spiral-matrix
0258-add-digits
0898-transpose-matrix

Number Theory

0258-add-digits

Counting Sort

0169-majority-element
0229-majority-element-ii
0347-top-k-frequent-elements
0383-ransom-note
0387-first-unique-character-in-a-string
1137-height-checker
1482-how-many-numbers-are-smaller-than-the-current-number
1823-determine-if-string-halves-are-alike

Bit Manipulation

0136-single-number
0137-single-number-ii
0260-single-number-iii
0268-missing-number
0287-find-the-duplicate-number

Divide and Conquer

0004-median-of-two-sorted-arrays
0053-maximum-subarray
0169-majority-element
0215-kth-largest-element-in-an-array
0347-top-k-frequent-elements

Memoization

0139-word-break
1013-fibonacci-number

Backtracking

0039-combination-sum
0046-permutations
0047-permutations-ii
0079-word-search
0113-path-sum-ii

Trie

0014-longest-common-prefix
0139-word-break

Sliding Window

0003-longest-substring-without-repeating-characters
0076-minimum-window-substring
0209-minimum-size-subarray-sum
0239-sliding-window-maximum
0424-longest-repeating-character-replacement
0438-find-all-anagrams-in-a-string
0643-maximum-average-subarray-i
0940-fruit-into-baskets
0966-binary-subarrays-with-sum
1046-max-consecutive-ones-iii
2255-minimum-swaps-to-group-all-1s-together-ii

Database

0182-duplicate-emails
0595-big-countries
0620-not-boring-movies

Heap (Priority Queue)

0215-kth-largest-element-in-an-array
0239-sliding-window-maximum
0347-top-k-frequent-elements

Monotonic Queue

0239-sliding-window-maximum

String Matching

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

Union Find

0128-longest-consecutive-sequence
0200-number-of-islands

Bucket Sort

0347-top-k-frequent-elements

Quickselect

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

About

Solved 100+ LeetCode DSA problems in Java — organized by topic, covering Arrays, Strings, Dynamic Programming, Trees, Two Pointers, Stack, Sorting, and more.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages