Sunday, 2 April 2017

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.

Submit your solution here:- Click here

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:-


Compare The Triplets in C++


You May Like This:-

1. Hacker Rank solution for Attribute Parser

2. Hacker Rank solution for Vector-Sort

3. Hacker Rank solution for Vector-Erase

4. Java Program For Find The Gross Salary Of An Employee

5. Hacker Rank solution for Sets-STL

6. Hacker Rank Solution For Mini-Max Sum In C++

7. Hacker Rank Solution For Birthday Cake Candles

8. C++ Program For Calculate Percentage Of 5 Subjects

9. Hacker Rank Solution For Strings

10. Hacker Rank Solution For Conditional Statements


Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

2 comments: