From d5ab1dda55fc2fadda95eec4d995c1c9d1182ce0 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 14 Apr 2025 12:03:51 +0530
Subject: [PATCH 001/115] Add maximum value of Ordered Triplets
---
 Java/.project                                 | 11 ++++++++
 ...Maximum Value of an  Ordered Triplets.java | 28 +++++++++++++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 Java/Maximum Value of an  Ordered Triplets.java
diff --git a/Java/.project b/Java/.project
index 4fdb69a93e..e4eed73892 100644
--- a/Java/.project
+++ b/Java/.project
@@ -14,4 +14,15 @@
 	
 		org.eclipse.jdt.core.javanature
 	
+	
+		
+			1744612223460
+			
+			30
+			
+				org.eclipse.core.resources.regexFilterMatcher
+				node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
+			
+		
+	
 
diff --git a/Java/Maximum Value of an  Ordered Triplets.java b/Java/Maximum Value of an  Ordered Triplets.java
new file mode 100644
index 0000000000..0d66520084
--- /dev/null
+++ b/Java/Maximum Value of an  Ordered Triplets.java	
@@ -0,0 +1,28 @@
+
+class Solution {
+    public long maximumTripletValue(int[]  nums){
+        int n = nums.length;
+        if (n < 3) return 0;
+
+        int[] leftMax = new int[n];
+        leftMax[0] = nums[0];
+        for (int i = 1; i < n; i++) {
+            leftMax[i] = Math.max(leftMax[i - 1], nums[i]);
+        }
+
+        int[] rightMax = new int[n];
+        rightMax[n - 1] = nums[n - 1];
+        for (int i = n - 2; i >= 0; i--) {
+            rightMax[i] = Math.max(rightMax[i + 1], nums[i]);
+        }
+
+        long ans = 0;  
+        for (int i = 1; i < n - 1; i++) {
+            int left = leftMax[i - 1];
+            int right = rightMax[i + 1];
+            ans = Math.max(ans, (long)(left - nums[i]) * right); 
+        }
+
+        return ans;
+    }
+}
\ No newline at end of file
From 797743ff1291441a8bd7c07c72ba619336e33b46 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 14 Apr 2025 12:08:51 +0530
Subject: [PATCH 002/115] U
---
 Java/Maximum Value of an  Ordered Triplets.java | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/Java/Maximum Value of an  Ordered Triplets.java b/Java/Maximum Value of an  Ordered Triplets.java
