There was an error while loading. Please reload this page.
1 parent b2e80e5 commit f795ddeCopy full SHA for f795dde
3639-zero-array-transformation-i/3639-zero-array-transformation-i.java
@@ -0,0 +1,24 @@
1
+class Solution {
2
+ public boolean isZeroArray(int[] nums, int[][] queries) {
3
+ int n = nums.length;
4
+ int[] sweep = new int[n+1];
5
+ for(int[] query :queries)
6
+ {
7
+ int l = query[0];
8
+ int r = query[1];
9
+ sweep[l] += 1;
10
+ sweep[r+1] -= 1;
11
+ }
12
+ for(int i=1;i<=n;i++)
13
14
+ sweep[i]+=sweep[i-1];
15
16
+ for(int i=0;i<n;i++)
17
18
+ if(sweep[i]<nums[i]) return false;
19
20
+ return true;
21
+
22
23
24
+}
0 commit comments