Skip to content

DSA_Leet_Questions: A hands-on repository of Data Structures and Algorithms (DSA) problems from LeetCode, organized by topic and difficulty, perfect for practice and interview preparation for both beginners programmers.

Notifications You must be signed in to change notification settings

Aniketgudgal/DSA_Leet_Questions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solutions

This repository collects my LeetCode solutions. Each problem is solved with clarity and efficiency in mind, and the repo is organized so you can browse solutions by problem number. The list below contains problems I have solved and uploaded here.

Problem List

  1. Two Sum
  2. Add Two Numbers
  3. Reverse Integer
  4. Palindrome Number
  5. Container With Most Water
  6. Longest Common Prefix
  7. Valid Parentheses
  8. Merge k Sorted Lists
  9. Remove Duplicates from Sorted Array
  10. Remove Element
  11. Search in Rotated Sorted Array
  12. Find First and Last Position of Element in Sorted Array
  13. Search Insert Position
  14. Rotate Image
  15. Pow(x, n)
  16. Maximum Subarray
  17. Spiral Matrix
  18. Plus One
  19. Add Binary
  20. Sqrt(x)
  21. Sort Colors
  22. Subsets
  23. Remove Duplicates from Sorted Array II
  24. Remove Duplicates from Sorted List
  25. Merge Sorted Array
  26. Best Time to Buy and Sell Stock
  27. Linked List Cycle
  28. Linked List Cycle II
  29. Reorder List
  30. Binary Tree Preorder Traversal
  31. Binary Tree Postorder Traversal
  32. Maximum Product Subarray
  33. Find Minimum in Rotated Sorted Array
  34. Find Peak Element
  35. Two Sum II - Input Array Is Sorted
  36. Majority Element
  37. Rotate Array
  38. Reverse Bits
  39. Number of 1 Bits
  40. Count Primes
  41. Minimum Size Subarray Sum
  42. Contains Duplicate
  43. Power of Two
  44. Palindrome Linked List
  45. Delete Node in a Linked List
  46. Product of Array Except Self
  47. Valid Anagram
  48. Add Digits
  49. Missing Number
  50. Move Zeroes
  51. Find the Duplicate Number
  52. Longest Increasing Subsequence
  53. Power of Three
  54. Reverse String
  55. Intersection of Two Arrays
  56. Valid Perfect Square
  57. Guess Number Higher or Lower
  58. First Unique Character in a String
  59. Fizz Buzz
  60. Third Maximum Number
  61. Find All Duplicates in an Array
  62. Perfect Number
  63. Fibonacci Number
  64. Subarray Sum Equals K
  65. Maximum Product of Three Numbers
  66. Maximum Average Subarray I
  67. Binary Search
  68. Subarray Product Less Than K
  69. Peak Index in a Mountain Array
  70. Transpose Matrix
  71. Minimum Absolute Difference
  72. Count Negative Numbers in a Sorted Matrix
  73. Maximum Points You Can Obtain from Cards
  74. Number of Smooth Descent Periods of a Stock
  75. Maximum Count of Positive Integer and Negative Integer
  76. Minimum Operations to Exceed Threshold Value I
  77. Delete Nodes From Linked List Present in Array
  78. Minimum Operations to Make Array Sum Divisible by K
  79. GCD of Odd and Even Sums
  80. Running Sum of 1d Array

Repository Documentation

Overview

This repo is a personal collection of problem solutions from LeetCode. Problems are individually implemented and aim to illustrate clear approaches, typical patterns, and optimized implementations where appropriate. Use the problem list above to find a specific problem and open its corresponding file to inspect the solution.

Topics & Techniques Covered (detailed)

