Maximize Segregation Cost
Reported by candidates from Akuna's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Akuna sent you a segregation cost problem in August, and you've got hours to figure out the pattern. This is a classic optimization puzzle where you're asked to partition or rearrange elements to maximize some penalty or cost metric. The trick almost always involves greedy decisions or dynamic programming. If you blank on the exact approach, StealthCoder will show you the structure in real time so you can code confidently.
Pattern and pitfall
Segregation cost problems typically hinge on understanding what you're optimizing for: swaps, group separations, or distance-based penalties. The naive approach (brute force permutations) dies on larger inputs. The real solution usually involves either a greedy pass that orders elements strategically, or a DP table that tracks the best cost at each decision point. Common pitfall: candidates try to solve it backwards or forget that reordering is often cheaper than penalty accumulation. StealthCoder acts as your safety net if you freeze on the recurrence or the ordering logic during the live OA.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Maximize Segregation Cost cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Akuna's OA.
Akuna reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximize Segregation Cost FAQ
What does 'segregation cost' actually mean here?+
Without the full problem text, it likely means the cost of moving or grouping elements to separate them by some property (type, value, etc.). Read the problem twice. It defines cost in the first example. That definition is everything.
Is this a sorting problem?+
Probably. Most segregation problems are solved by sorting elements by a key, then computing the cost of that arrangement or the minimal cost to achieve segregation. Greedy sorting is your first hypothesis.
Should I use DP?+
Only if greedy doesn't work. If you're choosing between multiple orderings and past choices affect future cost, DP is the backup. But start with greedy and test on the examples.
How do I prepare in 24 hours?+
Understand the cost function from the examples. Write out a small case by hand. Then code a solution that sorts or greedily assigns. Test on given cases. Don't overthink the algorithm before you've understood the problem.
Is Akuna asking this to filter or to see problem-solving speed?+
Akuna uses OA to screen quickly. This problem tests whether you can read a spec, spot the optimization pattern, and code it. Speed and correctness matter equally. The pattern is almost never novel.