FastPrepReconstruct Billing Status
Problems/Reconstruct Billing Status

Reconstruct Billing Status

Reddit logoReddit● EasyONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

The examples below use a small wrapper format: each transaction is encoded as [user_id, ad_delivery_pennies, payment_pennies], an empty string means the amount field is missing, and the return value is sorted by user_id as "user_id:ad_delivery_pennies,payment_pennies".

Reddit stores billing statuses for advertisers in a database. Due to a data issue, the stored billing statuses were deleted. However, the system still has the complete transaction log.

Your task is to rebuild each advertiser's BillingStatus from the transaction logs.

Each user's billing status starts with two counters:

ad_delivery_pennies = 0
payment_pennies = 0

You are given a list of transaction logs. Each transaction belongs to exactly one user and contains a user_id. A transaction may include one or more billing amount fields, such as ad_delivery_pennies or payment_pennies.

For each transaction, update the billing status of the corresponding user by adding every amount field present in that transaction. If a field is missing from a transaction, treat it as 0.

Return the final billing status for every user that appears in the transaction logs.

Object-form Function Signature

function reconstructBillingStatus(transactions: Transaction[]): Record<number, BillingStatus>

Object-form Input Shape

Transaction {
  user_id: number
  ad_delivery_pennies?: number
  payment_pennies?: number
}

Object-form Output Shape

BillingStatus {
  ad_delivery_pennies: number
  payment_pennies: number
}

Return a mapping from user_id to BillingStatus.

Function

reconstructBillingStatus(transactions: String[][]) → String[]

Examples

Example 1

transactions = [["1", "100", ""], ["1", "", "40"], ["2", "25", "10"]]return = ["1:100,40", "2:25,10"]
  • User 1 receives 100 ad-delivery pennies from the first transaction and 40 payment pennies from the second transaction.
  • User 2 receives 25 ad-delivery pennies and 10 payment pennies.

The result is returned in increasing user_id order.

Example 2

transactions = [["7", "", "5"], ["7", "15", ""], ["7", "20", "30"], ["3", "", "12"]]return = ["3:0,12", "7:35,35"]
  • User 7 accumulates 0 + 15 + 20 = 35 ad-delivery pennies and 5 + 0 + 30 = 35 payment pennies.
  • User 3 accumulates 0 ad-delivery pennies and 12 payment pennies.

Missing amount fields are treated as 0, and the result is sorted by numeric user_id.

Constraints

  • transactions.length >= 1
  • Each row has exactly three strings: user_id, ad_delivery_pennies, and payment_pennies.
  • user_id is a non-negative integer string.
  • Each amount field is either an empty string or a non-negative integer string.

More Reddit interview questions

  • Filter Undesired Comments and Their DescendantsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Straight-Line Word SearchPHONE SCREEN · Seen Nov 2026
  • Billing Log with Undo and RedoPHONE SCREEN · Seen Nov 2026
  • Tennis Game and Set ScoringPHONE SCREEN · Seen Oct 2026
  • Shortest Word Transformation SequencePHONE SCREEN · Seen Sep 2026
  • Validate a Single-Letter Word SequencePHONE SCREEN · Seen Sep 2026
  • Chatter Message WindowPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • Policy Violation Set ChecksPinterest · ONSITE INTERVIEWPinterest interview questions
  • Sustained Overspeed AlertsFleetx · ONSITE INTERVIEW
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Deep Copy a Random-Pointer ListAmazon · ONSITE INTERVIEW
  • Instant-Runoff Voting WinnerWise · ONSITE INTERVIEW
  • Budgeted API Inference with Out-of-Order FeedbackOpenAI · ONSITE INTERVIEWOpenAI interview questions
  • Randomized Collection with Duplicate ValuesOkta · ONSITE INTERVIEWOkta interview questions
  • Random Picks Excluding Recent ValuesGoogle · ONSITE INTERVIEWGoogle interview questions

Reddit interview experiences

  • Reddit MLE Notebook Phone Screen: 1 Experience
  • Reddit Experienced SWE and Android Interviews: 3 Experiences
All Reddit interview questionsSee Reddit hiring insights
Saved
class Solution {
    public String[] reconstructBillingStatus(String[][] transactions) {
      // write your code here
    }
}
Checking account…