Expense Ledger
Reddit interview questions · Hard · Coding round · 6 tests
Reddit lost the database table that stored the current billing status for advertisers, but the full transaction log still exists. Using that log, work out where each user mentioned in it ends up in terms of billing status.
Interface
interface Transaction {
userId: string;
adDeliveryPennies?: string | number | null;
paymentPennies?: string | number | null;
transactionTimestamp?: string; // present in logs but not needed for reconstruction
}
interface BillingStatus {
adDeliveryPennies: number;
paymentPennies: number;
}
reconstructBillingStatuses(
transactions: Transaction[],
): Record<string, BillingStatus>Run your code with Ctrl+Enter to see results.