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

📚 Data Structures and Algorithms (DSA) Repository

Welcome to my repository of Data Structures and Algorithms (DSA) learning and daily practice questions for competitive programming. This repository is a comprehensive resource for anyone looking to enhance their DSA skills and prepare for competitive programming challenges. Whether you're a beginner or an experienced coder, there's something here for everyone. Happy coding! 🚀


🗂️ Repository Structure

1. Daily Practice Questions

  • A collection of questions I solve daily to stay sharp and consistent.
  • Each solution includes:
    • Detailed explanations for better understanding.
    • Space and time complexity analysis.
  • Contributions and discussions on alternate solutions are highly encouraged!

2. Data Structures and Algorithms

Data Structures

  • In-depth explanations and implementations of fundamental data structures:
    • Arrays
    • Linked Lists
    • Trees
    • Graphs
    • Stacks
    • Queues
    • And more!
  • Example problems are provided to demonstrate real-world applications.

Algorithms

  • Comprehensive coverage of key algorithms:
    • Sorting and Searching
    • Dynamic Programming
    • Divide and Conquer
    • Greedy Algorithms
    • Backtracking
    • Graph Traversals (BFS, DFS)
  • Each algorithm includes:
    • Theoretical explanation: Clear and concise concepts.
    • Implementation: Step-by-step coding examples.
    • Example problems: Practical use cases and solutions.

3. Resources and References

  • A curated list of valuable resources for mastering DSA and competitive programming:
    • Recommended books 📖
    • Popular websites 🌐
    • Online courses 🎓
    • Practice platforms (LeetCode, Codeforces, HackerRank, etc.)
  • This list is continuously updated as new learning strategies and tools emerge.

🔗 How to Use This Repository

  1. Browse through the Daily Practice Questions folder for consistent problem-solving.
  2. Explore the Data Structures and Algorithms section for foundational concepts and their implementations.
  3. Refer to the Resources and References for additional learning material.
  4. Feel free to contribute! Open discussions and alternative solutions are always welcome.

💡 Why This Repository?

  • Consistency: Develop a habit of solving problems daily.
  • Practical Insights: Learn DSA concepts with real-world examples.
  • Community Learning: Share knowledge and grow with fellow learners.

Stay curious, keep solving, and happy coding! 🌟

LeetCode Topics

Array

0001-two-sum
0011-container-with-most-water
0036-valid-sudoku
0039-combination-sum
0042-trapping-rain-water
0048-rotate-image
0049-group-anagrams
0055-jump-game
0056-merge-intervals
0078-subsets
0081-search-in-rotated-sorted-array-ii
0088-merge-sorted-array
0153-find-minimum-in-rotated-sorted-array
0154-find-minimum-in-rotated-sorted-array-ii
0162-find-peak-element
0198-house-robber
0200-number-of-islands
0213-house-robber-ii
0215-kth-largest-element-in-an-array
0238-product-of-array-except-self
0239-sliding-window-maximum
0253-meeting-rooms-ii
0271-encode-and-decode-strings
0275-h-index-ii
0283-move-zeroes
0324-wiggle-sort-ii
0346-moving-average-from-data-stream
0380-insert-delete-getrandom-o1
0435-non-overlapping-intervals
0498-diagonal-traverse
0561-array-partition
0581-shortest-unsorted-continuous-subarray
0621-task-scheduler
0682-baseball-game
0735-asteroid-collision
0777-toeplitz-matrix
1014-k-closest-points-to-origin
1046-max-consecutive-ones-iii
1055-pairs-of-songs-with-total-durations-divisible-by-60
1074-high-five
1102-check-if-a-number-is-majority-element-in-a-sorted-array
1127-last-stone-weight
1171-shortest-path-in-binary-matrix
1206-corporate-flight-bookings
1345-perform-string-shifts
1435-xor-queries-of-a-subarray
1646-kth-missing-positive-number
1713-dot-product-of-two-sparse-vectors
1741-sort-array-by-increasing-frequency
1829-maximum-units-on-a-truck
1833-find-the-highest-altitude
1886-minimum-limit-of-balls-in-a-bag
1909-buildings-with-an-ocean-view
1961-maximum-ice-cream-bars
1966-frequency-of-the-most-frequent-element
2112-minimum-difference-between-highest-and-lowest-of-k-scores
2358-number-of-ways-to-split-array
2428-equal-row-and-column-pairs
2445-reachable-nodes-with-restrictions
2447-merge-similar-items
2691-count-vowel-strings-in-ranges
3151-minimum-processing-time
3639-zero-array-transformation-i

