FastPrepBadge Entry and Exit Count Violations

Badge Entry and Exit Count Violations

Atlassian logoAtlassian● EasyFULLTIMEPHONE SCREEN
Learn

Problem statement

You are given two lists of names from conference-room badge logs: entry contains people who badged in, and exit contains people who badged out. Each list is independently in timestamp order, but the timestamps and the relative order between the lists are not supplied.

For this exercise, assume the observation covers completed visits: the room starts and ends empty. Define a count violation as a person whose number of entry records differs from their number of exit records.

Return each person with a count violation once, in lexicographic order. Repeated occurrences represent separate badge records and must be counted.

This exercise checks count mismatches only. Equal entry and exit counts pass this check; these two lists alone do not establish a merged timeline for detecting badge-order violations.

Function

badgeViolations(entry: String[], exit: String[]) → String[]

Examples

Example 1

entry = ["Alice","Bob","Alice"]exit = ["Bob","Cara"]return = ["Alice","Cara"]

Alice has two entries and no exits; Cara has no entries and one exit. Bob has one of each.

Example 2

entry = ["Alice","Bob"]exit = ["Bob","Alice"]return = []

Both names have one entry and one exit. Relative event timing is unavailable and does not alter the count criterion.

Example 3

entry = ["Lee","Lee"]exit = ["Lee"]return = ["Lee"]

Lee has two entries and one exit; the name is returned once.

Constraints

  • For this exercise, assume 0 <= entry.length, exit.length <= 500.
  • For this exercise, assume every name contains 1 through 50 case-sensitive ASCII letters, digits, or underscores.
  • Empty lists are permitted. Within-list order has no effect on the count criterion.

More Atlassian problems

See Atlassian hiring insights
public String[] badgeViolations(String[] entry, String[] exit) {
    // Write your code here.
    return new String[0];
}
entry["Alice","Bob","Alice"]
exit["Bob","Cara"]
expected["Alice", "Cara"]
Checking account…