Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
One solution is to count ones in each direction separately and find the longest line. Don't you think it will take too much lines of code?
Is it possible to use some extra space to make the solution simple?
Can we use dynamic programming to make use of intermediate results?
Think of a 3D array which can be used to store the longest line obtained so far for each direction.