Sort Array by Increasing Frequency
A easy-tier problem at 80% community acceptance, tagged with Array, Hash Table, Sorting. Reported in interviews at Akuna Capital and 5 others.
Sort Array by Increasing Frequency looks trivial but trips candidates who overthink it. You're given an array of integers and need to sort by frequency (ascending), with ties broken by descending value. Akuna Capital, Agoda, SAP, Accenture, TCS, and Walmart Labs have all asked it. The 80% acceptance rate masks a real gotcha: candidates nail the frequency count but botch the tiebreaker or use an inefficient sort. If you blank on the sort order during your live OA, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Sort Array by Increasing Frequency"
Sort Array by Increasing Frequency is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.
Get StealthCoderThe trap is treating this as a standard sort. You need to count frequencies with a hash table (trivial), then sort by two criteria: frequency ascending, then value descending when frequencies match. Most candidates write the comparator wrong or forget the secondary key. Python's sort with a tuple key makes this clean: sort by (frequency, -value). C++ and Java require explicit comparators. The algorithm is O(n log n) dominated by sorting, not counting. This problem tests whether you actually understand how to compose sort keys, not whether you can use a built-in sort function. It's a speed check. StealthCoder is your hedge if you freeze on the comparator syntax during the assessment.
Pattern tags
You know the problem.
Make sure you actually pass it.
Sort Array by Increasing Frequency recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Sort Array by Increasing Frequency interview FAQ
Is this actually easy or are the acceptance rates inflated?+
The 80% rate is real. The problem is conceptually simple: count frequencies, sort twice. But live candidates botch the tiebreaker order or write a sloppy comparator. It's easy if you've drilled sort mechanics, brutal if you haven't touched them in months.
What's the exact tiebreaker rule when frequencies are equal?+
When two elements have the same frequency, the one with the larger value comes first. So if you have [1, 1, 2, 2], and both have frequency 2, the output is [2, 2, 1, 1]. Frequency ascending, then value descending.
Do I need a custom comparator or can I use built-in sort?+
Yes, you can use built-in sort if your language supports custom comparators or tuple keys. Python's sort with (frequency, -value) works cleanly. Java and C++ require explicit Comparator or lambda objects. The idea is the same across all languages.
Is this asked at FAANG or just mid-tier companies?+
Mid-tier to large: Akuna, Agoda, SAP, Accenture, TCS, Walmart Labs. Not a FAANG staple, but shows up at well-known companies. If you see it, treat it as a speed filter, not a hard problem.
What topics does this actually test?+
Hash Table (frequency counting), Array (input and output), and Sorting (the real skill being tested). It's a three-topic combo. If sorting comparators aren't fresh, this will burn time during your OA.
Want the actual problem statement? View "Sort Array by Increasing Frequency" on LeetCode →