A field research station scatters short-range wildlife trackers through a reserve. Over one night, the station's base receiver logs a stream of n pings; each ping carries the integer tag ID of the tracker that emitted it, in the order the pings arrived. To keep tallies trustworthy, an analyst wants every tracker's total number of pings this night to be distinguishable from every other tracker's total -- no two different tag IDs may have fired exactly the same number of times. Given the full night's ping log, decide whether this "clean fingerprint" property holds.
n, the number of pings.n space-separated integers, the tag IDs in the order the pings were logged.Print UNIQUE if every distinct tag ID's occurrence count differs from every other distinct tag ID's occurrence count, otherwise print REPEATED.
Example 1
Input
6 1 2 2 1 1 3
Expected
UNIQUE
Explanation
Tag 1 fires 3 times, tag 2 fires 2 times, and tag 3 fires 1 time. The counts 3, 2, and 1 are all different from each other, so the log has a clean fingerprint and UNIQUE is printed.
Example 2
Input
2 1 2
Expected
REPEATED
Explanation
Tag 1 fires once and tag 2 fires once. Both counts equal 1, a collision between two different tags, so REPEATED is printed.
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 →