Three medium problems the way a fintech interview frames them: two ledgers to reconcile, a net exposure that can run either way, and every currency route inside a fee budget.
The warm-up round tested single habits on easy problems. A fintech core round keeps those habits and asks for more structure. The problems are medium, and the stories move from one payment to a whole day of them.
Three ideas come back in almost every core round.
Interviewers also listen for how you talk about the data. Say which list is sorted, which end of a window is open, and what a route may not repeat. Those three sentences prevent most wrong answers.
Exercise · Predict the output: Exposure in both directions. Five entries arrive at seconds 0, 2, 3, 7 and 8. An entry stays in the window while it is less than 5 seconds old. What does this print?
times = [0, 2, 3, 7, 8]
amounts = [30, -90, 20, -40, 10]
span = 5
net = 0
left = 0
best = 0
for right in range(len(times)):
net += amounts[right]
while times[right] - times[left] >= span:
net -= amounts[left]
left += 1
best = max(best, abs(net))
print(best)Each problem is an Academy idea with one new rule. Read the signal in the statement, then reach for the move.
| Signal in the statement | The move | Academy lesson |
|---|---|---|
| two lists sorted by the same id, only in one or in both | a merge with three outcomes, then the tails | Merging sorted sequences |
| the net of the last few seconds, in either direction | a window with a running net, reported as an absolute value | Sliding window: fixed and variable windows |
| every route within a hop limit and a fee budget | a walk that steps in, counts, and steps back out | BFS and DFS on any graph |
Here is what changes from the Academy lessons. Reconciliation compares ids first and amounts only when the ids match, and it reports the rest of the longer list. The window is measured in seconds, not in entries, so it can hold many entries or one. The route walk counts every route, so it cannot mark a currency as visited for good.
Take the ledgers with bank ids 1, 2, 4, 5 and 8, and book ids 2, 3, 4 and 5. Ids 2 and 5 match with the same amount. Id 4 matches with a different amount.
Ids 1 and 8 are only in the bank list, and id 3 is only in the books. That is four reports, and the last one, id 8, comes from the tail.
Exercise · Predict the output: The tail of the longer list. This counts the differences between two ledgers sorted by id. The bank has ids 1, 2, 4, 5 and 8. The books have ids 2, 3, 4 and 5. What does it print?
bank_ids = [1, 2, 4, 5, 8]
bank_amounts = [100, 250, 75, 60, 10]
books_ids = [2, 3, 4, 5]
books_amounts = [250, 40, 80, 60]
i = 0
j = 0
reports = 0
while i < len(bank_ids) and j < len(books_ids):
if bank_ids[i] == books_ids[j]:
if bank_amounts[i] != books_amounts[j]:
reports += 1
i += 1
j += 1
elif bank_ids[i] < books_ids[j]:
reports += 1
i += 1
else:
reports += 1
j += 1
print(reports)A merge loop ends when one list is used up, so the rest of the other list must still be reported.
The window problem has one trap that the warm-up round did not have: the boundary. An entry leaves when times[right] - times[left] >= span. Writing > keeps entries that are exactly span seconds old, and the exposure grows. On the five entries above it grows from 60 to 110.
An entry leaves the window when it is span seconds old, and the exposure is the largest absolute net.
The route walk has its own trap. The walk marks a currency as used when it steps in, and it must mark it as free again when it steps out.
Exercise · Find the bug: Stepping back out. This counts the routes from one currency to another without using a currency twice. It is right on a chain, but it misses routes when two routes share a branch. Which line is wrong?
def count_routes(n, froms, tos, start, goal):
out = [[] for _ in range(n)]
for i in range(len(froms)):
out[froms[i]].append(tos[i])
used = [False] * n
used[start] = True
return walk(out, used, start, goal)
def walk(out, used, here, goal):
if here == goal:
return 1
total = 0
for nxt in out[here]:
if used[nxt]:
continue
used[nxt] = True
total += walk(out, used, nxt, goal)
used[here] = False
return totalThe three problems rise in difficulty. Each time box is what an interviewer allows for a medium problem, with time to explain and test.
Solve them in this order. The ledgers are a merge you already know, the exposure adds a window and a sign, and the routes add a budget and a walk.
A medium problem rarely ends at the first answer. The interviewer changes one rule and listens to how you adapt. Prepare one follow-up for each problem.
Treat the three problems as one session of 80 minutes, with a timer. A real core round often has two of them in 45 minutes, so the full set is a hard rehearsal.
span seconds, a start that is also the goal.Stop each problem at its box. Note what was left, because the unfinished part is what to practise next.
span seconds old.Checkpoint · Fintech core round
Q1/5 The bank has ids 1, 3 and 5. The books have ids 3 and 4. Id 3 has the same amount on both sides. How many ids are reported?
Answer: B
Id 1 is only in the bank, id 4 is only in the books, and id 5 is only in the bank, so three ids are reported. Id 5 comes from the tail, after the books are used up.
Q2/5 After three entries the net of a window is 40, -70 and -20. What is the largest exposure?
Answer: B
Exposure is the size of the net in either direction, so -70 counts as 70. Keeping the largest signed value would give 40.
Q3/5 An entry arrives at second 5 and the span is 5. An earlier entry is at second 0. Is it still in the window?
Answer: B
The window holds entries with times[right] - times[left] below span. A difference of exactly 5 is not below 5, so the entry has left.
Q4/5 A walk counts every route. Why does it mark a currency as free again when it steps back out?
Answer: B
A currency is only blocked while it is on the current route. After the branch is counted, another route may use it, and a mark that stays would hide those routes.
Q5/5 Corridors go 0 to 1, 1 to 3, 0 to 2, 2 to 3 and 0 to 3. How many routes from 0 to 3 have at most 1 hop?
Answer: A
Only the direct corridor 0 to 3 has one hop. The routes through 1 and through 2 have two hops, so a limit of 1 rejects them.
Review cards from this lesson.
A few questions, then explain the idea back in your own words. Your tutor marks it. Quiz and explain back.