Allocate refund across payments

Quick Overview

This question evaluates algorithm design and data-structure selection skills, focusing on greedy allocation, ordering by priority and recency, aggregation of transaction amounts, and analysis of time complexity.

Allocate refund across payments

Company: Airbnb

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

##### Question Given a list of completed payment transactions (each with payment method, date, and amount) and a refund amount R, write an algorithm that issues refunds according to the rules: Always refund in full from one payment before moving to the next. Prefer payment methods in the priority order CREDIT → CREDIT_CARD → PAYPAL. Within the same method, refund the most recent payment first. Return the list of refund allocations (payment id, method, amount). Explain the algorithm’s time complexity and data structures.

Quick Answer: This question evaluates algorithm design and data-structure selection skills, focusing on greedy allocation, ordering by priority and recency, aggregation of transaction amounts, and analysis of time complexity.

|Home/Coding & Algorithms/Airbnb
Airbnb logo
Airbnb
Jul 29, 2025, 8:05 AM
mediumSoftware EngineerOnsiteCoding & Algorithms
78
0
Question

Given a list of completed payment transactions (each with payment method, date, and amount) and a refund amount R,

write an algorithm that issues refunds according to the rules:

Always refund in full from one payment before moving to the next.

Prefer payment methods in the priority order CREDIT → CREDIT_CARD → PAYPAL.

Within the same method, refund the most recent payment first.

Return the list of refund allocations (payment id, method, amount). Explain the algorithm’s time complexity and data structures.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...