Skip to content

Welcome to my Data Structures and Algorithms (DSA) repository! This repository is dedicated to my journey of mastering data structures and algorithms. Here, you'll find solutions to various problems I've tackled as part of my learning process.

Notifications You must be signed in to change notification settings

nikhilmehlan/Dsa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Structures and Algorithms Journey

Welcome to my Data Structures and Algorithms (DSA) repository! This repository is a personal project where I document and solve various problems related to data structures and algorithms. It's a reflection of my journey in mastering these fundamental concepts and enhancing my problem-solving skills.

Leetcode Stats

📚 Repository Contents

  • Problems: A collection of solved problems categorized by data structures and algorithms.
  • Solutions: Implementations in multiple programming languages (e.g., C++, Python, Java).
  • Explanations: Detailed explanations and comments for each solution to aid understanding.
  • Challenges: A selection of challenging problems to push my limits and improve my skills.

🛠️ How to Use

  1. Explore: Browse through the different directories and files to find problems and their solutions.
  2. Run: Follow the instructions in each problem’s directory to run the code. You may need to install dependencies if required.
  3. Learn: Review the code and explanations to understand the problem-solving approach and algorithmic concepts.
  4. Contribute: If you have suggestions for improvements or additional problems, feel free to open an issue or submit a pull request.

📝 Topics Covered

  • Arrays
  • Linked Lists
  • Stacks
  • Queues
  • Trees (Binary Trees, Binary Search Trees, AVL Trees)
  • Graphs (DFS, BFS, Shortest Path Algorithms)
  • Dynamic Programming
  • Hashing
  • Sorting and Searching Algorithms
  • And more...

📈 My Progress

This repository is continually updated as I work through more problems and refine my solutions. Check out the commit history to see my progress and updates.

🚀 Getting Started

To get started with this repository:

  1. Clone the repository:
    git clone https://github.com/yourusername/your-repo-name.git
  2. Navigate to the problem's directory and follow the instructions provided in the respective README files for each problem.
  3. Run the provided code and review the results.

📫 Contact

For any questions or feedback, feel free to contact me via nikhilmehlan1234@gmail.com or open an issue on GitHub.


Happy coding!

LeetCode Topics

Array

0034-find-first-and-last-position-of-element-in-sorted-array
0035-search-insert-position
0037-sudoku-solver
0042-trapping-rain-water
0045-jump-game-ii
0051-n-queens
0055-jump-game
0056-merge-intervals
0057-insert-interval
0078-subsets
0079-word-search
0084-largest-rectangle-in-histogram
0085-maximal-rectangle
0090-subsets-ii
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0135-candy
0136-single-number
0139-word-break
0200-number-of-islands
0204-count-primes
0215-kth-largest-element-in-an-array
0239-sliding-window-maximum
0347-top-k-frequent-elements
0407-trapping-rain-water-ii
0435-non-overlapping-intervals
0455-assign-cookies
0496-next-greater-element-i
0503-next-greater-element-ii
0542-01-matrix
0621-task-scheduler
0733-flood-fill
0735-asteroid-collision
0792-binary-search
0876-hand-of-straights
0890-lemonade-change
0940-fruit-into-baskets
0943-sum-of-subarray-minimums
0966-binary-subarrays-with-sum
1034-subarrays-with-k-different-integers
1036-rotting-oranges
1046-max-consecutive-ones-iii
1050-construct-binary-search-tree-from-preorder-traversal
1370-count-number-of-nice-subarrays
1538-maximum-points-you-can-obtain-from-cards
2145-grid-game
2227-sum-of-subarray-ranges
2533-bitwise-xor-of-all-pairings
2685-first-completely-painted-row-or-column
2792-neighboring-bitwise-xor

String

0003-longest-substring-without-repeating-characters
0017-letter-combinations-of-a-phone-number
0020-valid-parentheses
0076-minimum-window-substring
0079-word-search
0131-palindrome-partitioning
0139-word-break
0282-expression-add-operators
0297-serialize-and-deserialize-binary-tree
0402-remove-k-digits
0424-longest-repeating-character-replacement
0678-valid-parenthesis-string
1460-number-of-substrings-containing-all-three-characters

Backtracking

0017-letter-combinations-of-a-phone-number
0037-sudoku-solver
0051-n-queens
0078-subsets
0079-word-search
0090-subsets-ii
0131-palindrome-partitioning
0282-expression-add-operators

Matrix

0037-sudoku-solver
0079-word-search
0085-maximal-rectangle
0200-number-of-islands
0407-trapping-rain-water-ii
0542-01-matrix
0733-flood-fill
1036-rotting-oranges
2145-grid-game
2685-first-completely-painted-row-or-column

Bit Manipulation

