Reported September 2026
Affirmhash table

Count Distinct Underwriting PII Values

Reported by candidates from Affirm's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Affirm OA. Under 2s to a working solution.
Founder's read

The Affirm OA reported in September 2026 hands you a batch of underwriting and fraud_flag rows and asks for one number: distinct non-empty PII entries across underwriting rows only. Five strings per row, and an empty string means the field is missing. It looks like a warm-up, and it mostly is. The catch is hiding in Example 3, where "same" in the address field and "same" in the phone field count as two entries. If you're taking this in the next day or two, the whole problem is a set per field. StealthCoder sits as a safety net on the live OA if you blank.

The problem

Process a batch of underwriting and fraud-flag events. Each row of events contains exactly five strings in this order:
the event type, either underwriting or fraud_flag;
an address;
a phone number;
an email address;
a Social Security number.
An empty string means that the corresponding PII field is absent. Ignore every fraud_flag row. Across the underwriting rows, count distinct non-empty PII entries and return the total.
PII identity includes its field: two equal strings in different fields are different entries, while repeated occurrences in the same field count once.

Function
countDistinctUnderwritingPii(events: String[][]) → int

Examples
Example 1
events = [["underwriting","1 Main St","111","a@example.com","S1"],["underwriting","1 Main St","222","a@example.com","S2"],["fraud_flag","9 Oak St","999","fraud@example.com","F9"]]
return = 6
The two underwriting rows contain one distinct address, two phones, one email, and two Social Security numbers. The fraud-flag row is ignored.
Example 2
events = [["fraud_flag","A","P","E","S"],["underwriting","A","","E",""],["underwriting","A","P","",""]]
return = 3
Only the underwriting rows contribute. They contain the distinct typed entries address A, email E, and phone P.
Example 3
events = [["underwriting","same","same","",""],["underwriting","same","","",""]]
return = 2
The address and phone fields are distinct PII identities even though their string values are equal. Repeating the same address does not increase the count.

Constraints
1 <= events.length <= 100000
events[i].length == 5
events[i][0] is either underwriting or fraud_flag.
Every non-empty PII value has length from 1 through 100.
The answer fits in a signed 32-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is field identity. Keep four hash sets, one each for address, phone, email and SSN. Loop through events, skip any row where events[i][0] is fraud_flag, then for each of the four PII columns add the value to its set only if it's non-empty. Return the sum of the four set sizes. That's O(n) time with n up to 100000 rows, and values are at most 100 characters, so memory is fine. The common pitfall is using one shared set and losing the Example 3 case, where equal strings in different fields must count separately. The other fix is prefixing each value with a field tag in a single set. Also don't forget the empty-string check and the fraud_flag skip. If you freeze during the live Affirm OA, StealthCoder can read the prompt and hand you this structure, but you should be able to write it from memory.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Count Distinct Underwriting PII Values 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Affirm's OA.

Affirm reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Distinct Underwriting PII Values FAQ

How hard is the Affirm Count Distinct Underwriting PII Values problem really?+

Easy. It's a hash set counting problem with two filters: skip fraud_flag rows and skip empty strings. Most of the difficulty is reading carefully. If you can write a loop and use a set, you can finish it in a few minutes.

What's the trick to getting the right answer?+

Treat each field as its own namespace. Use four separate sets, or one set with a field prefix like 0:value. Example 3 tests this directly: the same string in address and phone counts as two distinct entries.

Do fraud_flag rows affect anything?+

No. Ignore them completely, even if their values match underwriting values. Example 1 and Example 2 both include fraud_flag rows with data that must never be added to any set.

What's the time and space complexity?+

Time is O(n) for one pass over up to 100000 rows, with five columns each. Space is O(n) in the worst case, since every value could be unique across four sets. Strings are capped at 100 characters, so hashing cost is small.

How do I prepare for this in 48 hours?+

Write it once in your language of choice with four sets and test the three examples by hand. Then practice a few more hash set and counting problems with edge cases like empty values and filtered rows. Don't over-prep, this one is simple.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Affirm.

OA at Affirm?
Invisible during screen share
Get it