Skip to content
Programmingoneonone
Programmingoneonone
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth Ashish and Binary Matrix problem solution

YASH PAL, 31 July 202411 February 2026
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

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("Yesn");
else
printf("Non");
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;
}
coding problems solutions HackerEarth HackerEarth

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes