Reconstruct Billing Status
Reported by candidates from Reddit's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The data structure here is a hash map keyed by user_id, and that's basically the whole Reddit OA reported in July 2026. Rebuild each advertiser's billing status from a pile of transaction logs, summing two counters per user. It looks like a warmup. The catch is in the details: empty strings for missing fields, and output sorted by numeric user_id, not string order. If you blank on the parsing or the sort, StealthCoder runs invisibly during the live assessment and gives you a working solution so a simple problem doesn't sink you.
The problem
🥝 Practice note: This version should match about 80%-85% of the reported Reddit onsite question. The core part to practice is rebuilding each advertiser's billing status from transaction logs.
🍓 FastPrep format note: The original prompt described Transaction objects and a Record output, but did not include FastPrep-style sample tests. To make this page runnable, 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.
Original Function Signature
function reconstructBillingStatus(transactions: Transaction[]): Record<number, BillingStatus>
Original Input Shape
Transaction {
user_id: number
ad_delivery_pennies?: number
payment_pennies?: number
}
Original 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"]
This is a FastPrep practice example for the wrapper format.
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"]
This is a FastPrep practice example for the wrapper format.
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
FastPrep wrapper note: These constraints describe the runnable wrapper used on this page, not extra details from the original interview prompt.
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.Reported by candidates. Source: FastPrep
Pattern and pitfall
Walk the transactions once. Keep a hash map from user_id (as an integer) to a pair of running totals: ad_delivery and payment. For each row, parse the two amount strings, treat an empty string as 0, and add them to that user's pair. After the loop, sort the keys numerically and format each as "id:ad,pay". That's O(n + k log k) for k distinct users. The pitfalls are small but costly. Sorting user_ids as strings puts "10" before "3". Calling parseInt or int on an empty string throws or returns NaN. Users who only appear with empty amounts still need an entry showing 0,0. Initialize the pair on first sight, not on first nonzero amount. If any of that slips under time pressure, StealthCoder is the hedge during the live OA, catching it while you keep typing.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Reconstruct Billing Status cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Reddit's OA.
Reddit reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Reconstruct Billing Status FAQ
How hard is the Reddit Reconstruct Billing Status question really?+
Easy. It's a single pass with a hash map and a sort at the end. The difficulty is in the edge cases: empty-string amounts, numeric versus string sorting of user_id, and exact output formatting. Get those three right and you're done in minutes.
What's the trick to this problem?+
Use a map from integer user_id to two running totals. Convert empty strings to 0 before adding. Then sort keys as integers and format each as "user_id:ad,pay". No clever algorithm is needed, just careful parsing and output.
Why does my output order come out wrong?+
You're probably sorting user_ids as strings, so "10" lands before "2". Convert keys to integers before sorting, or pass a numeric comparator. Example 2 in the problem checks this: user 3 must come before user 7.
Do users with only empty amount fields still appear?+
Yes. The task says to return the status for every user that appears in the logs. Create the entry the first time you see a user_id, with both counters at 0, then add whatever amounts exist. Don't skip rows just because the fields are blank.
How do I prepare for this in 48 hours?+
Practice hash map accumulation problems with string parsing and custom sorting. Write this one from scratch twice in your language of choice, focusing on empty-string handling and numeric sort. It takes under an hour and covers the whole pattern.