Problem · Array

Count Distinct Underwriting PII Values

Learn this problem
EasyAffirm logoAffirmFULLTIMEPHONE SCREEN

Problem statement

Process a batch of underwriting and fraud-flag events. Each row of events contains exactly five strings in this order:

  1. the event type, either underwriting or fraud_flag;
  2. an address;
  3. a phone number;
  4. an email address;
  5. 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.

More Affirm problems

drafts saved locally
public int countDistinctUnderwritingPii(String[][] events) {
    // Write your code here.
}
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"]]
expected6
checking account