Prefix Sum

0238-product-of-array-except-self
0253-meeting-rooms-ii
1046-max-consecutive-ones-iii
1206-corporate-flight-bookings
1435-xor-queries-of-a-subarray
1833-find-the-highest-altitude
1966-frequency-of-the-most-frequent-element
2358-number-of-ways-to-split-array
2691-count-vowel-strings-in-ranges
3639-zero-array-transformation-i

Hash Table

0001-two-sum
0012-integer-to-roman
0017-letter-combinations-of-a-phone-number
0036-valid-sudoku
0049-group-anagrams
0146-lru-cache
0160-intersection-of-two-linked-lists
0202-happy-number
0242-valid-anagram
0314-binary-tree-vertical-order-traversal
0359-logger-rate-limiter
0380-insert-delete-getrandom-o1
0621-task-scheduler
1055-pairs-of-songs-with-total-durations-divisible-by-60
1074-high-five
1713-dot-product-of-two-sparse-vectors
1741-sort-array-by-increasing-frequency
1777-determine-if-two-strings-are-close
2177-check-whether-two-strings-are-almost-equivalent
2428-equal-row-and-column-pairs
2445-reachable-nodes-with-restrictions
2447-merge-similar-items
3474-better-compression-of-string

Matrix

0036-valid-sudoku
0048-rotate-image
0200-number-of-islands
0498-diagonal-traverse
0777-toeplitz-matrix
1171-shortest-path-in-binary-matrix
2428-equal-row-and-column-pairs

Simulation

0412-fizz-buzz
0498-diagonal-traverse
0682-baseball-game
0735-asteroid-collision
1119-robot-bounded-in-circle
2428-equal-row-and-column-pairs
2470-removing-stars-from-a-string

String

0012-integer-to-roman
0017-letter-combinations-of-a-phone-number
0020-valid-parentheses
0022-generate-parentheses
0049-group-anagrams
0072-edit-distance
0091-decode-ways
0161-one-edit-distance
0227-basic-calculator-ii
0242-valid-anagram
0257-binary-tree-paths
0271-encode-and-decode-strings
0392-is-subsequence
0394-decode-string
0408-valid-word-abbreviation
0412-fizz-buzz
0647-palindromic-substrings
0680-valid-palindrome-ii
0851-goat-latin
1119-robot-bounded-in-circle
1128-remove-all-adjacent-duplicates-in-string
1274-number-of-days-between-two-dates
1345-perform-string-shifts
1371-minimum-remove-to-make-valid-parentheses
1777-determine-if-two-strings-are-close
2177-check-whether-two-strings-are-almost-equivalent
2470-removing-stars-from-a-string
2580-circular-sentence
2691-count-vowel-strings-in-ranges
3474-better-compression-of-string

Stack

0020-valid-parentheses
0042-trapping-rain-water
0094-binary-tree-inorder-traversal
0227-basic-calculator-ii
0394-decode-string
0581-shortest-unsorted-continuous-subarray
0682-baseball-game
0735-asteroid-collision
1128-remove-all-adjacent-duplicates-in-string
1371-minimum-remove-to-make-valid-parentheses
1909-buildings-with-an-ocean-view
2470-removing-stars-from-a-string

Recursion

0050-powx-n
0326-power-of-three
0394-decode-string

Backtracking

0017-letter-combinations-of-a-phone-number
0022-generate-parentheses
0039-combination-sum
0077-combinations
0078-subsets
0257-binary-tree-paths

Tree

0094-binary-tree-inorder-traversal
0102-binary-tree-level-order-traversal
0116-populating-next-right-pointers-in-each-node
0117-populating-next-right-pointers-in-each-node-ii
0199-binary-tree-right-side-view
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0257-binary-tree-paths
0270-closest-binary-search-tree-value
0314-binary-tree-vertical-order-traversal
0333-largest-bst-subtree
0366-find-leaves-of-binary-tree
0543-diameter-of-binary-tree
0655-print-binary-tree
0975-range-sum-of-bst
1177-tree-diameter
1544-count-good-nodes-in-binary-tree
2445-reachable-nodes-with-restrictions

