题目:http://www.careercup.com/question?id=13719754
1 0 0 1
0 0 1 00 0 0 0
Step1: Bring 1 to first row and first column and set everywhere else to 0. O(n*m), we'll get:
1 0 1 1
1 0 0 0
0 0 0 0
Step2: Starting from 2nd column to last column, fill columns with 1:
1 0 1 1
1 0 1 1
0 0 1 1
Step3: Starting from first row to last row fill rows with 1:
1 1 1 1
1 1 1 1
0 0 1 1
Step4: Fill for column at first index:
1 1 1 1
1 1 1 1
1 0 1 1