0029-divide-two-integers
0078-subsets
0090-subsets-ii
0136-single-number
0222-count-complete-tree-nodes
0231-power-of-two
2323-minimum-bit-flips-to-convert-number
2533-bitwise-xor-of-all-pairings
2792-neighboring-bitwise-xor

Hash Table

0003-longest-substring-without-repeating-characters
0017-letter-combinations-of-a-phone-number
0037-sudoku-solver
0076-minimum-window-substring
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0139-word-break
0146-lru-cache
0347-top-k-frequent-elements
0355-design-twitter
0424-longest-repeating-character-replacement
0460-lfu-cache
0496-next-greater-element-i
0621-task-scheduler
0653-two-sum-iv-input-is-a-bst
0876-hand-of-straights
0893-all-nodes-distance-k-in-binary-tree
0940-fruit-into-baskets
0966-binary-subarrays-with-sum
1029-vertical-order-traversal-of-a-binary-tree
1034-subarrays-with-k-different-integers
1370-count-number-of-nice-subarrays
1460-number-of-substrings-containing-all-three-characters
2461-amount-of-time-for-binary-tree-to-be-infected
2685-first-completely-painted-row-or-column

Dynamic Programming

0042-trapping-rain-water
0045-jump-game-ii
0055-jump-game
0085-maximal-rectangle
0124-binary-tree-maximum-path-sum
0131-palindrome-partitioning
0139-word-break
0435-non-overlapping-intervals
0542-01-matrix
0678-valid-parenthesis-string
0943-sum-of-subarray-minimums

Trie

0139-word-break

Memoization

0139-word-break

Math

0029-divide-two-integers
0050-powx-n
0204-count-primes
0231-power-of-two
0282-expression-add-operators
1370-count-number-of-nice-subarrays

Recursion

0050-powx-n
0231-power-of-two

Binary Search

0034-find-first-and-last-position-of-element-in-sorted-array
0035-search-insert-position
0222-count-complete-tree-nodes
0792-binary-search
1046-max-consecutive-ones-iii

Enumeration

0204-count-primes

Number Theory

0204-count-primes

Brainteaser

2533-bitwise-xor-of-all-pairings

Stack

0020-valid-parentheses
0042-trapping-rain-water
0084-largest-rectangle-in-histogram
0085-maximal-rectangle
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
0225-implement-stack-using-queues
0232-implement-queue-using-stacks
0402-remove-k-digits
0496-next-greater-element-i
0503-next-greater-element-ii
0678-valid-parenthesis-string
0735-asteroid-collision
0937-online-stock-span
0943-sum-of-subarray-minimums
1050-construct-binary-search-tree-from-preorder-traversal
2227-sum-of-subarray-ranges

Design

0146-lru-cache
0155-min-stack
0173-binary-search-tree-iterator
0225-implement-stack-using-queues
0232-implement-queue-using-stacks
0295-find-median-from-data-stream
0297-serialize-and-deserialize-binary-tree
0355-design-twitter
0460-lfu-cache
0789-kth-largest-element-in-a-stream
0937-online-stock-span

Queue

0225-implement-stack-using-queues
0232-implement-queue-using-stacks
0239-sliding-window-maximum

Monotonic Stack

0042-trapping-rain-water
0084-largest-rectangle-in-histogram
0085-maximal-rectangle
0402-remove-k-digits
0496-next-greater-element-i
0503-next-greater-element-ii
0937-online-stock-span
0943-sum-of-subarray-minimums
1050-construct-binary-search-tree-from-preorder-traversal
2227-sum-of-subarray-ranges

Two Pointers

0042-trapping-rain-water
0295-find-median-from-data-stream
0455-assign-cookies
0653-two-sum-iv-input-is-a-bst

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
0199-binary-tree-right-side-view
0200-number-of-islands
0297-serialize-and-deserialize-binary-tree
0407-trapping-rain-water-ii
0542-01-matrix
0547-number-of-provinces
0653-two-sum-iv-input-is-a-bst
0662-maximum-width-of-binary-tree
0733-flood-fill
0893-all-nodes-distance-k-in-binary-tree
1029-vertical-order-traversal-of-a-binary-tree
1036-rotting-oranges
2461-amount-of-time-for-binary-tree-to-be-infected

Heap (Priority Queue)

0023-merge-k-sorted-lists
0215-kth-largest-element-in-an-array
0239-sliding-window-maximum
0295-find-median-from-data-stream
0347-top-k-frequent-elements
0355-design-twitter
0407-trapping-rain-water-ii
0621-task-scheduler
0789-kth-largest-element-in-a-stream

Simulation

0735-asteroid-collision

Greedy

0045-jump-game-ii
0055-jump-game
0135-candy
0402-remove-k-digits
0435-non-overlapping-intervals
0455-assign-cookies
0621-task-scheduler
0678-valid-parenthesis-string
0876-hand-of-straights
0890-lemonade-change

