forked from SedaKunda/hackerrank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashset.java
More file actions
27 lines (22 loc) · 796 Bytes
/
Hashset.java
File metadata and controls
27 lines (22 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
You are given n pairs of strings. Two pairs (a,b) and (c,d) are identical if a=c and b=d. That also implies (a,b) is not same as (b,a). After taking each pair as input, you need to print number of unique pairs you currently have.
Note: Brute force solution will not earn full points.
*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Hashset {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner s = new Scanner(System.in);
int sum = s.nextInt();
s.nextLine();
HashSet hs = new HashSet();
for (int i=0;i <sum;i++) {
hs.add(s.nextLine());
System.out.println(hs.size ());
}
}
}