条件的算法描述如下:
Given integer m and n where n is odd, for all mxn matrixes that consist of 0 and 1, find the one that has max count of 1s and meets following conditions:
- All 0s are connected;
- All 1s are adjacent to at least one 0 (Adjacent includes diagonal line adjacent, 8 directions);
- maxtrix[m-1][n/2] = 0.
Example :
Input: m=2, n=3
Output: [[1,1,1],[1,0,1]]
Follow up:
Given another list of ‘blocked’ points. Matrix will set those points to -1 and you cannot change that. Solve the problem again.
目前所得结果:
Max=135
如果有更高级解法,请指教~