Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
You have prepared four problems. The difficulty levels of the problems are A1,A2,A3,A4A1,A2,A3,A4 respectively. A problem set comprises at least two problems and no two problems in a problem set should have the same difficulty level. A problem can belong to at most one problem set. Find the maximum number of problem sets you can create using the four problems.
For each test case, print a single line containing one integer – the maximum number of problem sets you can create using the four problems.
Subtask #1 (100 points): Original constraints
3
1 4 3 2
4 5 5 5
2 2 2 2
2
1
0
Test case 11: You can prepare the first problem set using the first two problems and the second problem set using the next two problems. So the problem sets will be [1,4][1,4] and [3,2][3,2].
Test case 22: You can prepare one problem set using one problem having a difficulty level of 44 and the other having a difficulty level of 55. There is no way to prepare more than one problem set.
Test case 33: There is no way to prepare a problem set.
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n=4;
int a[n];
for (int i = 0; i < n; i++) {
cin>>a[i];
}
sort(a,a+n);
if(a[0]==a[1] && a[1]==a[2] && a[2]==a[3])
cout<<"0"<<endl;
else if(a[0]!=a[1] && a[1]!=a[2] && a[2]!=a[3])
cout<<"2"<<endl;
else if(a[0]==a[1] && a[1]==a[2])
cout<<"1"<<endl;
else if(a[1]==a[2] && a[2]==a[3])
cout<<"1"<<endl;
else
cout<<"2"<<endl;
}
return 0;
}
t = int(input())
for _ in range(t):
inputt = [int(i) for i in input().split()]
inputt.sort()
if(inputt[0]==inputt[1] and inputt[2]==inputt[3] and inputt[0]!=inputt[3]):
print(2)
continue
inputt = set(inputt)
if len(inputt) == 4 or len(inputt) == 3:
print(2)
continue
if len(inputt) ==2:
print(1)
else:
print(0)
In our experience, we suggest you solve this Problem Difficulties CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
Problem Difficulties Problem is available on Hacker Rank for Free, if you are stuck anywhere between a compilation, just visit Queslers to get Problem Difficulties CodeChef Solution.
I hope this Problem Difficulties CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More on Queslers >>