index 0d66520084..1453d1b089 100644
--- a/Java/Maximum Value of an  Ordered Triplets.java	
+++ b/Java/Maximum Value of an  Ordered Triplets.java	
@@ -1,3 +1,5 @@
+ //TC:O(N)
+ //SC:O(N)
 
 class Solution {
     public long maximumTripletValue(int[]  nums){
From 3cabcced8a53ab5de09d26c13d3b9f86afc26f53 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 15 Apr 2025 10:43:30 +0530
Subject: [PATCH 003/115] Change
---
 C++/Combination Sum.cpp | 49 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 C++/Combination Sum.cpp
diff --git a/C++/Combination Sum.cpp b/C++/Combination Sum.cpp
new file mode 100644
index 0000000000..6c9ffc221d
--- /dev/null
+++ b/C++/Combination Sum.cpp	
@@ -0,0 +1,49 @@
+#include
+#include
+
+class Solution {
+
+    public:
+    
+        vector> combinationSum(vector& candidates, int target) {
+    
+            vector> res;
+    
+            vector comb;
+    
+            makeCombination(candidates, target, 0, comb, 0, res);
+    
+            return res;        
+    
+        }
+    
+    private:
+    
+        void makeCombination(std::vector& candidates, int target, int idx, vector& comb, int total, vector>& res) {
+    
+            if (total == target) {
+    
+                res.push_back(comb);
+    
+                return;
+    
+            }
+    
+            if (total > target || idx >= candidates.size()) {
+    
+                return;
+    
+            }
+    
+            comb.push_back(candidates[idx]);
+    
+            makeCombination(candidates, target, idx, comb, total + candidates[idx], res);
+    
+            comb.pop_back();
+    
+            makeCombination(candidates, target, idx + 1, comb, total, res);
+    
+        }    
+    
+    };
+    
\ No newline at end of file
From 3c135ec3223ba13d545476793573536f56222e67 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 16 Apr 2025 14:49:36 +0530
Subject: [PATCH 004/115] Create Count of Good Subarrays.java
---
 Java/Count of Good Subarray.java | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Java/Count of Good Subarray.java
diff --git a/Java/Count of Good Subarray.java b/Java/Count of Good Subarray.java
new file mode 100644
index 0000000000..da19d185c5
--- /dev/null
+++ b/Java/Count of Good Subarray.java	
@@ -0,0 +1,22 @@
+public class Solution {
+
+    public long countGood(int[] nums, int k) {
+        int n = nums.length;
+        int same = 0, right = -1;
+        HashMap cnt = new HashMap<>();
+        long ans = 0;
+        for (int left = 0; left < n; ++left) {
+            while (same < k && right + 1 < n) {
+                ++right;
+                same += cnt.getOrDefault(nums[right], 0);
+                cnt.put(nums[right], cnt.getOrDefault(nums[right], 0) + 1);
+            }
+            if (same >= k) {
+                ans += n - right;
+            }
+            cnt.put(nums[left], cnt.get(nums[left]) - 1);
+            same -= cnt.get(nums[left]);
+        }
+        return ans;
+    }
+} 
From 1aa98bec7600cb53e83dd12531056f97b96f1d17 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 17 Apr 2025 09:37:57 +0530
Subject: [PATCH 005/115] Add Create Equal and Divisible in an Array
---
 Java/Count Equal and Divisible in an Array.java | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Java/Count Equal and Divisible in an Array.java
diff --git a/Java/Count Equal and Divisible in an Array.java b/Java/Count Equal and Divisible in an Array.java
new file mode 100644
index 0000000000..22d9f82330
--- /dev/null
+++ b/Java/Count Equal and Divisible in an Array.java	
@@ -0,0 +1,17 @@
+class Solution {
+    public int countPairs(int[] nums, int k) {
+        int n=nums.length;
+        int res=0;
+        for(int i=0;i
Date: Mon, 21 Apr 2025 20:31:48 +0530
Subject: [PATCH 006/115] Update
---
 Java/Count Hidden Sequence.java | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 Java/Count Hidden Sequence.java
diff --git a/Java/Count Hidden Sequence.java b/Java/Count Hidden Sequence.java
new file mode 100644
index 0000000000..5dc354b7f9
--- /dev/null
+++ b/Java/Count Hidden Sequence.java	
@@ -0,0 +1,18 @@
+public class Solution {
+    public int numberOfArrays(int[] differences, int lower, int upper) {
+        int n = differences.length;
+        int prefix = 0;
+        int min = 0;
+        int max = 0;
+        int diff = upper-lower;
+        for(int i = 0;i diff) return 0;
+        }
+        return (diff) - (max -min) +1;
+    }
+} 
+    
+
From 5e4c852cd8174e09303f46618889ab233231b656 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 21 Apr 2025 20:32:58 +0530
Subject: [PATCH 007/115] u
---
 Java/Count Hidden Sequence.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Java/Count Hidden Sequence.java b/Java/Count Hidden Sequence.java
index 5dc354b7f9..c398d16df7 100644
--- a/Java/Count Hidden Sequence.java	
+++ b/Java/Count Hidden Sequence.java	
@@ -1,10 +1,11 @@
-public class Solution {
+public  class Solution {
     public int numberOfArrays(int[] differences, int lower, int upper) {
         int n = differences.length;
         int prefix = 0;
         int min = 0;
         int max = 0;
         int diff = upper-lower;
+        
         for(int i = 0;i
Date: Tue, 22 Apr 2025 07:49:25 +0530
Subject: [PATCH 008/115] Update
---
 Java/Count and Say.java | 75 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 Java/Count and Say.java
diff --git a/Java/Count and Say.java b/Java/Count and Say.java
new file mode 100644
index 0000000000..bdebba3d63
--- /dev/null
+++ b/Java/Count and Say.java	
@@ -0,0 +1,75 @@
+class Combinations {
+    long[] fact;
+    long[] invFact;
+    long M;
+
+    public Combinations(int n, long mod) {
+        M = mod;
+        fact = new long[n + 1];
+        invFact = new long[n + 1];
+        fact[0] = 1;
+        invFact[0] = 1;
+        for (int i = 1; i <= n; i++) {
+            fact[i] = (fact[i - 1] * i) % M;
+            invFact[i] = power(fact[i], M - 2);
+        }
+    }
+
+    long power(long base, long exp) {
+        long res = 1;
+        base %= M;
+        while (exp > 0) {
+            if ((exp & 1) == 1) res = (res * base) % M;
+            base = (base * base) % M;
+            exp >>= 1;
+        }
+        return res;
+    }
+
+    long nCr(int n, int r) {
+        if (r < 0 || r > n) return 0;
+        long num = fact[n];
+        long den = (invFact[r] * invFact[n - r]) % M;
+        return (num * den) % M;
+    }
+}
+
+class Solution {
+    private static final int MOD = 1_000_000_007;
+
+    public int idealArrays(int n, int maxValue) {
+        Combinations comb = new Combinations(n, MOD);
+        long[] dp = new long[maxValue + 1];
+        long totalAns = maxValue;
+
+        for (int i = 1; i <= maxValue; i++) {
+            dp[i] = 1;
+        }
+
+        int kLimit = Math.min(n, 16);
+
+        for (int k = 2; k <= kLimit; k++) {
+            long[] next_dp = new long[maxValue + 1];
+            for (int j = 1; j <= maxValue; j++) {
+                if (dp[j] == 0) continue;
+                for (long i = 2L * j; i <= maxValue; i += j) {
+                    next_dp[(int) i] = (next_dp[(int) i] + dp[j]) % MOD;
+                }
+            }
+
+            long count = 0;
+            for (int i = 1; i <= maxValue; i++) {
+                count = (count + next_dp[i]) % MOD;
+            }
+
+            if (count == 0) break;
+
+            long factor = comb.nCr(n - 1, k - 1);
+            totalAns = (totalAns + count * factor % MOD) % MOD;
+
+            dp = next_dp;
+        }
+
+        return (int) totalAns;
+    }
+}
\ No newline at end of file
From a3f2228ec97790562196434b1e97315b59da14d6 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 23 Apr 2025 08:33:16 +0530
Subject: [PATCH 009/115] Change
---
 Java/Count Largest Group.java | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 Java/Count Largest Group.java
diff --git a/Java/Count Largest Group.java b/Java/Count Largest Group.java
new file mode 100644
index 0000000000..30507221a2
--- /dev/null
+++ b/Java/Count Largest Group.java	
@@ -0,0 +1,26 @@
+class Solution {
+    public int countLargestGroup(int n) {
+       MaphashMap=new HashMap();
+        int maxValue=0;
+        for(int i=1;i<=n;i++)
+        {
+            int key=0,num=i;
+            while(num!=0)
+            {
+                key+=num%10;
+                num=num/10;
+            }
+            hashMap.put(key,hashMap.getOrDefault(key,0)+1);
+            maxValue=Math.max(maxValue,hashMap.get(key));
+   }
+     int count=0;
+        for(Map.Entrykvpair: hashMap.entrySet()){
+            if(kvpair.getValue()== maxValue)
+                {
+                ++count;
+                }
+            }
+        return count;
+                
+    }
+}
\ No newline at end of file
From 3fbaf2922a07cefba84d09d42036181227cab6d3 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 24 Apr 2025 09:11:04 +0530
Subject: [PATCH 010/115] Update
---
 Java/.project                            | 11 ++++++++++
 Java/Count of Subarrays in An Array.java | 28 ++++++++++++++++++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 Java/Count of Subarrays in An Array.java
diff --git a/Java/.project b/Java/.project
index 4fdb69a93e..bf31459ef4 100644
--- a/Java/.project
+++ b/Java/.project
@@ -14,4 +14,15 @@
 	
 		org.eclipse.jdt.core.javanature
 	
+	
+		
+			1745466012044
+			
+			30
+			
+				org.eclipse.core.resources.regexFilterMatcher
+				node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
+			
+		
+	
 
diff --git a/Java/Count of Subarrays in An Array.java b/Java/Count of Subarrays in An Array.java
new file mode 100644
index 0000000000..5032b24ab9
--- /dev/null
+++ b/Java/Count of Subarrays in An Array.java	
@@ -0,0 +1,28 @@
+class Solution {
+    public int countCompleteSubarrays(int[] nums) {
+        int cnt = 0;
+        HashSet set = new HashSet<>();
+        for (int i = 0; i < nums.length; i++) {
+            set.add(nums[i]);
+        }
+        HashMap map = new HashMap<>();
+        int i = 0, j = 0;
+        while (j < nums.length) {
+            map.put(nums[j], map.getOrDefault(nums[j], 0) + 1);
+            if (map.size() == set.size()) {
+                cnt += nums.length - j;
+                while (true) {
+                    map.put(nums[i], map.get(nums[i]) - 1);
+                    if (map.get(nums[i]) == 0) {
+                        map.remove(nums[i++]);
+                        break;
+                    }
+                    cnt += nums.length - j;
+                    i++;
+                }
+            }
+            j++;
+        }
+        return cnt;
+    }
+}
\ No newline at end of file
From 957c010a714e157136690ec469a85b248f9c703c Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 5 May 2025 19:26:51 +0530
Subject: [PATCH 011/115] Domino
---
 C++/Combination Sum.cpp                       | 49 ++++++++++++
 C++/Diameter of a Binary Tree.cpp             | 17 +++++
 ...owest Common Ancestor of a Binary Tree.cpp | 32 ++++++++
 Java/.project                                 |  4 +
 ...Count Equal and Divisible in an Array.java | 17 +++++
 Java/Count Hidden Sequence.java               | 19 +++++
 Java/Count Largest Group.java                 | 26 +++++++
 ...rays of Length 3 within the condition.java | 27 +++++++
 ...Where max element appear more than k .java | 19 +++++
 Java/Count and Say.java                       | 75 +++++++++++++++++++
 Java/Count of Good Subarray.java              | 22 ++++++
 Java/Count of Interested Subarrays.java       | 32 ++++++++
 ...nt of Subarray with Score less than k.java | 15 ++++
 ...d Numbers with Even Numbers of Digits.java | 23 ++++++
 ...Maximum Value of an  Ordered Triplets.java | 30 ++++++++
 ...nimum Dominaeo Rotation for Equal row.java | 47 ++++++++++++
 16 files changed, 454 insertions(+)
 create mode 100644 C++/Combination Sum.cpp
 create mode 100644 C++/Diameter of a Binary Tree.cpp
 create mode 100644 C++/Lowest Common Ancestor of a Binary Tree.cpp
 create mode 100644 Java/Count Equal and Divisible in an Array.java
 create mode 100644 Java/Count Hidden Sequence.java
 create mode 100644 Java/Count Largest Group.java
 create mode 100644 Java/Count Number of Subarrays of Length 3 within the condition.java
 create mode 100644 Java/Count Subarray Where max element appear more than k .java
 create mode 100644 Java/Count and Say.java
 create mode 100644 Java/Count of Good Subarray.java
 create mode 100644 Java/Count of Interested Subarrays.java
 create mode 100644 Java/Count of Subarray with Score less than k.java
 create mode 100644 Java/Find Numbers with Even Numbers of Digits.java
 create mode 100644 Java/Maximum Value of an  Ordered Triplets.java
 create mode 100644 Java/Minimum Dominaeo Rotation for Equal row.java
diff --git a/C++/Combination Sum.cpp b/C++/Combination Sum.cpp
new file mode 100644
index 0000000000..6c9ffc221d
--- /dev/null
+++ b/C++/Combination Sum.cpp	
@@ -0,0 +1,49 @@
+#include
+#include
+
+class Solution {
+
+    public:
+    
+        vector> combinationSum(vector& candidates, int target) {
+    
+            vector> res;
+    
+            vector comb;
+    
+            makeCombination(candidates, target, 0, comb, 0, res);
+    
+            return res;        
+    
+        }
+    
+    private:
+    
+        void makeCombination(std::vector& candidates, int target, int idx, vector& comb, int total, vector>& res) {
+    
+            if (total == target) {
+    
+                res.push_back(comb);
+    
+                return;
+    
+            }
+    
+            if (total > target || idx >= candidates.size()) {
+    
+                return;
+    
+            }
+    
+            comb.push_back(candidates[idx]);
+    
+            makeCombination(candidates, target, idx, comb, total + candidates[idx], res);
+    
+            comb.pop_back();
+    
+            makeCombination(candidates, target, idx + 1, comb, total, res);
+    
+        }    
+    
+    };
+    
\ No newline at end of file
diff --git a/C++/Diameter of a Binary Tree.cpp b/C++/Diameter of a Binary Tree.cpp
new file mode 100644
index 0000000000..1fd2b037d2
--- /dev/null
+++ b/C++/Diameter of a Binary Tree.cpp	
@@ -0,0 +1,17 @@
+class Solution {
+    public: 
+    int ans=0;
+    int height(TreeNode* root){
+        if(root==NULL){
+            return 0;
+        }
+        int leftHt= height(root->left);
+        int rightHt= height(root->right);
+        ans=max(leftHt+rightHt,ans);
+        return max(leftHt,rightHt)+1;
+    }
+        int diameterOfBinaryTree(TreeNode* root) { 
+            height(root);
+            return ans;
+        }
+    };
\ No newline at end of file
diff --git a/C++/Lowest Common Ancestor of a Binary Tree.cpp b/C++/Lowest Common Ancestor of a Binary Tree.cpp
new file mode 100644
index 0000000000..f63c8b6a3b
--- /dev/null
+++ b/C++/Lowest Common Ancestor of a Binary Tree.cpp	
@@ -0,0 +1,32 @@
+/*
+ * Definition for a binary tree node.
+ * struct TreeNode {
+ *     int val;
+ *     TreeNode *left;
+ *     TreeNode *right;
+ *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
+ * };
+*/
+class Solution {
+    public:
+        TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
+          if(root==NULL){
+            return NULL;
+          }
+          if(root->val==p->val || root->val==q->val){
+            return root;
+          }
+          TreeNode* leftLCA=lowestCommonAncestor(root->left,p,q);
+          TreeNode* rightLCA=lowestCommonAncestor(root->right,p,q);
+          if(leftLCA && rightLCA)
+          {
+            return root;
+          }
+          else if(leftLCA!=NULL){
+            return leftLCA;
+          }
+          else{
+            return rightLCA;
+          }
+        }
+    };
\ No newline at end of file
diff --git a/Java/.project b/Java/.project
index bf31459ef4..d92baf7aec 100644
--- a/Java/.project
+++ b/Java/.project
@@ -16,7 +16,11 @@
 	
 	
 		
+<<<<<<< HEAD
 			1745466012044
+=======
+			1744612223460
+>>>>>>> ccb4566f91334ed4ca8447e7932db4fa2b1a10d1
 			
 			30
 			
diff --git a/Java/Count Equal and Divisible in an Array.java b/Java/Count Equal and Divisible in an Array.java
new file mode 100644
index 0000000000..22d9f82330
--- /dev/null
+++ b/Java/Count Equal and Divisible in an Array.java	
@@ -0,0 +1,17 @@
+class Solution {
+    public int countPairs(int[] nums, int k) {
+        int n=nums.length;
+        int res=0;
+        for(int i=0;i diff) return 0;
+        }
+        return (diff) - (max -min) +1;
+    }
+} 
+    
+
diff --git a/Java/Count Largest Group.java b/Java/Count Largest Group.java
new file mode 100644
index 0000000000..30507221a2
--- /dev/null
+++ b/Java/Count Largest Group.java	
@@ -0,0 +1,26 @@
+class Solution {
+    public int countLargestGroup(int n) {
+       MaphashMap=new HashMap();
+        int maxValue=0;
+        for(int i=1;i<=n;i++)
+        {
+            int key=0,num=i;
+            while(num!=0)
+            {
+                key+=num%10;
+                num=num/10;
+            }
+            hashMap.put(key,hashMap.getOrDefault(key,0)+1);
+            maxValue=Math.max(maxValue,hashMap.get(key));
+   }
+     int count=0;
+        for(Map.Entrykvpair: hashMap.entrySet()){
+            if(kvpair.getValue()== maxValue)
+                {
+                ++count;
+                }
+            }
+        return count;
+                
+    }
+}
\ No newline at end of file
diff --git a/Java/Count Number of Subarrays of Length 3 within the condition.java b/Java/Count Number of Subarrays of Length 3 within the condition.java
new file mode 100644
index 0000000000..1fcbe2a495
--- /dev/null
+++ b/Java/Count Number of Subarrays of Length 3 within the condition.java	
@@ -0,0 +1,27 @@
+public class Solution 
+{
+    public int countSubarrays(int[] nums) 
+    {
+        int count = 0;
+        
+        // Step 1: Loop through the array to check subarrays of size 3
+        for (int i = 0; i <= nums.length - 3; i++) 
+        {
+            // Step 2: Extract the three consecutive elements
+            int first = nums[i];
+            int second = nums[i + 1];
+            int third = nums[i + 2];
+            
+            // Step 3: Check if 2 * (first + third) == second
+            if (2 * (first + third) == second) 
+            {
+                count++; // Increment count if condition is satisfied
+            }
+        }
+        
+        // Step 4: Return the final count of subarrays that satisfy the condition
+        return count;
+        //he.ll
+    }
+
+} 
diff --git a/Java/Count Subarray Where max element appear more than k .java b/Java/Count Subarray Where max element appear more than k .java
new file mode 100644
index 0000000000..1557a4e9d1
--- /dev/null
+++ b/Java/Count Subarray Where max element appear more than k .java	
@@ -0,0 +1,19 @@
+class Solution {
+    public long countSubarrays(int[] nums, int k) {
+        int n = nums.length;
+        int maxVal = 0;
+        for (int v : nums) maxVal = Math.max(maxVal, v);
+
+        long res = 0;
+        int count = 0, left = 0;
+        for (int right = 0; right < n; right++) {
+            if (nums[right] == maxVal) count++;
+            while (count >= k) {
+                if (nums[left] == maxVal) count--;
+                left++;
+            }
+            res += left;
+        }
+        return res;
+    }
+}
diff --git a/Java/Count and Say.java b/Java/Count and Say.java
new file mode 100644
index 0000000000..bdebba3d63
--- /dev/null
+++ b/Java/Count and Say.java	
@@ -0,0 +1,75 @@
+class Combinations {
+    long[] fact;
+    long[] invFact;
+    long M;
+
+    public Combinations(int n, long mod) {
+        M = mod;
+        fact = new long[n + 1];
+        invFact = new long[n + 1];
+        fact[0] = 1;
+        invFact[0] = 1;
+        for (int i = 1; i <= n; i++) {
+            fact[i] = (fact[i - 1] * i) % M;
+            invFact[i] = power(fact[i], M - 2);
+        }
+    }
+
+    long power(long base, long exp) {
+        long res = 1;
+        base %= M;
+        while (exp > 0) {
+            if ((exp & 1) == 1) res = (res * base) % M;
+            base = (base * base) % M;
+            exp >>= 1;
+        }
+        return res;
+    }
+
+    long nCr(int n, int r) {
+        if (r < 0 || r > n) return 0;
+        long num = fact[n];
+        long den = (invFact[r] * invFact[n - r]) % M;
+        return (num * den) % M;
+    }
+}
+
+class Solution {
+    private static final int MOD = 1_000_000_007;
+
+    public int idealArrays(int n, int maxValue) {
+        Combinations comb = new Combinations(n, MOD);
+        long[] dp = new long[maxValue + 1];
+        long totalAns = maxValue;
+
+        for (int i = 1; i <= maxValue; i++) {
+            dp[i] = 1;
+        }
+
+        int kLimit = Math.min(n, 16);
+
+        for (int k = 2; k <= kLimit; k++) {
+            long[] next_dp = new long[maxValue + 1];
+            for (int j = 1; j <= maxValue; j++) {
+                if (dp[j] == 0) continue;
+                for (long i = 2L * j; i <= maxValue; i += j) {
+                    next_dp[(int) i] = (next_dp[(int) i] + dp[j]) % MOD;
+                }
+            }
+
+            long count = 0;
+            for (int i = 1; i <= maxValue; i++) {
+                count = (count + next_dp[i]) % MOD;
+            }
+
+            if (count == 0) break;
+
+            long factor = comb.nCr(n - 1, k - 1);
+            totalAns = (totalAns + count * factor % MOD) % MOD;
+
+            dp = next_dp;
+        }
+
+        return (int) totalAns;
+    }
+}
\ No newline at end of file
diff --git a/Java/Count of Good Subarray.java b/Java/Count of Good Subarray.java
new file mode 100644
index 0000000000..da19d185c5
--- /dev/null
+++ b/Java/Count of Good Subarray.java	
@@ -0,0 +1,22 @@
+public class Solution {
+
+    public long countGood(int[] nums, int k) {
+        int n = nums.length;
+        int same = 0, right = -1;
+        HashMap cnt = new HashMap<>();
+        long ans = 0;
+        for (int left = 0; left < n; ++left) {
+            while (same < k && right + 1 < n) {
+                ++right;
+                same += cnt.getOrDefault(nums[right], 0);
+                cnt.put(nums[right], cnt.getOrDefault(nums[right], 0) + 1);
+            }
+            if (same >= k) {
+                ans += n - right;
+            }
+            cnt.put(nums[left], cnt.get(nums[left]) - 1);
+            same -= cnt.get(nums[left]);
+        }
+        return ans;
+    }
+} 
diff --git a/Java/Count of Interested Subarrays.java b/Java/Count of Interested Subarrays.java
new file mode 100644
index 0000000000..5f904d73fd
--- /dev/null
+++ b/Java/Count of Interested Subarrays.java	
@@ -0,0 +1,32 @@
+class Solution 
+{
+    public long countInterestingSubarrays(List nums, int modulo, int k) 
+    {
+        // Step 1 : Initialize result, prefix sum, and a map with base case
+        long result = 0;
+        int prefix = 0;
+        Map map = new HashMap<>();
+        map.put(0, 1L);
+
+        // Step 2 : Traverse through nums
+        for (int num : nums) 
+        {
+            // Step 3 : Check condition and update prefix
+            if (num % modulo == k) 
+            {
+                prefix++;
+            }
+
+            // Step 4 : Calculate current prefix mod and target
+            int mod = prefix % modulo;
+            int target = (mod - k + modulo) % modulo;
+
+            // Step 5 : Add to result and update map
+            result += map.getOrDefault(target, 0L);
+            map.put(mod, map.getOrDefault(mod, 0L) + 1);
+        }
+
+        // Step 6 : Return final count
+        return result;
+    }
+}
diff --git a/Java/Count of Subarray with Score less than k.java b/Java/Count of Subarray with Score less than k.java
new file mode 100644
index 0000000000..9536523b93
--- /dev/null
+++ b/Java/Count of Subarray with Score less than k.java	
@@ -0,0 +1,15 @@
+class Solution {
+    public long countSubarrays(int[] nums, long k) {
+           int n=nums.length;
+        long res=0,total=0;
+        for(int i=0,j=0;j=k){
+                total-=nums[i];
+                i++;
+            }
+            res+=j-i+1;
+        }
+        return res;
+    }
+}
\ No newline at end of file
diff --git a/Java/Find Numbers with Even Numbers of Digits.java b/Java/Find Numbers with Even Numbers of Digits.java
new file mode 100644
index 0000000000..abe01753f6
--- /dev/null
+++ b/Java/Find Numbers with Even Numbers of Digits.java	
@@ -0,0 +1,23 @@
+class Solution {
+    // Helper function to check if the number of digits is even
+    private boolean hasEvenDigits(int num) {
+        int digitCount = 0;
+        while (num != 0) {
+            digitCount++;
+            num /= 10;
+        }
+        return (digitCount & 1) == 0;
+    }
+
+    public int findNumbers(int[] nums) {
+        // Counter to count the number of even digit integers
+        int evenDigitCount = 0;
+
+        for (int num : nums) {
+            if (hasEvenDigits(num))
+                evenDigitCount++;
+        }
+
+        return evenDigitCount;
+    }
+}
diff --git a/Java/Maximum Value of an  Ordered Triplets.java b/Java/Maximum Value of an  Ordered Triplets.java
new file mode 100644
index 0000000000..1453d1b089
--- /dev/null
+++ b/Java/Maximum Value of an  Ordered Triplets.java	
@@ -0,0 +1,30 @@
+ //TC:O(N)
+ //SC:O(N)
+
+class Solution {
+    public long maximumTripletValue(int[]  nums){
+        int n = nums.length;
+        if (n < 3) return 0;
+
+        int[] leftMax = new int[n];
+        leftMax[0] = nums[0];
+        for (int i = 1; i < n; i++) {
+            leftMax[i] = Math.max(leftMax[i - 1], nums[i]);
+        }
+
+        int[] rightMax = new int[n];
+        rightMax[n - 1] = nums[n - 1];
+        for (int i = n - 2; i >= 0; i--) {
+            rightMax[i] = Math.max(rightMax[i + 1], nums[i]);
+        }
+
+        long ans = 0;  
+        for (int i = 1; i < n - 1; i++) {
+            int left = leftMax[i - 1];
+            int right = rightMax[i + 1];
+            ans = Math.max(ans, (long)(left - nums[i]) * right); 
+        }
+
+        return ans;
+    }
+}
\ No newline at end of file
diff --git a/Java/Minimum Dominaeo Rotation for Equal row.java b/Java/Minimum Dominaeo Rotation for Equal row.java
new file mode 100644
index 0000000000..eba0c9432a
--- /dev/null
+++ b/Java/Minimum Dominaeo Rotation for Equal row.java	
@@ -0,0 +1,47 @@
+class Solution 
+{
+    public int minDominoRotations(int[] tops, int[] bottoms) 
+    {
+        // Step 1: Try to make all values equal to tops[0]
+        int result = check(tops[0], tops, bottoms);
+
+        // Step 2: If tops[0] failed, try bottoms[0]
+        if (result != -1) return result;
+
+        // Step 3: Return result from checking bottoms[0]
+        return check(bottoms[0], tops, bottoms);
+    }
+
+    // Step 4: Helper function to count rotations to make all values = target
+    private int check(int target, int[] tops, int[] bottoms) 
+    {
+        int rotateTop = 0;    // Rotations needed to bring target to top
+        int rotateBottom = 0; // Rotations needed to bring target to bottom
+
+        // Step 5: Loop through all dominoes
+        for (int i = 0; i < tops.length; i++) 
+        {
+            // Step 6: If target is not on either side, it's impossible
+            if (tops[i] != target && bottoms[i] != target) 
+            {
+                return -1;
+            }
+
+            // Step 7: If top doesn't have the target, it must be rotated
+            if (tops[i] != target)
+            {
+                rotateTop++;
+            } 
+
+            // Step 8: If bottom doesn't have the target, it must be rotated
+            if (bottoms[i] != target)
+            {
+                rotateBottom++;
+            } 
+        }
+
+        // Step 9: Return the minimum of the two rotation counts
+        return Math.min(rotateTop, rotateBottom);
+    }
+}
+    
\ No newline at end of file
From c049719798ec17654c46f53d9b9feac12ebc3a51 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 6 May 2025 09:04:47 +0530
Subject: [PATCH 012/115] Create
---
 Java/Build Array from Permutation.java | 11 +++++++++++
 Java/Domino and Tromino Tiling.java    | 26 ++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 Java/Build Array from Permutation.java
 create mode 100644 Java/Domino and Tromino Tiling.java
diff --git a/Java/Build Array from Permutation.java b/Java/Build Array from Permutation.java
new file mode 100644
index 0000000000..d1c56f7581
--- /dev/null
+++ b/Java/Build Array from Permutation.java	
@@ -0,0 +1,11 @@
+class Solution {
+
+    public int[] buildArray(int[] nums) {
+        int n = nums.length;
+        int[] ans = new int[n];
+        for (int i = 0; i < n; ++i) {
+            ans[i] = nums[nums[i]];
+        }
+        return ans;
+    }
+}
diff --git a/Java/Domino and Tromino Tiling.java b/Java/Domino and Tromino Tiling.java
new file mode 100644
index 0000000000..971539563e
--- /dev/null
+++ b/Java/Domino and Tromino Tiling.java	
@@ -0,0 +1,26 @@
+#include
+
+public class Solution {
+    public:
+        const int MOD = 1e9 + 7;
+        template 
+        inline T mod_add(T a, T b, T m) { return (a % m + b % m) % m; }
+        vector dp;
+        int rec(int idx) {
+            if (idx == 0) return 1;
+            if (idx == 1) return 1;
+            if (idx == 2) return 2;
+            if (dp[idx] != -1) return dp[idx];
+            auto ans = (2LL * rec(idx - 1)) % MOD;
+            ans = mod_add(ans, rec(idx - 3), MOD);
+            
+            return dp[idx] = ans;
+        }
+    
+    
+        int numTilings(int n) {
+            dp.assign(n + 1, -1);
+            return rec(n);
+        }
+    };
+
From 577aa59c07fe5a87e8e2e241f19ef7415bede7cb Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 7 May 2025 19:39:45 +0530
Subject: [PATCH 013/115] Changes
---
 ...Minimum time to reach the last Room I.java | 55 +++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 Java/Find Minimum time to reach the last Room I.java
diff --git a/Java/Find Minimum time to reach the last Room I.java b/Java/Find Minimum time to reach the last Room I.java
new file mode 100644
index 0000000000..b340e8113c
--- /dev/null
+++ b/Java/Find Minimum time to reach the last Room I.java	
@@ -0,0 +1,55 @@
+class Solution {
+
+    private static final int INF = 0x3f3f3f3f;
+
+    public int minTimeToReach(int[][] moveTime) {
+        int n = moveTime.length, m = moveTime[0].length;
+        int[][] d = new int[n][m];
+        boolean[][] v = new boolean[n][m];
+        for (int i = 0; i < n; i++) {
+            Arrays.fill(d[i], INF);
+        }
+
+        int[][] dirs = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } };
+        d[0][0] = 0;
+        PriorityQueue q = new PriorityQueue<>();
+        q.offer(new State(0, 0, 0));
+
+        while (!q.isEmpty()) {
+            State s = q.poll();
+            if (v[s.x][s.y]) {
+                continue;
+            }
+            v[s.x][s.y] = true;
+            for (int[] dir : dirs) {
+                int nx = s.x + dir[0];
+                int ny = s.y + dir[1];
+                if (nx < 0 || nx >= n || ny < 0 || ny >= m) {
+                    continue;
+                }
+                int dist = Math.max(d[s.x][s.y], moveTime[nx][ny]) + 1;
+                if (d[nx][ny] > dist) {
+                    d[nx][ny] = dist;
+                    q.offer(new State(nx, ny, dist));
+                }
+            }
+        }
+        return d[n - 1][m - 1];
+    }
+
+    static class State implements Comparable {
+
+        int x, y, dis;
+
+        State(int x, int y, int dis) {
+            this.x = x;
+            this.y = y;
+            this.dis = dis;
+        }
+
+        @Override
+        public int compareTo(State other) {
+            return Integer.compare(this.dis, other.dis);
+        }
+    }
+}
\ No newline at end of file
From df698de2a7d481af4c8a4886505754ec13780c08 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 8 May 2025 21:15:16 +0530
Subject: [PATCH 014/115] Create
---
 ...inimum time to reach the last room II.java | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 Java/Find Minimum time to reach the last room II.java
diff --git a/Java/Find Minimum time to reach the last room II.java b/Java/Find Minimum time to reach the last room II.java
new file mode 100644
index 0000000000..d04ab7516d
--- /dev/null
+++ b/Java/Find Minimum time to reach the last room II.java	
@@ -0,0 +1,72 @@
+import java.util.*;
+
+public class Solution {
+
+    public int minTimeToReach(int[][] moveTime) {
+
+        int n = moveTime.length;
+
+        int m = moveTime[0].length;
+
+        int[][] bestTime = new int[n][m];
+
+        for (int[] row : bestTime) {
+
+            Arrays.fill(row, Integer.MAX_VALUE);
+
+        }
+
+        int[][] directions = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
+
+        PriorityQueue pq = new PriorityQueue<>(Comparator.comparingInt(a -> a[0]));
+
+        pq.offer(new int[]{0, 0, 0, 0}); // time, i, j, nextMoveTime
+
+        while (!pq.isEmpty()) {
+
+            int[] curr = pq.poll();
+
+            int time = curr[0], i = curr[1], j = curr[2], nextMoveTime = curr[3];
+
+            if (time >= bestTime[i][j]) continue;
+
+            bestTime[i][j] = time;
+
+            if (i == n - 1 && j == m - 1) return time;
+
+            for (int[] d : directions) {
+
+                int x = i + d[0], y = j + d[1];
+
+                if (x >= 0 && x < n && y >= 0 && y < m) {
+
+                    int wait = moveTime[x][y];
+
+                    int futureMove = nextMoveTime == 1 ? 2 : 1;
+
+                    int nextTime = wait > time ? wait + futureMove : time + futureMove;
+
+                    if (i == 0 && j == 0 && wait <= time) {
+
+                        nextTime = wait + futureMove;
+
+                    }
+
+                    if (nextTime < bestTime[x][y]) {
+
+                        pq.offer(new int[]{nextTime, x, y, futureMove});
+
+                    }
+
+                }
+
+            }
+
+        }
+
+        return -1; // Should never reach
+
+    }
+
+}
+    
From c3fb29a2dc029a4e3ff2fce89e9d5dc318c08f9b Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 9 May 2025 12:45:07 +0530
Subject: [PATCH 015/115] Create Count Number of Balanced Permutation.java
---
 Count Number of Balanced Permutation.java | 69 +++++++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Count Number of Balanced Permutation.java
diff --git a/Count Number of Balanced Permutation.java b/Count Number of Balanced Permutation.java
new file mode 100644
index 0000000000..c05bf18993
--- /dev/null
+++ b/Count Number of Balanced Permutation.java	
@@ -0,0 +1,69 @@
+class Solution {
+
+    private static final long MOD = 1_000_000_007;
+
+    public int countBalancedPermutations(String num) {
+        int tot = 0, n = num.length();
+        int[] cnt = new int[10];
+        for (char ch : num.toCharArray()) {
+            int d = ch - '0';
+            cnt[d]++;
+            tot += d;
+        }
+        if (tot % 2 != 0) {
+            return 0;
+        }
+
+        int target = tot / 2;
+        int maxOdd = (n + 1) / 2;
+        long[][] comb = new long[maxOdd + 1][maxOdd + 1];
+        long[][] f = new long[target + 1][maxOdd + 1];
+
+        for (int i = 0; i <= maxOdd; i++) {
+            comb[i][i] = comb[i][0] = 1;
+            for (int j = 1; j < i; j++) {
+                comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % MOD;
+            }
+        }
+
+        f[0][0] = 1;
+        int psum = 0, totSum = 0;
+        for (int i = 0; i <= 9; i++) {
+            /* Sum of the number of the first i digits */
+            psum += cnt[i];
+            /* Sum of the first i numbers */
+            totSum += i * cnt[i];
+            for (
+                int oddCnt = Math.min(psum, maxOdd);
+                oddCnt >= Math.max(0, psum - (n - maxOdd));
+                oddCnt--
+            ) {
+                /* The number of bits that need to be filled in even numbered positions */
+                int evenCnt = psum - oddCnt;
+                for (
+                    int curr = Math.min(totSum, target);
+                    curr >= Math.max(0, totSum - target);
+                    curr--
+                ) {
+                    long res = 0;
+                    for (
+                        int j = Math.max(0, cnt[i] - evenCnt);
+                        j <= Math.min(cnt[i], oddCnt) && i * j <= curr;
+                        j++
+                    ) {
+                        /* The current digit is filled with j positions at odd positions, and cnt[i] - j positions at even positions */
+                        long ways =
+                            (comb[oddCnt][j] * comb[evenCnt][cnt[i] - j]) % MOD;
+                        res =
+                            (res +
+                                ((ways * f[curr - i * j][oddCnt - j]) % MOD)) %
+                            MOD;
+                    }
+                    f[curr][oddCnt] = res % MOD;
+                }
+            }
+        }
+
+        return (int) f[target][maxOdd];
+    }
+}
From 077559eae0d1f29ab6f24d07ab804ad656b2a066 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Sat, 10 May 2025 13:33:23 +0530
Subject: [PATCH 016/115] Minimum Equal sum of Two Array After Replacing
 Zeroes.java
---
 ... of Two Arrays After Replacing Zeroes.java | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Minimum Equal Sum of Two Arrays After Replacing Zeroes.java
diff --git a/Minimum Equal Sum of Two Arrays After Replacing Zeroes.java b/Minimum Equal Sum of Two Arrays After Replacing Zeroes.java
new file mode 100644
index 0000000000..c10f60ffee
--- /dev/null
+++ b/Minimum Equal Sum of Two Arrays After Replacing Zeroes.java	
@@ -0,0 +1,29 @@
+class Solution {
+
+    public long minSum(int[] nums1, int[] nums2) {
+        long sum1 = 0, sum2 = 0;
+        long zero1 = 0, zero2 = 0;
+
+        for (int i : nums1) {
+            sum1 += i;
+            if (i == 0) {
+                sum1++;
+                zero1++;
+            }
+        }
+
+        for (int i : nums2) {
+            sum2 += i;
+            if (i == 0) {
+                sum2++;
+                zero2++;
+            }
+        }
+
+        if ((zero1 == 0 && sum2 > sum1) || (zero2 == 0 && sum1 > sum2)) {
+            return -1;
+        }
+
+        return Math.max(sum1, sum2);
+    }
+}
\ No newline at end of file
From d3503e984295782f1508d759a2420f2296ec024d Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 12 May 2025 11:19:19 +0530
Subject: [PATCH 017/115] Create
---
 Three Consecutive Odds.java | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 Three Consecutive Odds.java
diff --git a/Three Consecutive Odds.java b/Three Consecutive Odds.java
new file mode 100644
index 0000000000..f6077e692c
--- /dev/null
+++ b/Three Consecutive Odds.java	
@@ -0,0 +1,14 @@
+class Solution {
+    public boolean threeConsecutiveOdds(int[] arr) {
+        // Loop through the array up to the third-to-last element
+        for (int i = 0; i < arr.length - 2; i++) {
+            // Check if the current element and the next two elements are all odd
+            int product=arr[i]*arr[i+1]*arr[i+2];
+            if(product% 2==1){
+                return true;
+            }
+        }
+
+        return false;
+    }
+}
From 04552222744b7fc69880df42a681d3364e156068 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 13 May 2025 09:24:24 +0530
Subject: [PATCH 018/115] Create Length of the String After Transformation
 I.java
---
 ... of the String After Transformation I.java | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Length of the String After Transformation I.java
diff --git a/Length of the String After Transformation I.java b/Length of the String After Transformation I.java
new file mode 100644
index 0000000000..e088f80bd9
--- /dev/null
+++ b/Length of the String After Transformation I.java	
@@ -0,0 +1,24 @@
+class Solution {
+    public int lengthAfterTransformations(String s, int t) {
+        int MOD = 1_000_000_007;
+        int[] v = new int[26];
+        for (char ch : s.toCharArray()) {
+            v[ch - 'a']++;
+        }
+        for (int i = 0; i < t; i++) {
+            int ele = v[25];
+            for (int j = 25; j > 0; j--) {
+                v[j] = v[j - 1];
+            }
+            v[0] = 0;
+            v[0] = (v[0] + ele) % MOD;
+            v[1] = (v[1] + ele) % MOD;
+        }
+        int sum = 0;
+        for (int i = 0; i < 26; i++) {
+            sum = (sum + v[i]) % MOD;
+        }
+        return sum;
+    }
+}
+    
\ No newline at end of file
From 708339421d72113b827fc9c9cafa9eb28de24355 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 14 May 2025 09:47:14 +0530
Subject: [PATCH 019/115] Create Length oof the String After Transformation
 II.java
---
 Length of String After Transformation II.java | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 Length of String After Transformation II.java
diff --git a/Length of String After Transformation II.java b/Length of String After Transformation II.java
new file mode 100644
index 0000000000..f2a1e660ce
--- /dev/null
+++ b/Length of String After Transformation II.java	
@@ -0,0 +1,50 @@
+class Solution {
+    private static final int mod = 1000000007;
+
+    private long[][] multiplyMatrices(long[][] A, long[][] B) {
+        int rowsA = A.length, colsA = A[0].length, colsB = B[0].length;
+        long[][] result = new long[rowsA][colsB];
+        for (int i = 0; i < rowsA; i++) {
+            for (int j = 0; j < colsB; j++) {
+                long sum = 0;
+                for (int k = 0; k < colsA; k++) {
+                    sum = (sum + (A[i][k] * B[k][j]) % mod) % mod;
+                }
+                result[i][j] = sum;
+            }
+        }
+        return result;
+    }
+
+    private long[][] powerMatrix(long[][] matrix, long exponent) {
+        int n = matrix.length;
+        long[][] result = new long[n][n];
+        for (int i = 0; i < n; i++) result[i][i] = 1;
+        while (exponent > 0) {
+            if ((exponent & 1) == 1) result = multiplyMatrices(result, matrix);
+            matrix = multiplyMatrices(matrix, matrix);
+            exponent >>= 1;
+        }
+        return result;
+    }
+
+    public int lengthAfterTransformations(String s, int t, List nums) {
+        long[][] transform = new long[26][26];
+        for (int i = 0; i < 26; i++) {
+            for (int shift = 0; shift < nums.get(i); shift++) {
+                transform[i][(i + 1 + shift) % 26]++;
+            }
+        }
+        transform = powerMatrix(transform, t);
+        long[][] freq = new long[1][26];
+        for (char ch : s.toCharArray()) {
+            freq[0][ch - 'a']++;
+        }
+        freq = multiplyMatrices(freq, transform);
+        long total = 0;
+        for (long cnt : freq[0]) {
+            total = (total + cnt) % mod;
+        }
+        return (int)total;
+    }
+}
\ No newline at end of file
From 9c03d5557cb396524e2d43d41e45d34c8913199e Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 15 May 2025 09:44:20 +0530
Subject: [PATCH 020/115] Create Longest Unequal Sequence I .java
---
 ...st Unequal Adjacent Sequence Groups I.java | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Longest Unequal Adjacent Sequence Groups I.java
diff --git a/Longest Unequal Adjacent Sequence Groups I.java b/Longest Unequal Adjacent Sequence Groups I.java
new file mode 100644
index 0000000000..e12b4df395
--- /dev/null
+++ b/Longest Unequal Adjacent Sequence Groups I.java	
@@ -0,0 +1,39 @@
+public class class Solution {
+
+    public List getLongestSubsequence(String[] words, int[] groups) {
+        int n = words.length;
+        int[] dp = new int[n];
+        int[] prev = new int[n];
+        int maxLen = 1, endIndex = 0;
+
+        for (int i = 0; i < n; i++) {
+            dp[i] = 1;
+            prev[i] = -1;
+        }
+        for (int i = 1; i < n; i++) {
+            int bestLen = 1;
+            int bestPrev = -1;
+            for (int j = i - 1; j >= 0; j--) {
+                if (groups[i] != groups[j] && dp[j] + 1 > bestLen) {
+                    bestLen = dp[j] + 1;
+                    bestPrev = j;
+                }
+            }
+            dp[i] = bestLen;
+            prev[i] = bestPrev;
+            if (dp[i] > maxLen) {
+                maxLen = dp[i];
+                endIndex = i;
+            }
+        }
+
+        List res = new ArrayList<>();
+        for (int i = endIndex; i != -1; i = prev[i]) {
+            res.add(words[i]);
+        }
+        Collections.reverse(res);
+        return res;
+    }
+}
+    
+
From c9f586df9f427541e7fe2c2fe71cc20f31be9edf Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 16 May 2025 19:55:36 +0530
Subject: [PATCH 021/115] Longest Unequal Adjacent Groups Sequence II.java
---
 ...t Unequal Adjacent Groups Sequence II.java | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Longest Unequal Adjacent Groups Sequence II.java
diff --git a/Longest Unequal Adjacent Groups Sequence II.java b/Longest Unequal Adjacent Groups Sequence II.java
new file mode 100644
index 0000000000..04f1d7a737
--- /dev/null
+++ b/Longest Unequal Adjacent Groups Sequence II.java	
@@ -0,0 +1,51 @@
+class Solution {
+
+    public List getWordsInLongestSubsequence(
+        String[] words,
+        int[] groups
+    ) {
+        int n = groups.length;
+        int[] dp = new int[n];
+        int[] prev = new int[n];
+        Arrays.fill(dp, 1);
+        Arrays.fill(prev, -1);
+        int maxIndex = 0;
+        for (int i = 1; i < n; i++) {
+            for (int j = 0; j < i; j++) {
+                if (
+                    check(words[i], words[j]) &&
+                    dp[j] + 1 > dp[i] &&
+                    groups[i] != groups[j]
+                ) {
+                    dp[i] = dp[j] + 1;
+                    prev[i] = j;
+                }
+            }
+            if (dp[i] > dp[maxIndex]) {
+                maxIndex = i;
+            }
+        }
+        List ans = new ArrayList<>();
+        for (int i = maxIndex; i >= 0; i = prev[i]) {
+            ans.add(words[i]);
+        }
+        Collections.reverse(ans);
+        return ans;
+    }
+
+    private boolean check(String s1, String s2) {
+        if (s1.length() != s2.length()) {
+            return false;
+        }
+        int diff = 0;
+        for (int i = 0; i < s1.length(); i++) {
+            if (s1.charAt(i) != s2.charAt(i)) {
+                if (++diff > 1) {
+                    return false;
+                }
+            }
+        }
+        return diff == 1;
+    }
+}
+    
From 2e89888d0733c94d0d5591ed19f72ef907719b5f Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Sat, 17 May 2025 08:37:09 +0530
Subject: [PATCH 022/115] Sort Colors
---
 Sort Colors | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Sort Colors
diff --git a/Sort Colors b/Sort Colors
new file mode 100644
index 0000000000..52765c5c79
--- /dev/null
+++ b/Sort Colors	
@@ -0,0 +1,16 @@
+lass Solution {
+    public void sortColors(int[] nums) {
+        int [] count=new int[3];
+        for (int num:nums)
+        {
+            count[num]++;
+        }
+        int index=0;
+        for(int i=0;i<3;i++){
+            while(count[i]>0){
+                nums[index++]=i;
+                count[i]--;
+            }
+        }
+    }
+}
\ No newline at end of file
From 2993d4a7a52c782c99a9c5e4c531361d103b1a1e Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Sun, 18 May 2025 09:04:34 +0530
Subject: [PATCH 023/115] Create Painting the Grid with N different Colors.java
---
 Painting the grid with n different colors | 66 +++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Painting the grid with n different colors
diff --git a/Painting the grid with n different colors b/Painting the grid with n different colors
new file mode 100644
index 0000000000..1826946429
--- /dev/null
+++ b/Painting the grid with n different colors	
@@ -0,0 +1,66 @@
+class Solution {
+
+    // update RGB combination as 0x7 for improvement.
+        
+    private static final int R = 1;
+    private static final int G = 2;
+    private static final int B = 4;
+    private static final int mod = (int)1e9+7;   
+    public int colorTheGrid(int m, int n) {
+
+        //compute overall number of possible permutations for a single column
+        int count = 3;
+        for(int i = 0; i  < m - 1; i++)
+            count *= 2;
+        
+        long[] perms = new long[count];
+        Queue que = new LinkedList<>();
+                
+        que.offer(R);
+        que.offer(G);
+        que.offer(B);
+        
+        //fill in all possible permuatations using Queue
+        int index = count;
+        
+        while(!que.isEmpty()){
+            int color  = que.poll();
+            if( color >=  1 << 3 * (m-1) ) //m - length permutation
+                perms[--index] = color;
+            else{
+                
+                   int nextcolors = 0x7^ (color & 0x7);
+                   while(nextcolors > 0){
+                       int nextcolor = nextcolors &(-nextcolors);
+                       que.add((color << 3) + nextcolor);
+                       nextcolors &= (nextcolors - 1);
+                    }
+                }
+        }
+        
+        int[] cur = new int[count];
+        Arrays.fill(cur, 1);
+        
+        //iterate by columns from left to right, 
+        //memorizing score count for every permutation in current column
+        for(int col = 0; col < n-1; col++){
+            
+            int[] next = new int[count];
+
+            for(int i = 0; i < count; i++){
+                for(int j = 0; j < count; j++){
+                    if((perms[i] & perms[j]) == 0) // both are OK to each other 
+                        next[j] = (next[j] + cur[i])%mod;
+                }
+            }
+            cur = next;
+        }
+        
+        //accumulate all scores for permuttions as per last column 
+        int result = 0;
+        for(int i = 0; i < count; i++)
+            result = (result + cur[i]) % mod;
+        
+        return result;    
+    }
+}
\ No newline at end of file
From 1dcec1060b6b50778e55fddb712471d7fc1bbdda Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 19 May 2025 19:06:54 +0530
Subject: [PATCH 024/115] Create Type of Triangle.java
---
 Type of Triangle.java | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Type of Triangle.java
diff --git a/Type of Triangle.java b/Type of Triangle.java
new file mode 100644
index 0000000000..84cebe1a95
--- /dev/null
+++ b/Type of Triangle.java	
@@ -0,0 +1,15 @@
+class Solution {
+
+    public String triangleType(int[] nums) {
+        Arrays.sort(nums);
+        if (nums[0] + nums[1] <= nums[2]) {
+            return "none";
+        } else if (nums[0] == nums[2]) {
+            return "equilateral";
+        } else if (nums[0] == nums[1] || nums[1] == nums[2]) {
+            return "isosceles";
+        } else {
+            return "scalene";
+        }
+    }
+}
From ec187056e11b9c2350ce0cb76423d88e1e02eebc Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 20 May 2025 19:46:28 +0530
Subject: [PATCH 025/115] Zero Array Transformation I
---
 Zero Array Transformation I.java | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Zero Array Transformation I.java
diff --git a/Zero Array Transformation I.java b/Zero Array Transformation I.java
new file mode 100644
index 0000000000..877d99dc55
--- /dev/null
+++ b/Zero Array Transformation I.java	
@@ -0,0 +1,24 @@
+class Solution {
+
+    public boolean isZeroArray(int[] nums, int[][] queries) {
+        int[] deltaArray = new int[nums.length + 1];
+        for (int[] query : queries) {
+            int left = query[0];
+            int right = query[1];
+            deltaArray[left] += 1;
+            deltaArray[right + 1] -= 1;
+        }
+        int[] operationCounts = new int[deltaArray.length];
+        int currentOperations = 0;
+        for (int i = 0; i < deltaArray.length; i++) {
+            currentOperations += deltaArray[i];
+            operationCounts[i] = currentOperations;
+        }
+        for (int i = 0; i < nums.length; i++) {
+            if (operationCounts[i] < nums[i]) {
+                return false;
+            }
+        }
+        return true;
+    }
+}
\ No newline at end of file
From f0cff592bb0666ebaba6c63f1d6ededf2e4e0fa1 Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 21 May 2025 19:37:45 +0530
Subject: [PATCH 026/115] Set Zeroes Matrix
---
 Set Zeroes Matrix.java | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 Set Zeroes Matrix.java
diff --git a/Set Zeroes Matrix.java b/Set Zeroes Matrix.java
new file mode 100644
index 0000000000..e69de29bb2
From ea7840c81440f599c76e1b854d76da3f3c467bbc Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 21 May 2025 19:38:30 +0530
Subject: [PATCH 027/115] Create
---
 Set Zeroes Matrix.java | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
diff --git a/Set Zeroes Matrix.java b/Set Zeroes Matrix.java
index e69de29bb2..fee5785605 100644
--- a/Set Zeroes Matrix.java	
+++ b/Set Zeroes Matrix.java	
@@ -0,0 +1,25 @@
+class Solution {
+    public void setZeroes(int[][] matrix) {
+        int n = matrix.length;
+        int m = matrix[0].length;
+        boolean[] row = new boolean[n];
+        boolean[] col = new boolean[m];
+
+        for (int i = 0; i < n; i++) {
+            for (int j = 0; j < m; j++) {
+                if (matrix[i][j] == 0) {
+                    row[i] = true;
+                    col[j] = true;
+                }
+            }
+        }
+
+        for (int i = 0; i < n; i++) {
+            for (int j = 0; j < m; j++) {
+                if (row[i] || col[j]) {
+                    matrix[i][j] = 0;
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
From 4029ede9bc19f21056f01931de136568624d2fd3 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 22 May 2025 20:29:27 +0530
Subject: [PATCH 028/115] Create Zero Array Transformation.java
---
 Java/Zero Array Transformation.java | 32 +++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 Java/Zero Array Transformation.java
diff --git a/Java/Zero Array Transformation.java b/Java/Zero Array Transformation.java
new file mode 100644
index 0000000000..76e5ea4653
--- /dev/null
+++ b/Java/Zero Array Transformation.java	
@@ -0,0 +1,32 @@
+class Solution {
+    public static int maxRemoval(int[] nums, int[][] queries) {
+        int n = nums.length, q = queries.length;
+        List> qEnd = new ArrayList<>();
+        for (int i = 0; i < n; i++) qEnd.add(new ArrayList<>());
+        for (int[] query : queries) {
+            qEnd.get(query[0]).add(query[1]);
+        }
+
+        PriorityQueue pq = new PriorityQueue<>(Collections.reverseOrder());
+        int[] cntQ = new int[n + 1];
+        int dec = 0;
+
+        for (int i = 0; i < n; i++) {
+            dec += cntQ[i];
+            for (int end : qEnd.get(i)) {
+                pq.offer(end);
+            }
+
+            int x = nums[i];
+            while (x > dec && !pq.isEmpty() && pq.peek() >= i) {
+                int k = pq.poll();
+                cntQ[k + 1]--;
+                dec++;
+            }
+
+            if (x > dec) return -1;
+        }
+
+        return pq.size();
+    }
+}
From 761d45fd41f7b2833267d1a42d6c40928085164d Mon Sep 17 00:00:00 2001
From: Dipanita45 <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 22 May 2025 21:10:25 +0530
Subject: [PATCH 029/115] Zero Array Transformation III
---
 Zero Array Transformation III.java | 32 ++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 Zero Array Transformation III.java
diff --git a/Zero Array Transformation III.java b/Zero Array Transformation III.java
new file mode 100644
index 0000000000..72ecfedf0e
--- /dev/null
+++ b/Zero Array Transformation III.java	
@@ -0,0 +1,32 @@
+class Solution {
+    public static int maxRemoval(int[] nums, int[][] queries) {
+        int n = nums.length, q = queries.length;
+        List> qEnd = new ArrayList<>();
+        for (int i = 0; i < n; i++) qEnd.add(new ArrayList<>());
+        for (int[] query : queries) {
+            qEnd.get(query[0]).add(query[1]);
+        }
+
+        PriorityQueue pq = new PriorityQueue<>(Collections.reverseOrder());
+        int[] cntQ = new int[n + 1];
+        int dec = 0;
+
+        for (int i = 0; i < n; i++) {
+            dec += cntQ[i];
+            for (int end : qEnd.get(i)) {
+                pq.offer(end);
+            }
+
+            int x = nums[i];
+            while (x > dec && !pq.isEmpty() && pq.peek() >= i) {
+                int k = pq.poll();
+                cntQ[k + 1]--;
+                dec++;
+            }
+
+            if (x > dec) return -1;
+        }
+
+        return pq.size();
+    }
+}
\ No newline at end of file
From 625e1764a687df40dc68f72f4c9f982b3f70df2f Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 22 May 2025 21:21:03 +0530
Subject: [PATCH 030/115] Create Valid parenthesis.java
---
 Valid parenthesis.java | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Valid parenthesis.java
diff --git a/Valid parenthesis.java b/Valid parenthesis.java
new file mode 100644
index 0000000000..ff46fbc7af
--- /dev/null
+++ b/Valid parenthesis.java	
@@ -0,0 +1,22 @@
+bool isValid(char* s) {
+    int n = strlen(s);
+    char stack[n];
+    int top = -1;
+
+    for (int i = 0; i < n; i++) {
+        if (s[i] == '(' || s[i] == '{' || s[i] == '[') {
+            stack[++top] = s[i];
+        } else {
+            if (top == -1) {
+                return false;
+            }
+            char last = stack[top];
+            if ((last == '(' && s[i] == ')') || (last == '{' && s[i] == '}') || (last == '[' && s[i] == ']')) {
+                top--;
+            } else {
+                return false;
+            }
+        }
+    }
+    return top == -1;
+}
From 8e676f9d5aeab74facf60bc0d25b24939b73869f Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 23 May 2025 19:07:34 +0530
Subject: [PATCH 031/115] Create Reverse Integer.cpp
---
 Reverse Integer.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 Reverse Integer.cpp
diff --git a/Reverse Integer.cpp b/Reverse Integer.cpp
new file mode 100644
index 0000000000..e24130d942
--- /dev/null
+++ b/Reverse Integer.cpp	
@@ -0,0 +1,18 @@
+class Solution {
+public:
+    int reverse(int x) {
+        int ans = 0; // Initialize the reversed number to 0
+        while (x != 0) {
+            int digit = x % 10; // Get the last digit of x
+            
+            // Check for overflow/underflow before updating ans
+            if ((ans > INT_MAX / 10) || (ans < INT_MIN / 10)) {
+                return 0; // Return 0 if reversing x would cause overflow/underflow
+            }
+            
+            ans = ans * 10 + digit; // Append the digit to the reversed number
+            x = x / 10; // Remove the last digit from x
+        }
+        return ans; // Return the reversed number
+    }
+};
From a0f7c65631cabdeb86de7da16547c0f4f9a26114 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sat, 24 May 2025 12:57:36 +0530
Subject: [PATCH 032/115] Create Find Words Containing Character.java
---
 Find Words Containing Character.java | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 Find Words Containing Character.java
diff --git a/Find Words Containing Character.java b/Find Words Containing Character.java
new file mode 100644
index 0000000000..6d5cbed9ca
--- /dev/null
+++ b/Find Words Containing Character.java	
@@ -0,0 +1,13 @@
+class Solution {
+    public List findWordsContaining(String[] words, char x) {
+        List res=new ArrayList<>();
+        int n=words.length;
+        for(int i=0;i
Date: Sun, 25 May 2025 16:43:10 +0530
Subject: [PATCH 033/115] Create Longest palindrome by concatenating two
 words.java
---
 Longest palindrome by concatenating two words | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 Longest palindrome by concatenating two words
diff --git a/Longest palindrome by concatenating two words b/Longest palindrome by concatenating two words
new file mode 100644
index 0000000000..0b89c378c4
--- /dev/null
+++ b/Longest palindrome by concatenating two words	
@@ -0,0 +1,31 @@
+import java.util.*;
+
+class Solution {
+    public int longestPalindrome(String[] words) {
+        Map map = new HashMap<>();
+        int count = 0;
+        boolean hasCentralWord = false;
+
+        for (String word : words)
+            map.put(word, map.getOrDefault(word, 0) + 1);
+
+        for (String word : map.keySet()) {
+            int freq = map.get(word);
+            if (freq == 0) continue;
+
+            String reversed = new StringBuilder(word).reverse().toString();
+            if (word.equals(reversed)) {
+                count += (freq / 2) * 4;
+                if (freq % 2 == 1) hasCentralWord = true;
+            } else if (map.containsKey(reversed)) {
+                int pairs = Math.min(freq, map.get(reversed));
+                count += pairs * 4;
+                map.put(reversed, 0);
+            }
+            map.put(word, 0);
+        }
+
+        if (hasCentralWord) count += 2;
+        return count;
+    }
+}
From 17066bcdc28ca33f99f5ae9c10a2be1fa615a689 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 26 May 2025 19:27:09 +0530
Subject: [PATCH 034/115] Create Add Two Numbers.java
---
 Add Two Numbers.java | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Add Two Numbers.java
diff --git a/Add Two Numbers.java b/Add Two Numbers.java
new file mode 100644
index 0000000000..2a5b96c1b1
--- /dev/null
+++ b/Add Two Numbers.java	
@@ -0,0 +1,22 @@
+class Solution {
+    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
+        ListNode dummy = new ListNode();
+        ListNode cur=dummy;
+        int carry=0;
+        while(l1!=null || l2!=null || carry!=0){
+            int sum=carry;
+            if(l1!=null){
+                sum +=l1.val;
+                l1=l1.next;
+            }
+            if (l2 != null) {
+                sum += l2.val;
+                l2 = l2.next;
+            }
+            carry = sum / 10;
+            cur.next = new ListNode(sum % 10);
+            cur = cur.next;
+        }
+        return dummy.next;
+    }
+}
From 037cd67ce86ce2877db1fedc5f00eace57d29a1d Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 27 May 2025 08:46:11 +0530
Subject: [PATCH 035/115] Create Divisible And Non-divisible Sum
 Differences.java
---
 Divisible And Non-divisible Sum Differences.java | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 Divisible And Non-divisible Sum Differences.java
diff --git a/Divisible And Non-divisible Sum Differences.java b/Divisible And Non-divisible Sum Differences.java
new file mode 100644
index 0000000000..6e63287990
--- /dev/null
+++ b/Divisible And Non-divisible Sum Differences.java	
@@ -0,0 +1,13 @@
+class Solution {
+    public int differenceOfSums(int n, int m) {
+        int ans=0;
+        for(int i=1;i<=n;i++){
+            if(i % m ==0){
+                ans-=i;
+            }else{
+                ans+=i;
+            }
+        }
+        return ans;
+    }
+}
From c6a57ba3bd12c248978a297c06392a73e45a9e8c Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 28 May 2025 08:35:08 +0530
Subject: [PATCH 036/115] Create Reverse Integer . java
---
 Java/Reverse Integer . java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Java/Reverse Integer . java
diff --git a/Java/Reverse Integer . java b/Java/Reverse Integer . java
new file mode 100644
index 0000000000..da0fe250b1
--- /dev/null
+++ b/Java/Reverse Integer . java	
@@ -0,0 +1,16 @@
+class Solution {
+    public int reverse(int x) {
+        int ans = 0;
+        while(x != 0){
+            int rem = x % 10;
+            if(ans < Integer.MIN_VALUE/10 || ans > Integer.MAX_VALUE/10)
+                return 0;
+            ans = (ans*10) + rem;
+            x = x/10;
+
+        }
+
+        return ans;
+
+    }
+}
From 4cfbb7adc251f168af093f1797606a1f05860891 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 29 May 2025 08:44:11 +0530
Subject: [PATCH 037/115] Create Palindrome Number.cpp
---
 C++/Palindrome Number.cpp | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 C++/Palindrome Number.cpp
diff --git a/C++/Palindrome Number.cpp b/C++/Palindrome Number.cpp
new file mode 100644
index 0000000000..40a8b56aad
--- /dev/null
+++ b/C++/Palindrome Number.cpp	
@@ -0,0 +1,25 @@
+class Solution {
+public:
+        int reverse(int x){
+        int revNum=0;
+        while(x!=0)
+        {
+            int dig=x%10;
+            if(revNum>INT_MAX/10 || revNum
Date: Fri, 30 May 2025 08:53:42 +0530
Subject: [PATCH 038/115] Create Longest Palindromic Substring.java
---
 Java/Longest Palindromic Substring.java | 36 +++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 Java/Longest Palindromic Substring.java
diff --git a/Java/Longest Palindromic Substring.java b/Java/Longest Palindromic Substring.java
new file mode 100644
index 0000000000..a7b19c40bd
--- /dev/null
+++ b/Java/Longest Palindromic Substring.java	
@@ -0,0 +1,36 @@
+public class Solution {
+    public String longestPalindrome(String s) {
+        if (s.length() <= 1) {
+            return s;
+        }
+
+        int maxLen = 1;
+        String maxStr = s.substring(0, 1);
+
+        for (int i = 0; i < s.length(); i++) {
+            for (int j = i + maxLen; j <= s.length(); j++) {
+                if (j - i > maxLen && isPalindrome(s.substring(i, j))) {
+                    maxLen = j - i;
+                    maxStr = s.substring(i, j);
+                }
+            }
+        }
+
+        return maxStr;
+    }
+
+    private boolean isPalindrome(String str) {
+        int left = 0;
+        int right = str.length() - 1;
+
+        while (left < right) {
+            if (str.charAt(left) != str.charAt(right)) {
+                return false;
+            }
+            left++;
+            right--;
+        }
+
+        return true;
+    }
+}
From 973f390519b4c1fd6cbeae66b649d5b83a3d4a51 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sat, 31 May 2025 10:42:01 +0530
Subject: [PATCH 039/115] Create Snakes And Ladders.java
---
 Java/Snakes And Ladders.java | 48 ++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Java/Snakes And Ladders.java
diff --git a/Java/Snakes And Ladders.java b/Java/Snakes And Ladders.java
new file mode 100644
index 0000000000..7910770562
--- /dev/null
+++ b/Java/Snakes And Ladders.java	
@@ -0,0 +1,48 @@
+class Solution {
+    public int snakesAndLadders(int[][] board) {
+        int n = board.length;
+        boolean[] visited = new boolean[n * n + 1];
+        Queue queue = new LinkedList<>();
+        queue.offer(new int[]{1, 0}); // {square number, number of moves}
+        visited[1] = true;
+
+        while (!queue.isEmpty()) {
+            int[] curr = queue.poll();
+            int square = curr[0];
+            int moves = curr[1];
+
+            for (int i = 1; i <= 6; i++) {
+                int next = square + i;
+                if (next > n * n) continue;
+
+                int[] pos = getCoordinates(next, n);
+                int r = pos[0], c = pos[1];
+
+                if (board[r][c] != -1) {
+                    next = board[r][c];
+                }
+
+                if (next == n * n) {
+                    return moves + 1;
+                }
+
+                if (!visited[next]) {
+                    visited[next] = true;
+                    queue.offer(new int[]{next, moves + 1});
+                }
+            }
+        }
+
+        return -1; // unreachable
+    }
+
+    // Converts 1-based square number to (row, col) in board
+    private int[] getCoordinates(int num, int n) {
+        int r = (n - 1) - (num - 1) / n;
+        int c = (num - 1) % n;
+        if (((n - 1 - r) % 2) == 1) {
+            c = n - 1 - c;
+        }
+        return new int[]{r, c};
+    }
+}
From 875a93cf677b27e1d555b508ad4c2aefeeacec6b Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sun, 1 Jun 2025 09:29:37 +0530
Subject: [PATCH 040/115] Create Distribute Candies Among Children II .java
---
 Java/Distribute Candies Among Children II .java | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 Java/Distribute Candies Among Children II .java
diff --git a/Java/Distribute Candies Among Children II .java b/Java/Distribute Candies Among Children II .java
new file mode 100644
index 0000000000..2cd3b4f794
--- /dev/null
+++ b/Java/Distribute Candies Among Children II .java	
@@ -0,0 +1,14 @@
+class Solution {
+    public long distributeCandies(int n, int limit) {
+        java.util.function.LongUnaryOperator C2 = x -> (x >= 2) ? (x * (x - 1) / 2) : 0L;
+        long N = n, L = limit;
+        long total = (N + 2) * (N + 1) / 2;
+        long x1 = N - L + 1; 
+        long t1 = C2.applyAsLong(x1);
+        long x2 = N - 2 * L;
+        long t2 = C2.applyAsLong(x2);
+        long x3 = N - 3 * L - 1;
+        long t3 = C2.applyAsLong(x3);
+        return total - 3 * t1 + 3 * t2 - t3;
+    }
+}
From 4c13f67e5cd4e59296564c8f561f732b945fdc69 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 2 Jun 2025 09:36:47 +0530
Subject: [PATCH 041/115] Create Candy.java
---
 Java/Candy.java | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Java/Candy.java
diff --git a/Java/Candy.java b/Java/Candy.java
new file mode 100644
index 0000000000..2c29a5df20
--- /dev/null
+++ b/Java/Candy.java
@@ -0,0 +1,29 @@
+class Solution {
+    public int candy(int[] ratings) {
+        int n = ratings.length;
+        int[] cand = new int[n];
+        Arrays.fill(cand, 1); // Step 1: Each child gets at least one candy
+
+        // Step 2: Left to right pass
+        for (int i = 1; i < n; i++) {
+            if (ratings[i] > ratings[i - 1]) {
+                cand[i] = cand[i - 1] + 1;
+            }
+        }
+
+        // Step 3: Right to left pass
+        for (int i = n - 2; i >= 0; i--) {
+            if (ratings[i] > ratings[i + 1] && cand[i] <= cand[i + 1]) {
+                cand[i] = cand[i + 1] + 1;
+            }
+        }
+
+        // Step 4: Sum all candies
+        int ans = 0;
+        for (int c : cand) {
+            ans += c;
+        }
+
+        return ans;
+    }
+}
From f48c37a2c280f80c7f217a9a0cf3340e6ad45a55 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 2 Jun 2025 09:38:54 +0530
Subject: [PATCH 042/115] Create Zigzag Conversion
---
 C++/Zigzag Conversion | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 C++/Zigzag Conversion
diff --git a/C++/Zigzag Conversion b/C++/Zigzag Conversion
new file mode 100644
index 0000000000..4b4d073fa8
--- /dev/null
+++ b/C++/Zigzag Conversion	
@@ -0,0 +1,33 @@
+
+
+class Solution {
+public:
+
+    string convert(string s, int numRows) {
+    
+    if(numRows <= 1) return s;
+
+    vectorv(numRows, ""); 
+
+    int j = 0, dir = -1;
+
+    for(int i = 0; i < s.length(); i++)
+    {
+
+        if(j == numRows - 1 || j == 0) dir *= (-1); 
+		 
+        v[j] += s[i];
+
+        if(dir == 1) j++;
+
+        else j--;
+    }
+
+    string res;
+
+    for(auto &it : v) res += it; 
+
+    return res;
+
+    }
+};
From 6c4c7544fb152e37275bef72acbb0a8b10bfb897 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 3 Jun 2025 09:00:04 +0530
Subject: [PATCH 043/115] Create Divide Two Integers.java
---
 Java/Divide Two Integers.java | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 Java/Divide Two Integers.java
diff --git a/Java/Divide Two Integers.java b/Java/Divide Two Integers.java
new file mode 100644
index 0000000000..dc074a186b
--- /dev/null
+++ b/Java/Divide Two Integers.java	
@@ -0,0 +1,25 @@
+class Solution {
+    public int divide(int dividend, int divisor) {
+        if (divisor == 1) {
+            return dividend;
+        }
+        if (dividend == Integer.MIN_VALUE && divisor == -1) {
+            return Integer.MAX_VALUE;
+        }
+        boolean sign = (dividend> 0 && divisor > 0) || (dividend< 0 && divisor< 0);
+        dividend= dividend > 0 ? -dividend : dividend;
+        divisor = divisor > 0 ? -divisor : divisor;
+        int ans = 0;
+        while (dividend <= divisor) {
+            int x = divisor;
+            int cnt = 1;
+            while (x >= (Integer.MIN_VALUE >> 1) && dividend <= (x << 1)) {
+                x <<= 1;
+                cnt <<= 1;
+            }
+            ans += cnt;
+            dividend-= x;
+        }
+        return sign ? ans : -ans;
+    }
+}
From 56a678c22972144c126609abcb9d42f0a4513987 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 4 Jun 2025 09:39:08 +0530
Subject: [PATCH 044/115] Create Find the Lexicographically Largest string from
 the box .java
---
 ...raphically Largest string from the box .java | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Java/Find the Lexicographically Largest string from the box .java
diff --git a/Java/Find the Lexicographically Largest string from the box .java b/Java/Find the Lexicographically Largest string from the box .java
new file mode 100644
index 0000000000..24e571c0f6
--- /dev/null
+++ b/Java/Find the Lexicographically Largest string from the box .java	
@@ -0,0 +1,17 @@
+class Solution {
+
+    public String answerString(String word, int numFriends) {
+        if (numFriends == 1) {
+            return word;
+        }
+        int n = word.length();
+        String res = "";
+        for (int i = 0; i < n; i++) {
+            String s = word.substring(i, Math.min(i + n - numFriends + 1, n));
+            if (res.compareTo(s) <= 0) {
+                res = s;
+            }
+        }
+        return res;
+    }
+}
From 5db6813ec0772d9e2048e9380f8de4ce3d2fcaaf Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 5 Jun 2025 08:46:54 +0530
Subject: [PATCH 045/115] Create Roman To Integer.cpp
---
 C++/Roman To Integer.cpp | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 C++/Roman To Integer.cpp
diff --git a/C++/Roman To Integer.cpp b/C++/Roman To Integer.cpp
new file mode 100644
index 0000000000..2ff259aab2
--- /dev/null
+++ b/C++/Roman To Integer.cpp	
@@ -0,0 +1,27 @@
+class Solution {
+public:
+    int char2num(char a) {
+        switch (a) {
+            case 'I': return 1;
+            case 'V': return 5;
+            case 'X': return 10;
+            case 'L': return 50;
+            case 'C': return 100;
+            case 'D': return 500;
+            case 'M': return 1000;
+            default: return 0;
+        }
+    }
+
+    int romanToInt(string s) {
+        int result = 0;
+        for (int i = 0; i < s.length(); i++) {
+            if (i + 1 < s.length() && char2num(s[i]) < char2num(s[i + 1])) {
+                result -= char2num(s[i]);
+            } else {
+                result += char2num(s[i]);
+            }
+        }
+        return result;
+    }
+};
From 5d77cdb464cfe1c2b98d16fc08a97b3bb92f5b17 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 6 Jun 2025 10:43:05 +0530
Subject: [PATCH 046/115] Create Using a Robot to Print the Lexicographically
 the Smallest String .java
---
 ...exicographically the Smallest String .java | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 Java/Using a Robot to Print the Lexicographically the Smallest String .java
diff --git a/Java/Using a Robot to Print the Lexicographically the Smallest String .java b/Java/Using a Robot to Print the Lexicographically the Smallest String .java
new file mode 100644
index 0000000000..f57a17ef37
--- /dev/null
+++ b/Java/Using a Robot to Print the Lexicographically the Smallest String .java	
@@ -0,0 +1,43 @@
+class Solution 
+{
+    public String robotWithString(String s) 
+    {
+        int n = s.length();
+
+        // Step 1: Initialize min_suffix array
+        char[] minSuffix = new char[n];
+        minSuffix[n - 1] = s.charAt(n - 1);
+
+        // Step 2: Fill min_suffix from right to left
+        for (int i = n - 2; i >= 0; i--) 
+        {
+            minSuffix[i] = (char)Math.min(s.charAt(i), minSuffix[i + 1]);
+        }
+
+        // Step 3: Initialize result and stack
+        Deque stack = new ArrayDeque<>();
+        StringBuilder result = new StringBuilder();
+        int i = 0;
+
+        // Step 4: Process characters from s
+        while (i < n) 
+        {
+            stack.push(s.charAt(i++)); // Push to t
+
+            // Step 4 (cont.): Pop from t to result if top is safe
+            while (!stack.isEmpty() && stack.peek() <= minSuffix[i == n ? n - 1 : i]) 
+            {
+                result.append(stack.pop());
+            }
+        }
+
+        // Step 5: Clean remaining stack
+        while (!stack.isEmpty()) 
+        {
+            result.append(stack.pop());
+        }
+
+        // Step 6: Return result
+        return result.toString();
+    }
+}
From 3f811fea346737a9af800fbf9777341ceb08f6f1 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sat, 7 Jun 2025 10:08:44 +0530
Subject: [PATCH 047/115] Create Integer To Roman.java
---
 Java/Integer To Roman.java | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 Java/Integer To Roman.java
diff --git a/Java/Integer To Roman.java b/Java/Integer To Roman.java
new file mode 100644
index 0000000000..05718dc1bf
--- /dev/null
+++ b/Java/Integer To Roman.java	
@@ -0,0 +1,13 @@
+class Solution {
+    public String intToRoman(int num) {
+        String Roman = "";
+        int[][] storeIntRoman = {{1000, "M"}, {900, "CM"}, {500, "D"}, {400, "CD"}, {100, "C"}, {90, "XC"}, {50, "L"}, {40, "XL"}, {10, "X"}, {9, "IX"}, {5, "V"}, {4, "IV"}, {1, "I"}};
+        for (int i = 0; i < storeIntRoman.length; i++) {
+            while (num >= storeIntRoman[i][0]) {
+                Roman += storeIntRoman[i][1];
+                num -= storeIntRoman[i][0];
+            }
+        }
+        return Roman;
+    }
+}
From 8c4e53ef73c777b019c4aed526e2b49aab7662a2 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sun, 8 Jun 2025 10:55:09 +0530
Subject: [PATCH 048/115] Create Lexicographical Numbers
---
 Python3/Lexicographical Numbers | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 Python3/Lexicographical Numbers
diff --git a/Python3/Lexicographical Numbers b/Python3/Lexicographical Numbers
new file mode 100644
index 0000000000..234f0d2d1f
--- /dev/null
+++ b/Python3/Lexicographical Numbers	
@@ -0,0 +1,9 @@
+class Solution:
+    def lexicalOrder(self, n: int) -> List[int]:
+        l=[] # take list
+        for i in range (1, n+1) :
+            l.append(str(i)) # store all n numbers as string 
+        l.sort() # list is sorted to get lexicographical 
+        for i in range(n):
+            l[i]=int(l[i]) # convert all strings into integers
+        return l
From 4a87008a7dd1dd140ffb371530a64d53434764ad Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 9 Jun 2025 10:03:16 +0530
Subject: [PATCH 049/115] Create Kth Smallest in Lexicograpical Order
---
 Java/Kth Smallest in Lexicograpical Order | 34 +++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Java/Kth Smallest in Lexicograpical Order
diff --git a/Java/Kth Smallest in Lexicograpical Order b/Java/Kth Smallest in Lexicograpical Order
new file mode 100644
index 0000000000..0226dbe777
--- /dev/null
+++ b/Java/Kth Smallest in Lexicograpical Order	
@@ -0,0 +1,34 @@
+class Solution {
+
+    public int findKthNumber(int n, int k) {
+        int curr = 1;
+        k--;
+
+        while (k > 0) {
+            int step = countSteps(n, curr, curr + 1);
+            // If the steps are less than or equal to k, we skip this prefix's subtree
+            if (step <= k) {
+                // Move to the next prefix and decrease k by the number of steps we skip
+                curr++;
+                k -= step;
+            } else {
+                // Move to the next level of the tree and decrement k by 1
+                curr *= 10;
+                k--;
+            }
+        }
+
+        return curr;
+    }
+
+    // To count how many numbers exist between prefix1 and prefix2
+    private int countSteps(int n, long prefix1, long prefix2) {
+        int steps = 0;
+        while (prefix1 <= n) {
+            steps += Math.min(n + 1, prefix2) - prefix1;
+            prefix1 *= 10;
+            prefix2 *= 10;
+        }
+        return steps;
+    }
+}
From b63b8bfc566f47038598d6494ed14ca43ec562fd Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 10 Jun 2025 08:59:38 +0530
Subject: [PATCH 050/115] Create Maximum Difference Between Even and Odd
 frequency I.java
---
 ...erence Between Even and Odd frequency I.java | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Java/Maximum Difference Between Even and Odd frequency I.java
diff --git a/Java/Maximum Difference Between Even and Odd frequency I.java b/Java/Maximum Difference Between Even and Odd frequency I.java
new file mode 100644
index 0000000000..a53ef150f5
--- /dev/null
+++ b/Java/Maximum Difference Between Even and Odd frequency I.java	
@@ -0,0 +1,17 @@
+class Solution {
+    public int maxDifference(String s) {
+        Map freq = new HashMap<>();
+        for (int i = 0; i < s.length(); i++) {
+            char c = s.charAt(i);
+            freq.put(c, freq.getOrDefault(c, 0) + 1);
+        }
+        int maxOdd = -1;
+        int minEven = Integer.MAX_VALUE;
+        for (int f : freq.values()) {
+            if ((f & 1) == 1) maxOdd = Math.max(maxOdd, f);
+            else minEven = Math.min(minEven, f);
+        }
+        if (maxOdd == -1 || minEven == Integer.MAX_VALUE) return -1;
+        return maxOdd - minEven;
+    }
+}
From 5a5b04f7f85cbaf9ecafe3371b2b3f70ca1d7180 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 11 Jun 2025 19:40:29 +0530
Subject: [PATCH 051/115] Create Maximum Difference Between Even and Odd
 Frequency II .java
---
 ...ce Between Even and Odd Frequency II .java | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Java/Maximum Difference Between Even and Odd Frequency II .java
diff --git a/Java/Maximum Difference Between Even and Odd Frequency II .java b/Java/Maximum Difference Between Even and Odd Frequency II .java
new file mode 100644
index 0000000000..13ffa173b2
--- /dev/null
+++ b/Java/Maximum Difference Between Even and Odd Frequency II .java	
@@ -0,0 +1,48 @@
+class Solution {
+
+    public int maxDifference(String s, int k) {
+        int n = s.length();
+        int ans = Integer.MIN_VALUE;
+        for (char a = '0'; a <= '4'; ++a) {
+            for (char b = '0'; b <= '4'; ++b) {
+                if (a == b) {
+                    continue;
+                }
+                int[] best = new int[4];
+                Arrays.fill(best, Integer.MAX_VALUE);
+                int cnt_a = 0, cnt_b = 0;
+                int prev_a = 0, prev_b = 0;
+                int left = -1;
+
+                for (int right = 0; right < n; ++right) {
+                    cnt_a += (s.charAt(right) == a) ? 1 : 0;
+                    cnt_b += (s.charAt(right) == b) ? 1 : 0;
+
+                    while (right - left >= k && cnt_b - prev_b >= 2) {
+                        int left_status = getStatus(prev_a, prev_b);
+                        best[left_status] = Math.min(
+                            best[left_status],
+                            prev_a - prev_b
+                        );
+                        ++left;
+                        prev_a += (s.charAt(left) == a) ? 1 : 0;
+                        prev_b += (s.charAt(left) == b) ? 1 : 0;
+                    }
+
+                    int right_status = getStatus(cnt_a, cnt_b);
+                    if (best[right_status ^ 0b10] != Integer.MAX_VALUE) {
+                        ans = Math.max(
+                            ans,
+                            cnt_a - cnt_b - best[right_status ^ 0b10]
+                        );
+                    }
+                }
+            }
+        }
+        return ans;
+    }
+
+    private int getStatus(int cnt_a, int cnt_b) {
+        return ((cnt_a & 1) << 1) | (cnt_b & 1);
+    }
+}
From 73555fdf625d4a128e6036ef79ced712eb6b9223 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 12 Jun 2025 08:22:07 +0530
Subject: [PATCH 052/115] Create Maximum Difference between adjacent elements
 in a Circular Array.java
---
 ... between adjacent elements in a Circular Array.java | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 Java/Maximum Difference between adjacent elements in a Circular Array.java
diff --git a/Java/Maximum Difference between adjacent elements in a Circular Array.java b/Java/Maximum Difference between adjacent elements in a Circular Array.java
new file mode 100644
index 0000000000..397823b7bb
--- /dev/null
+++ b/Java/Maximum Difference between adjacent elements in a Circular Array.java	
@@ -0,0 +1,10 @@
+class Solution {
+   public int maxAdjacentDistance(int[] nums) {
+        int n = nums.length;
+        int res = Math.abs(nums[0] - nums[n - 1]);
+        for (int i = 0; i < n - 1; ++i) {
+            res = Math.max(res, Math.abs(nums[i] - nums[i + 1]));
+        }
+        return res;
+    }
+}  
From 40a01be1834fb217e5f9e0ea14f51e43c71596bc Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 13 Jun 2025 07:27:33 +0530
Subject: [PATCH 053/115] Create Minimize the Maximum Difference of Pairs.java
---
 ...imize the Maximum Difference of Pairs.java | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Java/Minimize the Maximum Difference of Pairs.java
diff --git a/Java/Minimize the Maximum Difference of Pairs.java b/Java/Minimize the Maximum Difference of Pairs.java
new file mode 100644
index 0000000000..21c5e56d6f
--- /dev/null
+++ b/Java/Minimize the Maximum Difference of Pairs.java	
@@ -0,0 +1,34 @@
+class Solution {
+    // Find the number of valid pairs by greedy approach
+    private int countValidPairs(int[] nums, int threshold) {
+        int index = 0, count = 0;
+        while (index < nums.length - 1) {
+            // If a valid pair is found, skip both numbers.
+            if (nums[index + 1] - nums[index] <= threshold) {
+                count++;
+                index++;
+            }
+            index++;
+        }
+        return count;
+    }
+
+    public int minimizeMax(int[] nums, int p) {
+        Arrays.sort(nums);
+        int n = nums.length;
+        int left = 0, right = nums[n - 1] - nums[0];
+
+        while (left < right) {
+            int mid = left + (right - left) / 2;
+
+            // If there are enough pairs, look for a smaller threshold.
+            // Otherwise, look for a larger threshold.
+            if (countValidPairs(nums, mid) >= p) {
+                right = mid;
+            } else {
+                left = mid + 1;
+            }
+        }
+        return left;
+    }
+}
From 6be2239f2643c7fa51fb6af15d8fc45a4400de83 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sat, 14 Jun 2025 12:28:39 +0530
Subject: [PATCH 054/115] Create Maximum Difference By Remapping a Digit.java
---
 .../Maximum Difference By Remapping a Digit.java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Java/Maximum Difference By Remapping a Digit.java
diff --git a/Java/Maximum Difference By Remapping a Digit.java b/Java/Maximum Difference By Remapping a Digit.java
new file mode 100644
index 0000000000..9ad5fdd477
--- /dev/null
+++ b/Java/Maximum Difference By Remapping a Digit.java	
@@ -0,0 +1,16 @@
+class Solution {
+
+    public int minMaxDifference(int num) {
+        String s = Integer.toString(num);
+        String t = s;
+        int pos = 0;
+        while (pos < s.length() && s.charAt(pos) == '9') {
+            pos++;
+        }
+        if (pos < s.length()) {
+            s = s.replace(s.charAt(pos), '9');
+        }
+        t = t.replace(t.charAt(0), '0');
+        return Integer.parseInt(s) - Integer.parseInt(t);
+    }
+}
From 502be1628ac77b70bc36cf57c06e4601648d7d07 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sun, 15 Jun 2025 09:55:30 +0530
Subject: [PATCH 055/115] Create Max Difference You Can Get From Changing An
 Integer.cpp
---
 ...e You Can Get From Changing An Integer.cpp | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 C++/Max Difference You Can Get From Changing An Integer.cpp
diff --git a/C++/Max Difference You Can Get From Changing An Integer.cpp b/C++/Max Difference You Can Get From Changing An Integer.cpp
new file mode 100644
index 0000000000..9b7a51773e
--- /dev/null
+++ b/C++/Max Difference You Can Get From Changing An Integer.cpp	
@@ -0,0 +1,34 @@
+class Solution {
+public:
+    int maxDiff(int num) {
+        string str1 = to_string(num);
+        string str2 = str1;
+        int n = str1.size();
+        // Get max number
+        int i;
+        for(i = 0; i < n; i++) {
+            if(str1[i] != '9') break;
+        }
+        char ele1 = str1[i];
+        for(int k = 0; k < n; k++) {
+            if(str1[k] == ele1) str1[k] = '9';
+        }
+        // Get min number
+        char ele2 = str2[0];
+        char replace = '1';
+        if(ele2 == '1') {
+            for(int k = 1; k < n; k++) {
+                if(str2[k] != '0' && str2[k] != '1') {
+                    ele2 = str2[k];
+                    replace = '0';
+                    break;
+                }
+            }
+        }
+        for(int k = 0; k < n; k++) {
+            if(str2[k] == ele2) str2[k] = replace;
+        }
+
+        return stoi(str1) - stoi(str2);
+    }
+};
From dd7ecf498af446e4bf51d23dec82823c1cf33706 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 17 Jun 2025 08:48:09 +0530
Subject: [PATCH 056/115] Create Count the number of Arrays with K Matching
 Adjacent Elements.java
---
 ...ays with K Matching Adjacent Elements.java | 55 +++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 Java/Count the number of Arrays with K Matching Adjacent Elements.java
diff --git a/Java/Count the number of Arrays with K Matching Adjacent Elements.java b/Java/Count the number of Arrays with K Matching Adjacent Elements.java
new file mode 100644
index 0000000000..02213c13bb
--- /dev/null
+++ b/Java/Count the number of Arrays with K Matching Adjacent Elements.java	
@@ -0,0 +1,55 @@
+class Solution {
+    // Modulo for all calculations
+    int mod = 1_000_000_007;
+
+    // Arrays to store factorials and modular inverses
+    static long[] revs = new long[100001]; // Not used in this version
+    static int[] f = new int[100001];      // Factorials
+
+    // Main function to count good arrays
+    public int countGoodArrays(int n, int m, int k) {
+        // Base case: factorial[0] = 1
+        if (f[0] == 0)
+            f[0] = 1;
+
+        // Formula:
+        // m               --> choose value for the first element
+        // pow(m-1, n-1-k) --> number of ways to keep same value (for n-1-k positions)
+        // C(n-1, n-1-k)   --> choose positions to remain the same among (n-1)
+        long res = m * pow(m - 1, n - 1 - k) % mod * C(n - 1, n - 1 - k) % mod;
+        
+        return (int) res;
+    }
+
+    // Fast exponentiation: computes (a^b) % mod
+    public long pow(int a, int b) {
+        long res = 1;
+        long base = a;
+        while (b > 0) {
+            if ((b & 1) == 1)
+                res = res * base % mod;
+            base = base * base % mod;
+            b /= 2;
+        }
+        return res;
+    }
+
+    // Computes nCr % mod using factorial and modular inverse
+    public long C(int a, int b) {
+        return (long) getF(a) * rev(getF(a - b)) % mod * rev(getF(b)) % mod;
+    }
+
+    // Computes factorial with memoization: f[a] = a!
+    public long getF(int a) {
+        if (f[a] != 0)
+            return f[a];
+        return f[a] = (int) (getF(a - 1) * a % mod);
+    }
+
+    // Modular inverse using Fermat's Little Theorem: a^(-1) β‘ a^(mod - 2)
+    public long rev(long a) {
+        if (a == 1)
+            return a;
+        return mod - mod / a * rev(mod % a) % mod;
+    }
+}
From 8f481bfbd319f5b832469bf51b813dcc1d640f33 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 18 Jun 2025 09:08:32 +0530
Subject: [PATCH 057/115] Create Divide Array Into Arrays With Max
 Difference.cpp
---
 ...Divide Array Into Arrays With Max Difference.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 C++/Divide Array Into Arrays With Max Difference.cpp
diff --git a/C++/Divide Array Into Arrays With Max Difference.cpp b/C++/Divide Array Into Arrays With Max Difference.cpp
new file mode 100644
index 0000000000..ab357638da
--- /dev/null
+++ b/C++/Divide Array Into Arrays With Max Difference.cpp	
@@ -0,0 +1,13 @@
+class Solution {
+public:
+    vector> divideArray(vector& nums, int k) {
+        vector> ans;
+        int n=nums.size();
+        sort(nums.begin(),nums.end());
+        for(int i=0;ik) return {};
+            ans.push_back({nums[i],nums[i+1],nums[i+2]});
+        }
+        return ans;
+    }
+};
From c5b75b78f21e4fde86511649f198065b71113a5f Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 19 Jun 2025 09:10:26 +0530
Subject: [PATCH 058/115] Create Partition Array Such That Maximum Difference
 is K.java
---
 ...n Array Such That Maximum Difference is K.java | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Java/Partition Array Such That Maximum Difference is K.java
diff --git a/Java/Partition Array Such That Maximum Difference is K.java b/Java/Partition Array Such That Maximum Difference is K.java
new file mode 100644
index 0000000000..cad0e6fa30
--- /dev/null
+++ b/Java/Partition Array Such That Maximum Difference is K.java	
@@ -0,0 +1,15 @@
+class Solution {
+
+    public int partitionArray(int[] nums, int k) {
+        Arrays.sort(nums);
+        int ans = 1;
+        int rec = nums[0];
+        for (int i = 0; i < nums.length; i++) {
+            if (nums[i] - rec > k) {
+                ans++;
+                rec = nums[i];
+            }
+        }
+        return ans;
+    }
+}
From 4d664d117cec46a68da327f01e3e96b6e29f5d63 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 20 Jun 2025 18:56:37 +0530
Subject: [PATCH 059/115] Create String to Integer(atoi).java
---
 Java/String to Integer(atoi).java | 49 +++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Java/String to Integer(atoi).java
diff --git a/Java/String to Integer(atoi).java b/Java/String to Integer(atoi).java
new file mode 100644
index 0000000000..90a0d26857
--- /dev/null
+++ b/Java/String to Integer(atoi).java	
@@ -0,0 +1,49 @@
+class Solution {
+    public int myAtoi(String s) {
+        // Step 1: Trim leading/trailing whitespaces
+        s = s.trim();
+
+        // Initialize result
+        int res = 0;
+        int n = s.length();
+        if (n < 1)
+            return res; // return 0 for empty string
+
+        // Step 2: Determine the sign
+        int sign = 1;
+        int base = 0;
+        int i = 0;
+
+        // Skip any leading spaces (already trimmed, but this is defensive)
+        while (i < n && s.charAt(i) == ' ')
+            i++;
+
+        // Check if the next character is '+' or '-'
+        if (i < n && (s.charAt(i) == '-' || s.charAt(i) == '+')) {
+            if (s.charAt(i) == '-') {
+                sign = -1;
+            }
+            i++;
+        }
+
+        // Step 3: Convert the numeric characters to integer
+        while (i < n && s.charAt(i) >= '0' && s.charAt(i) <= '9') {
+            int num = s.charAt(i) - '0';
+
+            // Step 4: Check for overflow before it happens
+            if (base > Integer.MAX_VALUE / 10 ||
+                    (base == Integer.MAX_VALUE / 10 && num > 7)) {
+                // Return max or min int depending on the sign
+                return sign == 1 ? Integer.MAX_VALUE : Integer.MIN_VALUE;
+            }
+
+            // Step 5: Append current digit
+            base = base * 10 + num;
+            i++;
+        }
+
+        // Step 6: Return final result with correct sign
+        return base * sign;
+    }
+}
+
From bdfca8666b059ac92ff3c0b2fa1fcdea08d6f2b7 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sat, 21 Jun 2025 10:57:44 +0530
Subject: [PATCH 060/115] Create Remove Nth Node From End of the List.java
---
 Java/Remove Nth Node From End of the List.java | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 Java/Remove Nth Node From End of the List.java
diff --git a/Java/Remove Nth Node From End of the List.java b/Java/Remove Nth Node From End of the List.java
new file mode 100644
index 0000000000..7202027646
--- /dev/null
+++ b/Java/Remove Nth Node From End of the List.java	
@@ -0,0 +1,13 @@
+class Solution {
+    public ListNode removeNthFromEnd(ListNode head, int n) {
+        ListNode res = new ListNode(0, head);
+        ListNode dummy = res;
+        for(int i=0;i
Date: Sun, 22 Jun 2025 11:02:39 +0530
Subject: [PATCH 061/115] Create Divide a String into Groups of size K.java
---
 ...Divide a String into Groups of size K.java | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Java/Divide a String into Groups of size K.java
diff --git a/Java/Divide a String into Groups of size K.java b/Java/Divide a String into Groups of size K.java
new file mode 100644
index 0000000000..b0fbbf9193
--- /dev/null
+++ b/Java/Divide a String into Groups of size K.java	
@@ -0,0 +1,22 @@
+class Solution {
+    public String[] divideString(String s, int k, char fill) {
+        int n = s.length();
+        int groups = (n + k - 1) / k;
+        String[] result = new String[groups];
+        
+        for (int i = 0; i < groups; i++) {
+            StringBuilder group = new StringBuilder();
+            for (int j = 0; j < k; j++) {
+                int index = i * k + j;
+                if (index < n) {
+                    group.append(s.charAt(index));
+                } else {
+                    group.append(fill); // Padding
+                }
+            }
+            result[i] = group.toString();
+        }
+        
+        return result;
+    }
+}
From 981cb04ec5cc7950df4d332b34476b70391f3f39 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 23 Jun 2025 11:19:47 +0530
Subject: [PATCH 062/115] Create Sum of k-Mirror Numbers.java
---
 Java/Sum of k-Mirror Numbers.java | 46 +++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 Java/Sum of k-Mirror Numbers.java
diff --git a/Java/Sum of k-Mirror Numbers.java b/Java/Sum of k-Mirror Numbers.java
new file mode 100644
index 0000000000..99c6bd4f32
--- /dev/null
+++ b/Java/Sum of k-Mirror Numbers.java	
@@ -0,0 +1,46 @@
+class Solution {
+
+    private int[] digit = new int[100];
+
+    public long kMirror(int k, int n) {
+        int left = 1, count = 0;
+        long ans = 0;
+        while (count < n) {
+            int right = left * 10;
+            // op = 0 indicates enumerating odd-length palindromes
+            // op = 1 indicates enumerating even-length palindromes
+            for (int op = 0; op < 2; ++op) {
+                // enumerate i'
+                for (int i = left; i < right && count < n; ++i) {
+                    long combined = i;
+                    int x = (op == 0 ? i / 10 : i);
+                    while (x > 0) {
+                        combined = combined * 10 + (x % 10);
+                        x /= 10;
+                    }
+                    if (isPalindrome(combined, k)) {
+                        ++count;
+                        ans += combined;
+                    }
+                }
+            }
+            left = right;
+        }
+        return ans;
+    }
+
+    private boolean isPalindrome(long x, int k) {
+        int length = -1;
+        while (x > 0) {
+            ++length;
+            digit[length] = (int) (x % k);
+            x /= k;
+        }
+        for (int i = 0, j = length; i < j; ++i, --j) {
+            if (digit[i] != digit[j]) {
+                return false;
+            }
+        }
+        return true;
+    }
+}
From b4b55b85686bccf70ae39361ec6e22ce7f12a0d2 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 24 Jun 2025 09:06:55 +0530
Subject: [PATCH 063/115] Create Find All K-Distant Indices in an Array.cpp
---
 C++/Find All K-Distant Indices in an Array.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 C++/Find All K-Distant Indices in an Array.cpp
diff --git a/C++/Find All K-Distant Indices in an Array.cpp b/C++/Find All K-Distant Indices in an Array.cpp
new file mode 100644
index 0000000000..1793c34b3c
--- /dev/null
+++ b/C++/Find All K-Distant Indices in an Array.cpp	
@@ -0,0 +1,15 @@
+class Solution {
+public:
+    vector findKDistantIndices(vector& nums, int key, int k) {
+        const int n=nums.size();
+        vector ans;
+        for(int i=0, j=0; i
Date: Tue, 24 Jun 2025 09:08:40 +0530
Subject: [PATCH 064/115] Create Find All K-Distant Indices in an Array.java
---
 Java/Find All K-Distant Indices in an Array.java | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Java/Find All K-Distant Indices in an Array.java
diff --git a/Java/Find All K-Distant Indices in an Array.java b/Java/Find All K-Distant Indices in an Array.java
new file mode 100644
index 0000000000..32ff081dc8
--- /dev/null
+++ b/Java/Find All K-Distant Indices in an Array.java	
@@ -0,0 +1,15 @@
+class Solution {
+    public List findKDistantIndices(int[] nums, int key, int k) {
+        List res=new ArrayList<>();
+        int n= nums.length;
+        for(int i=0;i
Date: Wed, 25 Jun 2025 08:45:43 +0530
Subject: [PATCH 065/115] Create Integer  To Roman.java
---
 Java/Integer  To Roman.java | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Java/Integer  To Roman.java
diff --git a/Java/Integer  To Roman.java b/Java/Integer  To Roman.java
new file mode 100644
index 0000000000..ecc37e2324
--- /dev/null
+++ b/Java/Integer  To Roman.java	
@@ -0,0 +1,17 @@
+class Solution {
+    public String intToRoman(int num) {
+        int[] n = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
+        String[] s = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
+        int i =0;
+        String str = new String(); 
+        while (num>0){
+            if (num>=n[i]){
+                str=str+s[i];
+                num-=n[i];
+            } else{
+                i++;
+            }
+        }
+        return str;
+    }
+}
From 750acb4ac503cdfab996f8a2dabaa3b2f057863c Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 26 Jun 2025 11:02:04 +0530
Subject: [PATCH 066/115] Create Longest Binary Subsequence Less Than or Equal
 to k.cpp
---
 ...ry Subsequence Less Than or Equal to k.cpp | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 C++/Longest Binary Subsequence Less Than or Equal to k.cpp
diff --git a/C++/Longest Binary Subsequence Less Than or Equal to k.cpp b/C++/Longest Binary Subsequence Less Than or Equal to k.cpp
new file mode 100644
index 0000000000..68955de95e
--- /dev/null
+++ b/C++/Longest Binary Subsequence Less Than or Equal to k.cpp	
@@ -0,0 +1,28 @@
+class Solution {
+public:
+    int longestSubsequence(string s, int k) {
+     int n = s.length();
+    int count = 0;
+    long long val = 0;
+    int power = 0;
+
+    // Traverse from right to left
+    for (int i = n - 1; i >= 0; i--) {
+        if (s[i] == '0') {
+            count++; // 0 KABHI BHI VALUE KOO BADHATE NAHI HAI 
+        } else {
+            if (power < 32) {
+                val += (1LL << power);
+                if (val <= k) {
+                    count++;
+                } else {
+                    val -= (1LL << power); // undo
+                }
+            }
+        }
+        power++;
+    }
+
+    return count;
+    }
+};
From c956dcfa313c95e00c5c2db29c92e4477c13f9de Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 26 Jun 2025 11:08:21 +0530
Subject: [PATCH 067/115] Create Regular Expression Matching.java
---
 Java/Regular Expression Matching.java | 34 +++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Java/Regular Expression Matching.java
diff --git a/Java/Regular Expression Matching.java b/Java/Regular Expression Matching.java
new file mode 100644
index 0000000000..9197309c38
--- /dev/null
+++ b/Java/Regular Expression Matching.java	
@@ -0,0 +1,34 @@
+class Solution {
+    public boolean isMatch(String s, String p) {
+        int m = s.length();
+        int n = p.length();
+        boolean[][] dp = new boolean[m + 1][n + 1];
+
+     
+        dp[0][0] = true;
+
+        
+        for (int j = 1; j <= n; j++) {
+            if (p.charAt(j - 1) == '*' && j >= 2) {
+                dp[0][j] = dp[0][j - 2];
+            }
+        }
+
+        
+        for (int i = 1; i <= m; i++) {
+            for (int j = 1; j <= n; j++) {
+                if (p.charAt(j - 1) == s.charAt(i - 1) || p.charAt(j - 1) == '.') {
+                    dp[i][j] = dp[i - 1][j - 1];
+                } else if (p.charAt(j - 1) == '*') {
+                    dp[i][j] = dp[i][j - 2];
+
+                    if (p.charAt(j - 2) == s.charAt(i - 1) || p.charAt(j - 2) == '.') {
+                        dp[i][j] |= dp[i - 1][j]; 
+                    }
+                }
+            }
+        }
+
+        return dp[m][n];
+    }
+}
From 060e6afcbd4ba8da89a265dd436f2d1801a4f006 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 27 Jun 2025 09:28:53 +0530
Subject: [PATCH 068/115] Create Container With Most Water.cpp
---
 C++/Container With Most Water.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 C++/Container With Most Water.cpp
diff --git a/C++/Container With Most Water.cpp b/C++/Container With Most Water.cpp
new file mode 100644
index 0000000000..1158bc54fd
--- /dev/null
+++ b/C++/Container With Most Water.cpp	
@@ -0,0 +1,17 @@
+class Solution {
+public:
+    int maxArea(vector& height) {
+        int leftbound=0, rightbound=height.size()-1;
+        int currArea,maxWater=0;
+        int wt,ht;
+        while(leftbound
Date: Sun, 29 Jun 2025 20:33:11 +0530
Subject: [PATCH 069/115] Create Merge Two Sorted Lists.cpp
---
 C++/Merge Two Sorted Lists.cpp | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 C++/Merge Two Sorted Lists.cpp
diff --git a/C++/Merge Two Sorted Lists.cpp b/C++/Merge Two Sorted Lists.cpp
new file mode 100644
index 0000000000..1fefac9394
--- /dev/null
+++ b/C++/Merge Two Sorted Lists.cpp	
@@ -0,0 +1,34 @@
+					// ππππPlease upvote if it helps ππππ
+class Solution {
+public:
+	ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) 
+  {
+		// if list1 happen to be NULL
+		// we will simply return list2.
+		if(l1 == NULL)
+        {
+			return l2;
+		}
+		
+		// if list2 happen to be NULL
+		// we will simply return list1.
+		if(l2 == NULL)
+        {
+			return l1;
+		} 
+		
+		// if value pointend by l1 pointer is less than equal to value pointed by l2 pointer
+		// we wall call recursively l1 -> next and whole l2 list.
+		if(l1 -> val <= l2 -> val)
+        {
+			l1 -> next = mergeTwoLists(l1 -> next, l2);
+			return l1;
+		}
+		// we will call recursive l1 whole list and l2 -> next
+		else
+        {
+			l2 -> next = mergeTwoLists(l1, l2 -> next);
+			return l2;            
+		}
+	}
+};	
From 47b53a041830ca95e7f2c7acbffee5560a5cbfc9 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 8 Jul 2025 08:39:02 +0530
Subject: [PATCH 070/115] Create Add Two Numbers.java
---
 Java/Add Two Numbers.java | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Java/Add Two Numbers.java
diff --git a/Java/Add Two Numbers.java b/Java/Add Two Numbers.java
new file mode 100644
index 0000000000..be9df50447
--- /dev/null
+++ b/Java/Add Two Numbers.java	
@@ -0,0 +1,28 @@
+class Solution {
+public:
+    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
+        ListNode* dummyHead = new ListNode(0);
+        ListNode* tail = dummyHead;
+        int carry = 0;
+
+        while (l1 != nullptr || l2 != nullptr || carry != 0) {
+            int digit1 = (l1 != nullptr) ? l1->val : 0;
+            int digit2 = (l2 != nullptr) ? l2->val : 0;
+
+            int sum = digit1 + digit2 + carry;
+            int digit = sum % 10;
+            carry = sum / 10;
+
+            ListNode* newNode = new ListNode(digit);
+            tail->next = newNode;
+            tail = tail->next;
+
+            l1 = (l1 != nullptr) ? l1->next : nullptr;
+            l2 = (l2 != nullptr) ? l2->next : nullptr;
+        }
+
+        ListNode* result = dummyHead->next;
+        delete dummyHead;
+        return result;
+    }
+};
From fa27d836ecf6ac3be41b40810e21ce89b4128060 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 8 Jul 2025 08:40:19 +0530
Subject: [PATCH 071/115] Delete Java/Add Two Numbers.java
---
 Java/Add Two Numbers.java | 28 ----------------------------
 1 file changed, 28 deletions(-)
 delete mode 100644 Java/Add Two Numbers.java
diff --git a/Java/Add Two Numbers.java b/Java/Add Two Numbers.java
deleted file mode 100644
index be9df50447..0000000000
--- a/Java/Add Two Numbers.java	
+++ /dev/null
@@ -1,28 +0,0 @@
-class Solution {
-public:
-    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
-        ListNode* dummyHead = new ListNode(0);
-        ListNode* tail = dummyHead;
-        int carry = 0;
-
-        while (l1 != nullptr || l2 != nullptr || carry != 0) {
-            int digit1 = (l1 != nullptr) ? l1->val : 0;
-            int digit2 = (l2 != nullptr) ? l2->val : 0;
-
-            int sum = digit1 + digit2 + carry;
-            int digit = sum % 10;
-            carry = sum / 10;
-
-            ListNode* newNode = new ListNode(digit);
-            tail->next = newNode;
-            tail = tail->next;
-
-            l1 = (l1 != nullptr) ? l1->next : nullptr;
-            l2 = (l2 != nullptr) ? l2->next : nullptr;
-        }
-
-        ListNode* result = dummyHead->next;
-        delete dummyHead;
-        return result;
-    }
-};
From ce8295bac4e81b87880e556741bf664cc1f32364 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 8 Jul 2025 08:41:00 +0530
Subject: [PATCH 072/115] Create Add Two Numbers.java
---
 Java/Add Two Numbers.java | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Java/Add Two Numbers.java
diff --git a/Java/Add Two Numbers.java b/Java/Add Two Numbers.java
new file mode 100644
index 0000000000..be9df50447
--- /dev/null
+++ b/Java/Add Two Numbers.java	
@@ -0,0 +1,28 @@
+class Solution {
+public:
+    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
+        ListNode* dummyHead = new ListNode(0);
+        ListNode* tail = dummyHead;
+        int carry = 0;
+
+        while (l1 != nullptr || l2 != nullptr || carry != 0) {
+            int digit1 = (l1 != nullptr) ? l1->val : 0;
+            int digit2 = (l2 != nullptr) ? l2->val : 0;
+
+            int sum = digit1 + digit2 + carry;
+            int digit = sum % 10;
+            carry = sum / 10;
+
+            ListNode* newNode = new ListNode(digit);
+            tail->next = newNode;
+            tail = tail->next;
+
+            l1 = (l1 != nullptr) ? l1->next : nullptr;
+            l2 = (l2 != nullptr) ? l2->next : nullptr;
+        }
+
+        ListNode* result = dummyHead->next;
+        delete dummyHead;
+        return result;
+    }
+};
From 05109435dae7d0d67a5a0db35f42da578944d807 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 9 Jul 2025 15:53:53 +0530
Subject: [PATCH 073/115] Create Reschedule meeting for Maximum Free Time
 I.java
---
 ...edule meeting for Maximum Free Time I.java | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Java/Reschedule meeting for Maximum Free Time I.java
diff --git a/Java/Reschedule meeting for Maximum Free Time I.java b/Java/Reschedule meeting for Maximum Free Time I.java
new file mode 100644
index 0000000000..1171097baa
--- /dev/null
+++ b/Java/Reschedule meeting for Maximum Free Time I.java	
@@ -0,0 +1,22 @@
+public class Solution {
+
+    public int maxFreeTime(
+        int eventTime,
+        int k,
+        int[] startTime,
+        int[] endTime
+    ) {
+        int n = startTime.length;
+        int res = 0;
+        int[] sum = new int[n + 1];
+        for (int i = 0; i < n; i++) {
+            sum[i + 1] = sum[i] + endTime[i] - startTime[i];
+        }
+        for (int i = k - 1; i < n; i++) {
+            int right = i == n - 1 ? eventTime : startTime[i + 1];
+            int left = i == k - 1 ? 0 : endTime[i - k];
+            res = Math.max(res, right - left - (sum[i + 1] - sum[i - k + 1]));
+        }
+        return res;
+    }
+}
From c7ca46b728e5fdcb187dd27f1df6582d9fe36841 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 9 Jul 2025 15:54:13 +0530
Subject: [PATCH 074/115] Delete Java/Reschedule meeting for Maximum Free Time
 I.java
---
 ...edule meeting for Maximum Free Time I.java | 22 -------------------
 1 file changed, 22 deletions(-)
 delete mode 100644 Java/Reschedule meeting for Maximum Free Time I.java
diff --git a/Java/Reschedule meeting for Maximum Free Time I.java b/Java/Reschedule meeting for Maximum Free Time I.java
deleted file mode 100644
index 1171097baa..0000000000
--- a/Java/Reschedule meeting for Maximum Free Time I.java	
+++ /dev/null
@@ -1,22 +0,0 @@
-public class Solution {
-
-    public int maxFreeTime(
-        int eventTime,
-        int k,
-        int[] startTime,
-        int[] endTime
-    ) {
-        int n = startTime.length;
-        int res = 0;
-        int[] sum = new int[n + 1];
-        for (int i = 0; i < n; i++) {
-            sum[i + 1] = sum[i] + endTime[i] - startTime[i];
-        }
-        for (int i = k - 1; i < n; i++) {
-            int right = i == n - 1 ? eventTime : startTime[i + 1];
-            int left = i == k - 1 ? 0 : endTime[i - k];
-            res = Math.max(res, right - left - (sum[i + 1] - sum[i - k + 1]));
-        }
-        return res;
-    }
-}
From 9847856084f4cfcbd93175a736c852ce61332a6f Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 9 Jul 2025 15:55:05 +0530
Subject: [PATCH 075/115] Create Reschedule meeting for Maximum Free Time
 I.java
---
 ...edule meeting for Maximum Free Time I.java | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Java/Reschedule meeting for Maximum Free Time I.java
diff --git a/Java/Reschedule meeting for Maximum Free Time I.java b/Java/Reschedule meeting for Maximum Free Time I.java
new file mode 100644
index 0000000000..1171097baa
--- /dev/null
+++ b/Java/Reschedule meeting for Maximum Free Time I.java	
@@ -0,0 +1,22 @@
+public class Solution {
+
+    public int maxFreeTime(
+        int eventTime,
+        int k,
+        int[] startTime,
+        int[] endTime
+    ) {
+        int n = startTime.length;
+        int res = 0;
+        int[] sum = new int[n + 1];
+        for (int i = 0; i < n; i++) {
+            sum[i + 1] = sum[i] + endTime[i] - startTime[i];
+        }
+        for (int i = k - 1; i < n; i++) {
+            int right = i == n - 1 ? eventTime : startTime[i + 1];
+            int left = i == k - 1 ? 0 : endTime[i - k];
+            res = Math.max(res, right - left - (sum[i + 1] - sum[i - k + 1]));
+        }
+        return res;
+    }
+}
From 24eb8ee91533e124d780bdb424d411f482140f01 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 10 Jul 2025 11:52:49 +0530
Subject: [PATCH 076/115] Create Longest Substring Without Repeating
 Charcters.cpp
---
 ... Substring Without Repeating Charcters.cpp | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 C++/Longest Substring Without Repeating Charcters.cpp
diff --git a/C++/Longest Substring Without Repeating Charcters.cpp b/C++/Longest Substring Without Repeating Charcters.cpp
new file mode 100644
index 0000000000..09d0f82087
--- /dev/null
+++ b/C++/Longest Substring Without Repeating Charcters.cpp	
@@ -0,0 +1,24 @@
+class Solution {
+public:
+    int lengthOfLongestSubstring(string s) {
+        int n = s.length();
+        int maxLength = 0;
+        unordered_set charSet;
+        int left = 0;
+        
+        for (int right = 0; right < n; right++) {
+            if (charSet.count(s[right]) == 0) {
+                charSet.insert(s[right]);
+                maxLength = max(maxLength, right - left + 1);
+            } else {
+                while (charSet.count(s[right])) {
+                    charSet.erase(s[left]);
+                    left++;
+                }
+                charSet.insert(s[right]);
+            }
+        }
+        
+        return maxLength;
+    }
+};
From 9bfe32de74054853020df2a2d693d87503777fc6 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 11 Jul 2025 11:59:46 +0530
Subject: [PATCH 077/115] Create Meeting Rooms III.cpp
---
 C++/Meeting Rooms III.cpp | 43 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 C++/Meeting Rooms III.cpp
diff --git a/C++/Meeting Rooms III.cpp b/C++/Meeting Rooms III.cpp
new file mode 100644
index 0000000000..ed1938744b
--- /dev/null
+++ b/C++/Meeting Rooms III.cpp	
@@ -0,0 +1,43 @@
+class Solution {
+public:
+    int mostBooked(int n, vector>& meetings) {
+        vector busy(n, 0); // Room end times
+        vector count(n, 0);      // Booking counts per room
+
+        sort(meetings.begin(), meetings.end());
+
+        for (auto& meeting : meetings) {
+            int start = meeting[0], end = meeting[1];
+            long long earliest = LLONG_MAX;
+            int roomIndex = -1;
+            bool assigned = false;
+
+            for (int i = 0; i < n; ++i) {
+                if (busy[i] < earliest) {
+                    earliest = busy[i];
+                    roomIndex = i;
+                }
+                if (busy[i] <= start) {
+                    busy[i] = end;
+                    count[i]++;
+                    assigned = true;
+                    break;
+                }
+            }
+
+            if (!assigned) {
+                busy[roomIndex] += (end - start);
+                count[roomIndex]++;
+            }
+        }
+
+        int res = 0, maxCount = 0;
+        for (int i = 0; i < n; ++i) {
+            if (count[i] > maxCount) {
+                maxCount = count[i];
+                res = i;
+            }
+        }
+        return res;
+    }
+};
From aa1dbaff1e4c9e60e5b53454ff5d2fa4805c6661 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sun, 13 Jul 2025 11:20:19 +0530
Subject: [PATCH 078/115] Create Maximum Matching of Players  With
 Trainers.java
---
 ...um Matching of Players  With Trainers.java | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 Java/Maximum Matching of Players  With Trainers.java
diff --git a/Java/Maximum Matching of Players  With Trainers.java b/Java/Maximum Matching of Players  With Trainers.java
new file mode 100644
index 0000000000..5808bfb398
--- /dev/null
+++ b/Java/Maximum Matching of Players  With Trainers.java	
@@ -0,0 +1,26 @@
+class Solution {
+
+    public int matchPlayersAndTrainers(int[] players, int[] trainers) {
+        Arrays.sort(players);
+        Arrays.sort(trainers);
+
+        int m = players.length;
+        int n = trainers.length;
+        int count = 0;
+
+        int i = 0;
+        int j = 0;
+
+        while (i < m && j < n) {
+            if (players[i] <= trainers[j]) {
+                count++;
+                i++;
+                j++;
+            } else {
+                j++;
+            }
+        }
+
+        return count;
+    }
+}
From e8c0140e070c97f3d5278f485dd25ea8eceb4a4e Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 14 Jul 2025 19:12:15 +0530
Subject: [PATCH 079/115] Create Convert binary number of linked list to
 Integer.java
---
 ...onvert binary number of linked list to Integer.java | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 Java/Convert binary number of linked list to Integer.java
diff --git a/Java/Convert binary number of linked list to Integer.java b/Java/Convert binary number of linked list to Integer.java
new file mode 100644
index 0000000000..ff20c712a1
--- /dev/null
+++ b/Java/Convert binary number of linked list to Integer.java	
@@ -0,0 +1,10 @@
+class Solution {
+    public int getDecimalValue(ListNode head) {
+        int num = 0;
+        while (head != null) {
+            num = (num << 1) | head.val;
+            head = head.next;
+        }
+        return num;
+    }
+}
From 981d735d9e2c8d6548589f7bc171869624e346f4 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 15 Jul 2025 08:16:20 +0530
Subject: [PATCH 080/115] Create Valid word.java
---
 Java/Valid word.java | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Java/Valid word.java
diff --git a/Java/Valid word.java b/Java/Valid word.java
new file mode 100644
index 0000000000..ebfc911028
--- /dev/null
+++ b/Java/Valid word.java	
@@ -0,0 +1,29 @@
+class Solution {
+
+    public boolean isValid(String word) {
+        if (word.length() < 3) {
+            return false;
+        }
+        boolean hasVowel = false;
+        boolean hasConsonant = false;
+        for (char c : word.toCharArray()) {
+            if (Character.isLetter(c)) {
+                char ch = Character.toLowerCase(c);
+                if (
+                    ch == 'a' ||
+                    ch == 'e' ||
+                    ch == 'i' ||
+                    ch == 'o' ||
+                    ch == 'u'
+                ) {
+                    hasVowel = true;
+                } else {
+                    hasConsonant = true;
+                }
+            } else if (!Character.isDigit(c)) {
+                return false;
+            }
+        }
+        return hasVowel && hasConsonant;
+    }
+}
From a8c511b05d7a0a6dd00ba1a440904a0864985f83 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 16 Jul 2025 21:07:08 +0530
Subject: [PATCH 081/115] Create Find The Maximum Length of Valid Subsequence
 I.java
---
 ...e Maximum Length of Valid Subsequence I.java | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Java/Find The Maximum Length of Valid Subsequence I.java
diff --git a/Java/Find The Maximum Length of Valid Subsequence I.java b/Java/Find The Maximum Length of Valid Subsequence I.java
new file mode 100644
index 0000000000..48c96e0017
--- /dev/null
+++ b/Java/Find The Maximum Length of Valid Subsequence I.java	
@@ -0,0 +1,17 @@
+class Solution {
+
+    public int maximumLength(int[] nums) {
+        int res = 0;
+        int[][] patterns = { { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 } };
+        for (int[] pattern : patterns) {
+            int cnt = 0;
+            for (int num : nums) {
+                if (num % 2 == pattern[cnt % 2]) {
+                    cnt++;
+                }
+            }
+            res = Math.max(res, cnt);
+        }
+        return res;
+    }
+}
From d9550d3a040522f6bbe71c94d74fff1f423694ff Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 17 Jul 2025 08:36:50 +0530
Subject: [PATCH 082/115] Create Find the maximum length of valid Subsequence
 II.java
---
 ...he maximum length of valid Subsequence II.java | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Java/Find the maximum length of valid Subsequence II.java
diff --git a/Java/Find the maximum length of valid Subsequence II.java b/Java/Find the maximum length of valid Subsequence II.java
new file mode 100644
index 0000000000..ab1bfb9bf2
--- /dev/null
+++ b/Java/Find the maximum length of valid Subsequence II.java	
@@ -0,0 +1,15 @@
+class Solution {
+
+    public int maximumLength(int[] nums, int k) {
+        int[][] dp = new int[k][k];
+        int res = 0;
+        for (int num : nums) {
+            num %= k;
+            for (int prev = 0; prev < k; prev++) {
+                dp[prev][num] = dp[num][prev] + 1;
+                res = Math.max(res, dp[prev][num]);
+            }
+        }
+        return res;
+    }
+}
From d1cf5484e0cf3a8456f2c2b3faf9cc630d2019c1 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 18 Jul 2025 20:38:43 +0530
Subject: [PATCH 083/115] Create Sudoku Solver.java
---
 Java/Sudoku Solver.java | 45 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 Java/Sudoku Solver.java
diff --git a/Java/Sudoku Solver.java b/Java/Sudoku Solver.java
new file mode 100644
index 0000000000..f64cb62caf
--- /dev/null
+++ b/Java/Sudoku Solver.java	
@@ -0,0 +1,45 @@
+class Solution {
+public:
+    
+    bool isValid(vector>& board , int row , int col , int num){
+        for(int i=0 ; i<9 ; i++){
+            if(board[row][i]== '0'+num) return false ;
+        }
+        // col check
+        for(int j=0 ; j<9 ; j++){
+            if(board[j][col] == '0'+num) return false ;
+        }
+
+        // small 3x3 grid check
+        int x = (row/3)*3 ;
+        int y = (col/3)*3 ;
+
+        for(int i=x ; i>& board , int row , int col){
+        if(row == 9) return true ;
+        if(col == 9) return helper(board , row+1 , 0) ;
+        if(board[row][col] != '.') return helper(board , row , col+1) ;
+
+        for(int i=1 ; i<=9 ; i++){
+            if(isValid(board , row , col , i)){
+                board[row][col] = '0' + i ;
+                bool res = helper(board , row , col+1) ;
+                if(res) return true ;
+                board[row][col] = '.' ;
+            }
+        }
+        return false ;
+    }
+
+    void solveSudoku(vector>& board) {
+        helper(board , 0 , 0) ;
+        return ;
+    }
+};
From 964a580237375b3fa386a45e736f856ed1325b82 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sat, 19 Jul 2025 08:03:39 +0530
Subject: [PATCH 084/115] Create Remove Sub-Folders From the FileSystem.java
---
 ...emove Sub-Folders From the FileSystem.java | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 Java/Remove Sub-Folders From the FileSystem.java
diff --git a/Java/Remove Sub-Folders From the FileSystem.java b/Java/Remove Sub-Folders From the FileSystem.java
new file mode 100644
index 0000000000..b263701f6d
--- /dev/null
+++ b/Java/Remove Sub-Folders From the FileSystem.java	
@@ -0,0 +1,25 @@
+class Solution {
+
+    public List removeSubfolders(String[] folder) {
+        // Sort the folders alphabetically
+        Arrays.sort(folder);
+
+        // Initialize the result list and add the first folder
+        List result = new ArrayList<>();
+        result.add(folder[0]);
+
+        // Iterate through each folder and check if it's a sub-folder of the last added folder in the result
+        for (int i = 1; i < folder.length; i++) {
+            String lastFolder = result.get(result.size() - 1);
+            lastFolder += '/';
+
+            // Check if the current folder starts with the last added folder path
+            if (!folder[i].startsWith(lastFolder)) {
+                result.add(folder[i]);
+            }
+        }
+
+        // Return the result containing only non-sub-folders
+        return result;
+    }
+}
From 6a955181c3b4d87828fd270b16883bb993e79c26 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sun, 20 Jul 2025 09:09:17 +0530
Subject: [PATCH 085/115] Create Jump Game.py
---
 Python/Jump Game.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 Python/Jump Game.py
diff --git a/Python/Jump Game.py b/Python/Jump Game.py
new file mode 100644
index 0000000000..af7ce5ff02
--- /dev/null
+++ b/Python/Jump Game.py	
@@ -0,0 +1,11 @@
+class Solution:
+    def canJump(self, nums: List[int]) -> bool:
+        gas = 0
+        for n in nums:
+            if gas < 0:
+                return False
+            elif n > gas:
+                gas = n
+            gas -= 1
+            
+        return True
From 9a36e54b9b21ec8a6ac47b2e6cdcc3cddb465789 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 21 Jul 2025 08:43:42 +0530
Subject: [PATCH 086/115] Create Delete Characters To Make Fancy String.java
---
 ...elete Characters To Make Fancy String.java | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Java/Delete Characters To Make Fancy String.java
diff --git a/Java/Delete Characters To Make Fancy String.java b/Java/Delete Characters To Make Fancy String.java
new file mode 100644
index 0000000000..aa7968ab3c
--- /dev/null
+++ b/Java/Delete Characters To Make Fancy String.java	
@@ -0,0 +1,22 @@
+
+class Solution {
+    public String makeFancyString(String s) {
+        char[] chars = s.toCharArray();
+        char last = chars[0];
+        int count = 1;
+        int pos = 1;
+
+        for (int i = 1; i < chars.length; i++) {
+            if (chars[i] != last) {
+                last = chars[i];
+                count = 0;
+            }
+
+            if (++count > 2) continue;
+
+            chars[pos++] = chars[i];
+        }
+
+        return new String(chars, 0, pos);
+    }
+}
From 6c910195597d6e7cefe14d0c9dc526eaa95001fa Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 22 Jul 2025 09:52:16 +0530
Subject: [PATCH 087/115] Create Maximum Erasure Value.java
---
 Java/Maximum Erasure Value.java | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Java/Maximum Erasure Value.java
diff --git a/Java/Maximum Erasure Value.java b/Java/Maximum Erasure Value.java
new file mode 100644
index 0000000000..8dc13b45ad
--- /dev/null
+++ b/Java/Maximum Erasure Value.java	
@@ -0,0 +1,24 @@
+class Solution {
+    public int maximumUniqueSubarray(int[] nums) {
+        int n = nums.length;
+        boolean[] seen = new boolean[10001];
+        int left = 0;
+        int currentSum = 0;
+        int maxSum = 0;
+        
+        for (int right = 0; right < n; right++) {
+            while (seen[nums[right]]) {
+                currentSum -= nums[left];
+                seen[nums[left]] = false;
+                left++;
+            }
+            currentSum += nums[right];
+            seen[nums[right]] = true;
+            if (currentSum > maxSum) {
+                maxSum = currentSum;
+            }
+        }
+        
+        return maxSum;
+    }
+}
From c22408e7f025fc4261281762b82bed6d84715164 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 23 Jul 2025 20:20:09 +0530
Subject: [PATCH 088/115] Create Maximum Score From Removing Substrings.java
---
 Maximum Score From Removing Substrings.java | 42 +++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 Maximum Score From Removing Substrings.java
diff --git a/Maximum Score From Removing Substrings.java b/Maximum Score From Removing Substrings.java
new file mode 100644
index 0000000000..0566c4e36f
--- /dev/null
+++ b/Maximum Score From Removing Substrings.java	
@@ -0,0 +1,42 @@
+class Solution {
+public:
+    int maximumGain(string s, int x, int y) {
+        if (x < y) {
+            swap(x, y);
+            reverse(s.begin(), s.end());
+        }
+
+        int res = 0;
+        stack st;
+
+        // First pass: remove "ab" (or "ba" if x < y was true and we reversed)
+        for (char c : s) {
+            if (!st.empty() && st.top() == 'a' && c == 'b') {
+                st.pop();
+                res += x;
+            } else {
+                st.push(c);
+            }
+        }
+
+        // Rebuild remaining string after first pass
+        string remaining;
+        while (!st.empty()) {
+            remaining += st.top();
+            st.pop();
+        }
+        reverse(remaining.begin(), remaining.end());
+
+        // Second pass: remove "ba" (or "ab" if reversed earlier)
+        for (char c : remaining) {
+            if (!st.empty() && st.top() == 'b' && c == 'a') {
+                st.pop();
+                res += y;
+            } else {
+                st.push(c);
+            }
+        }
+
+        return res;
+    }
+};
From 1d41d8d6dec4ff7d7c935f050a59963f13ce5ae4 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 24 Jul 2025 20:24:46 +0530
Subject: [PATCH 089/115] Create Valid parentheses.cpp
---
 C++/Valid parentheses.cpp | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 C++/Valid parentheses.cpp
diff --git a/C++/Valid parentheses.cpp b/C++/Valid parentheses.cpp
new file mode 100644
index 0000000000..07af0e79aa
--- /dev/null
+++ b/C++/Valid parentheses.cpp	
@@ -0,0 +1,39 @@
+class Solution {
+public:
+    bool isValid(string s) {
+
+
+        stack st;
+      for(int i=0;i
Date: Fri, 25 Jul 2025 10:07:44 +0530
Subject: [PATCH 090/115] Create Maximum Unique Subarray Sum After
 Deletion.java
---
 ...aximum Unique Subarray Sum After Deletion.java | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Java/Maximum Unique Subarray Sum After Deletion.java
diff --git a/Java/Maximum Unique Subarray Sum After Deletion.java b/Java/Maximum Unique Subarray Sum After Deletion.java
new file mode 100644
index 0000000000..735e23321d
--- /dev/null
+++ b/Java/Maximum Unique Subarray Sum After Deletion.java	
@@ -0,0 +1,15 @@
+class Solution {
+
+    public int maxSum(int[] nums) {
+        Set positiveNumsSet = new HashSet<>();
+        for (int num : nums) {
+            if (num > 0) {
+                positiveNumsSet.add(num);
+            }
+        }
+        if (positiveNumsSet.isEmpty()) {
+            return Arrays.stream(nums).max().getAsInt();
+        }
+        return positiveNumsSet.stream().mapToInt(Integer::intValue).sum();
+    }
+}
From 1c7b656b7c8e1f85786bc5e042401096cbd2c5aa Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sun, 27 Jul 2025 11:14:45 +0530
Subject: [PATCH 091/115] Create Count Hills And Valleys in an Array.java
---
 Java/Count Hills And Valleys in an Array.java | 38 +++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 Java/Count Hills And Valleys in an Array.java
diff --git a/Java/Count Hills And Valleys in an Array.java b/Java/Count Hills And Valleys in an Array.java
new file mode 100644
index 0000000000..648910b3e4
--- /dev/null
+++ b/Java/Count Hills And Valleys in an Array.java	
@@ -0,0 +1,38 @@
+class Solution {
+
+    public int countHillValley(int[] nums) {
+        int res = 0; // number of peaks and valleys
+        int n = nums.length;
+        for (int i = 1; i < n - 1; ++i) {
+            if (nums[i] == nums[i - 1]) {
+                // deduplication
+                continue;
+            }
+            int left = 0; // left side possibly unequal neighboring corresponding state
+            for (int j = i - 1; j >= 0; --j) {
+                if (nums[j] > nums[i]) {
+                    left = 1;
+                    break;
+                } else if (nums[j] < nums[i]) {
+                    left = -1;
+                    break;
+                }
+            }
+            int right = 0; // right side possibly unequal neighboring corresponding state
+            for (int j = i + 1; j < n; ++j) {
+                if (nums[j] > nums[i]) {
+                    right = 1;
+                    break;
+                } else if (nums[j] < nums[i]) {
+                    right = -1;
+                    break;
+                }
+            }
+            if (left == right && left != 0) {
+                // at this time, index i is part of a peak or valley.
+                ++res;
+            }
+        }
+        return res;
+    }
+}
From 091a9d786ffbb50e8a44ac1d71bd248388da895e Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 28 Jul 2025 08:54:02 +0530
Subject: [PATCH 092/115] Create Binary Search Tree Iterator.cpp
---
 C++/Binary Search Tree Iterator.cpp | 42 +++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 C++/Binary Search Tree Iterator.cpp
diff --git a/C++/Binary Search Tree Iterator.cpp b/C++/Binary Search Tree Iterator.cpp
new file mode 100644
index 0000000000..fe7c88435f
--- /dev/null
+++ b/C++/Binary Search Tree Iterator.cpp	
@@ -0,0 +1,42 @@
+/**
+ * Definition for a binary tree node.
+ * struct TreeNode {
+ *     int val;
+ *     TreeNode *left;
+ *     TreeNode *right;
+ *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
+ *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
+ *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
+ * };
+ */
+class BSTIterator {
+public:
+    stack s;
+void storeleftNodes(TreeNode* root){
+    while(root!=NULL){
+        s.push(root);
+        root=root->left;
+    }
+}
+    BSTIterator(TreeNode* root) {
+        storeleftNodes(root);
+    }
+    
+    int next() {
+        TreeNode* ans=s.top();
+        s.pop();
+        storeleftNodes(ans->right);
+        return ans->val;
+    }
+    
+    bool hasNext() {
+        return s.size()>0;
+    }
+};
+
+/**
+ * Your BSTIterator object will be instantiated and called as such:
+ * BSTIterator* obj = new BSTIterator(root);
+ * int param_1 = obj->next();
+ * bool param_2 = obj->hasNext();
+ */
From 64a9be703066e8b4d9ee415601d85ac1b06542a6 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 29 Jul 2025 16:55:46 +0530
Subject: [PATCH 093/115] Create Regular Expression Matching.py
---
 Python3/Regular Expression Matching.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Python3/Regular Expression Matching.py
diff --git a/Python3/Regular Expression Matching.py b/Python3/Regular Expression Matching.py
new file mode 100644
index 0000000000..56558f3a5a
--- /dev/null
+++ b/Python3/Regular Expression Matching.py	
@@ -0,0 +1,15 @@
+class Solution(object):
+    def isMatch(self, text: str, pattern: str) -> bool:
+        if not pattern:
+            return not text
+
+        first_match = bool(text) and pattern[0] in {text[0], "."}
+
+        if len(pattern) >= 2 and pattern[1] == "*":
+            return (
+                self.isMatch(text, pattern[2:])
+                or first_match
+                and self.isMatch(text[1:], pattern)
+            )
+        else:
+            return first_match and self.isMatch(text[1:], pattern[1:])
From af85884523fa62173b674b67cc4f0dab31255cc1 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 30 Jul 2025 09:50:00 +0530
Subject: [PATCH 094/115] Create Longest Subarray With Maximum Bitwise And.cpp
---
 ...gest Subarray With Maximum Bitwise And.cpp | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 C++/Longest Subarray With Maximum Bitwise And.cpp
diff --git a/C++/Longest Subarray With Maximum Bitwise And.cpp b/C++/Longest Subarray With Maximum Bitwise And.cpp
new file mode 100644
index 0000000000..c4a80c11cb
--- /dev/null
+++ b/C++/Longest Subarray With Maximum Bitwise And.cpp	
@@ -0,0 +1,22 @@
+class Solution {
+public:
+    int longestSubarray(vector& nums) {
+        int maxVal = 0, ans = 0, currentStreak = 0;
+
+        for (int num : nums) {
+            if (maxVal < num) {
+                maxVal = num;
+                ans = currentStreak = 0;
+            }
+
+            if (maxVal == num) {
+                currentStreak++;
+            } else {
+                currentStreak = 0;
+            }
+
+            ans = max(ans, currentStreak);
+        }
+        return ans;
+    }
+};
From ac98698d4f87afe3f578073f9dde307c36635062 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 31 Jul 2025 09:50:45 +0530
Subject: [PATCH 095/115] Create Bitwise ORs of Subarrays.cpp
---
 C++/Bitwise ORs of Subarrays.cpp | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 C++/Bitwise ORs of Subarrays.cpp
diff --git a/C++/Bitwise ORs of Subarrays.cpp b/C++/Bitwise ORs of Subarrays.cpp
new file mode 100644
index 0000000000..e1be2ac3f9
--- /dev/null
+++ b/C++/Bitwise ORs of Subarrays.cpp	
@@ -0,0 +1,19 @@
+class Solution {
+public:
+    int subarrayBitwiseORs(vector& arr) {
+        unordered_set ans;
+        const int n=arr.size();
+        for(int i=0; i=0; j--){
+                skip|=arr[j];
+                take=skip|x;
+                if (skip==take) break;
+                ans.insert(take);
+            }
+        }   
+        return ans.size();
+    }
+};
From a2373f8ad69ff8d71a6c8c5997a845eebf40af9d Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 1 Aug 2025 16:19:12 +0530
Subject: [PATCH 096/115] Create Pascal 's Triangle.java
---
 Java/Pascal 's Triangle.java | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Java/Pascal 's Triangle.java
diff --git a/Java/Pascal 's Triangle.java b/Java/Pascal 's Triangle.java
new file mode 100644
index 0000000000..d1c25aa85f
--- /dev/null
+++ b/Java/Pascal 's Triangle.java	
@@ -0,0 +1,19 @@
+class Solution {
+    public List> generate(int numRows) {
+        List> triangle = new ArrayList<>();
+        triangle.add(Arrays.asList(1));
+
+        for (int i = 1; i < numRows; i++) {
+            List row = new ArrayList<>();
+            List prev = triangle.get(i - 1);
+            row.add(1);
+            for (int j = 1; j < i; j++) {
+                row.add(prev.get(j - 1) + prev.get(j));
+            }
+            row.add(1);
+            triangle.add(row);
+        }
+
+        return triangle;
+    }
+}
From 2f4358e967b1ac77ec8da30b21907352520ed5fd Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sat, 2 Aug 2025 12:58:03 +0530
Subject: [PATCH 097/115] Create Rearranging Fruits.java
---
 Java/Rearranging Fruits.java | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 Java/Rearranging Fruits.java
diff --git a/Java/Rearranging Fruits.java b/Java/Rearranging Fruits.java
new file mode 100644
index 0000000000..35d602248d
--- /dev/null
+++ b/Java/Rearranging Fruits.java	
@@ -0,0 +1,31 @@
+class Solution {
+
+    public long minCost(int[] basket1, int[] basket2) {
+        TreeMap freq = new TreeMap<>();
+        int m = Integer.MAX_VALUE;
+        for (int b1 : basket1) {
+            freq.put(b1, freq.getOrDefault(b1, 0) + 1);
+            m = Math.min(m, b1);
+        }
+        for (int b2 : basket2) {
+            freq.put(b2, freq.getOrDefault(b2, 0) - 1);
+            m = Math.min(m, b2);
+        }
+
+        List merge = new ArrayList<>();
+        for (var entry : freq.entrySet()) {
+            int count = entry.getValue();
+            if (count % 2 != 0) return -1;
+            for (int i = 0; i < Math.abs(count) / 2; i++) {
+                merge.add(entry.getKey());
+            }
+        }
+
+        Collections.sort(merge);
+        long res = 0;
+        for (int i = 0; i < merge.size() / 2; i++) {
+            res += Math.min(2 * m, merge.get(i));
+        }
+        return res;
+    }
+}
From 71d9a820b418628e8b2ad7c649d0e41bf69e2847 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sun, 3 Aug 2025 17:05:20 +0530
Subject: [PATCH 098/115] Create Maximum Fruit Harvesting at Atmost K times
 .java
---
 ...m Fruit Harvesting at Atmost K times .java | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 Java/Maximum Fruit Harvesting at Atmost K times .java
diff --git a/Java/Maximum Fruit Harvesting at Atmost K times .java b/Java/Maximum Fruit Harvesting at Atmost K times .java
new file mode 100644
index 0000000000..5b3986f1af
--- /dev/null
+++ b/Java/Maximum Fruit Harvesting at Atmost K times .java	
@@ -0,0 +1,26 @@
+class Solution {
+    public int maxTotalFruits(int[][] fruits, int startPos, int k) {
+        int left = 0, sum = 0, max = 0;
+
+        for (int right = 0; right < fruits.length; right++) {
+            sum += fruits[right][1];
+
+            while (left <= right && minSteps(fruits[left][0], fruits[right][0], startPos) > k) {
+                sum -= fruits[left][1];
+                left++;
+            }
+
+            max = Math.max(max, sum);
+        }
+
+        return max;
+    }
+
+    private int minSteps(int left, int right, int start) {
+        // Two paths: left first or right first
+        int goLeft = Math.abs(start - left) + (right - left);
+        int goRight = Math.abs(start - right) + (right - left);
+        return Math.min(goLeft, goRight);
+    }
+}
+
From d5345b7b4bf80b8a28d4bb56af60adddb974b865 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 4 Aug 2025 15:26:53 +0530
Subject: [PATCH 099/115] Create Fruits Into Basket.java
---
 Java/Fruits Into Basket.java | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Java/Fruits Into Basket.java
diff --git a/Java/Fruits Into Basket.java b/Java/Fruits Into Basket.java
new file mode 100644
index 0000000000..127c9da267
--- /dev/null
+++ b/Java/Fruits Into Basket.java	
@@ -0,0 +1,21 @@
+class Solution {
+    public int totalFruit(int[] fruits) {
+        int start = 0,end = 0;
+        int n = fruits.length,maxLen = 0;
+        Map map = new HashMap<>();
+        while(end=3)
+            {
+                map.put(fruits[start],map.get(fruits[start])-1);
+                if(map.get(fruits[start]) == 0) map.remove(fruits[start]);
+                start++;
+            }
+            int currLen = end-start+1;
+            maxLen = Math.max(maxLen,currLen);
+            end++;
+        }
+        return maxLen;
+    }
+}
From 30dc0296d2b78b69856eb565738792f859dd5584 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 5 Aug 2025 10:46:06 +0530
Subject: [PATCH 100/115] Create Fruits Into Basket II.cpp
---
 C++/Fruits Into Basket II.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 C++/Fruits Into Basket II.cpp
diff --git a/C++/Fruits Into Basket II.cpp b/C++/Fruits Into Basket II.cpp
new file mode 100644
index 0000000000..8eca229855
--- /dev/null
+++ b/C++/Fruits Into Basket II.cpp	
@@ -0,0 +1,17 @@
+class Solution {
+public:
+    int numOfUnplacedFruits(vector& fruits, vector& baskets) {
+        const int n=fruits.size();
+        int ans=n;
+        for(int i=0; i
Date: Wed, 6 Aug 2025 16:32:47 +0530
Subject: [PATCH 101/115] Create Fruits Into Basket III.java
---
 Java/Fruits Into Basket III.java | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 Java/Fruits Into Basket III.java
diff --git a/Java/Fruits Into Basket III.java b/Java/Fruits Into Basket III.java
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/Java/Fruits Into Basket III.java	
@@ -0,0 +1 @@
+
From 742a1fef9867e70b8b8351827c80b70c85c3f45b Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 8 Aug 2025 11:43:17 +0530
Subject: [PATCH 102/115] Create Soup Servings.java
---
 Java/Soup Servings.java | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 Java/Soup Servings.java
diff --git a/Java/Soup Servings.java b/Java/Soup Servings.java
new file mode 100644
index 0000000000..b77bf38604
--- /dev/null
+++ b/Java/Soup Servings.java	
@@ -0,0 +1,36 @@
+class Solution {
+    private Double[][] cache; // Memoization storage
+
+    public double soupServings(int n) {
+        // Large n behaves like probability 1
+        if (n > 5000) return 1.0;
+
+        int units = (int) Math.ceil(n / 25.0); // Convert mL β 25 mL units
+        cache = new Double[units + 1][units + 1];
+
+        return calcProb(units, units);
+    }
+
+    private double calcProb(int soupA, int soupB) {
+        // Both soups empty β half probability
+        if (soupA <= 0 && soupB <= 0) return 0.5;
+        // A empty first
+        if (soupA <= 0) return 1.0;
+        // B empty first
+        if (soupB <= 0) return 0.0;
+
+        // If already computed, return cached result
+        if (cache[soupA][soupB] != null) return cache[soupA][soupB];
+
+        // Calculate and store probability
+        double prob = 0.25 * (
+            calcProb(soupA - 4, soupB) +
+            calcProb(soupA - 3, soupB - 1) +
+            calcProb(soupA - 2, soupB - 2) +
+            calcProb(soupA - 1, soupB - 3)
+        );
+
+        cache[soupA][soupB] = prob;
+        return prob;
+    }
+}
From a9edfafc89081faf4605674c5a4e48b3a76ef762 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sat, 9 Aug 2025 10:18:24 +0530
Subject: [PATCH 103/115] Create Power of Two.java
---
 Java/Power of Two.java | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 Java/Power of Two.java
diff --git a/Java/Power of Two.java b/Java/Power of Two.java
new file mode 100644
index 0000000000..69b2eac95d
--- /dev/null
+++ b/Java/Power of Two.java	
@@ -0,0 +1,5 @@
+class Solution {
+    public boolean isPowerOfTwo(int n) {
+        return n > 0 && ( n & (n-1))==0;
+    }
+}
From df38b698ff5de48056e6c1582b0b70a947e9888e Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sun, 10 Aug 2025 11:05:05 +0530
Subject: [PATCH 104/115] Create Reordered Power of 2.java
---
 Java/Reordered Power of 2.java | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 Java/Reordered Power of 2.java
diff --git a/Java/Reordered Power of 2.java b/Java/Reordered Power of 2.java
new file mode 100644
index 0000000000..e9da9734d9
--- /dev/null
+++ b/Java/Reordered Power of 2.java	
@@ -0,0 +1,32 @@
+class Solution {
+    // Count digit frequencies of a non-negative integer n
+    private int[] digitFreq(int n) {
+        int[] freq = new int[10];
+        while (n > 0) {
+            freq[n % 10]++;
+            n /= 10;
+        }
+        return freq;
+    }
+
+    // Compare two frequency arrays (length 10)
+    private boolean equalFreq(int[] a, int[] b) {
+        for (int i = 0; i < 10; i++) {
+            if (a[i] != b[i])
+                return false;
+        }
+        return true;
+    }
+
+    public boolean reorderedPowerOf2(int N) {
+        int[] target = digitFreq(N);
+
+        // Check all powers of two up to 2^30 (fits in 32-bit signed int ie till limit ie 10^9)
+        for (int i = 0; i <= 30; i++) {
+            int powerof2 = (int) Math.pow(2, i); // 2^i
+            if (equalFreq(target, digitFreq(powerof2)))
+                return true;
+        }
+        return false;
+    }
+}
From 9f74984006ca72d3aa01231fa37ae0080515256c Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Mon, 11 Aug 2025 10:35:47 +0530
Subject: [PATCH 105/115] Create Range Product Queries of Power.java
---
 Java/Range Product Queries of Power.java | 28 ++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Java/Range Product Queries of Power.java
diff --git a/Java/Range Product Queries of Power.java b/Java/Range Product Queries of Power.java
new file mode 100644
index 0000000000..9becdc62b8
--- /dev/null
+++ b/Java/Range Product Queries of Power.java	
@@ -0,0 +1,28 @@
+class Solution {
+
+    private static final int MOD = 1000000007;
+
+    public int[] productQueries(int n, int[][] queries) {
+        List bins = new ArrayList<>();
+        int rep = 1;
+        while (n > 0) {
+            if (n % 2 == 1) {
+                bins.add(rep);
+            }
+            n /= 2;
+            rep *= 2;
+        }
+
+        int[] ans = new int[queries.length];
+        for (int i = 0; i < queries.length; i++) {
+            long cur = 1;
+            int start = queries[i][0];
+            int end = queries[i][1];
+            for (int j = start; j <= end; j++) {
+                cur = (cur * bins.get(j)) % MOD;
+            }
+            ans[i] = (int) cur;
+        }
+        return ans;
+    }
+}
From 8d8df3f61d19291bfa75fdebce3e1fbb1eef2b23 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 12 Aug 2025 10:56:42 +0530
Subject: [PATCH 106/115] Create Ways To Express an Integer as a Sum of
 Powers.java
---
 ...ys To Express an Integer as a Sum of Powers.java | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 Java/Ways To Express an Integer as a Sum of Powers.java
diff --git a/Java/Ways To Express an Integer as a Sum of Powers.java b/Java/Ways To Express an Integer as a Sum of Powers.java
new file mode 100644
index 0000000000..8e456d7033
--- /dev/null
+++ b/Java/Ways To Express an Integer as a Sum of Powers.java	
@@ -0,0 +1,13 @@
+class Solution {
+    private static final int MOD = 1_000_000_007;
+    public int numberOfWays(int n, int x) {
+        long[] dp = new long[n + 1];
+        dp[0] = 1; 
+        for (int i = 1; Math.pow(i, x) <= n; i++) {
+            int power = (int) Math.pow(i, x);
+            for (int sum = n; sum >= power; sum--) {
+            dp[sum] = (dp[sum] + dp[sum - power]) % MOD;
+            }
+        } return (int) dp[n];
+    }
+}
From 5c20bdc1ae1a1ace43ecdf4a73649eb65510075c Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 13 Aug 2025 10:19:38 +0530
Subject: [PATCH 107/115] Create POWER OF THREE.java
---
 Java/POWER OF THREE.java | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 Java/POWER OF THREE.java
diff --git a/Java/POWER OF THREE.java b/Java/POWER OF THREE.java
new file mode 100644
index 0000000000..97894e2d05
--- /dev/null
+++ b/Java/POWER OF THREE.java	
@@ -0,0 +1,6 @@
+public class Solution {
+    public boolean isPowerOfThree(int n) {
+        int maxPowerOf3 = 1162261467; // 3^19 is the largest power of 3 in int range
+        return n > 0 && maxPowerOf3 % n == 0;
+    }
+}
From 2fcaf94e0a7e76dcdba093b97d0e651899e056a1 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Thu, 14 Aug 2025 13:17:04 +0530
Subject: [PATCH 108/115] Create Largest 3-same -digit number in a string
---
 Java/Largest 3-same -digit number in a string | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 Java/Largest 3-same -digit number in a string
diff --git a/Java/Largest 3-same -digit number in a string b/Java/Largest 3-same -digit number in a string
new file mode 100644
index 0000000000..1e71575692
--- /dev/null
+++ b/Java/Largest 3-same -digit number in a string	
@@ -0,0 +1,27 @@
+class Solution {
+    private List sameDigitNumbers = List.of("999", "888", "777", "666", "555", "444", "333", "222", "111", "000");
+
+    // Check whether the 'num' string contains the 'sameDigitNumber' string or not.
+    private boolean contains(String sameDigitNumber, String num) {
+        for (int index = 0; index <= num.length() - 3; ++index) {
+            if (num.charAt(index) == sameDigitNumber.charAt(0) &&
+                num.charAt(index + 1) == sameDigitNumber.charAt(1) &&
+                num.charAt(index + 2) == sameDigitNumber.charAt(2)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public String largestGoodInteger(String num) {
+        // Iterate on all 'sameDigitNumbers' and check if the string 'num' contains it.
+        for (String sameDigitNumber : sameDigitNumbers) {
+            if (contains(sameDigitNumber, num)) {
+                // Return the current 'sameDigitNumbers'.
+                return sameDigitNumber;
+            }
+        }
+        // No 3 consecutive same digits are present in the string 'num'.
+        return "";
+    }
+}
From 391248d67eae66a0e0303a432a19a8b335e4b16f Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 15 Aug 2025 11:54:17 +0530
Subject: [PATCH 109/115] Create Power of Four.c
---
 C#/Power of Four.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 C#/Power of Four.c
diff --git a/C#/Power of Four.c b/C#/Power of Four.c
new file mode 100644
index 0000000000..31684e7e5c
--- /dev/null
+++ b/C#/Power of Four.c	
@@ -0,0 +1,15 @@
+bool isPowerOfFour(int n) {
+    if(n==0)
+        {
+        return 0;
+        }
+    for(int i=0;i<=16;i++)
+        {
+        if(pow(4,i)==n)
+            {
+            return 1;
+            }
+        }
+    return 0;
+    
+}
From 99aba8b043fe55773af7688ee70538ef335336b0 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Fri, 15 Aug 2025 11:58:15 +0530
Subject: [PATCH 110/115] Update Power of Four.c
---
 C#/Power of Four.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/C#/Power of Four.c b/C#/Power of Four.c
index 31684e7e5c..0cd34c3e35 100644
--- a/C#/Power of Four.c	
+++ b/C#/Power of Four.c	
@@ -5,7 +5,7 @@ bool isPowerOfFour(int n) {
         }
     for(int i=0;i<=16;i++)
         {
-        if(pow(4,i)==n)
+        if((int)pow(4,i)==n)
             {
             return 1;
             }
From ee0a1bc07a9edd366595df7710a15e7db6947a34 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 20 Aug 2025 13:24:13 +0530
Subject: [PATCH 111/115] Create Count Number of Square Submatrices with all
 ones.java
---
 ...r of Square Submatrices with all ones.java | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Java/Count Number of Square Submatrices with all ones.java
diff --git a/Java/Count Number of Square Submatrices with all ones.java b/Java/Count Number of Square Submatrices with all ones.java
new file mode 100644
index 0000000000..47dc8e32d2
--- /dev/null
+++ b/Java/Count Number of Square Submatrices with all ones.java	
@@ -0,0 +1,22 @@
+class Solution {
+
+    public int countSquares(int[][] matrix) {
+        int row = matrix.length, col = matrix[0].length;
+        int[][] dp = new int[row + 1][col + 1];
+        int ans = 0;
+        for (int i = 0; i < row; i++) {
+            for (int j = 0; j < col; j++) {
+                if (matrix[i][j] == 1) {
+                    dp[i + 1][j + 1] =
+                        Math.min(
+                            Math.min(dp[i][j + 1], dp[i + 1][j]),
+                            dp[i][j]
+                        ) +
+                        1;
+                    ans += dp[i + 1][j + 1];
+                }
+            }
+        }
+        return ans;
+    }
+}
From 0c14e8f596f911f91b878c3926e07a87836a4e3b Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sat, 23 Aug 2025 11:36:44 +0530
Subject: [PATCH 112/115] Create Permutation II.java
---
 Java/Permutation II.java | 46 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 Java/Permutation II.java
diff --git a/Java/Permutation II.java b/Java/Permutation II.java
new file mode 100644
index 0000000000..803d36e425
--- /dev/null
+++ b/Java/Permutation II.java	
@@ -0,0 +1,46 @@
+class Solution {
+    public List> permuteUnique(int[] nums) {
+        List> results = new ArrayList<>();
+
+        // count the occurrence of each number
+        HashMap counter = new HashMap<>();
+        for (int num : nums) {
+            if (!counter.containsKey(num)) counter.put(num, 0);
+            counter.put(num, counter.get(num) + 1);
+        }
+
+        LinkedList comb = new LinkedList<>();
+        this.backtrack(comb, nums.length, counter, results);
+        return results;
+    }
+
+    protected void backtrack(
+        LinkedList comb,
+        Integer N,
+        HashMap counter,
+        List> results
+    ) {
+        if (comb.size() == N) {
+            // make a deep copy of the resulting permutation,
+            // since the permutation would be backtracked later.
+            results.add(new ArrayList(comb));
+            return;
+        }
+
+        for (Map.Entry entry : counter.entrySet()) {
+            Integer num = entry.getKey();
+            Integer count = entry.getValue();
+            if (count == 0) continue;
+            // add this number into the current combination
+            comb.addLast(num);
+            counter.put(num, count - 1);
+
+            // continue the exploration
+            backtrack(comb, N, counter, results);
+
+            // revert the choice for the next exploration
+            comb.removeLast();
+            counter.put(num, count);
+        }
+    }
+}
From ddc0b67b0fdb0b59754cb605900ad59026aa139e Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Sun, 24 Aug 2025 13:21:21 +0530
Subject: [PATCH 113/115] Create Longest Subarray of 1 after deleting of One
 element.java
---
 ...ay of 1 after deleting of One element.java | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Java/Longest Subarray of 1 after deleting of One element.java
diff --git a/Java/Longest Subarray of 1 after deleting of One element.java b/Java/Longest Subarray of 1 after deleting of One element.java
new file mode 100644
index 0000000000..3cdcd2acb6
--- /dev/null
+++ b/Java/Longest Subarray of 1 after deleting of One element.java	
@@ -0,0 +1,24 @@
+class Solution {
+    public int longestSubarray(int[] nums) {
+        // Number of zero's in the window.
+        int zeroCount = 0;
+        int longestWindow = 0;
+        // Left end of the window.
+        int start = 0;
+        
+        for (int i = 0; i < nums.length; i++) {
+            zeroCount += (nums[i] == 0 ? 1 : 0);
+                          
+            // Shrink the window until the count of zero's
+            // is less than or equal to 1.
+            while (zeroCount > 1) {
+                zeroCount -= (nums[start] == 0 ? 1 : 0);
+                start++;
+            }
+              
+            longestWindow = Math.max(longestWindow, i - start);
+        }
+
+        return longestWindow;
+    }
+}
From 6f33f183fb5b559a45c9dbfd5c503fbedc35d2c2 Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Tue, 26 Aug 2025 11:26:26 +0530
Subject: [PATCH 114/115] Create Maximum Area of Longest Diagonal
 Rectangle.java
---
 ...mum Area of Longest Diagonal Rectangle.java | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 Maximum Area of Longest Diagonal Rectangle.java
diff --git a/Maximum Area of Longest Diagonal Rectangle.java b/Maximum Area of Longest Diagonal Rectangle.java
new file mode 100644
index 0000000000..bd76335ec6
--- /dev/null
+++ b/Maximum Area of Longest Diagonal Rectangle.java	
@@ -0,0 +1,18 @@
+class Solution {
+    public int areaOfMaxDiagonal(int[][] dimensions) {
+        int n = dimensions.length;
+        int maxArea = 0, maxDiag = 0;
+
+        for (int i = 0; i < n; i++) {
+            int l = dimensions[i][0];
+            int w = dimensions[i][1];
+            int currDiag = l * l + w * w;
+
+            if (currDiag > maxDiag || (currDiag == maxDiag && l * w > maxArea)) {
+                maxDiag = currDiag;
+                maxArea = l * w;
+            }
+        }
+        return maxArea;
+    }
+}
From 8852aef595050ff4e17d60541ed95b738be9243e Mon Sep 17 00:00:00 2001
From: Dipanita Mondal <132455672+Dipanita45@users.noreply.github.com>
Date: Wed, 27 Aug 2025 20:18:00 +0530
Subject: [PATCH 115/115] Create length of longest v shaped diagonal
 segment.java
---
 ... of longest v shaped diagonal segment.java | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Java/length of longest v shaped diagonal segment.java
diff --git a/Java/length of longest v shaped diagonal segment.java b/Java/length of longest v shaped diagonal segment.java
new file mode 100644
index 0000000000..66cb600d51
--- /dev/null
+++ b/Java/length of longest v shaped diagonal segment.java	
@@ -0,0 +1,65 @@
+class Solution {
+
+    private static final int[][] DIRS = {
+        { 1, 1 },
+        { 1, -1 },
+        { -1, -1 },
+        { -1, 1 },
+    };
+    private int[][][][] memo;
+    private int[][] grid;
+    private int m, n;
+
+    public int lenOfVDiagonal(int[][] grid) {
+        this.grid = grid;
+        this.m = grid.length;
+        this.n = grid[0].length;
+        this.memo = new int[m][n][4][2];
+
+        for (int i = 0; i < m; i++) {
+            for (int j = 0; j < n; j++) {
+                for (int k = 0; k < 4; k++) {
+                    Arrays.fill(memo[i][j][k], -1);
+                }
+            }
+        }
+
+        int res = 0;
+        for (int i = 0; i < m; i++) {
+            for (int j = 0; j < n; j++) {
+                if (grid[i][j] == 1) {
+                    for (int direction = 0; direction < 4; direction++) {
+                        res = Math.max(res, dfs(i, j, direction, true, 2) + 1);
+                    }
+                }
+            }
+        }
+        return res;
+    }
+
+    private int dfs(int cx, int cy, int direction, boolean turn, int target) {
+        int nx = cx + DIRS[direction][0];
+        int ny = cy + DIRS[direction][1];
+        /* If it goes beyond the boundary or the next node's value is not the target value, then return */
+        if (nx < 0 || ny < 0 || nx >= m || ny >= n || grid[nx][ny] != target) {
+            return 0;
+        }
+
+        int turnInt = turn ? 1 : 0;
+        if (memo[nx][ny][direction][turnInt] != -1) {
+            return memo[nx][ny][direction][turnInt];
+        }
+
+        /* Continue walking in the original direction. */
+        int maxStep = dfs(nx, ny, direction, turn, 2 - target);
+        if (turn) {
+            /* Clockwise rotate 90 degrees turn */
+            maxStep = Math.max(
+                maxStep,
+                dfs(nx, ny, (direction + 1) % 4, false, 2 - target)
+            );
+        }
+        memo[nx][ny][direction][turnInt] = maxStep + 1;
+        return maxStep + 1;
+    }
+}