Count Distinct Underwriting PII Values
Learn this problemProblem statement
Process a batch of underwriting and fraud-flag events. Each row of events contains exactly five strings in this order:
- the event type, either
underwritingorfraud_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[][]) → intExamples
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 = 6The 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 = 3Only 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 = 2The 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 <= 100000events[i].length == 5events[i][0]is eitherunderwritingorfraud_flag.- Every non-empty PII value has length from
1through100. - The answer fits in a signed 32-bit integer.