Indeed Interview Question

Sum range problem