Opening your workspace…
Workspace/Coding room
Opening your workspace…
On the duck ferry a positive fare means one passenger paid, however many crumbs they handed over. A negative fare is a promise to pay that many crumbs later. Zero is the ferrymouse riding home. Return two numbers in order. Give the number of paying passengers and the total crumbs still owed, expressed as a positive amount or zero.
[4,-3,0,2,-5]OUTPUT[2,8]Two ducks paid. The two IOUs promise three and five crumbs.
[7,9]OUTPUT[2,0]Both passengers paid up front.
A paying duck counts as one. An IOU counts for the number of crumbs written on it.
/** @param {number[]} fares * @returns {number[]} */ function solve(fares) { // Write your answer here. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.
[4,-3,0,2,-5][2,8]