Prototype: implement prototype(long[] values, List<Update> commands) returning List<Long> with a direct baseline.
Final: implement solve(long[] values, List<Update> commands) with the mechanism and bounds described above. Update("add", index, delta) changes internal state; Update("sum", left, right) queries [left,right). Return only query totals in order. Negative values/deltas and empty ranges are valid. Reject unknown operations, out-of-bounds add indices, and ranges unless 0 <= left <= right <= n. Preserve original values and commands. Both stages have the same observable contract. The prototype may use the simpler method; final must use the target data structure.
The supplied nested record types define the API. All methods are static members of Exercise.
Complete the starter code, then run the checks.
Results and errors will appear here.
Java runs on this device with CheerpJ 4.3.