2158. Amount of New Area Painted Each Day
O(n*m) Time Limit Exceeded
```java
class Solution {
public int[] amountPainted(int[][] paint) {
int[] result = new int[paint.length];
boolean[] area = new boolean[100001];
for (int i = 0; i < paint.length; i++) {
int start = paint[i][0];
int end = paint[i][1];
int count = 0;
for (int j = start; j < end; j++) {
if (area[j]) {
count++;
}
area[j] = true;
}
result[i] = end - start - count;
}
return result;
}
}
```line sweep , use TreeSet
Jump line
Previous2018. Check if Word Can Be Placed In CrosswordNext2345. Finding the Number of Visible Mountains
Last updated
Was this helpful?