Question bank › Prefix Sum
Dsa Prefix Sum Easy

Fitness Tracker

A fitness application tracks the number of steps a user takes daily. Write a program that computes the total number of steps taken over a specified range of days. Input format: - The first line contains an integer F (1 ≤ F ≤ 100,000), the number of days. - The second line contains F integers, representing the number of steps recorded for each day. - The third line contains two integers, startDay and endDay (0 ≤ startDay ≤ endDay < F), indicating the range of days. Output format: - Output a single integer: the total steps from startDay to endDay (inclusive). Example: Input: 7 5000 10000 15000 20000 25000 30000 35000 2 5 Output: 120000

Key concepts

prefix_sumsubarray_sum

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.