Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
5f55f21
Create TwoSum.java
IshaAggarwalDev Feb 14, 2026
e3e2f64
Update README.md
IshaAggarwalDev Feb 14, 2026
9dc8dd0
Rename TwoSum.java to TwoSum_BruteForce.java
IshaAggarwalDev Feb 14, 2026
79c683f
Create TwoSum_HashMap.java
IshaAggarwalDev Feb 14, 2026
e9b65e8
Update TwoSum_BruteForce.java
IshaAggarwalDev Feb 14, 2026
4e91c9f
Update README.md
IshaAggarwalDev Feb 14, 2026
87ce222
Rename TwoSum_BruteForce.java to 1_TwoSum_BruteForce.java
IshaAggarwalDev Feb 17, 2026
20b202b
Rename TwoSum_HashMap.java to 1_TwoSum_HashMap.java
IshaAggarwalDev Feb 17, 2026
df3a4bd
Create 560_Subarray_Sum_Equals_K.java
IshaAggarwalDev Feb 17, 2026
0e187af
Rename Subarray_Sum_Equals_K.java to 560_Subarray_Sum_Equals_K.java
IshaAggarwalDev Feb 17, 2026
fe2758b
Update README.md
IshaAggarwalDev Feb 17, 2026
db738bb
Create 128_Longest_Consecutive_Sequence.java
IshaAggarwalDev Feb 17, 2026
6a3efae
Create 523_ Continuous_Subarray_Sum.java
IshaAggarwalDev Feb 17, 2026
4c8fd0c
Update README.md
IshaAggarwalDev Feb 17, 2026
e378679
Create 49_Group_Anagrams.java
IshaAggarwalDev Feb 17, 2026
9aaeb03
Rename 1_TwoSum_BruteForce.java to 001_TwoSum_BruteForce.java
IshaAggarwalDev Feb 17, 2026
c6fabc6
Rename 1_TwoSum_HashMap.java to 001_TwoSum_HashMap.java
IshaAggarwalDev Feb 17, 2026
39ecf19
Rename 49_Group_Anagrams.java to 049_Group_Anagrams.java
IshaAggarwalDev Feb 17, 2026
a534d9f
Update README.md
IshaAggarwalDev Feb 17, 2026
40d3a6e
Update README.md
IshaAggarwalDev Feb 17, 2026
3fcbd1e
Create 121_Best_Time_to_Buy_and_Sell_Stock.java
IshaAggarwalDev Feb 17, 2026
d3776da
Update README.md
IshaAggarwalDev Feb 17, 2026
598d9ea
Create 268_Missing_Number.java
IshaAggarwalDev Feb 17, 2026
1f27b74
Update README.md
IshaAggarwalDev Feb 17, 2026
65732fb
Create 704_Binary_Search.java
IshaAggarwalDev Feb 17, 2026
c4d6bcd
Update 704_Binary_Search.java
IshaAggarwalDev Feb 17, 2026
78aeca1
Update README.md
IshaAggarwalDev Feb 17, 2026
d8c3430
Create 26Remove_Duplicates_from_Sorted_Array.java
IshaAggarwalDev Feb 17, 2026
45fd68c
Update README.md
IshaAggarwalDev Feb 17, 2026
785ae60
Rename 26Remove_Duplicates_from_Sorted_Array.java to 026_Remove_Dupli…
IshaAggarwalDev Feb 17, 2026
6b5fc60
Create 283_Move_Zeroes.java
IshaAggarwalDev Feb 17, 2026
1e7f5f8
Update README.md
IshaAggarwalDev Feb 17, 2026
ea0cc92
Create 2396_Strictly_Palindromic_Number.java
IshaAggarwalDev Feb 17, 2026
45c6f5c
Rename 001_TwoSum_BruteForce.java to 0001_TwoSum_BruteForce.java
IshaAggarwalDev Feb 17, 2026
f801a82
Rename 001_TwoSum_HashMap.java to 0001_TwoSum_HashMap.java
IshaAggarwalDev Feb 17, 2026
fbcb654
Rename 026_Remove_Duplicates_from_Sorted_Array.java to 00026_Remove_D…
IshaAggarwalDev Feb 17, 2026
edaf20e
Rename 00026_Remove_Duplicates_from_Sorted_Array.java to 0026_Remove_…
IshaAggarwalDev Feb 17, 2026
547c5be
Rename 049_Group_Anagrams.java to 0049_Group_Anagrams.java
IshaAggarwalDev Feb 17, 2026
7e2f302
Rename 121_Best_Time_to_Buy_and_Sell_Stock.java to 0121_Best_Time_to_…
IshaAggarwalDev Feb 17, 2026
faf7d34
Update and rename 128_Longest_Consecutive_Sequence.java to 0128_Longe…
IshaAggarwalDev Feb 17, 2026
94ff8fe
Rename 268_Missing_Number.java to 0268_Missing_Number.java
IshaAggarwalDev Feb 17, 2026
e9bd8ac
Rename 283_Move_Zeroes.java to 0283_Move_Zeroes.java
IshaAggarwalDev Feb 17, 2026
96fbb42
Rename 523_ Continuous_Subarray_Sum.java to 0523_ Continuous_Subarray…
IshaAggarwalDev Feb 17, 2026
fb20593
Rename 560_Subarray_Sum_Equals_K.java to 0560_Subarray_Sum_Equals_K.java
IshaAggarwalDev Feb 17, 2026
712c20d
Rename 704_Binary_Search.java to 0704_Binary_Search.java
IshaAggarwalDev Feb 17, 2026
21c7753
Create 0088_Merge_Sorted_Array.java
IshaAggarwalDev Feb 17, 2026
b102bce
Update README.md
IshaAggarwalDev Feb 17, 2026
ff4e7df
Create 0053_Maximum_Subarray.java
IshaAggarwalDev Feb 17, 2026
054783c
Create 75_Sort_Colors.java
IshaAggarwalDev Feb 17, 2026
f0277fa
Rename 75_Sort_Colors.java to 0075_Sort_Colors.java
IshaAggarwalDev Feb 17, 2026
2a2f738
Create 11_Container_With_Most_Water.java
IshaAggarwalDev Feb 17, 2026
e42f9b9
Update README.md
IshaAggarwalDev Feb 17, 2026
2cf8406
Rename 11_Container_With_Most_Water.java to 0011_Container_With_Most_…
IshaAggarwalDev Feb 17, 2026
6ef4d41
Update README.md
IshaAggarwalDev Feb 17, 2026
523c12a
Update README.md
IshaAggarwalDev Feb 22, 2026
c056609
Update README.md
IshaAggarwalDev Feb 22, 2026
480035a
Update README.md
IshaAggarwalDev Feb 22, 2026
c672d83
Delete 0049_Group_Anagrams.java
IshaAggarwalDev Feb 22, 2026
5399b6e
Delete 2396_Strictly_Palindromic_Number.java
IshaAggarwalDev Feb 22, 2026
2352170
Delete 0001_TwoSum_HashMap.java
IshaAggarwalDev Feb 22, 2026
3e30db3
Delete 0128_Longest_Consecutive_Sequence.java
IshaAggarwalDev Feb 22, 2026
8c413ae
Delete 0523_ Continuous_Subarray_Sum.java
IshaAggarwalDev Feb 22, 2026
7807f09
Delete 0560_Subarray_Sum_Equals_K.java
IshaAggarwalDev Feb 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions 0001_TwoSum_BruteForce.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution {
public int[] twoSum(int[] nums, int target) {
int n = nums.length;

for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (nums[i] + nums[j] == target) {
return new int[] {i, j};
}
}
}
return new int[] {};
}
}
24 changes: 24 additions & 0 deletions 0011_Container_With_Most_Water.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class Solution {
public int maxArea(int[] height) {
int left = 0;
int right = height.length - 1;
int maxArea = 0;

while (left < right) {
int width = right - left;
int minHeight = Math.min(height[left], height[right]);
int area = width * minHeight;

maxArea = Math.max(maxArea, area);

// Move the pointer with smaller height
if (height[left] < height[right]) {
left++;
} else {
right--;
}
}

return maxArea;
}
}
16 changes: 16 additions & 0 deletions 0026_Remove_Duplicates_from_Sorted_Array.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution {
public int removeDuplicates(int[] nums) {
if (nums.length == 0) return 0;

int i = 0; // slow pointer

for (int j = 1; j < nums.length; j++) {
if (nums[j] != nums[i]) {
i++;
nums[i] = nums[j];
}
}

return i + 1; // number of unique elements
}
}
13 changes: 13 additions & 0 deletions 0053_Maximum_Subarray.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public int maxSubArray(int[] nums) {
int max_sum = nums[0];
int current_sum = nums[0];

for (int i = 1; i < nums.length; i++) {
current_sum = Math.max(nums[i], current_sum + nums[i]);
max_sum = Math.max(max_sum, current_sum);
}

return max_sum;
}
}
26 changes: 26 additions & 0 deletions 0075_Sort_Colors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Solution {
public void sortColors(int[] nums) {
int low = 0;
int mid = 0;
int high = nums.length - 1;

while (mid <= high) {
if (nums[mid] == 0) {
int temp = nums[low];
nums[low] = nums[mid];
nums[mid] = temp;
low++;
mid++;
}
else if (nums[mid] == 1) {
mid++;
}
else { // nums[mid] == 2
int temp = nums[high];
nums[high] = nums[mid];
nums[mid] = temp;
high--;
}
}
}
}
27 changes: 27 additions & 0 deletions 0088_Merge_Sorted_Array.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class Solution {
public void merge(int[] nums1, int m, int[] nums2, int n) {

int i = m - 1; // Pointer for nums1
int j = n - 1; // Pointer for nums2
int k = m + n - 1; // Pointer for final position

// Merge from the back
while (i >= 0 && j >= 0) {
if (nums1[i] > nums2[j]) {
nums1[k] = nums1[i];
i--;
} else {
nums1[k] = nums2[j];
j--;
}
k--;
}

// If nums2 still has elements left
while (j >= 0) {
nums1[k] = nums2[j];
j--;
k--;
}
}
}
15 changes: 15 additions & 0 deletions 0121_Best_Time_to_Buy_and_Sell_Stock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution {
public int maxProfit(int[] prices) {

int profit = 0 ;
int n = prices.length;
int min_price = prices[0];
for(int i = 0; i<n ; i++)
{
min_price = Math.min(min_price,prices[i]);
profit = Math.max(profit,prices[i]-min_price);
}
return profit ;

}
}
14 changes: 14 additions & 0 deletions 0268_Missing_Number.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution {
public int missingNumber(int[] nums) {
int n = nums.length;

int expectedSum = n * (n + 1) / 2;
int actualSum = 0;

for (int num : nums) {
actualSum += num;
}

return expectedSum - actualSum;
}
}
19 changes: 19 additions & 0 deletions 0283_Move_Zeroes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution {
public void moveZeroes(int[] nums) {
int insertPos = 0; // position to place next non-zero

// Move all non-zero elements to the front
for (int i = 0; i < nums.length; i++) {
if (nums[i] != 0) {
nums[insertPos] = nums[i];
insertPos++;
}
}

// Fill the remaining positions with zeros
while (insertPos < nums.length) {
nums[insertPos] = 0;
insertPos++;
}
}
}
26 changes: 26 additions & 0 deletions 0704_Binary_Search.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Solution {
public int search(int[] nums, int target) {

int low = 0;
int high = nums.length - 1;

while (low <= high) {

int mid = low + (high - low) / 2;

if (nums[mid] == target) {
return mid;
}
else if (nums[mid] < target) {
low = mid + 1;
}
else {
high = mid - 1;
}
}

return -1;
}
}


