start from first row i=0;
move right until you find 1.
if you find 0 , say at index j ( arr[0][j] ), them one row down i.e at
row[1][j]and then move right.
continue in this this fashion and keep track row at which latest '1' is
found.
when you reach j=N...you will have the row index which has
in above algo..little correction.
move down every time you find 0 , and move right every time you find 1.
On Tue, Dec 27, 2011 at 3:42 PM, atul anand atul.87fri...@gmail.com wrote:
start from first row i=0;
move right until you find 1.
if you find 0 , say at index j ( arr[0][j] ), them one
A NxN matrix is given containing only 1’s and 0’s. Every row is sorted in
descending order. Find the row containing maximum no. of ones.
time complexity-O(n);
--
Jyoti Saini.
B.Tech-Final year.
Information Technology.
National Institute of Technology,Kurukshetra.
Alt Email jsa...@yahoo-inc.com