Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int[] findConflictingStudent(int[] schedule, String[] students, String[] courses,
- int[][] studentCourses, int k) {
- boolean isLegal = true;
- int[] output = new int[4];
- int[] legal = new int[0];
- for (int i = 0; i < schedule.length & isLegal == true; i = i + 1) {
- for (int j = 0; j < schedule.length & isLegal == true; j = j + 1) {
- if (i != j && schedule[i] == schedule[j]) { // check if there
- // are two exams at
- // the same day
- for (int m = 0; m < studentCourses.length & isLegal == true; m = m + 1) {// check
- // if
- // there
- // is
- // a
- // student
- // is
- // registered
- // to
- // both
- // courses
- boolean isFirstCourse = false;
- boolean isSecondCourse = false;
- for (int f = 0; f < studentCourses[m].length & isFirstCourse == false; f = f + 1)
- if (studentCourses[m][f] == i) {
- isFirstCourse = true;
- output[1] = m;
- output[2] = studentCourses[m][f];
- }
- for (int g = 0; g < studentCourses[m].length & isSecondCourse == false; g = g + 1)
- if (studentCourses[m][g] == j) {
- isSecondCourse = true;
- output[3] = studentCourses[m][g];
- output[0] = schedule[i];
- }
- if(isFirstCourse&isSecondCourse)
- isLegal=false;
- }
- }
- }
- }
- if (isLegal==false)
- return output;
- else
- return legal;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement