This repository contains my solutions to LeetCode problems, organized by difficulty and language. Each solution includes the problem description, approach, and performance details.
- Language: C++
- File: Easy/removeDuplicates.cpp
- Problem: LeetCode #26
- Description: Given a sorted array, remove duplicates in-place and return the length of the new array.
- Approach: Used two pointers (
i
for the last unique element,j
to scan). Ifnums[i] != nums[j]
, placenums[j]
atnums[i+1]
and incrementi
. - Performance: 100% beats (faster than 100% of C++ submissions), O(n) time, O(1) space.
- Solutions are added daily.
- Each solution is optimized for runtime and space complexity.
- Feedback welcome! Connect with me on X.