Depth-First Search

0094-binary-tree-inorder-traversal
0116-populating-next-right-pointers-in-each-node
0117-populating-next-right-pointers-in-each-node-ii
0199-binary-tree-right-side-view
0200-number-of-islands
0210-course-schedule-ii
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0257-binary-tree-paths
0270-closest-binary-search-tree-value
0314-binary-tree-vertical-order-traversal
0333-largest-bst-subtree
0339-nested-list-weight-sum
0366-find-leaves-of-binary-tree
0543-diameter-of-binary-tree
0655-print-binary-tree
0975-range-sum-of-bst
1177-tree-diameter
1544-count-good-nodes-in-binary-tree
1558-course-schedule-iv
1576-reorder-routes-to-make-all-paths-lead-to-the-city-zero
2445-reachable-nodes-with-restrictions

Binary Tree

0094-binary-tree-inorder-traversal
0102-binary-tree-level-order-traversal
0116-populating-next-right-pointers-in-each-node
0117-populating-next-right-pointers-in-each-node-ii
0199-binary-tree-right-side-view
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0257-binary-tree-paths
0270-closest-binary-search-tree-value
0314-binary-tree-vertical-order-traversal
0333-largest-bst-subtree
0366-find-leaves-of-binary-tree
0543-diameter-of-binary-tree
0655-print-binary-tree
0975-range-sum-of-bst
1544-count-good-nodes-in-binary-tree

Sorting

0049-group-anagrams
0056-merge-intervals
0088-merge-sorted-array
0215-kth-largest-element-in-an-array
0242-valid-anagram
0253-meeting-rooms-ii
0314-binary-tree-vertical-order-traversal
0324-wiggle-sort-ii
0435-non-overlapping-intervals
0561-array-partition
0581-shortest-unsorted-continuous-subarray
0621-task-scheduler
1014-k-closest-points-to-origin
1074-high-five
1741-sort-array-by-increasing-frequency
1777-determine-if-two-strings-are-close
1829-maximum-units-on-a-truck
1961-maximum-ice-cream-bars
1966-frequency-of-the-most-frequent-element
2112-minimum-difference-between-highest-and-lowest-of-k-scores
2447-merge-similar-items
3151-minimum-processing-time
3474-better-compression-of-string

Counting

0621-task-scheduler
1055-pairs-of-songs-with-total-durations-divisible-by-60
1777-determine-if-two-strings-are-close
2177-check-whether-two-strings-are-almost-equivalent
3474-better-compression-of-string

Math

0012-integer-to-roman
0048-rotate-image
0050-powx-n
0062-unique-paths
0070-climbing-stairs
0202-happy-number
0223-rectangle-area
0227-basic-calculator-ii
0326-power-of-three
0380-insert-delete-getrandom-o1
0412-fizz-buzz
1014-k-closest-points-to-origin
1119-robot-bounded-in-circle
1274-number-of-days-between-two-dates
1345-perform-string-shifts
2610-closest-prime-numbers-in-range

Breadth-First Search

0102-binary-tree-level-order-traversal
0116-populating-next-right-pointers-in-each-node
0117-populating-next-right-pointers-in-each-node-ii
0199-binary-tree-right-side-view
0200-number-of-islands
0210-course-schedule-ii
0314-binary-tree-vertical-order-traversal
0339-nested-list-weight-sum
0655-print-binary-tree
1171-shortest-path-in-binary-matrix
1177-tree-diameter
1544-count-good-nodes-in-binary-tree
1558-course-schedule-iv
1576-reorder-routes-to-make-all-paths-lead-to-the-city-zero
2445-reachable-nodes-with-restrictions

Ordered Set

2447-merge-similar-items

Heap (Priority Queue)

0215-kth-largest-element-in-an-array
0239-sliding-window-maximum
0253-meeting-rooms-ii
0621-task-scheduler
1014-k-closest-points-to-origin
1074-high-five
1127-last-stone-weight

Divide and Conquer

0215-kth-largest-element-in-an-array
0324-wiggle-sort-ii
1014-k-closest-points-to-origin

