Here is some sample data:
Bio 256:
LEC 1: 9am-10am
LEC 2: 10am-11am
LEC 3: 2pm-3pm
LAB 1: 10:30am-12pm
LAB 2: 1pm-2:30pm
LAB 3: 3pm-4:30pm
Chem 356:
LEC 1: 9am-10am
LEC 2: 11am-12pm
LEC 3: 12pm-1pm
LAB 1: 8am-9:30am
LAB 2: 2pm-3:30pm
LAB 3: 4pm-5:30pm
Math 266:
LEC 1: 8am-9am
LEC 2: 10am-11am
LEC 3: 3pm-4pm
LAB 1: 10am-11:30am
LAB 2: 12:30pm-2pm
LAB 3: 3:30pm-5pm
Overall, a student would have 6 classes (1 lecture and 1 lab for each course), how do I find from this data the shortest amount of time a student would have to spend at school?
I tried simple greed algorithms (arrange by earliest end time, and removing rest of group, for example Lab2 and Lab3 if, Lab1 is picked), however that doesn't work.