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 1/3] 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 2/3] 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 3/3] 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