Given unsorted transactions, find the maximum total amount spent in any continuous 24-hour period, either for a given account or across all accounts combined.
Each transaction is a string "trxId,accountId,timestamp,amount".
trxId: unique transaction ID.accountId: account that made the transaction.timestamp: Unix time in seconds.amount: non-negative integer amount. All amounts use the same currency unit.long maxSpendForAccount(List<String> transactions, String accountId)
long maxSpendAllAccounts(List<String> transactions)
Return 0 if there are no applicable transactions.
A window starting at start includes timestamps satisfying start ≤ timestamp < start + 86,400. Transactions exactly 24 hours apart cannot be included together. Count separate transactions at the same timestamp individually.
0 ≤ transactions.size() ≤ 100,0000 ≤ timestamp ≤ 1,000,000,000,0000 ≤ amount ≤ 1,000,000,000transactions = List.of("t4,B2,93600,110", "t1,A1,0,90", "t5,A1,100000,20", "t2,A1,3600,50", "t3,B2,90000,70")
maxSpendForAccount(transactions = transactions, accountId = "A1")140. Transactions t1 and t2 total 90 + 50 = 140.maxSpendAllAccounts(transactions = transactions)200. The window [90000, 176400) contains t3, t4, and t5, totaling 70 + 110 + 20 = 200.transactions = List.of("t8,A1,86400,60", "t6,A1,0,100", "t7,B2,0,50")
maxSpendForAccount(transactions = transactions, accountId = "A1")100. Transactions t6 and t8 are exactly 24 hours apart, so they cannot be included together.maxSpendAllAccounts(transactions = transactions)150. The window [0, 86400) includes t6 and t7.maxSpendForAccount(transactions = transactions, accountId = "C3")0. Account C3 has no transactions.