108 changes: 106 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,106 @@
# LeetCode-DSA-Practice
A collection of my LeetCode problem solutions written in Java. This repository documents my journey of practicing Data Structures and Algorithms for coding interviews and competitive programming. Each solution focuses on optimized time and space complexity.
# Arrays

## 1. Two Sum
Problem Link: https://leetcode.com/problems/two-sum/
Difficulty: Easy
### Approach : Brute Force
Time Complexity: O(n²)
Space Complexity: O(1)
### Concepts Used:
Array Traversal,Nested Loops,Pair Checking

### Approach 2: HashMap (Optimized)
Time Complexity: O(n)
Space Complexity: O(n)
### Concepts Used:
Array Traversal,HashMap,Complement Technique,Single Pass Algorithm,Key-Value Mapping

## 11. Container With Most Water
Problem Link: https://leetcode.com/problems/container-with-most-water/
Difficulty: Medium
### Approach: Two Pointers (Greedy Optimization)
Time Complexity: O(n)
Space Complexity: O(1)
### Concepts Used:
Two Pointers, Greedy Strategy, Area Calculation, Width–Height Optimization, Pointer Movement Logic

## 26. Remove Duplicates from Sorted Array
Problem Link: https://leetcode.com/problems/remove-duplicates-from-sorted-array/
Difficulty: Easy
### Approach: Two Pointer Technique (Optimized)
Time Complexity: O(n)
Space Complexity: O(1)
### Concepts Used:
Two Pointer Technique, In-Place Modification, Sorted Array Property, Single Pass Algorithm

