Everpure Interview Question

Asked to solve prefix sum