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

HackerEarth Ashish and Binary Matrix problem solution

YASH PAL, 31 July 202417 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 *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

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