Filter Restaurants by Vegan-Friendly, Price and Distance
A medium-tier problem at 63% community acceptance, tagged with Array, Sorting. Reported in interviews at Yelp and 0 others.
You're sorting a list of restaurants by multiple criteria. Yelp asks this one. The trap is handling the sorting order correctly when you've got three different filters stacked on top of each other. Most candidates sort once, then realize they need to sort again, or they cascade sorts wrong and blow the efficiency. If you blank on the sort order during your assessment, StealthCoder will surface a working solution invisibly. This is the kind of problem that looks simple until you get the priority wrong and fail test cases.
Companies that ask "Filter Restaurants by Vegan-Friendly, Price and Distance"
Filter Restaurants by Vegan-Friendly, Price and Distance 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 real trick is understanding sort stability and priority. You can't just sort by distance, then price, then vegan status in separate passes and expect it to work. You need either a comparator that chains the conditions in the right order, or you sort once with a multi-key comparator. The common failure is sorting by vegan status first and getting the index ordering wrong on subsequent sorts, or treating price and distance as single-pass sorts when they need to be weighted together. Array and Sorting as the topics means you're working with a flat list and a custom comparator. If this shows up live and you hit a wall on the comparator logic, StealthCoder solves it in seconds without the proctor knowing.
Pattern tags
You know the problem.
Make sure you actually pass it.
Filter Restaurants by Vegan-Friendly, Price and Distance recycles across companies for a reason. It's medium-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.
Filter Restaurants by Vegan-Friendly, Price and Distance interview FAQ
What's the actual sorting priority here?+
The problem title order matters: vegan-friendly first (boolean filter), then price (ascending), then distance (ascending). Use a comparator that checks vegan status first, then price if vegan status is equal, then distance as the tiebreaker. This is a chained comparison, not separate sorts.
Can I just sort multiple times?+
Technically yes if you do it backwards (distance, then price, then vegan) because sorts in many languages are stable. But it's fragile and unclear. A single comparator is cleaner and won't surprise you during code review or if edge cases slip through.
How do I handle the vegan boolean in the comparator?+
Treat vegan restaurants as higher priority. In most languages, you can return false values first (or true first, depending on the problem spec). Check your output examples to see if vegan should come before non-vegan, then set up the comparator accordingly.
Is this actually asked at Yelp?+
Yes, Yelp has reported asking it. It's a real company filter problem. Acceptance rate is around 63%, which means a meaningful number of candidates are getting the sort order or comparator logic wrong under time pressure.
What's the time complexity I should aim for?+
O(n log n) with a comparison-based sort. That's the standard. Don't try to optimize further unless the problem explicitly says the constraints allow for radix sort or bucketing. A clean comparator that chains three conditions is good enough.
Want the actual problem statement? View "Filter Restaurants by Vegan-Friendly, Price and Distance" on LeetCode →