Skip to content

Commit

Permalink
Create PROBDIFF.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Manjot1151 authored Oct 4, 2021
1 parent de91431 commit 973c32e
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.util.*;
import java.lang.*;
import java.io.*;

public class Codechef {

public static void main(String[] args) throws Exception {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while (t-- > 0) {
HashMap < Integer, Integer > freq = new HashMap < Integer, Integer > ();
for (int i = 0; i < 4; i++) {
int a = in.nextInt();
if (!freq.containsKey(a)) {
freq.put(a, 1);
} else {
freq.put(a, freq.get(a) + 1);
}
}
System.out.println(pairs(freq));
}
}
private static int pairs(HashMap < Integer, Integer > freq) {
if (freq.containsValue(4))
return 0;
else if (freq.containsValue(3))
return 1;
else
return 2;

}
}

0 comments on commit 973c32e

Please sign in to comment.