I think here ,

else if(temp-curr[0]+courses[i][0] <= courses[i][1] && courses[i][0] < curr[0])

temp-curr[0]+courses[i][0] <= courses[i][1] is unneccessary.

Because temp <= course[i-1][1] <= course[i][1]

so courses[i][0] < curr[0] ensures temp-curr[0]+courses[i][0] <= courses[i][1]