Python interview question: range sum queries

EasyPrefix sums

Problem

revenue is a store’s daily revenue, with days numbered from 1. Each query [first, last] in queries asks for the total from day first through day last, both included. Return the totals in query order.

def range_revenue(revenue: list[int], queries: list[list[int]]) -> list[int]:

Example

Solve it free

Checked against hidden tests, right in your browser. No sign-up needed.

Skills it tests

More interview questions

All questions