Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function currMax = findBlock(A)
- [numRows, numCols] = size(A);
- currMax = 0;
- for (i = 1 : numRows)
- row = A(1,:);
- %Get longest run of 1s
- count = getMaxRun(row);
- for j = i+1 : numRows
- row = bitand(row, A(j,:));
- nuCount = getMaxRun(row) * (j - i + 1);
- if nuCount >= count
- count = nuCount;
- else
- break;
- end
- end
- if count > currMax
- currMax = count;
- end
- end
- end
- function maxRun = getMaxRun(vec)
- maxRun = max(diff(find([0 vec 0]~=1))) - 1;
- end
Add Comment
Please, Sign In to add comment