Skip to content

Amin Asef Agah #7

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
24 changes: 24 additions & 0 deletions Cars.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import java.util.*;

public class Cars {
public static void main(String[] args){
Queue<String> 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");
}
}
}
17 changes: 12 additions & 5 deletions Detective.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

import java.util.ArrayList;

class ToDos {

public static void main(String[] args) {

// Sherlock
Expand All @@ -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);

}

}
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<>();
for (T member : set) {
HashCodes.add(member.hashCode());
}
return HashCodes.size();
}

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

public static void main(String[] args) {
Expand Down
13 changes: 13 additions & 0 deletions shuffle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.util.*;
public class shuffle {
public static void main(String[] args){
LinkedList<Integer> 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);
}

}
42 changes: 42 additions & 0 deletions uni.java
Original file line number Diff line number Diff line change
@@ -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<student> 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<student> 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;
}
}