Skip to content

vishussingh24/Data-Structures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Structures and Algorithms - LeetCode Solutions

LeetCode Language Language

This repository contains solutions to various LeetCode problems, primarily implemented in C++ with some Java solutions. The problems cover a wide range of data structures and algorithms topics, perfect for interview preparation and competitive programming practice.

📊 Statistics

  • Total Problems: 68
  • Easy: 33 problems
  • Medium: 32 problems
  • Hard: 3 problems

📚 Problem List

Easy Problems (33)

# Problem Solution Difficulty
1 Two Sum C++ Easy
20 Valid Parentheses C++ Easy
26 Remove Duplicates from Sorted Array C++ Easy
35 Search Insert Position C++ Easy
69 Sqrt(x) C++ Easy
70 Climbing Stairs Java Easy
88 Merge Sorted Array C++ Easy
118 Pascal's Triangle C++ Easy
119 Pascal's Triangle II C++ Easy
121 Best Time to Buy and Sell Stock C++ Easy
136 Single Number C++ Easy
169 Majority Element C++ Easy
231 Power of Two C++ Easy
242 Valid Anagram C++ Easy
283 Move Zeroes C++ Easy
392 Is Subsequence C++ Easy
485 Max Consecutive Ones C++ Easy
496 Next Greater Element I C++ Easy
792 Binary Search - Easy
1013 Fibonacci Number C++ Easy
1018 Largest Perimeter Triangle C++ Easy
1353 Find Resultant Array After Removing Anagrams C++ Easy
1421 Find Numbers with Even Number of Digits C++ Easy
1476 Count Negative Numbers in a Sorted Matrix C++ Easy
1642 Water Bottles C++ Easy
1769 Get Maximum in Generated Array C++ Easy
1791 Richest Customer Wealth C++ Easy
1878 Check if Array Is Sorted and Rotated C++ Easy
1950 Sign of the Product of an Array C++ Easy
2106 Find Greatest Common Divisor of Array C++ Easy
2132 Convert 1D Array Into 2D Array C++ Easy
4039 Compute Decimal Representation C++ Easy
4068 Sum of Elements With Frequency Divisible by K C++ Easy

Medium Problems (32)

# Problem Solution Difficulty
6 Zigzag Conversion C++ Medium
7 Reverse Integer C++ Medium
11 Container With Most Water C++ Medium
18 4Sum C++ Medium
31 Next Permutation C++ Medium
33 Search in Rotated Sorted Array C++ Medium
34 Find First and Last Position of Element in Sorted Array C++ Medium
48 Rotate Image C++ Medium
53 Maximum Subarray C++ Medium
54 Spiral Matrix C++ Medium
56 Merge Intervals C++ Medium
73 Set Matrix Zeroes C++ Medium
74 Search a 2D Matrix C++ Medium
75 Sort Colors C++ Medium
128 Longest Consecutive Sequence C++ Medium
134 Gas Station C++ Medium
152 Maximum Product Subarray C++ Medium
155 Min Stack C++ Medium
189 Rotate Array C++ Medium
229 Majority Element II C++ Medium
240 Search a 2D Matrix II C++ Medium
287 Find the Duplicate Number C++ Medium
417 Pacific Atlantic Water Flow C++ Medium
503 Next Greater Element II C++ Medium
540 Single Element in a Sorted Array C++ Medium
556 Next Greater Element III C++ Medium
948 Sort an Array C++ Medium
2271 Rearrange Array Elements by Sign C++ Medium
2324 Find Triangular Sum of an Array C++ Medium
3336 Water Bottles II C++ Medium
3383 Taking Maximum Energy From the Mystic Dungeon C++ Medium
4055 Longest Balanced Substring I C++ Medium

Hard Problems (3)

# Problem Solution Difficulty
315 Count of Smaller Numbers After Self C++ Hard
407 Trapping Rain Water II C++ Hard
493 Reverse Pairs C++ Hard

🚀 Topics Covered

  • Arrays: Two Sum, Move Zeroes, Rotate Array, Majority Element, Remove Duplicates
  • Dynamic Programming: Climbing Stairs, Fibonacci Number, Maximum Subarray, Maximum Product Subarray
  • Matrix Operations: Rotate Image, Spiral Matrix, Set Matrix Zeroes, Search 2D Matrix
  • Searching: Binary Search, Search in Rotated Sorted Array, Find First and Last Position
  • Sorting: Sort Colors, Sort an Array, Merge Intervals
  • Stack: Valid Parentheses, Min Stack, Next Greater Element I/II/III
  • String Manipulation: Zigzag Conversion, Valid Anagram, Is Subsequence
  • Math: Reverse Integer, Sqrt(x), Pascal's Triangle, Power of Two
  • Greedy: Best Time to Buy and Sell Stock, Container With Most Water, Gas Station
  • Hashing: Two Sum, Single Number, Majority Element
  • Two Pointers: Move Zeroes, Sort Colors, Merge Sorted Array
  • Divide & Conquer: Reverse Pairs, Count of Smaller Numbers After Self
  • Bit Manipulation: Single Number, Power of Two, Sign of Product
  • Graph/DFS/BFS: Pacific Atlantic Water Flow, Trapping Rain Water II

📝 Repository Structure

Each problem is organized in its own directory with the following structure:

problem-number-problem-name/
├── README.md           # Problem description from LeetCode
└── problem-name.cpp    # C++ solution

💡 How to Use This Repository

  1. Browse Problems: Navigate through the categorized problem list above
  2. Study Solutions: Each problem folder contains:
    • README.md: Original problem description from LeetCode
    • Solution file (.cpp or .java): Commented code with explanations
  3. Practice: Try solving the problems yourself before looking at the solutions
  4. Learn: Study the approaches, time/space complexity, and patterns used

🤝 Contributing

Contributions are welcome! If you'd like to add more solutions or improve existing ones:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/new-solution)
  3. Add your solution following the existing structure
  4. Commit your changes (git commit -m 'Add solution for Problem XYZ')
  5. Push to the branch (git push origin feature/new-solution)
  6. Open a Pull Request

📝 Solution Guidelines

  • Use clear and descriptive variable names
  • Add comments explaining complex logic
  • Include time and space complexity analysis where applicable
  • Follow consistent code formatting

🔗 Connect

Feel free to explore the solutions and learn from them. If you have any suggestions or improvements, contributions are welcome!

⭐ Show Your Support

If you find this repository helpful, please consider giving it a star! It helps others discover these solutions.


Note: This repository is maintained for educational purposes and interview preparation. All solutions are original implementations based on LeetCode problem descriptions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •