leetle

Daily challenge for 2026-09-15

623. Airport Luggage Routing Mismatches

An airport tracking system assigns every piece of luggage an original destination tag and records its actual loaded destination. You are given two equal-length lists of strings: tagged and loaded, representing the intended and actual destinations of pieces of luggage.

A piece of luggage is considered rerouted if tagged[i] != loaded[i]. A rerouted pair is mutually swapped if there exists another luggage piece j (where j != i) such that tagged[i] == loaded[j] and loaded[i] == tagged[j].

Return the maximum number of disjoint mutually swapped pairs of luggage. Each piece of luggage may be used in at most one pair. Note that each pair involves two luggage pieces, so if luggage A and B swapped destinations, they form exactly 1 mutually swapped pair.

Example:
Input: tagged = ["JFK", "LHR", "ORD"], loaded = ["LHR", "JFK", "SFO"]
Output: 1

Run this challenge interactively in Python or JavaScript when the app loads.