Cross-Day User Trust Scores
Reported by candidates from Affirm's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Affirm's September 2026 OA reports a trust-score problem that looks like a bookkeeping exercise until you read the constraints. Up to 200,000 log entries and 200,000 queries means any per-query scan of the log is dead on arrival. This is a hash-table problem, plain and simple. You build per-user state once, then answer every query with a lookup. If you blank on the structure under the clock, StealthCoder is the safety net running invisibly during the live assessment. But the idea is small enough to hold in your head tonight.
The problem
A lending service records loan-related activity for two consecutive days. Parallel arrays users, days, and loanTypes describe each log entry. A user earns 50 trust-score points when they appear on both days, and another 50 points when they have at least two distinct loan types across the complete log. Duplicate entries do not increase either signal. For each name in queryUsers, return its trust-score percentage in the same order. A user absent from the log has score 0. Function calculateTrustScores(users: String[], days: int[], loanTypes: String[], queryUsers: String[]) → int[] Examples Example 1 users = ["ana","ana","bob","bob","cara"] days = [1,2,1,1,2] loanTypes = ["personal","auto","card","home","personal"] queryUsers = ["ana","bob","cara","dave"] return = [100,50,0,0] Ana appears on both days and has two loan types. Bob has two loan types but appears only on day 1. Cara satisfies neither signal, and Dave has no entries. Example 2 users = ["x","x","x","y","y"] days = [1,1,2,1,2] loanTypes = ["card","card","card","auto","auto"] queryUsers = ["x","y"] return = [50,50] Both users appear on both days, but repeated entries for one loan type still count as only one distinct type. Constraints 1 <= users.length == days.length == loanTypes.length <= 200000. 1 <= queryUsers.length <= 200000. days[i] is either 1 or 2. User and loan-type strings contain 1 to 40 lowercase English letters. The total number of characters across all strings is at most 2,000,000.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is one pass over the log, then O(1) per query. Keep a map from user to a record: a bitmask for days seen (bit 0 for day 1, bit 1 for day 2) and a set of distinct loan types. Actually you only need to know if there are two distinct types, so store the first type and a boolean flag that flips when a different type shows up. Score is 50 if mask equals 3, plus 50 if the flag is set. The common pitfall is the brute force: for each query, scan all entries, which is 200,000 times 200,000. Another pitfall is counting duplicates, like Example 2 where repeated card entries still count as one type. Absent users return 0, so use a default on lookup. Total work is linear in the character count, which fits the 2,000,000 limit. StealthCoder is your hedge if the live OA rattles you.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Cross-Day User Trust Scores cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Affirm's OA.
Affirm reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Cross-Day User Trust Scores FAQ
What's the trick in the Affirm Cross-Day User Trust Scores question?+
Precompute per-user state in one pass, then answer queries by lookup. Track which days a user appeared (a 2-bit mask) and whether they've shown two different loan types. Each signal is worth 50. Duplicates are harmless because the mask and the flag are idempotent.
Why does brute force fail here?+
With up to 200,000 log entries and 200,000 queries, scanning the log per query is about 40 billion operations. That's far too slow. A hash map built once makes the whole thing linear, so queries cost constant time each.
How do I count distinct loan types without a full set per user?+
You only care whether there are at least two. Store the first loan type seen for the user. When a later entry has a different type, set a boolean. No full set needed, which also saves memory on 200,000 entries.
What edge cases should I test?+
Query users missing from the log must return 0. Users with many duplicate entries, like Example 2, should score 50 and not more. A user on day 1 only with two loan types scores 50. A user with one entry scores 0. Also check output order matches queryUsers.
How do I prepare for this in 48 hours?+
Write the hash map solution once from memory and run both examples. Then practice the same shape on similar problems: group by key, keep a small state per key, answer queries by lookup. This pattern shows up often in OAs, and it takes under an hour to get comfortable.