A conference tracks attendees in two independent systems that are supposed to stay in sync: a name registry, where each entry pairs an attendee ID with the attendee's name, and a payment ledger, where each entry pairs an attendee ID with an amount paid. Ideally every attendee ID appears in both systems, but due to sync issues some IDs are missing from one side. An attendee ID has incomplete data if it appears in the name registry but not the payment ledger (paid nothing on record despite being named), or if it appears in the payment ledger but not the name registry (paid but never named). Find every such attendee ID.
R and P — the number of name-registry entries and the number of payment-ledger entries.R lines: each contains an integer attendee_id followed by a name token (a non-empty string of letters and/or digits with no whitespace). All attendee_id values in this block are distinct.P lines: each contains an integer attendee_id followed by an integer amount. All attendee_id values in this block are distinct.m — the number of attendee IDs with incomplete data (appearing in exactly one of the two systems).m lines: each such attendee ID, one per line, in ascending order.Example 1
Input
3 2 11 asha 7 ravi 5 lina 7 250 9 100
Expected
3 5 9 11
Explanation
The name registry has IDs {11, 7, 5}; the payment ledger has IDs {7, 9}. ID 7 appears in both, so it is complete and excluded. IDs 11 and 5 are registered but never paid (missing payment), and ID 9 paid but was never registered (missing name). Sorted ascending, the incomplete IDs are 5, 9, 11 — a count of 3.
Example 2
Input
2 2 100 kai 200 zoe 100 500 200 700
Expected
0
Explanation
Both attendee IDs (100 and 200) appear in the name registry and in the payment ledger, so every record is complete. There are no attendee IDs with missing data, so the output is just '0'.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →