Clarity on overriding equals() and hashcode() in Java

Revision en1, by rohantrix, 2021-12-28 21:27:01

In today's Codeforces Round (#763) problem B, I tried finding a pair object in a HashSet. Even after overriding equals() and hashcode() methods, I still ended up with WA on test 4. Here is the link to my solutions:

1) WA Submission using HashSet

2) Working Solution using 2D matrix

Please let me know of a good fix for this.

vinam SecondThread

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English rohantrix 2021-12-28 21:27:01 577 Initial revision (published)