lixx3527
BAN USER
public int solve(int[] array){
if(array.length<=1){
return 0;
}
int mod = (int)(1e9+7);
int sum = 0;
int pre_sum = array[0];
for(int i=1;i<array.length;i++){
sum += (pre_sum%array[i]);
pre_sum+=array[i];
sum %= mod;
pre_sum %= mod;
}
int suffix_sum = array[array.length-1];
for(int i=array.length-2;i>=0;i--){
sum += (suffix_sum%array[i]);
suffix_sum += array[i];
sum %= mod;
suffix_sum %= mod;
}
return sum;
}
general idea: combine two sensors if these two sensors intersect with each other, and store their y range{(min_y, max_y)} which can reach in the room. If some union sensors' y_range satisfies min_y<=0 and max_y<=room_width, then thief cannot reach the right side, otherwise the thief can reach right side
- lixx3527 July 09, 2019
I don't understand this question! Given any matrix, what is the output?
- lixx3527 August 09, 2019