DAY 1 – 16.06.
2025
1. Given max+1 length of the array. FInd the duplicates in the array.
[Link]
[Link]
import [Link].*;
public class Main
{
public static void main(String[] args) {
int[] arr={3,1,3,4,2};
//Method 1: Sorting and comparing adjacent elements
[Link](arr);
for(int i=0;i<[Link]-1;i++){
if(arr[i]==arr[i+1]){
[Link](arr[i]);
break;
}
}
//Method 2 : Using HashMap
int[] brr={3,6,2,1,5,2};
HashMap<Integer,Integer> map=new HashMap<>();
for(int i=0;i<[Link];i++){
if([Link](brr[i])){
[Link](brr[i]);
break;
}else{
[Link](brr[i],[Link](brr[i],0)+1);
}
}
//Method 3 : Hashing the same Array
int[] crr={1,3,4,2,2};
for(int i=0;i<[Link];i++){
int val=[Link](crr[i]);
if(crr[val]<0){
[Link](val);
break;
}else{
crr[val]=-crr[val];
}
}
}
}
2. Next Permutation
[Link]
Point 1 : We have to first find the drop point and find rightmost index
Point 2: We have to swap that index with just greater value from last
import [Link].*;
public class Main
{
static void swap(int[] arr, int s,int e){
int t=arr[s];
arr[s]=arr[e];
arr[e]=t;
}
static void reverse(int[] arr,int s, int e){
swap(arr,s++,e--);
}
public static void main(String[] args) {
int[] arr={1, 2, 3, 5, 4};
int pivot=-1;
int n=[Link];
int i=n-2;
while(i>=0 && arr[i]>=arr[i+1]){
i--;
}
pivot=i;
if(pivot==-1){
reverse(arr,0,n-1);
}
int j=n-1;
while(j>=pivot){
if(arr[j]>pivot){
swap(arr,j,pivot);
break;
}
j--;
}
reverse(arr,n-1,pivot+1);
for(int k=0;k<n;k++){
[Link](arr[k]+" ");
}
}
}
3. Max Chunks to make sorted
[Link]
class Solution {
public int maxChunksToSorted(int[] arr) {
int n=[Link];
int chunks=0,max=0;
for(int i=0;i<n;i++){
max=[Link](arr[i],max);
if(max==i){
chunks++;
}
}
return chunks;
}
}
4. Majority Element 1
[Link]
5. Sum of Arrays
import [Link].*;
public class Main
{
public static void main(String[] args) {
int[] arr={2,3,1};
int[] brr={9,9};
int size=([Link]>[Link]) ? [Link] : [Link];
int i=[Link]-1;
int j=[Link]-1;
int k=size-1;
int[] res=new int[size];
int carry=0;
while(k>=0){
int sum=carry;
if(i>=0){
sum+=arr[i];
}
if(j>=0){
sum+=brr[j];
}
int rem=sum%10;
res[k]=rem;
carry=sum/10;
i--;
j--;
k--;
}
if(carry!=0){
[Link](carry);
}
for(int h=0;h<size;h++){
[Link](res[h]);
}
}
}
6. Longest Substring Without Repeating Characters
[Link]
7. Boats to Save People
[Link]
8. 2 Sum - Pair Sum Closest to Target
[Link]
DAY 2 – 18.06.2025
1. Two Sum
[Link]
2. 3Sum
[Link]
3. Two Sum II – Input Array is Sorted
[Link]
4. Container with most water
[Link]
5. Maximum average Subarray Sum I
[Link]
6. First negative in every window of size k –gfg
[Link]
45/1
7. Count Occurrences of Anagrams-gfg
[Link]
8. Max Sum Subarray of size k - gfg
[Link]
DAY 3 – 19.06.2025
1. Longest Substring Without Repeating Characters
[Link]
2. Minimum Size Subarray Sum
[Link]
3. Fruit Into Basket
[Link]
4. Maximize Number of 1's -gfg
[Link]
5. Longest Repeating Character Replacement
[Link]
6. Matrix Boundary Traversal
[Link]
7. Diagonal Traverse
[Link]
8. Rotate Image
[Link]
9. Set Matrix Zeroes
[Link]
10.Number of Laser Beams in Bank
[Link]
11.Brick Wall
[Link]
12.Lucky Number in a Matrix
[Link]
13.Spiral Matrix
[Link]
Day 4 -20.06.2025
1. Palindrome Linked List:
[Link]
2. Reverse Linked List: [ Fold the linked list ]
[Link]
3. Reorder List:
[Link]
4. Intersection of LinkedList:
[Link]
5. LinkedList cycle:
[Link]
5. Unfold a folded LinkedList:
[Link]
6. Remove the Nth Node at the End of list
[Link]
8. Swapping Nodes in a Linked List
[Link]
9. Add Two Numbers
[Link]
10. Add Two Numbers II
[Link]
11. Delete the Middle Node of a Linked List
[Link]
12. Middle of the Linked List
[Link]
13. Remove Linked List Elements
[Link]
14. Odd Even Linked List
[Link]
15. Reverse Nodes in k-group
[Link]
16. Longest Common Subsequence
[Link]
Day 5 – 21.06.2025
1. Next Greater Element gfg
[Link]
2. Next Greater Element
[Link]
3. Stock Span gfg
[Link]
4. Histogram Max Rectangular Area gfg and leetcode
[Link]
15620/1
[Link]
5. Asteroid Collision:
[Link]
6. Evaluate Reverse Polish Notation
[Link]
7. Min Stack
[Link]
8. Valid Parentheses
[Link]
9. Remove Outermost Parenthesis
[Link]
10.Implement Stack using Queues:
[Link]
11.Trapping Rain Water
12.Remove All Adjacent Duplicates In String
[Link]
Day 6– 22.06.2025
1. Binary Tree Preorder Traversal
[Link]
2. Binary Tree Postorder Traversal
[Link]
3. Binary Tree Inorder Traversal
[Link]
4. Binary Level Order Traversal
[Link]
5. Average of Levels in binary tree
[Link]
6. Maximum LevelSum of a binary Tree
[Link]
7. Maximum width of Binary Tree (Leetcode & gfg)
[Link]
[Link]
Solution:
[Link]
8. All Nodes Distance K in Binary Tree
[Link]
[Link]
Day 7 - 23.06.2025
1. Burning Tree gfg
[Link]
2. Amount of time for Binary Tree to be infected
[Link]
Day 8 - 24.06.2025
1. Path Sum
[Link]
2. Path Sum II
[Link]
3. LCA of a binary Tree
[Link]
4. Path Sum III
5. Subarray Sum equals K
6. Left View
7. Right View
8. Top View
9. Bottom View
10.Vertical View
11.Boundary Traversal
12.Binary Tree Cameras - incomplete
13.Max Sum Path - incomplete
DAY 9 - 25.06.2024
1. Permutations:
[Link]
2. Permutation II:
[Link]
3. Combination I:
[Link]
4. Combination II:
[Link]
5. Combinations
[Link]
6. Combination III:
[Link]
7. Unique Path I:
[Link]
8. Unique Path II:
[Link]
9. Unique Paths III:
[Link]
10.Rate in a maze problem - I
[Link]
ython3
Day 10 - 26.06.2025
1. Rat in a maze problem -1 gfg
[Link]
2. Unique Paths III
[Link]
3. Fibonacci Number
[Link]
4. Climbing Stairs
[Link]
5. Frog Jump gfg
[Link]
6. Unique Paths
7. House Robber I
8. House Robber II
9. Maximum Path Sum in Matrix
10. Longest Common Subsequence
11. Longest Increasing Subsequence
12. Triangle - incomplete
13. Subset Sum Problem
14..KnapSack
[Link]
Day 11 - 27.06.2025
1. Minimum Path Sum
[Link]
2. Minimum Path Triangle Sum
[Link]
[Link]
3. Minimum Falling Path Sum
[Link]
4. Minimum Falling Path Sum II
[Link]
5. Subsets
[Link]
6. Partition Equal Subset Sum
[Link]
7. Longest palindrome Sequence
[Link]
8. Longest Common substring
[Link]
9. WildCard Matching - Incomplete
[Link]
10.Edit Distance
[Link]
11.Distinct Subsequences - Incomplete
[Link]
12.Longest bionic Subsequence - Incomplete
[Link]
Day 12 - 28.06.2025
Graph
1. The matrix size is based on the number of nodes.
2. The time complexity and space complexity is O(n^2)
3. Edge finding time complexity is O(1)
4. Edge deletion time complexity is O(1)
5. DFS is applied to the graph time complexity is O(n) for each vertex/node. (To check
the neighbour) Total time Complexity is O(n^2).
Adjacency Matrix: Directed Graph
Adjacency Matrix: UnDirected Graph:
Adjacency List-Directed Graph
1. Time Complexity: O(V+E)
2. Space Complexity: O(E+V)
3. Array is not dynamic and ArrayList is dynamic so we use ArrayList to change the size
immediately.
4. Edge finding time complexity = O(out degree).
5. Edge Deleting time complexity = O(out degree).
6. DFS Time Complexity - O(V+E)
Due to the edge finding and edge deleting complexity we move with matrix if it is a dense graph
and for sparse graph adjacency list.
For DFS - Adjacency list is better
Adjacency Graph - Undirected Graph
Difference between Sparse and Dense Graph:
Day 12 - 28.06.2025
1. Find if path exists in Graph:
[Link]
2. All Paths from Source to Target
[Link]
3. BFS of Graph
[Link]
4. DFS of Graph
[Link]
5. Number of provinces
[Link]
6. Count Unreachable Pairs of Nodes in an Undirected Graph
[Link]
7. Number of Islands
[Link]
8. Undirected Graph Cycle
[Link]
9. Directed Graph Cycle
[Link]
Day 13 - 29.06.2025
1. Coloring a border
[Link]
2. Shortest path in an unweighted graph
[Link]
_981297
[Link]
3. Rotten Orange - incomplete
[Link]
4. Word Ladder- incomplete
[Link]
5. Word Ladder II - incomplete
[Link]
6. 01 Matrix - incomplete
[Link]
7. Bus Routes - incomplete
[Link]
8. Swim in rising water - dijkstra - incomplete
[Link]
[Link]
Day 14 - 30.06.2025
1. Topological Sort
[Link]
2. Course Schedule
[Link]
3. Course schedule II
[Link]
4. Dijkstra Algorithm gfg
[Link]
ency-matrix/1
[Link] - solution
Day 15 - 01.07.2025
1. Network Delay Time
[Link]
2. Number of ways to Arrive at Destination
[Link]
3. Path with Minimum Effort
[Link]
4. Shortest Path in Binary Matrix
[Link]