Stripe new grad SWE OA. I did it about a week ago, and my memory is a little hazy. It was basically a state machine + OOP. Sharing this to save everyone some time.
60 minutes, progressing through levels. Nothing difficult algorithmically, but there really was a lot of code to write.
A payment system, using command-line-style instructions. One detail worth mentioning: every command has the same number of arguments, with empty-string placeholders for unused positions, so parsing can be handled uniformly. Roughly like this:
CREATE id payer payee amount
APPROVE id "" "" amount
CAPTURE id "" "" amount
CANCEL id "" "" ""
Both CAPTURE and APROVE include an amount.
The state transitions were roughly like this (
from memory, so I can't guarantee they're accurate
):
ALLOWED = {
"CREATED": {"APPROVED"},
"APPROVED": {"PARTIALLY_CAPTURED", "SUCCEEDED"},
"PARTIALLY_CAPTURED": {"SUCCEEDED"},
}
CANCEL cancels everything that hasn't been approved yet.
My impressions:
The problem itself wasn't hard; I just couldn't finish writing it.
I was racing my typing speed the whole time, with basically no time to think. It was all writing code and sorting out states. Doing more and more algorithm problems doesn't help much with this kind of thing. It's more like writing a small API on the spot.
Hope everyone gets an offer 🙏
Discussion
Loading comments…