其他OA #15
Most Unique Elements (Part 2 :)
估计中等可在线判题
You are given a list of strings and a boolean useJaccard. When false, use Part 1's highest-character-frequency ratio and select all strings with the lowest ratio; when true, use Part 3's average multiset Jaccard similarity and select all strings with the lowest average. Finally, return the characters that appear only in the selected group of strings.
输入格式
The input is a JSON object: {"strings":[non-empty strings...],"useJaccard":true or false}. Site limits: 2≤number of strings≤80, each string has length≤1000, and the total length≤10000; characters are handled as Unicode code points.
输出格式
Output a JSON string. The selected strings are concatenated in input order, keeping repeated characters in their original order within each string, and excluding only characters that also appear in unselected strings.
样例 1
输入:
{"strings": ["aba", "ab", "abbcdd"], "useJaccard": false}
输出:
"cdd"
样例 2
输入:
{"strings": ["baa", "abbc", "ab"], "useJaccard": true}
输出:
"c"
样例 3
输入:
{"strings": ["a", "a", "aa"], "useJaccard": true}
输出:
""
样例 4
输入:
{"strings": ["aaab", "aabb", "abbb", "cccc"], "useJaccard": true}
输出:
"cccc"
样例说明
The Part 1/Part 3 branch computes a score for each string; compare the lowest score and ties using exact fractions, then filter out characters that appear in unselected strings.