注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
他们换成karat了
Course Schedule /*
You're developing a system for scheduling advising meetings with students in a Computer Science program. Each meeting should be scheduled when a student has completed 50% of their academic program.
Each course at our university has at most one prerequisite that must be taken first. No two courses share a prerequisite. There is only one path through the program.
Write a function that takes a list of (prerequisite, course) pairs, and returns the name of the course that the student will be taking when they are halfway through their program. (If a track has an even number of courses, and therefore has two "middle" courses, you should return the first one.)
Sample input 1: (arbitrarily ordered)
prereqs_courses1 = [
["Foundations of Computer Science", "Operating Systems"],
["Data Structures", "Algorithms"],
["Computer Networks", "Computer Architecture"Algorithms", "Foundations of Computer Science"},
{"Computer Architecture", "Data Structures"},
{"Software Design", "Computer Networks"}
};
String[][] prereqsCourses2 = {
{"Data Structures", "Algorithms"},
{"Algorithms", "Foundations of Computer Science"},
{"Foundations of Computer Science", "Logic"}
};
String[][] prereqsCourses3 = {
{"Data Structures", "Algorithms"}
};
}
|