Reported October 2024
Expediasorting

Rank Secondary Popularity

Reported by candidates from Expedia's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Expedia OA. Under 2s to a working solution.
Founder's read

Expedia asked this in October 2024, and it's a sorting problem wrapped in a ranking scenario. You're given data about items with a primary and secondary popularity metric, and you need to rank them by specific rules. The catch is figuring out the tiebreaker logic and the sort order. It looks straightforward until you realize secondary popularity matters only when primary values collide. StealthCoder will catch the edge case you miss under pressure.

Pattern and pitfall

The pattern is pure sorting, but the trick is the two-level comparison. You'll likely sort by primary popularity descending, then by secondary popularity descending as the tiebreaker. The gotcha candidates hit is ignoring the secondary metric entirely or getting the sort direction backwards. Some implementations also fumble null/missing values or tied pairs. The algorithm is O(n log n) and straightforward to code once you nail the comparator. Under live OA stress, you might default to ascending or forget the secondary key entirely. That's where StealthCoder acts as a safety net, reading the problem statement and feeding you the exact sort order before you write a line.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Rank Secondary Popularity 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 StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Expedia's OA.

Expedia 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.

Rank Secondary Popularity FAQ

Do I need to modify the input or return a new ranked list?+

Return a new list or array ranked by the criteria. Don't mutate input in place unless the problem explicitly says so. Check the expected output format in the problem statement.

What if primary popularity scores are equal for multiple items?+

That's when secondary popularity becomes the tiebreaker. Sort by secondary descending. If both are equal, preserve original order or return in any consistent order, depending on the problem spec.

Is this problem asking me to calculate popularity or just reorder given data?+

You're reordering. The popularity metrics are given as attributes on each item. No math needed. Focus entirely on the comparator logic.

What's the fastest way to code this in 10 minutes?+

Use a built-in sort with a custom comparator. In Python, use sorted() with key=. In Java, implement Comparator. Define the rule clearly before you code to avoid flip-flops.

Are there edge cases I should test?+

Empty list, single item, all items with identical primary scores, all items with identical secondary scores, and negative or zero popularity values. Test at least two of these mentally before submitting.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Expedia.

OA at Expedia?
Invisible during screen share
Get it