## 53. Maximum Subarray
Problem Link: https://leetcode.com/problems/maximum-subarray/
Difficulty: Medium
### Approach: Kadane’s Algorithm (Dynamic Programming / Greedy)
Time Complexity: O(n)
Space Complexity: O(1)
### Concepts Used:
Kadane’s Algorithm, Dynamic Programming, Greedy Strategy, Running Sum, Maximum Tracking

## 75. Sort Colors
Problem Link: https://leetcode.com/problems/sort-colors/
Difficulty: Medium
### Approach: Dutch National Flag Algorithm (Three Pointers)
Time Complexity: O(n)
Space Complexity: O(1)
### Concepts Used:
Three Pointers, Two Pointer Technique, In-Place Sorting, Partitioning Logic, Dutch National Flag Algorithm

## 88. Merge Sorted Array
Problem Link: https://leetcode.com/problems/merge-sorted-array/
Difficulty: Easy
### Approach: Two Pointers (Backward Merge)
Time Complexity: O(m + n)
Space Complexity: O(1)
### Concepts Used:
Two Pointers, Array Traversal, In-Place Algorithm, Backward Iteration, Merging Technique

## 121. Best Time to Buy and Sell Stock
Problem Link: https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
Difficulty: Easy
### Approach: Greedy (One Pass Optimization)
Time Complexity: O(n)
Space Complexity: O(1)
### Concepts Used:
Array Traversal,Greedy Strategy,Minimum Tracking,Profit Maximization,Single Pass Algorithm

