In this

**HackerEarth Ashish and Binary Matrix problem solution**Pulkit is really good at maths. Recently, he came to know about a problem on matrices. Amazed by the problem he got, he asked Ashish the same problem. Ashish also being good at maths solved the problem within 5 minutes. Now, its your time to solve the problem.You will be given n*m binary matrix. You need to tell if it is possible to delete a column such that after deleting that column, rows of the matrix will be unique. If yes than print "Yes" else print "No".

## HackerEarth Ashish and Binary Matrix problem solution.

`#include<bits/stdc++.h>`

using namespace std;

int main()

{

set<string> s;

int t;

scanf("%d",&t);

while(t--)

{

int n,m;

scanf("%d %d",&n,&m);

string str;

for(int i=0;i<n;++i)

{

cin>>str;

s.insert(str);

}

if(s.size()==n)

printf("Yes\n");

else

printf("No\n");

s.clear();

}

return 0;

}

### Second solution

`#include <bits/stdc++.h>`

using namespace std;

int main()

{

int t;

cin >> t;

while ( t-- ) {

int n,m1;

cin >> n >> m1;

vector <string> v;

map <string,int> m;

map <string,int> :: iterator it;

for ( int i = 0; i < n; i++ ) {

string s;

cin >> s;

m[s]++;

v.push_back(s);

}

for ( it = m.begin(); it != m.end(); it++ ) {

if ( (*it).second > 1 ) {

cout << "No" << endl;

goto p1;

}

}

cout << "Yes" << endl;

p1: { }

}

return 0;

}

## 0 Comments