-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de91431
commit 973c32e
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
Contests/August Long Challenge 2021 Division 3/Problem Difficulties (PROBDIFF)/PROBDIFF.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} | ||
} |