LeetCode
Prison Cells After N Days
Click
here
for an explanation.