Problem in hackerrank java hashset

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

My solution