/DSA

Some problems of leetcode on various techniques and concepts of DSA

Primary LanguageJava

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

LeetCode Topics

Array

0001-two-sum
0015-3sum
0026-remove-duplicates-from-sorted-array
0033-search-in-rotated-sorted-array
0037-sudoku-solver
0039-combination-sum
0040-combination-sum-ii
0042-trapping-rain-water
0046-permutations
0048-rotate-image
0049-group-anagrams
0051-n-queens
0053-maximum-subarray
0074-search-a-2d-matrix
0075-sort-colors
0084-largest-rectangle-in-histogram
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0108-convert-sorted-array-to-binary-search-tree
0121-best-time-to-buy-and-sell-stock
0128-longest-consecutive-sequence
0169-majority-element
0215-kth-largest-element-in-an-array
0217-contains-duplicate
0238-product-of-array-except-self
0239-sliding-window-maximum
0347-top-k-frequent-elements
0485-max-consecutive-ones
0496-next-greater-element-i
0540-single-element-in-a-sorted-array
1050-construct-binary-search-tree-from-preorder-traversal
1207-delete-nodes-and-return-forest
2846-robot-collisions

Divide and Conquer

0053-maximum-subarray
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0108-convert-sorted-array-to-binary-search-tree
0169-majority-element
0215-kth-largest-element-in-an-array
0347-top-k-frequent-elements

Dynamic Programming

0005-longest-palindromic-substring
0042-trapping-rain-water
0053-maximum-subarray
0062-unique-paths
0121-best-time-to-buy-and-sell-stock
0124-binary-tree-maximum-path-sum
0131-palindrome-partitioning

Two Pointers

0005-longest-palindromic-substring
0015-3sum
0019-remove-nth-node-from-end-of-list
0026-remove-duplicates-from-sorted-array
0028-find-the-index-of-the-first-occurrence-in-a-string
0042-trapping-rain-water
0075-sort-colors
0141-linked-list-cycle
0142-linked-list-cycle-ii
0151-reverse-words-in-a-string
0160-intersection-of-two-linked-lists
0165-compare-version-numbers
0234-palindrome-linked-list
0295-find-median-from-data-stream
0653-two-sum-iv-input-is-a-bst
0908-middle-of-the-linked-list

Sorting

0015-3sum
0049-group-anagrams
0075-sort-colors
0169-majority-element
0215-kth-largest-element-in-an-array
0217-contains-duplicate
0242-valid-anagram
0295-find-median-from-data-stream
0347-top-k-frequent-elements
0726-number-of-atoms
1029-vertical-order-traversal-of-a-binary-tree
2846-robot-collisions

Math

0013-roman-to-integer
0048-rotate-image
0050-powx-n
0062-unique-paths

Matrix

0037-sudoku-solver
0048-rotate-image
0074-search-a-2d-matrix

Binary Search

0033-search-in-rotated-sorted-array
0074-search-a-2d-matrix
0540-single-element-in-a-sorted-array

Recursion

0021-merge-two-sorted-lists
0025-reverse-nodes-in-k-group
0050-powx-n
0206-reverse-linked-list
0234-palindrome-linked-list

Hash Table

0001-two-sum
0003-longest-substring-without-repeating-characters
0013-roman-to-integer
0037-sudoku-solver
0049-group-anagrams
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0128-longest-consecutive-sequence
0138-copy-list-with-random-pointer
0141-linked-list-cycle
0142-linked-list-cycle-ii
0146-lru-cache
0160-intersection-of-two-linked-lists
0169-majority-element
0217-contains-duplicate
0242-valid-anagram
0347-top-k-frequent-elements
0460-lfu-cache
0496-next-greater-element-i
0653-two-sum-iv-input-is-a-bst
0726-number-of-atoms
1029-vertical-order-traversal-of-a-binary-tree
1207-delete-nodes-and-return-forest

Counting

0169-majority-element
0347-top-k-frequent-elements

Combinatorics

0062-unique-paths

Union Find

0128-longest-consecutive-sequence

String

0003-longest-substring-without-repeating-characters
0005-longest-palindromic-substring
0008-string-to-integer-atoi
0013-roman-to-integer
0014-longest-common-prefix
0020-valid-parentheses
0028-find-the-index-of-the-first-occurrence-in-a-string
0038-count-and-say
0049-group-anagrams
0131-palindrome-partitioning
0151-reverse-words-in-a-string
0165-compare-version-numbers
0242-valid-anagram
0297-serialize-and-deserialize-binary-tree
0686-repeated-string-match
0726-number-of-atoms
2217-step-by-step-directions-from-a-binary-tree-node-to-another

Sliding Window

0003-longest-substring-without-repeating-characters
0239-sliding-window-maximum

Linked List

0019-remove-nth-node-from-end-of-list
0021-merge-two-sorted-lists
0025-reverse-nodes-in-k-group
0114-flatten-binary-tree-to-linked-list
0116-populating-next-right-pointers-in-each-node
0138-copy-list-with-random-pointer
0141-linked-list-cycle
0142-linked-list-cycle-ii
0146-lru-cache
0160-intersection-of-two-linked-lists
0206-reverse-linked-list
0234-palindrome-linked-list
0237-delete-node-in-a-linked-list
0460-lfu-cache
0908-middle-of-the-linked-list

