Skip to content

Commit bdcb0f8

Browse files
authored
Update 2411-smallest-subarrays-with-maximum-bitwise-or.js
1 parent 78c9926 commit bdcb0f8

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

2411-smallest-subarrays-with-maximum-bitwise-or.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
* @param {number[]} nums
33
* @return {number[]}
44
*/
5-
const smallestSubarrays = function(nums) {
6-
const n = nums.length, last = Array(30).fill(0), res = [];
7-
for (let i = n - 1; i >= 0; --i) {
8-
res[i] = 1;
9-
for (let j = 0; j < 30; ++j) {
10-
if ((nums[i] & (1 << j)) > 0) last[j] = i;
11-
res[i] = Math.max(res[i], last[j] - i + 1);
5+
const smallestSubarrays = function (nums) {
6+
const n = nums.length,
7+
last = Array(30).fill(0),
8+
res = []
9+
for (let i = n - 1; i >= 0; i--) {
10+
res[i] = 1
11+
for (let j = 0; j < 30; j++) {
12+
if ((nums[i] & (1 << j)) > 0) last[j] = i
13+
res[i] = Math.max(res[i], last[j] - i + 1)
1214
}
1315
}
14-
return res;
15-
};
16+
return res
17+
}

0 commit comments

Comments
 (0)