Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • 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 2024
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

Post navigation

Previous post
Next post

Related website

The Computer Science

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes