InterviewLegend

Graphs & Trees

Alex Chen14 min readUpdated

A Cash App payment is an edge in a graph. One account sends money to another. That single transfer becomes a line between two nodes, and across millions of users the structure gets enormous. Fraud teams score how money moves between accounts to catch scams, and the shape underneath that work is a graph question: who connects to whom, and how far the connection reaches. The coding round almost never uses the word graph. It hands you a stream of transfers, a list of seller locations, or a grid a delivery has to cross, and recognizing the traversal is the job.

This lesson bundles the traversal patterns that round out Block's medium bar. BFS and DFS over a graph, the same search over a grid as a step-by-step simulation, tree aggregation, and the lighter dynamic programming that surfaces onsite. Where the structure is textbook, the foundational version lives in the free course. This page stays on the Cash App and Square problems Block reaches for and the escalating follow-ups that carry the grade.

The Block angle
A connected component in the transfer graph is a fraud ring, and no Block graph question maps onto the product more directly. Fraud scoring leans on how money flows between accounts, so a flagged account raises a natural next question: which other accounts sit in the same cluster of transfers? That is a connected-components search. Build an adjacency list from the transfers, walk outward from the flagged account with BFS or DFS, and the set you reach is the exposure. The follow-up an interviewer tends to add is direction or weight. Transfers have a sender and a receiver. Make the graph directed and you can ask who reaches the flagged account versus who it reaches, or carry the dollar amounts along the way and sum them.
What's inside
  • 2 problems, worked step by step
  • about 14 min

Premium lessonBlock interview guide

These took digging.

What candidates walked out with, from 20,000+ reports, forum threads behind logins and write-ups in Chinese. Then solved step by step.

100 companies. Checked every month.

Unlock all 100 companies

$49 a year · less than $1 a week · Cancel anytime

Had your Block interview?Tell us what they asked. Reviewed before it goes in, never with your name.
Block interview guide

Know what Block asks before you walk in.

13 coding · 5 system design · 14 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.