[TypeScript, JavaScript] 100% fastest TypeScript solution
The task can be treated as summing up the products of amounts of devices in non-empty rows.\nFor the given example ["011001","000000","010100","001000"] we have
The task can be treated as summing up the products of amounts of devices in non-empty rows.\nFor the given example `["011001","000000","010100","001000"]` we have 3 devices in the first row, skip second one as it\'s empty, 2 in the third and 1 in the fourth row: `[3, 2, 1]` which is `3 * 2 + 2 * 1 = 8`.\nThis statement counts 1s in each row, then skips zeroes.\n```\nbank.map(e => (e.match(/1/g) || []).length).filter(a => a !== 0);\n```\nSo we have\n```\nfunction numberOfBeams(bank: string[]): number {\n  const devices: number[] = bank.map(e => (e.match(/1/g) || []).length).filter(a => a !== 0);\n  \n  if (!devices.length || devices.length === 1) {\n    return 0;\n  }\n\n  let sum = 0;\n\n  for (let i = 1; i < devices.length; i++) {\n    sum += devices[i] * devices[i - 1];\n  }\n  \n  return sum;\n}\n```\nLet me know if you have any questions. Please hit upvote if you find it useful.
['String', 'TypeScript', 'JavaScript']