NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

A merchant receives payouts on a fixed schedule. You are given an array transactions and a positive integer payoutInterval. Each transaction record has the format "<transactionId>,<amount>,<day>", where amount and day are integers representing the amount in cents and the transaction day, respectively.

Payout days are payoutInterval, twice payoutInterval, and so on. Each transaction belongs to the earliest payout day strictly after its transaction day, so a transaction on a payout day belongs to the next payout.

Transactions assigned to the same payout day are combined. Each payout has the format "<payoutDay>,<amountInDollars>,<transactionIds>". Its amount is the sum in cents converted to dollars with exactly two decimal places, and its transaction IDs are joined by "|" in their original input order.

Return the payouts with transactions, sorted by payout day.

Constraints:

  • 0 ≤ transactions.length ≤ 1,000.
  • 1 ≤ payoutInterval ≤ 1,000.
  • 0 ≤ day ≤ 106.
  • 0 ≤ amount ≤ 106 cents.
  • Transaction IDs are unique and nonempty, contain no commas or vertical bars, and have at most 30 characters. Records are well-formed.

Example 1:

Input: transactions = ["t1,1250,0", "t2,375,2", "t3,500,3"], payoutInterval = 3 Output: ["3,16.25,t1|t2", "6,5.00,t3"] Explanation: The first two transactions belong to day 3 and total 16.25 dollars. The transaction on day 3 belongs to day 6.

Example 2:

Input: transactions = ["c,5,8", "a,99,1", "b,1,2", "d,500,6", "e,0,5"], payoutInterval = 3 Output: ["3,1.00,a|b", "6,0.00,e", "9,5.05,c|d"]

Example 3:

Input: transactions = ["a,100,4", "b,250,0", "c,50,4", "d,1,5"], payoutInterval = 5 Output: ["5,4.00,a|b|c", "10,0.01,d"]


Accepted
96/375
Acceptance Rate25.6%
Test Cases
Input
transactions =
payoutInterval =
Output
Expected