There are 24*60 = 1440
minutes per day. So you could easily brute force it, since you don't need to get more than on a minute basis accuracy. However I'm gonna describe a simple DP.
You can create a boolean array that stores whether that minute has a class in it by one of the students in the group. You also have a second array. This array stores the number of open spaces in this block and to the left. So what you can do is traverse the boolean array from right to left and if the block has a class in it you make the number 0, otherwise you make it 1 plus the number in the minute prior.
However, I feel my explanation lacking, so here is pseudo code:
blocked = <boolean array>;
numtoleft = <array containing the counts>;
if blocked[0]:
numtoleft[0] = 0;
else:
numtoleft[0] = 1;
for i = 1 to 1440-1:
if blocked[i]:
numtoleft[i] = 0;
else:
numtoleft[i] = numtoleft[i-1];
Then you can easily find the biggest open slot by finding the maximum number in the 'numtoleft' array and you can add restrictions to the times you are looking at.
EDIT:
Here's the algorithm in python:
def largestslot(blocked, startminute, endminute):
numtoleft = [0]*1440
numtoleft[startminute] = 0 if blocked[startminute] else 1
for i in xrange(startminute+1, endminute+1):
numtoleft[i] = 0 if blocked[i] else 1
ansmax = max(numtoleft[startminute:endminute+1)
ansi = numtoleft.index(ansmax)
return (ansi-ansmax, ansi)