This repository contains solutions to common Array problems in Data Structures & Algorithms (DSA).
Each problem is implemented in C++ with multiple approaches — from Brute Force to Optimal — along with time and space complexity analysis.
- Multiple approaches (Brute Force, Better, Optimal).
- Well-commented C++ solutions.
- Time and Space Complexity mentioned for each solution.
- Covers common array problem patterns:
- Searching & Sorting
- Prefix/Suffix techniques
- Two pointers
- Hashing & Frequency maps
- Sliding Window
- Mathematical tricks
Here are some of the problems solved in this repo:
-
Product of Array Except Self
- Brute Force, Division Method, Prefix & Suffix (Optimal).
-
Count Pairs with Sum Equal to K
- Brute Force, Sorting + Two Pointers, Hash Map (Optimal).
-
Search in Rotated Sorted Array
- Linear Search, Binary Search (Optimal).
-
Remove Duplicates from Sorted Array
- Brute Force, Two-Pointer Technique.
…and more.
Clone the repository and compile any file using g++
:
# Clone repo
git clone https://github.com/<your-username>/DSA_array.git
# Go into repo
cd DSA_array
# Compile a file
g++ problemfile_name.cpp -o output_file
# Run the program
./output