Given a 2D array only has 1s and 0s. 1 means there is a point and return false if there is no rectangle in this array. For example,
int [] [] array = { {1,0,0,0,1},
{1,0,1,0,1},
{0,1,1,0,1} }
return true
int [] [] array = { {1,0,0,0,1},
{1,0,1,0,0},
{0,1,1,0,1} }
return false
I came up with a O(n^3) solution, but I was wondering that is there any method can do better?
Thanks!