## 128. Longest Consecutive Sequence
Problem Link: https://leetcode.com/problems/longest-consecutive-sequence/
Difficulty: Medium
### Approach: HashSet (Optimized)
Time Complexity: O(n)
Space Complexity: O(n)
### Concepts Used:
HashSet, Sequence Pattern, Array Traversal

## 268. Missing Number
Problem Link: https://leetcode.com/problems/missing-number/
Difficulty: Easy
### Approach: Mathematical Formula (Sum Formula)
Time Complexity: O(n)
Space Complexity: O(1)
### Concepts Used:
Mathematical Formula, Arithmetic Series, Array Traversal, Summation Technique

## 283. Move Zeroes
Problem Link: https://leetcode.com/problems/move-zeroes/
Difficulty: Easy
### Approach: Two Pointers (In-Place Modification)
Time Complexity: O(n)
Space Complexity: O(1)
### Concepts Used:
Two Pointers, Array Traversal, In-Place Algorithm, Element Shifting, Stable Partitioning

## 704. Binary Search
Problem Link: https://leetcode.com/problems/binary-search/
Difficulty: Easy
### Approach: Binary Search (Optimized)
Time Complexity: O(log n)
Space Complexity: O(1)
### Concepts Used:
Divide and Conquer,Sorted Array Requirement,Two Pointers (Low & High),Mid Calculation,Half Search Space Reduction