Rippling interview question

DS, algorithms