totalChalk
to store the sum of all chalk requirements.chalk
array to calculate totalChalk
.remainingChalk
by taking the modulo of k
with totalChalk
.chalk
array again and subtract each student's chalk requirement from remainingChalk
.remainingChalk
is less than the current student's requirement, return the index of that student.remainingChalk
, return 0 as the process will start over.