Skip to content

has done #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions Detective.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@

import java.util.ArrayList;

class ToDos {

public static void main(String[] args) {

// Sherlock
ArrayList<String> sherlocksToDos = new ArrayList<String>();

sherlocksToDos.add("visit the crime scene");
sherlocksToDos.add("play violin");
sherlocksToDos.add("interview suspects");
sherlocksToDos.add("solve the case");
sherlocksToDos.add("apprehend the criminal");

// Poirot
ArrayList<String> poirotsToDos = new ArrayList<String>();

poirotsToDos.add("visit the crime scene");
poirotsToDos.add("interview suspects");
poirotsToDos.add("let the little grey cells do their work");
poirotsToDos.add("trim mustache");
poirotsToDos.add("call all suspects together");
poirotsToDos.add("reveal the truth of the crime");

// Print the size of each ArrayList below:
System.out.println("Sherlock's to-do list size: " + sherlocksToDos.size());
System.out.println("Poirot's to-do list size: " + poirotsToDos.size());



// Print the name of the detective with the larger to-do list:

if (sherlocksToDos.size() > poirotsToDos.size()) {
System.out.println("Sherlock has more tasks.");
} else if (sherlocksToDos.size() < poirotsToDos.size()) {
System.out.println("Poirot has more tasks.");
} else {
System.out.println("Both detectives have the same number of tasks.");
}
}

}
14 changes: 10 additions & 4 deletions HashCollisionChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

public class HashCollisionChecker {
public static <T> int countOfUniqueHashCodes(HashSet<T> set) {
// TODO: Implement
return 0;
HashSet<Integer> hashCodes = new HashSet<Integer>();
for (T item : set) {
hashCodes.add(item.hashCode());
}
return hashCodes.size();
}

public static <K, V> int countOfUniqueHashCodes(HashMap<K, V> map) {
// TODO: Implement
return 0;
HashSet<Integer> hashCodes = new HashSet<Integer>();
for (K key : map.keySet()) {
hashCodes.add(key.hashCode());
}
return hashCodes.size();
}

public static void main(String[] args) {
Expand Down