From 91f195c14a634e8dcfea58e348dfee3dca2c7581 Mon Sep 17 00:00:00 2001 From: sohrabiei Date: Sat, 29 Jun 2024 13:38:14 +0330 Subject: [PATCH] Update HashCollisionChecker.java --- HashCollisionChecker.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/HashCollisionChecker.java b/HashCollisionChecker.java index 80631a7..a27740e 100644 --- a/HashCollisionChecker.java +++ b/HashCollisionChecker.java @@ -3,12 +3,20 @@ public class HashCollisionChecker { public static int countOfUniqueHashCodes(HashSet set) { // TODO: Implement - return 0; + HashSet unique = new HashSet<>(); + for (T i: set) { + unique.add(i.hashCode()); + } + return unique.size(); } public static int countOfUniqueHashCodes(HashMap map) { // TODO: Implement - return 0; + HashSet unique = new HashSet<>(); + for (K i: map.keySet()) { + unique.add(key.hashCode()); + } + return unique.size(); } public static void main(String[] args) {