Code Room
CodingEasycod-g1295
Subject Prefix sumLevel Entry–Mid~11 minCommon in Databases & SQL · Algorithms & data structures interviewsIndustries Software development

Question

Given a list of integers, a batch of queries, and an integer limit, count how many queries select a range whose sum is strictly below the limit. Each query is a pair [l, r] with 0 <= l <= r < n, selecting elements l through r inclusive. Return the number of qualifying queries. Values may be negative. Example: values = [8, 2, 5, 1], queries = [[0, 1], [1, 3], [2, 3]], limit = 9 gives 2 — the range sums are 10, 8, and 6.

Implement
count_below_limit(values: list[int], queries: list[list[int]], limit: int) → int
Examples
in[[8,2,5,1],[[0,1],[1,3],[2,3]],9]out2
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.