Longest Signal Run in the Antenna Grid

A radio observatory points a rectangular array of antennas at a distant pulsar. During one observation pass, every antenna records a 1 if it locked onto the pulsar's sweep at that instant, or a 0 if it caught only background noise.

The beam travels across the array along a perfectly straight path, so a genuine detection run always shows up as consecutive 1s aligned in exactly one of four ways:

  • Horizontal: left to right within a single row.
  • Vertical: top to bottom within a single column.
  • Diagonal: along the main diagonal direction, from top-left toward bottom-right.
  • Anti-diagonal: along the counter-diagonal direction, from top-right toward bottom-left.

Given the recorded bit grid, return the length of the longest straight detection run of consecutive 1s found anywhere in the grid, considering all four alignments. Runs may start at any cell, may touch the border, and may overlap each other. If no antenna ever locked on, return 0.

Examples
Input: [[1,1,0,0],[0,1,1,0],[0,0,1,0],[0,0,0,1]]
Output: 4
Hints

Longest Signal Run in the Antenna Grid

A radio observatory points a rectangular array of antennas at a distant pulsar. During one observation pass, every antenna records a `1` if it locked onto the pulsar's sweep at that instant, or a `0` if it caught only background noise.