diff --git a/Cars.java b/Cars.java new file mode 100644 index 0000000..01276fa --- /dev/null +++ b/Cars.java @@ -0,0 +1,24 @@ +import java.util.*; + +public class Cars { + public static void main(String[] args){ + Queue cars = new LinkedList<>(); + Scanner scn = new Scanner(System.in); + + int n = scn.nextInt(); + for (int i = 0; i < n; i++) { + cars.add(scn.next()); + } + + for (int i = 0; i < n; i++) { + System.out.println(cars.poll()); + } + + if (cars.isEmpty()){ + System.out.println("is empty"); + } + else { + System.out.println("is not empty"); + } + } +} diff --git a/Detective.java b/Detective.java index 5707416..9b166ff 100644 --- a/Detective.java +++ b/Detective.java @@ -1,8 +1,5 @@ - import java.util.ArrayList; - class ToDos { - public static void main(String[] args) { // Sherlock @@ -26,10 +23,20 @@ public static void main(String[] args) { // Print the size of each ArrayList below: - + System.out.println("Sherlock: " + sherlocksToDos.size()); + System.out.println("Poirot: " + poirotsToDos.size()); // Print the name of the detective with the larger to-do list: - + + String busyDetective; + if (sherlocksToDos.size() > poirotsToDos.size()){ + busyDetective = "Sherlock"; + } + else { + busyDetective = "Sherlock"; + } + System.out.println(busyDetective); + } } diff --git a/HashCollisionChecker.java b/HashCollisionChecker.java index 80631a7..75be41f 100644 --- a/HashCollisionChecker.java +++ b/HashCollisionChecker.java @@ -2,13 +2,19 @@ public class HashCollisionChecker { public static int countOfUniqueHashCodes(HashSet set) { - // TODO: Implement - return 0; + HashSet HashCodes = new HashSet<>(); + for (T member : set) { + HashCodes.add(member.hashCode()); + } + return HashCodes.size(); } public static int countOfUniqueHashCodes(HashMap map) { - // TODO: Implement - return 0; + HashSet HashCodes = new HashSet<>(); + for (K key : map.keySet()){ + HashCodes.add(key.hashCode()); + } + return HashCodes.size(); } public static void main(String[] args) { diff --git a/shuffle.java b/shuffle.java new file mode 100644 index 0000000..3380405 --- /dev/null +++ b/shuffle.java @@ -0,0 +1,13 @@ +import java.util.*; +public class shuffle { + public static void main(String[] args){ + LinkedList myLL = new LinkedList<>(); + Scanner scn = new Scanner(System.in); + int n = scn.nextInt(); + for (int i = 0; i < n; i++){ + myLL.add(scn.nextInt()); + } + Collections.shuffle(myLL); + } + +} diff --git a/uni.java b/uni.java new file mode 100644 index 0000000..b239786 --- /dev/null +++ b/uni.java @@ -0,0 +1,42 @@ +import java.util.Scanner; +import java.util.*; + +public class uni { + public static void main(String args[]){ + Scanner scn = new Scanner(System.in); + int studentsCount = scn.nextInt(); + TreeSet studentsTreeSet = new TreeSet<>(); + + for (int i=0 ; i < studentsCount ; i++){ + String name = scn.next(); + int id = scn.nextInt(); + double gpa = scn.nextDouble(); + student student=new student(name, id , gpa); + studentsTreeSet.add(student); + } + } + public static student searchId(int Id, TreeSet studentsTreeSet){ + student st = new student("john", 00, 0.00); + for (student i : studentsTreeSet){ + if (i.id == Id){ + st = i; + } + } + return st; + } + + public static void printInfo(student st){ + System.out.println("name :" + st.name+ "Id : "+ st.id+"gpa :" + st.gpa); + } +} + +class student { + String name; + int id; + double gpa; + public student(String name , int id , double gpa){ + this.name=name; + this.id=id; + this.gpa = gpa; + } +}