This is quite a simple script, you pass in the array of students arrival time, and the minimum amount of students for class to start.
Then you simply loop for the times of students arrivals, and for each on time or before you add to a counter, now if the counter is equal or bigger then the min amount then we have a class.