This repository contains my solutions to various Data Structures and Algorithms problems in C++, largely sourced from LeetCode. The problems are categorized by topic to facilitate structured learning.
CPP-DSA/
├── Arrays/
│ ├── two_sum.cpp
│ ├── max_subarray.cpp
│ ├── move_zeroes.cpp
│ ├── merge_sorted_array.cpp
│ ├── best_time_stock.cpp
│ └── contains_duplicate.cpp
├── Strings/
│ ├── longest_substring.cpp
│ ├── valid_anagram.cpp
│ └── reverse_string.cpp
├── Hashing/
│ ├── subarray_sum_k.cpp
│ └── longest_consecutive.cpp
├── Stack/
│ └── valid_parentheses.cpp
├── BinarySearch/
│ ├── binary_search.cpp
│ └── search_rotated_array.cpp
├── Heap/
│ ├── kth_largest.cpp
│ └── top_k_frequent.cpp
├── DP/
│ └── climbing_stairs.cpp
├── BitManipulation/
│ ├── single_number.cpp
│ ├── power_of_two.cpp
│ ├── missing_number.cpp
│ └── count_bits.cpp
├── LinkedList/
│ ├── reverse_linked_list.cpp
│ ├── linked_list_cycle.cpp
│ └── merge_two_sorted_lists.cpp
├── Trees/
│ ├── invert_binary_tree.cpp
│ └── maximum_depth.cpp
└── Graphs/
└── number_of_islands.cpp
- Two Sum: Find two numbers that add up to a target sum.
- Maximum Subarray: Find the contiguous subarray with the largest sum.
- Move Zeroes: Move all 0s to the end while maintaining order.
- Merge Sorted Array: Merge two sorted arrays.
- Best Time to Buy and Sell Stock: Maximize profit from a single transaction.
- Contains Duplicate: Check if an array contains duplicate elements.
- Longest Substring Without Repeating Characters: Find the longest unique substring.
- Valid Anagram: Check if two strings are anagrams.
- Reverse String: Reverse an array of characters in-place.
- Reverse Linked List: The most famous pointer manipulation interview question.
- Linked List Cycle: Use Tortoise and Hare pointers to find loops.
- Merge Two Sorted Lists: Combine two sequentially ordered lists together.
- Invert Binary Tree: The classic recursive tree traversal problem.
- Maximum Depth of Binary Tree: Learn the base case down to leaf nodes.
- Number of Islands: Master Depth First Search (DFS) on 2D grids.
- Subarray Sum Equals K: Count subarrays that sum to K.
- Longest Consecutive Sequence: Find the length of the longest consecutive sequence.
- Valid Parentheses: Determine if a string of brackets is validly matched.
- Binary Search: Classic binary search on a sorted array.
- Search in Rotated Sorted Array: Find element index in a rotated array in O(log N).
- Kth Largest Element in an Array: Find the Kth largest element.
- Top K Frequent Elements: Return the K most frequent elements.
- Climbing Stairs: Find ways to climb a staircase (Fibonacci sequence).
- Single Number: Find the number that does not appear twice.
- Power of Two: Check if an integer is a power of two.
- Missing Number: Find the single missing number in a range.
- Counting Bits: Count number of 1s in binary representations up to N.