Sliding Window

0003-longest-substring-without-repeating-characters
0076-minimum-window-substring
0239-sliding-window-maximum
0424-longest-repeating-character-replacement
0940-fruit-into-baskets
0966-binary-subarrays-with-sum
1034-subarrays-with-k-different-integers
1046-max-consecutive-ones-iii
1370-count-number-of-nice-subarrays
1460-number-of-substrings-containing-all-three-characters
1538-maximum-points-you-can-obtain-from-cards

Monotonic Queue

0239-sliding-window-maximum

Data Stream

0295-find-median-from-data-stream
0789-kth-largest-element-in-a-stream
0937-online-stock-span

Linked List

0023-merge-k-sorted-lists
0114-flatten-binary-tree-to-linked-list
0146-lru-cache
0355-design-twitter
0460-lfu-cache

Doubly-Linked List

0146-lru-cache
0460-lfu-cache

Prefix Sum

0966-binary-subarrays-with-sum
1046-max-consecutive-ones-iii
1370-count-number-of-nice-subarrays
1538-maximum-points-you-can-obtain-from-cards
2145-grid-game

Counting

0347-top-k-frequent-elements
0621-task-scheduler
1034-subarrays-with-k-different-integers

Divide and Conquer

0023-merge-k-sorted-lists
0105-construct-binary-tree-from-preorder-and-inorder-traversal
0106-construct-binary-tree-from-inorder-and-postorder-traversal
0215-kth-largest-element-in-an-array
0347-top-k-frequent-elements

Sorting

0056-merge-intervals
0215-kth-largest-element-in-an-array
0295-find-median-from-data-stream
0347-top-k-frequent-elements
0435-non-overlapping-intervals
0455-assign-cookies
0621-task-scheduler
0876-hand-of-straights
1029-vertical-order-traversal-of-a-binary-tree

Quickselect

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

Merge Sort

0023-merge-k-sorted-lists

Tree

0094-binary-tree-inorder-traversal
0098-validate-binary-search-tree
0099-recover-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
0114-flatten-binary-tree-to-linked-list
0124-binary-tree-maximum-path-sum
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0173-binary-search-tree-iterator
0199-binary-tree-right-side-view
0222-count-complete-tree-nodes
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
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
0783-search-in-a-binary-search-tree
0784-insert-into-a-binary-search-tree
0789-kth-largest-element-in-a-stream
0893-all-nodes-distance-k-in-binary-tree
1029-vertical-order-traversal-of-a-binary-tree
1050-construct-binary-search-tree-from-preorder-traversal
2461-amount-of-time-for-binary-tree-to-be-infected

Binary Search Tree

0098-validate-binary-search-tree
0099-recover-binary-search-tree
0173-binary-search-tree-iterator
0230-kth-smallest-element-in-a-bst
0235-lowest-common-ancestor-of-a-binary-search-tree
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
0789-kth-largest-element-in-a-stream
1050-construct-binary-search-tree-from-preorder-traversal

Binary Tree

0094-binary-tree-inorder-traversal
0098-validate-binary-search-tree
0099-recover-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
0114-flatten-binary-tree-to-linked-list
0124-binary-tree-maximum-path-sum
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0173-binary-search-tree-iterator
0199-binary-tree-right-side-view
0222-count-complete-tree-nodes
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
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
0783-search-in-a-binary-search-tree
0784-insert-into-a-binary-search-tree
0789-kth-largest-element-in-a-stream
0893-all-nodes-distance-k-in-binary-tree
1029-vertical-order-traversal-of-a-binary-tree
1050-construct-binary-search-tree-from-preorder-traversal
2461-amount-of-time-for-binary-tree-to-be-infected

Bucket Sort

0347-top-k-frequent-elements

Depth-First Search

0094-binary-tree-inorder-traversal
0098-validate-binary-search-tree
0099-recover-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
0124-binary-tree-maximum-path-sum
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0199-binary-tree-right-side-view
0200-number-of-islands
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
0547-number-of-provinces
0653-two-sum-iv-input-is-a-bst
0662-maximum-width-of-binary-tree
0733-flood-fill
0893-all-nodes-distance-k-in-binary-tree
1029-vertical-order-traversal-of-a-binary-tree
2461-amount-of-time-for-binary-tree-to-be-infected

Iterator

0173-binary-search-tree-iterator

Union Find

0200-number-of-islands
0547-number-of-provinces

Graph

0547-number-of-provinces

About

Welcome to my Data Structures and Algorithms (DSA) repository! This repository is dedicated to my journey of mastering data structures and algorithms. Here, you'll find solutions to various problems I've tackled as part of my learning process.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published