1110110011

by Valentin Sarychev

JavaScript

const f = (bits) => bits.join("")
  .split(/0{2,}/g)
  .map(part => part.split(/0/g)
    .map(ones => ones.length)
    .reduce((max, item, index, arr) => Math.max(max, item + arr[index - 1])))
  .reduce((max, item) => Math.max(max, item))

console.log(f([1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1]))
console.log(f([]))