Stack

0020-valid-parentheses
0042-trapping-rain-water
0084-largest-rectangle-in-histogram
0094-binary-tree-inorder-traversal
0114-flatten-binary-tree-to-linked-list
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0155-min-stack
0173-binary-search-tree-iterator
0232-implement-queue-using-stacks
0234-palindrome-linked-list
0496-next-greater-element-i
0726-number-of-atoms
1050-construct-binary-search-tree-from-preorder-traversal
2846-robot-collisions

Monotonic Stack

0042-trapping-rain-water
0084-largest-rectangle-in-histogram
0496-next-greater-element-i
1050-construct-binary-search-tree-from-preorder-traversal

Heap (Priority Queue)

0215-kth-largest-element-in-an-array
0239-sliding-window-maximum
0295-find-median-from-data-stream
0347-top-k-frequent-elements

Bucket Sort

0347-top-k-frequent-elements

Quickselect

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

Prefix Sum

0238-product-of-array-except-self

Backtracking

0037-sudoku-solver
0039-combination-sum
0040-combination-sum-ii
0046-permutations
0051-n-queens
0131-palindrome-partitioning

Design

0146-lru-cache
0155-min-stack
0173-binary-search-tree-iterator
0232-implement-queue-using-stacks
0295-find-median-from-data-stream
0297-serialize-and-deserialize-binary-tree
0460-lfu-cache

Data Stream

0295-find-median-from-data-stream

Queue

0232-implement-queue-using-stacks
0239-sliding-window-maximum

Doubly-Linked List

0146-lru-cache
0460-lfu-cache

Monotonic Queue

0239-sliding-window-maximum

Trie

0014-longest-common-prefix

String Matching

0028-find-the-index-of-the-first-occurrence-in-a-string
0686-repeated-string-match

Simulation

2846-robot-collisions

Tree

0094-binary-tree-inorder-traversal
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
0108-convert-sorted-array-to-binary-search-tree
0110-balanced-binary-tree
0114-flatten-binary-tree-to-linked-list
0116-populating-next-right-pointers-in-each-node
0124-binary-tree-maximum-path-sum
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0173-binary-search-tree-iterator
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0236-lowest-common-ancestor-of-a-binary-tree
0297-serialize-and-deserialize-binary-tree
0543-diameter-of-binary-tree
0653-two-sum-iv-input-is-a-bst
0662-maximum-width-of-binary-tree
0774-maximum-depth-of-n-ary-tree
0783-search-in-a-binary-search-tree
1029-vertical-order-traversal-of-a-binary-tree
1050-construct-binary-search-tree-from-preorder-traversal
1207-delete-nodes-and-return-forest
2217-step-by-step-directions-from-a-binary-tree-node-to-another

Depth-First Search

0094-binary-tree-inorder-traversal
0098-validate-binary-search-tree
0100-same-tree
0101-symmetric-tree
0104-maximum-depth-of-binary-tree
0110-balanced-binary-tree
0114-flatten-binary-tree-to-linked-list
0116-populating-next-right-pointers-in-each-node
0124-binary-tree-maximum-path-sum
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0236-lowest-common-ancestor-of-a-binary-tree
0297-serialize-and-deserialize-binary-tree
0543-diameter-of-binary-tree
0653-two-sum-iv-input-is-a-bst
0662-maximum-width-of-binary-tree
0774-maximum-depth-of-n-ary-tree
1029-vertical-order-traversal-of-a-binary-tree
1207-delete-nodes-and-return-forest
2217-step-by-step-directions-from-a-binary-tree-node-to-another

Binary Tree

0094-binary-tree-inorder-traversal
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
0108-convert-sorted-array-to-binary-search-tree
0110-balanced-binary-tree
0114-flatten-binary-tree-to-linked-list
0116-populating-next-right-pointers-in-each-node
0124-binary-tree-maximum-path-sum
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0173-binary-search-tree-iterator
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0236-lowest-common-ancestor-of-a-binary-tree
0297-serialize-and-deserialize-binary-tree
0543-diameter-of-binary-tree
0653-two-sum-iv-input-is-a-bst
0662-maximum-width-of-binary-tree
0783-search-in-a-binary-search-tree
1029-vertical-order-traversal-of-a-binary-tree
1050-construct-binary-search-tree-from-preorder-traversal
1207-delete-nodes-and-return-forest
2217-step-by-step-directions-from-a-binary-tree-node-to-another

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
0116-populating-next-right-pointers-in-each-node
0297-serialize-and-deserialize-binary-tree
0653-two-sum-iv-input-is-a-bst
0662-maximum-width-of-binary-tree
0774-maximum-depth-of-n-ary-tree
1029-vertical-order-traversal-of-a-binary-tree

Binary Search Tree

0098-validate-binary-search-tree
0108-convert-sorted-array-to-binary-search-tree
0173-binary-search-tree-iterator
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0653-two-sum-iv-input-is-a-bst
0783-search-in-a-binary-search-tree
1050-construct-binary-search-tree-from-preorder-traversal

Iterator

0173-binary-search-tree-iterator