All problems

Customers Whose Balance Jumped

mediumPythonGroupByFiltering

Northline Bank's marketing team wants to send a "thanks for growing with us" note to customers whose account grew the most this cycle. How much growth earns a note depends on how many notes they can afford to send that month, so the bar moves — some cycles it is set high enough that only one or two people clear it, other cycles it is dropped to catch anyone who ended the cycle up at all.

Transactions

id customer_id amount type txn_date
1 1 500 deposit 2023-07-01
2 1 -120 withdrawal 2023-07-03
3 2 1000 deposit 2023-07-02
4 2 -300 withdrawal 2023-07-05
5 3 250 deposit 2023-07-04
6 3 -600 withdrawal 2023-07-06
7 4 800 deposit 2023-07-07
8 4 -450 withdrawal 2023-07-08
9 5 2000 deposit 2023-07-09
10 5 -1500 withdrawal 2023-07-10
11 1 -200 transfer 2023-07-11
12 3 400 deposit 2023-07-12

Input

Both tables above are already built for you — the customer and transaction rows are not read from input. What does arrive is a single line holding this cycle's bar, a whole number of dollars.

Task: A customer's net change over the cycle is what their amounts come to altogether. Print a sorted list of the names of customers whose net change is strictly above the bar that arrives — somebody landing on it exactly misses out.

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…