📖 오늘의 학습 키워드
배열
[Count the Hidden Sequences]
https://leetcode.com/problems/count-the-hidden-sequences/description/
class Solution {
public int numberOfArrays(int[] differences, int lower, int upper) {
int min = 0;
int max = 0;
int sum = 0;
for(int d : differences) {
sum += d;
if(d > 0) {
max = Math.max(max, sum);
}
else {
min = Math.min(min, sum);
}
}
return Math.max(0, (upper-max)-(lower-min)+1);
}
}