You are given n lines of a flat configuration file, each of the exact form key=value (the value may be empty and may itself contain =; always split a line on only its FIRST =). Keys are compared CASE-INSENSITIVELY for the purpose of detecting duplicates (so Timeout and timeout count as the same key), even though the exact text of each line may differ in case.
Scanning the lines from the first (line 1) to the last, find the first line whose key has already appeared (case-insensitively) on some earlier line. Print that line's 1-indexed line number. If no such duplicate exists among all n lines, print UNIQUE.
Line 1: an integer n.
Lines 2..n+1: each a key=value line.
A single line: either the 1-indexed line number of the first duplicate key, or UNIQUE.
Example 1
Input
3 Timeout=30 RETRIES=5 timeout=45
Expected
3
Explanation
Line 3's key `timeout` matches line 1's key `Timeout` case-insensitively, so the first duplicate is at line 3.
Example 2
Input
2 host=abc port=99
Expected
UNIQUE
Explanation
The two keys are different, so there is no duplicate: `UNIQUE`.
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 →