Indeed interview question

Sum range problem