Question bank › Prefix Sum
Dsa Prefix Sum Easy

Drone Battery Drain

A logistics drone flies over a straight path divided into N sectors. Each sector has a specific 'wind resistance' value. The battery consumed to cross a range of sectors is the sum of their resistance values. Given the resistance of each sector and Q flight plans (each defined by a start and end sector), calculate the total battery consumed for each plan. Input Format: - Line 1: Two integers N and Q. - Line 2: N integers representing the wind resistance of each sector (0-indexed). - Next Q lines: Two integers L and R, representing the inclusive range of sectors [L, R]. Output Format: - For each query, print the total battery consumed on a new line. Example: Input: 5 2 10 20 30 40 50 0 2 1 4 Output: 60 140

Key concepts

prefix_sumrange_query

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.