This question evaluates a candidate's ability to perform frequency analysis and stable tie-breaking on a linear sequence, exercising skills in hashing, counting, and handling edge cases such as equal frequencies.
You are given a list of strings in the following repeating order:
[id1, name1, tag1, id2, name2, tag2, ...]
So every 3 consecutive elements describe one record: (id, name, tag).
Return the tag that is the second most frequent among all records’ tags.
Tie/edge-case rules:
"notag"
.
Constraints/expectations:
Example:
Input: ["1","A","x","2","B","y","3","C","y","4","D","x","5","E","z"]
Counts: x=2, y=2, z=1 → second most frequent is z → return "z".
Write a function to compute the required tag.