# Hacker Rank solution for Compare The Triplets in C++

Problem:- Solution of Hackerrank - Compare The Triplets in java or Compare The Triplets solution or Compare The Triplets solution in C++ or Compare The Triplets hacker rank solution in Java or Compare The Triplets hacker rank solution c++ or Compare The Triplets hacker rank solution c++ or Compare The Triplets program in c or Compare The Triplets solution in c or Compare The Triplets hacker rank solution in python or Compare The Triplets in java or Compare The Triplets hacker rank solution in c or Hacker Rank Solution For Compare The Triplets in C++ or Compare The Triplets in C++ or Hacker Rank solution for Compare The Triplets in C++.

Check This- Hacker rank Solution for C++ Sub Domain Introduction, Classes, STL, Inheritance.

Logic:- Compare The Triplets problem is very simple and similar to comparing marks of three subject of two students in a way like if subject1, student1 got high marks than student2 than student1 got 1 point and the same repeat for subject2, and subject3 at the end print the both student points. Maximum points can a student earn is 3 or minimum can be 0 or there may be the equal point if in subject1 both students got the same point. Check the explanation section for better understanding.

Explanation:- Let's take an example and compare with our logic, suppose two students are Bob and Alice and Bob got 56, 75, 26 marks and Alice got 84, 45, 26 Now Compare The Triplets

Bob Marks===> 56, 75, 26
Alice Marks==> 84, 45, 26

Bob Marks         Alice Marks         Bob Point          Alice Point

56              <              84                   0                         1
75              >              45                   1                         0
26              =              26                   0                         0

So we can see that Bob and Alice got 1, 1 point in tale That is an answer print on the screen.

Also check- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard Domain.

Copy the full solution or colored code and paste into the hacker rank editor and click to Run Code if the code runs successfully then click to Submit Code. Before pasting the code into the editor make sure you have chosen c++ editor in the top right drop down option.

Tip:- No need to use huge header file as you can see I use in below problem use a Master Header File #include<bits/stdc++.h>. This single header file is enough for perform all operations in C++ include strings operations. Before copy the solution I recommended please read this full article, this will help you to build your own logic.

Solution:-

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main()
{
int a0;
int a1;
int a2;
cin >> a0 >> a1 >> a2;
int b0;
int b1;
int b2;
cin >> b0 >> b1 >> b2;
int a=0,b=0;
if(a0>b0)
a++;
if(a0<b0)
b++;
if(a1>b1)
a++;
if(a1<b1)
b++;
if(a2>b2)
a++;
if(a2<b2)
b++;
cout<<a<<" "<<b;
return 0;
}

Output:-