Finding largest sequence in 2D array

by mymemesarespiciest   Last Updated September 11, 2019 02:05 AM

I'm practicing problems and found this weird one. I can't figure out the best way to solve it.

You are given a 2D matrix size n*n with only 1's and 0's, you have to find the longest sequence of 1's either column-wise or row-wise.

I'm pretty stuck on this problem. I was trying to use a divide and conquer technique to split up the array into 4 n/2 * n/2 arrays, but the step where I merge together is still so slow because I have to check every adjacent row/column. Any advice on a fast solution would be great. I've spent way too much time staring at this.

Related Questions

Updated June 29, 2015 16:02 PM

Updated January 31, 2018 15:05 PM

Updated October 13, 2017 17:05 PM

Updated December 30, 2016 08:02 AM