Problem in hackerrank java hashset

data-structure
java
sets

#1

I tried to solve this problem on hackerrank but I am failing some test cases.

My solution