Company: Amazon_17feb
Difficulty: medium
Sort Bug Report Frequencies Problem Description You're helping a QA team at a software company sift through bug reports pulled from automated test logs spanning many devices and services. Each log entry carries an integer bug code, and one test session may log the same bug code more than once if that issue got triggered repeatedly. To help prioritize which bugs get fixed first, these rules apply: Rarer bugs matter more, since they may point to edge cases that are harder to catch. When two bugs occur equally often, the one with the smaller code number takes priority. Sort the bug codes so the most important ones come first, following these rules — that is, lower-frequency bugs lead, and ties go to the lower code number. Example Given bugs = [8, 4, 6, 5, 4, 8] . Start by tallying how often each bug code shows up: Item Code Frequency 8 2 4 2 6 1 5 1 Applying the rules: Bugs occurring once outrank bugs occurring twice. Among bugs tied on frequency, the smaller code number ranks higher. Sor