InterviewLegend

Card Games, Trees and Stacks

Alex Chen40 min readUpdated 47 real interview reports

A card-game simulation turns up in Affirm's coding rounds again and again, on phone screens and onsites alike. You usually write it as a class and then run it. Once the basic game works, a follow-up changes the rules and the code has to bend with it.

The other problems here are smaller class builds, some over trees and one over a stack.

Under the stories they're plain structures: queues, trees and linked lists. Once you name the structure, the rest is careful bookkeeping.

The Affirm angle
Agree on the rules before you write the class. These prompts come as a few loose sentences. They won't say how a tie breaks or what happens right at the edge of a rule. Ask, then put each answer into the code as a named constant or a short comment. Pass any randomness in from outside so a test can pin it, and run the smallest version on a fixed input before you add anything.

AffirmPremium lesson · Coding round

The 5 Affirm problems are below.

  1. A Premium questionCoding · Medium · Signature problem
  2. A Premium questionCoding · Medium · Frequently asked
  3. A Premium questionCoding · Medium · Frequently asked

+ 2 more in this lesson

Each with hints, the follow-up and a tested solution.

Get the Affirm questions

$49 a year · all 100 companies · cancel anytime

From 20,000+ candidate reports, forum threads behind logins and write-ups in Chinese.

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

Know what Affirm asks before you walk in.

24 coding · 2 system design · 13 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.