Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Transaction Totals Per Minute

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Transaction Totals Per Minute. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Ramp needs a chronological minute-by-minute summary of card transaction activity. Given a list of Ramp card transactions, return the total amount for every minute from the earliest transaction minute through the latest transaction minute, including minutes with no transactions.

Formal Specification

Implement aggregate_minute_totals(transactions). Each transaction is a dictionary with:

  • timestamp: a non-negative Unix timestamp in seconds
  • amount: an integer amount in cents

Return a list of integer totals in chronological minute order. A transaction belongs to minute timestamp // 60. The output starts at the minute containing the earliest transaction and ends at the minute containing the latest transaction, both inclusive. Preserve zero totals for empty minutes. The input order is arbitrary.

Constraints

  • 1 <= len(transactions) <= 10^5
  • 0 <= timestamp <= 10^12
  • 0 <= amount <= 10^9
  • The output timeframe contains at most 10^6 minutes
  • Amounts are non-negative integers representing cents

Function Signature

def aggregate_minute_totals(transactions):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output