Problem:
思路
用枚举子数组的方法,暴力
Code
class Solution {
public int minimumSubarrayLength(int[] nums, int k) {
int count = 60;
int n = nums.length;
boolean flag = false;
for (int i = 0; i < n; i++) {
int t = 0;
for (int j = i; j < n; j++) {
//按位或
t = t | nums[j];
if (t >= k) {
flag = true;
count = Math.min(count, j - i + 1);
break;
}
}
}
if (flag) {
return count;
} else {
return -1;
}
}
}
标签:count,return,运算,nums,int,flag,按位
From: https://www.cnblogs.com/arioya/p/18675861