Wipro NLTH Coding Sample Question- 3

PrepSter Wipro NLTH Coding Question – 3

Ques:  Given an n-by-n matrix of 0’s and 1’s where all 1’s in each row come before all 0’s, find the most efficient way to return the row with the maximum number of 0’s.

{1,1,1,1},
{1,1,0,0},
{1,0,0,0},
{1,1,0,0},

NOTE:- Please comment down the code in other languages as well below –

#include <stdio.h>
#include <stdlib.h> #define COL 4 #define ROW 4 using namespace std; int main () { int arr[ROW][COL] = { {1, 1, 1, 1}, {1, 1, 0, 0}, {1, 0, 0, 0}, {1, 1, 0, 0}, }; int rownum; int i = 0, j = COL - 1; while (i; 0) { if (arr[i][j] == 0) { j--; rownum = i; } else i++; } printf ("%d", rownum); getch (); return 0; }
Code is not available yet, comment down the code below the page 
in the comment section using the same logic or different approach you want to.
Code is not available yet, comment down the code below the page in the comment section 
using the same logic or different approach you want to.
Code is not available yet, comment down the code below the page in the comment
section using the same logic or different approach you want to.