java hashset hackerrank solution - java 15
for explanation watch video:
code:
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
scn.nextLine();
HashSet<String> hs = new HashSet<>();
for(int i=0;i<t;i++){
String s = scn.nextLine();
hs.add(s);
System.out.println(hs.size());
}
}
}
Comments
Post a Comment