Quickselect

0215-kth-largest-element-in-an-array
0324-wiggle-sort-ii
1014-k-closest-points-to-origin

Greedy

0011-container-with-most-water
0055-jump-game
0253-meeting-rooms-ii
0324-wiggle-sort-ii
0435-non-overlapping-intervals
0561-array-partition
0581-shortest-unsorted-continuous-subarray
0621-task-scheduler
0680-valid-palindrome-ii
1829-maximum-units-on-a-truck
1961-maximum-ice-cream-bars
1966-frequency-of-the-most-frequent-element
3151-minimum-processing-time

Binary Search

0081-search-in-rotated-sorted-array-ii
0153-find-minimum-in-rotated-sorted-array
0154-find-minimum-in-rotated-sorted-array-ii
0162-find-peak-element
0270-closest-binary-search-tree-value
0275-h-index-ii
0374-guess-number-higher-or-lower
1046-max-consecutive-ones-iii
1102-check-if-a-number-is-majority-element-in-a-sorted-array
1646-kth-missing-positive-number
1886-minimum-limit-of-balls-in-a-bag
1966-frequency-of-the-most-frequent-element

Interactive

0374-guess-number-higher-or-lower

Dynamic Programming

0022-generate-parentheses
0042-trapping-rain-water
0055-jump-game
0062-unique-paths
0070-climbing-stairs
0072-edit-distance
0091-decode-ways
0198-house-robber
0213-house-robber-ii
0333-largest-bst-subtree
0392-is-subsequence
0435-non-overlapping-intervals
0647-palindromic-substrings

Combinatorics

0062-unique-paths

Queue

0239-sliding-window-maximum
0346-moving-average-from-data-stream

Sliding Window

0239-sliding-window-maximum
1046-max-consecutive-ones-iii
1966-frequency-of-the-most-frequent-element
2112-minimum-difference-between-highest-and-lowest-of-k-scores

Monotonic Queue

0239-sliding-window-maximum

Linked List

0061-rotate-list
0116-populating-next-right-pointers-in-each-node
0117-populating-next-right-pointers-in-each-node-ii
0146-lru-cache
0160-intersection-of-two-linked-lists
0237-delete-node-in-a-linked-list
0328-odd-even-linked-list

Binary Search Tree

0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
0270-closest-binary-search-tree-value
0333-largest-bst-subtree
0975-range-sum-of-bst

Two Pointers

0011-container-with-most-water
0042-trapping-rain-water
0061-rotate-list
0088-merge-sorted-array
0160-intersection-of-two-linked-lists
0161-one-edit-distance
0202-happy-number
0253-meeting-rooms-ii
0283-move-zeroes
0392-is-subsequence
0408-valid-word-abbreviation
0581-shortest-unsorted-continuous-subarray
0647-palindromic-substrings
0680-valid-palindrome-ii
1713-dot-product-of-two-sparse-vectors

Graph

0210-course-schedule-ii
1177-tree-diameter
1558-course-schedule-iv
1576-reorder-routes-to-make-all-paths-lead-to-the-city-zero
2445-reachable-nodes-with-restrictions

Counting Sort

0561-array-partition
1961-maximum-ice-cream-bars

Monotonic Stack

0042-trapping-rain-water
0581-shortest-unsorted-continuous-subarray
1909-buildings-with-an-ocean-view

Topological Sort

0210-course-schedule-ii
1177-tree-diameter
1558-course-schedule-iv

Number Theory

2610-closest-prime-numbers-in-range

Geometry

0223-rectangle-area
1014-k-closest-points-to-origin

Design

0146-lru-cache
0271-encode-and-decode-strings
0346-moving-average-from-data-stream
0359-logger-rate-limiter
0380-insert-delete-getrandom-o1
1713-dot-product-of-two-sparse-vectors

Bit Manipulation

0078-subsets
1435-xor-queries-of-a-subarray

Union Find

0200-number-of-islands
2445-reachable-nodes-with-restrictions

Randomized

0380-insert-delete-getrandom-o1

Memoization

0070-climbing-stairs

Data Stream

0346-moving-average-from-data-stream
0359-logger-rate-limiter

Doubly-Linked List

0146-lru-cache