Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions row_with_max_1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// problem link:https://practice.geeksforgeeks.org/problems/row-with-max-1s0023/1?page=2&status[]=unsolved&category[]=Arrays&category[]=Recursion&sortBy=submissions

//{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;

// } Driver Code Ends
//User function template for C++
class Solution{
public:
int rowWithMax1s(vector<vector<int> > arr, int n, int m) {

for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
if(arr[j][i]==1)
return j;
}
}
return -1;
}

};

//{ Driver Code Starts.
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
vector< vector<int> > arr(n,vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin>>arr[i][j];
}
}
Solution ob;
auto ans = ob.rowWithMax1s(arr, n, m);
cout << ans << "\n";
}
return 0;
}

// } Driver Code Ends