Below are the major algorithmic topics and key points covered across the problems in this repository. For each topic, I include concise explanations and representative problems from this repo.

  • Arrays & Hashing:

    • Key ideas: indexing, in-place updates, frequency maps, element-to-index mappings.
    • Use cases: counting, deduplication, lookup in O(1).
    • Representative problems: Two Sum (1), Contains Duplicate (217), Intersection of Two Arrays (349), Move Zeroes (283), Missing Number (268), Find All Duplicates in an Array (442).
  • Two Pointers:

    • Key ideas: left/right pointers, in-place swaps, shrinking/expanding windows for sorted arrays or paired operations.
    • Representative problems: Container With Most Water (11), Two Sum II (167), Remove Duplicates from Sorted Array (26), Remove Element (27), Sort Colors (75).
  • Sliding Window:

    • Key ideas: variable-size window, maintain running aggregates, optimize subarray problems to O(n).
    • Representative problems: Minimum Size Subarray Sum (209), Subarray Product Less Than K (713), Maximum Average Subarray I (643).
  • Prefix Sum & Hashing:

    • Key ideas: prefix sums to transform range-sum queries into constant-time checks; use hashmaps to store seen sums/indices.
    • Representative problems: Subarray Sum Equals K (560), Product of Array Except Self (238) (prefix-like transforms), Missing Number (268).
  • Sorting & Partitioning:

    • Key ideas: sort + two-pointer, partition (Dutch National Flag), selection for k-th largest, use sorting to simplify logic.
    • Representative problems: Sort Colors (75), Maximum Product of Three Numbers (628), Merge Sorted Array (88).
  • Binary Search & Variants:

    • Key ideas: search on index/answer, handle edge cases (duplicates, rotated arrays), use while-loops with mid computation.
    • Representative problems: Sqrt(x) (69), Find Minimum in Rotated Sorted Array (153), Search in Rotated Sorted Array (33), Binary Search (704).
  • Dynamic Programming (DP):

    • Key ideas: define state, recurrence, optimize space when possible, handle base cases.
    • Representative problems: Maximum Subarray (53) (Kadane — 1D DP), Maximum Product Subarray (152), Longest Increasing Subsequence (300), Fibonacci Number (509).
  • Greedy:

    • Key ideas: local optimal choices lead to global optimum, sorting + greedy selection.
    • Representative problems: Best Time to Buy and Sell Stock (121) (single pass greedy), Maximum Product of Three Numbers (628).
  • Bit Manipulation & Math:

    • Key ideas: bit ops for flags/counting bits, arithmetic tricks, modular considerations.
    • Representative problems: Reverse Bits (190), Number of 1 Bits (191), Power of Two (231), Add Digits (258), Pow(x, n) (50).
  • Linked List Techniques:

    • Key ideas: slow/fast pointers, cycle detection, two-pointer removal, list merging.
    • Representative problems: Linked List Cycle (141), Linked List Cycle II (142), Palindrome Linked List (234), Merge k Sorted Lists (23).
  • Recursion, Tree Traversal & DFS:

    • Key ideas: recursion for traversal, stack-based iterative alternatives, preorder/inorder/postorder patterns.
    • Representative problems: Binary Tree Preorder Traversal (144).
  • Number Theory & Primes:

    • Key ideas: sieve, primality checks, factorization where relevant.
    • Representative problems: Count Primes (204), Perfect Number (507), Valid Perfect Square (367).
  • Windowed and Monotonic Methods:

    • Key ideas: monotonic queues/stacks for range maxima/minima and optimized sliding-window variants.
    • Representative problems: Peak Index in a Mountain Array (852), Number of Smooth Descent Periods of a Stock (2110) (pattern counting).

Each solution typically includes a short explanation in the file header and attempts to show the pattern used so the approach is reusable across similar problems.

File structure

  • Root: problem files (named by problem or number). See the problem list above.
  • README.md: this documentation.

How to run / Inspect solutions

  • Clone the repo:
git clone https://github.com/Aniketgudgal/DSA_Leet_Questions.git
cd DSA_Leet_Questions
  • Open the solution file for a problem (files are organized per problem). Each file contains a solution and usually a small test or example usage in comments.
  • Run the file using the language runtime your solution is implemented in (Python, Java, C++, etc.). Example for Python:
python path/to/problem_solution.py

If you want, I can standardize runners or add a small test harness — tell me which language you'd like prioritized.

Contribution Guidelines

  • Add solutions in a clear file-naming format (e.g., 001_two_sum.py or 1_two_sum.cpp).
  • Include a brief explanation at the top of each solution file describing the approach and complexity.
  • Add tests or example usage for your solution where possible.

Contact

For questions or suggestions, contact: [email protected]


Thank you for exploring these solutions — keep practicing and refining patterns!

About

DSA_Leet_Questions: A hands-on repository of Data Structures and Algorithms (DSA) problems from LeetCode, organized by topic and difficulty, perfect for practice and interview preparation for both beginners programmers.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages