Implement prototype(loads) and solve(loads) in exercise.mjs. Input is an array of nonnegative BigInt values. Return the two-element array [total, firstMaximumIndex], where total is BigInt and the index is a Number or null.

Ties choose the smallest original index. [8n, 2n, 8n] returns [18n, 0]; [0n] returns [0n, 0]; [] returns [0n, null]. Values such as 10n ** 30n are valid and totals must remain exact.

Prototype: make direct scans. Final: retain total and first maximum index in one O(n) scan with O(1) auxiliary state. Do not sort or mutate input. No additional validation is required.

Run with Node.js 20+ from this directory:

Shell
node main.mjs --stage prototype
node main.mjs --stage final

Edit exercise.mjs; keep main.mjs unchanged. Both stages begin as unfinished learner functions. The website uses the same test functions in a separate browser worker. Tests check deterministic examples, boundaries, documented validation, input preservation, and stage-specific cases. Passing tests does not prove the required time complexity.

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.