diff --git a/src/main/java/g3301_3400/s3354_make_array_elements_equal_to_zero/Solution.java b/src/main/java/g3301_3400/s3354_make_array_elements_equal_to_zero/Solution.java
new file mode 100644
index 000000000..fcba6649c
--- /dev/null
+++ b/src/main/java/g3301_3400/s3354_make_array_elements_equal_to_zero/Solution.java
@@ -0,0 +1,28 @@
+package g3301_3400.s3354_make_array_elements_equal_to_zero;
+
+// #Easy #Array #Simulation #Prefix_Sum #2024_11_19_Time_1_ms_(95.09%)_Space_41.9_MB_(92.55%)
+
+public class Solution {
+ public int countValidSelections(int[] nums) {
+ int[] rightSum = new int[nums.length];
+ int[] leftSum = new int[nums.length];
+ int result = 0;
+ leftSum[0] = 0;
+ rightSum[nums.length - 1] = 0;
+ for (int i = 1; i < nums.length; i++) {
+ leftSum[i] = leftSum[i - 1] + nums[i - 1];
+ }
+ for (int j = nums.length - 2; j >= 0; j--) {
+ rightSum[j] = rightSum[j + 1] + nums[j + 1];
+ }
+ for (int k = 0; k < nums.length; k++) {
+ if (nums[k] == 0 && Math.abs(rightSum[k] - leftSum[k]) == 1) {
+ result++;
+ }
+ if (nums[k] == 0 && Math.abs(rightSum[k] - leftSum[k]) == 0) {
+ result += 2;
+ }
+ }
+ return result;
+ }
+}
diff --git a/src/main/java/g3301_3400/s3354_make_array_elements_equal_to_zero/readme.md b/src/main/java/g3301_3400/s3354_make_array_elements_equal_to_zero/readme.md
new file mode 100644
index 000000000..123fbff41
--- /dev/null
+++ b/src/main/java/g3301_3400/s3354_make_array_elements_equal_to_zero/readme.md
@@ -0,0 +1,51 @@
+3354\. Make Array Elements Equal to Zero
+
+Easy
+
+You are given an integer array `nums`.
+
+Start by selecting a starting position `curr` such that `nums[curr] == 0`, and choose a movement **direction** of either left or right.
+
+After that, you repeat the following process:
+
+* If `curr` is out of the range `[0, n - 1]`, this process ends.
+* If `nums[curr] == 0`, move in the current direction by **incrementing** `curr` if you are moving right, or **decrementing** `curr` if you are moving left.
+* Else if `nums[curr] > 0`:
+ * Decrement `nums[curr]` by 1.
+ * **Reverse** your movement direction (left becomes right and vice versa).
+ * Take a step in your new direction.
+
+A selection of the initial position `curr` and movement direction is considered **valid** if every element in `nums` becomes 0 by the end of the process.
+
+Return the number of possible **valid** selections.
+
+**Example 1:**
+
+**Input:** nums = [1,0,2,0,3]
+
+**Output:** 2
+
+**Explanation:**
+
+The only possible valid selections are the following:
+
+* Choose `curr = 3`, and a movement direction to the left.
+ * [1,0,2,**0**,3] -> [1,0,**2**,0,3] -> [1,0,1,**0**,3] -> [1,0,1,0,**3**] -> [1,0,1,**0**,2] -> [1,0,**1**,0,2] -> [1,0,0,**0**,2] -> [1,0,0,0,**2**] -> [1,0,0,**0**,1] -> [1,0,**0**,0,1] -> [1,**0**,0,0,1] -> [**1**,0,0,0,1] -> [0,**0**,0,0,1] -> [0,0,**0**,0,1] -> [0,0,0,**0**,1] -> [0,0,0,0,**1**] -> [0,0,0,0,0].
+* Choose `curr = 3`, and a movement direction to the right.
+ * [1,0,2,**0**,3] -> [1,0,2,0,**3**] -> [1,0,2,**0**,2] -> [1,0,**2**,0,2] -> [1,0,1,**0**,2] -> [1,0,1,0,**2**] -> [1,0,1,**0**,1] -> [1,0,**1**,0,1] -> [1,0,0,**0**,1] -> [1,0,0,0,**1**] -> [1,0,0,**0**,0] -> [1,0,**0**,0,0] -> [1,**0**,0,0,0] -> [**1**,0,0,0,0] -> [0,0,0,0,0].
+
+**Example 2:**
+
+**Input:** nums = [2,3,4,0,4,1,0]
+
+**Output:** 0
+
+**Explanation:**
+
+There are no possible valid selections.
+
+**Constraints:**
+
+* `1 <= nums.length <= 100`
+* `0 <= nums[i] <= 100`
+* There is at least one element `i` where `nums[i] == 0`.
\ No newline at end of file
diff --git a/src/main/java/g3301_3400/s3355_zero_array_transformation_i/Solution.java b/src/main/java/g3301_3400/s3355_zero_array_transformation_i/Solution.java
new file mode 100644
index 000000000..8ca0f6420
--- /dev/null
+++ b/src/main/java/g3301_3400/s3355_zero_array_transformation_i/Solution.java
@@ -0,0 +1,36 @@
+package g3301_3400.s3355_zero_array_transformation_i;
+
+// #Medium #Array #Prefix_Sum #2024_11_19_Time_3_ms_(91.34%)_Space_96_MB_(17.22%)
+
+public class Solution {
+ public boolean isZeroArray(int[] nums, int[][] queries) {
+ int n = nums.length;
+ int sum = 0;
+ for (int num : nums) {
+ sum += num;
+ }
+ if (sum == 0) {
+ return true;
+ }
+ int[] diff = new int[n + 1];
+ for (int[] q : queries) {
+ int low = q[0];
+ int high = q[1];
+ diff[low] -= 1;
+ if (high + 1 < n) {
+ diff[high + 1] += 1;
+ }
+ }
+ for (int i = 0; i < n; i++) {
+ if (i > 0) {
+ diff[i] += diff[i - 1];
+ }
+ nums[i] += diff[i];
+ sum += diff[i];
+ if (nums[i] > 0) {
+ return false;
+ }
+ }
+ return sum <= 0;
+ }
+}
diff --git a/src/main/java/g3301_3400/s3355_zero_array_transformation_i/readme.md b/src/main/java/g3301_3400/s3355_zero_array_transformation_i/readme.md
new file mode 100644
index 000000000..1ec464ee9
--- /dev/null
+++ b/src/main/java/g3301_3400/s3355_zero_array_transformation_i/readme.md
@@ -0,0 +1,51 @@
+3355\. Zero Array Transformation I
+
+Medium
+
+You are given an integer array `nums` of length `n` and a 2D array `queries`, where queries[i] = [li, ri].
+
+For each `queries[i]`:
+
+* Select a subset of indices within the range [li, ri] in `nums`.
+* Decrement the values at the selected indices by 1.
+
+A **Zero Array** is an array where all elements are equal to 0.
+
+Return `true` if it is _possible_ to transform `nums` into a **Zero Array** after processing all the queries sequentially, otherwise return `false`.
+
+A **subset** of an array is a selection of elements (possibly none) of the array.
+
+**Example 1:**
+
+**Input:** nums = [1,0,1], queries = [[0,2]]
+
+**Output:** true
+
+**Explanation:**
+
+* **For i = 0:**
+ * Select the subset of indices as `[0, 2]` and decrement the values at these indices by 1.
+ * The array will become `[0, 0, 0]`, which is a Zero Array.
+
+**Example 2:**
+
+**Input:** nums = [4,3,2,1], queries = [[1,3],[0,2]]
+
+**Output:** false
+
+**Explanation:**
+
+* **For i = 0:**
+ * Select the subset of indices as `[1, 2, 3]` and decrement the values at these indices by 1.
+ * The array will become `[4, 2, 1, 0]`.
+* **For i = 1:**
+ * Select the subset of indices as `[0, 1, 2]` and decrement the values at these indices by 1.
+ * The array will become `[3, 1, 0, 0]`, which is not a Zero Array.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 0 <= nums[i] <= 105
+* 1 <= queries.length <= 105
+* `queries[i].length == 2`
+* 0 <= li <= ri < nums.length
\ No newline at end of file
diff --git a/src/main/java/g3301_3400/s3356_zero_array_transformation_ii/Solution.java b/src/main/java/g3301_3400/s3356_zero_array_transformation_ii/Solution.java
new file mode 100644
index 000000000..9241894c6
--- /dev/null
+++ b/src/main/java/g3301_3400/s3356_zero_array_transformation_ii/Solution.java
@@ -0,0 +1,29 @@
+package g3301_3400.s3356_zero_array_transformation_ii;
+
+// #Medium #Array #Binary_Search #Prefix_Sum #2024_11_19_Time_4_ms_(93.46%)_Space_118.5_MB_(13.87%)
+
+public class Solution {
+ public int minZeroArray(int[] nums, int[][] queries) {
+ int[] diff = new int[nums.length];
+ int idx = 0;
+ int d = 0;
+ for (int i = 0; i < nums.length; i++) {
+ d += diff[i];
+ while (nums[i] + d > 0 && idx < queries.length) {
+ int[] q = queries[idx];
+ if (i >= q[0] && i <= q[1]) {
+ d -= q[2];
+ }
+ diff[q[0]] -= q[2];
+ if (q[1] + 1 < nums.length) {
+ diff[q[1] + 1] += q[2];
+ }
+ idx++;
+ }
+ if (nums[i] + d > 0) {
+ return -1;
+ }
+ }
+ return idx;
+ }
+}
diff --git a/src/main/java/g3301_3400/s3356_zero_array_transformation_ii/readme.md b/src/main/java/g3301_3400/s3356_zero_array_transformation_ii/readme.md
new file mode 100644
index 000000000..0561449eb
--- /dev/null
+++ b/src/main/java/g3301_3400/s3356_zero_array_transformation_ii/readme.md
@@ -0,0 +1,53 @@
+3356\. Zero Array Transformation II
+
+Medium
+
+You are given an integer array `nums` of length `n` and a 2D array `queries` where queries[i] = [li, ri, vali].
+
+Each `queries[i]` represents the following action on `nums`:
+
+* Decrement the value at each index in the range [li, ri] in `nums` by **at most** vali.
+* The amount by which each value is decremented can be chosen **independently** for each index.
+
+A **Zero Array** is an array with all its elements equal to 0.
+
+Return the **minimum** possible **non-negative** value of `k`, such that after processing the first `k` queries in **sequence**, `nums` becomes a **Zero Array**. If no such `k` exists, return -1.
+
+**Example 1:**
+
+**Input:** nums = [2,0,2], queries = [[0,2,1],[0,2,1],[1,1,3]]
+
+**Output:** 2
+
+**Explanation:**
+
+* **For i = 0 (l = 0, r = 2, val = 1):**
+ * Decrement values at indices `[0, 1, 2]` by `[1, 0, 1]` respectively.
+ * The array will become `[1, 0, 1]`.
+* **For i = 1 (l = 0, r = 2, val = 1):**
+ * Decrement values at indices `[0, 1, 2]` by `[1, 0, 1]` respectively.
+ * The array will become `[0, 0, 0]`, which is a Zero Array. Therefore, the minimum value of `k` is 2.
+
+**Example 2:**
+
+**Input:** nums = [4,3,2,1], queries = [[1,3,2],[0,2,1]]
+
+**Output:** \-1
+
+**Explanation:**
+
+* **For i = 0 (l = 1, r = 3, val = 2):**
+ * Decrement values at indices `[1, 2, 3]` by `[2, 2, 1]` respectively.
+ * The array will become `[4, 1, 0, 0]`.
+* **For i = 1 (l = 0, r = 2, val \= 1):**
+ * Decrement values at indices `[0, 1, 2]` by `[1, 1, 0]` respectively.
+ * The array will become `[3, 0, 0, 0]`, which is not a Zero Array.
+
+**Constraints:**
+
+* 1 <= nums.length <= 105
+* 0 <= nums[i] <= 5 * 105
+* 1 <= queries.length <= 105
+* `queries[i].length == 3`
+* 0 <= li <= ri < nums.length
+* 1 <= vali <= 5
\ No newline at end of file
diff --git a/src/main/java/g3301_3400/s3357_minimize_the_maximum_adjacent_element_difference/Solution.java b/src/main/java/g3301_3400/s3357_minimize_the_maximum_adjacent_element_difference/Solution.java
new file mode 100644
index 000000000..9b2bf3042
--- /dev/null
+++ b/src/main/java/g3301_3400/s3357_minimize_the_maximum_adjacent_element_difference/Solution.java
@@ -0,0 +1,55 @@
+package g3301_3400.s3357_minimize_the_maximum_adjacent_element_difference;
+
+// #Hard #Array #Greedy #Binary_Search #2024_11_19_Time_5_ms_(100.00%)_Space_59.2_MB_(29.41%)
+
+public class Solution {
+ public int minDifference(int[] nums) {
+ int n = nums.length;
+ int maxAdj = 0;
+ int mina = Integer.MAX_VALUE;
+ int maxb = Integer.MIN_VALUE;
+ for (int i = 0; i < n - 1; ++i) {
+ int a = nums[i];
+ int b = nums[i + 1];
+ if (a > 0 && b > 0) {
+ maxAdj = Math.max(maxAdj, Math.abs(a - b));
+ } else if (a > 0 || b > 0) {
+ mina = Math.min(mina, Math.max(a, b));
+ maxb = Math.max(maxb, Math.max(a, b));
+ }
+ }
+ int res = 0;
+ for (int i = 0; i < n; ++i) {
+ if ((i > 0 && nums[i - 1] == -1) || nums[i] > 0) {
+ continue;
+ }
+ int j = i;
+ while (j < n && nums[j] == -1) {
+ j++;
+ }
+ int a = Integer.MAX_VALUE;
+ int b = Integer.MIN_VALUE;
+ if (i > 0) {
+ a = Math.min(a, nums[i - 1]);
+ b = Math.max(b, nums[i - 1]);
+ }
+ if (j < n) {
+ a = Math.min(a, nums[j]);
+ b = Math.max(b, nums[j]);
+ }
+ if (a <= b) {
+ if (j - i == 1) {
+ res = Math.max(res, Math.min(maxb - a, b - mina));
+ } else {
+ res =
+ Math.max(
+ res,
+ Math.min(
+ maxb - a,
+ Math.min(b - mina, (maxb - mina + 2) / 3 * 2)));
+ }
+ }
+ }
+ return Math.max(maxAdj, (res + 1) / 2);
+ }
+}
diff --git a/src/main/java/g3301_3400/s3357_minimize_the_maximum_adjacent_element_difference/readme.md b/src/main/java/g3301_3400/s3357_minimize_the_maximum_adjacent_element_difference/readme.md
new file mode 100644
index 000000000..b345c7bab
--- /dev/null
+++ b/src/main/java/g3301_3400/s3357_minimize_the_maximum_adjacent_element_difference/readme.md
@@ -0,0 +1,53 @@
+3357\. Minimize the Maximum Adjacent Element Difference
+
+Hard
+
+You are given an array of integers `nums`. Some values in `nums` are **missing** and are denoted by -1.
+
+You can choose a pair of **positive** integers `(x, y)` **exactly once** and replace each **missing** element with _either_ `x` or `y`.
+
+You need to **minimize** the **maximum** **absolute difference** between _adjacent_ elements of `nums` after replacements.
+
+Return the **minimum** possible difference.
+
+**Example 1:**
+
+**Input:** nums = [1,2,-1,10,8]
+
+**Output:** 4
+
+**Explanation:**
+
+By choosing the pair as `(6, 7)`, nums can be changed to `[1, 2, 6, 10, 8]`.
+
+The absolute differences between adjacent elements are:
+
+* `|1 - 2| == 1`
+* `|2 - 6| == 4`
+* `|6 - 10| == 4`
+* `|10 - 8| == 2`
+
+**Example 2:**
+
+**Input:** nums = [-1,-1,-1]
+
+**Output:** 0
+
+**Explanation:**
+
+By choosing the pair as `(4, 4)`, nums can be changed to `[4, 4, 4]`.
+
+**Example 3:**
+
+**Input:** nums = [-1,10,-1,8]
+
+**Output:** 1
+
+**Explanation:**
+
+By choosing the pair as `(11, 9)`, nums can be changed to `[11, 10, 9, 8]`.
+
+**Constraints:**
+
+* 2 <= nums.length <= 105
+* `nums[i]` is either -1 or in the range [1, 109].
\ No newline at end of file
diff --git a/src/test/java/g3301_3400/s3354_make_array_elements_equal_to_zero/SolutionTest.java b/src/test/java/g3301_3400/s3354_make_array_elements_equal_to_zero/SolutionTest.java
new file mode 100644
index 000000000..8d6c14598
--- /dev/null
+++ b/src/test/java/g3301_3400/s3354_make_array_elements_equal_to_zero/SolutionTest.java
@@ -0,0 +1,27 @@
+package g3301_3400.s3354_make_array_elements_equal_to_zero;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.junit.jupiter.api.Test;
+
+class SolutionTest {
+ @Test
+ void countValidSelections() {
+ assertThat(new Solution().countValidSelections(new int[] {1, 0, 2, 0, 3}), equalTo(2));
+ }
+
+ @Test
+ void countValidSelections2() {
+ assertThat(
+ new Solution().countValidSelections(new int[] {2, 3, 4, 0, 4, 1, 0}), equalTo(0));
+ }
+
+ @Test
+ void countValidSelections3() {
+ assertThat(
+ new Solution()
+ .countValidSelections(new int[] {16, 13, 10, 0, 0, 0, 10, 6, 7, 8, 7}),
+ equalTo(3));
+ }
+}
diff --git a/src/test/java/g3301_3400/s3355_zero_array_transformation_i/SolutionTest.java b/src/test/java/g3301_3400/s3355_zero_array_transformation_i/SolutionTest.java
new file mode 100644
index 000000000..d8741997d
--- /dev/null
+++ b/src/test/java/g3301_3400/s3355_zero_array_transformation_i/SolutionTest.java
@@ -0,0 +1,29 @@
+package g3301_3400.s3355_zero_array_transformation_i;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.junit.jupiter.api.Test;
+
+class SolutionTest {
+ @Test
+ void isZeroArray() {
+ assertThat(
+ new Solution().isZeroArray(new int[] {1, 0, 1}, new int[][] {{0, 2}}),
+ equalTo(true));
+ }
+
+ @Test
+ void isZeroArray2() {
+ assertThat(
+ new Solution().isZeroArray(new int[] {4, 3, 2, 1}, new int[][] {{1, 3}, {0, 2}}),
+ equalTo(false));
+ }
+
+ @Test
+ void isZeroArray3() {
+ assertThat(
+ new Solution().isZeroArray(new int[] {-1, 0, 1}, new int[][] {{1, 3}, {0, 2}}),
+ equalTo(true));
+ }
+}
diff --git a/src/test/java/g3301_3400/s3356_zero_array_transformation_ii/SolutionTest.java b/src/test/java/g3301_3400/s3356_zero_array_transformation_ii/SolutionTest.java
new file mode 100644
index 000000000..fbde58ae8
--- /dev/null
+++ b/src/test/java/g3301_3400/s3356_zero_array_transformation_ii/SolutionTest.java
@@ -0,0 +1,25 @@
+package g3301_3400.s3356_zero_array_transformation_ii;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.junit.jupiter.api.Test;
+
+class SolutionTest {
+ @Test
+ void minZeroArray() {
+ assertThat(
+ new Solution()
+ .minZeroArray(
+ new int[] {2, 0, 2}, new int[][] {{0, 2, 1}, {0, 2, 1}, {1, 1, 3}}),
+ equalTo(2));
+ }
+
+ @Test
+ void minZeroArray2() {
+ assertThat(
+ new Solution()
+ .minZeroArray(new int[] {4, 3, 2, 1}, new int[][] {{1, 3, 2}, {0, 2, 1}}),
+ equalTo(-1));
+ }
+}
diff --git a/src/test/java/g3301_3400/s3357_minimize_the_maximum_adjacent_element_difference/SolutionTest.java b/src/test/java/g3301_3400/s3357_minimize_the_maximum_adjacent_element_difference/SolutionTest.java
new file mode 100644
index 000000000..11564cc5d
--- /dev/null
+++ b/src/test/java/g3301_3400/s3357_minimize_the_maximum_adjacent_element_difference/SolutionTest.java
@@ -0,0 +1,28 @@
+package g3301_3400.s3357_minimize_the_maximum_adjacent_element_difference;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.junit.jupiter.api.Test;
+
+class SolutionTest {
+ @Test
+ void minDifference() {
+ assertThat(new Solution().minDifference(new int[] {1, 2, -1, 10, 8}), equalTo(4));
+ }
+
+ @Test
+ void minDifference2() {
+ assertThat(new Solution().minDifference(new int[] {-1, -1, -1}), equalTo(0));
+ }
+
+ @Test
+ void minDifference3() {
+ assertThat(new Solution().minDifference(new int[] {-1, 10, -1, 8}), equalTo(1));
+ }
+
+ @Test
+ void minDifference4() {
+ assertThat(new Solution().minDifference(new int[] {14, -1, -1, 46}), equalTo(11));
+ }
+}