Implement Prototype(values []int, queries [][2]int) ([]int,error) with independent scans; Solve uses one prefix table in O(n+q) time and O(n) auxiliary space. Each query is [left,right), with 0 <= left <= right <= len(values). Empty ranges total zero. Invalid bounds return a nonnil error. Preserve both inputs, including on error. Integers and results fit int.

Edit exercise.go; retain the public types and signatures. prototype and final are separate stages. The executable tests recover panics as failures, report named checks, and exit nonzero on any failure. A successful run must execute at least one check. Tests use logical time or explicit synchronization where relevant.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.