Flipkart Interview Question
Software Engineer / DevelopersI am unable to understand the question
Can you please provide another example with details
@mac
You are absolutely right.
they want the same soln.
Only modification is. u can use binary search. i.e check mid one if its 0 go left else right.
complexity with ur soln is 0(n+n) . and they want exactly the same
#include<stdio.h>
int main()
{
int arr[7][7]={
1,1,0,0,0,0,0,
1,1,1,0,0,0,0,
1,0,0,0,0,0,0,
1,0,0,0,0,0,0,
1,1,1,1,1,0,0,
1,1,1,1,1,1,1,
1,0,0,0,0,0,0
};
int i=0,j=0,flag=0;
while(i<7)
{
while(arr[i][j]==1)
{
j++;
}
printf("j= %d\n",j);
i++;
}
i--;
j--;
printf("i=%d and j=%d",i,j);
return 0;
}
i think the Question is .
- mac June 26, 2010if situation is like .
110000
111000
100000
100000
111110
then Answer would be the last row and No of 1's are 5 ..
Solution :
Start from the first row .. go till we encounter any zero.
Then step down by one if this new value of second row and same column is also Zero then keep stepping down without increasing Column No. else go in the same Row till find any zero.
You would be with the Row No and No'f of Max 1's at the end.
Please correct if m wrong