ZZomato·DSASDE-1DSA Round
Maximum Restaurants Reachable Within Budget and Rating Filter
Problem
Given a list of restaurants with distance, cost, and rating, and constraints maxBudget and minRating, find the maximum number of restaurants you can visit in a single outing (each visited once, visited in any order).
Travel cost between restaurants is the absolute difference in their distances from origin.
Example
restaurants = [{d:1, c:20, r:4.5}, {d:3, c:30, r:4.0}, {d:5, c:10, r:3.5}]
maxBudget=50, minRating=4.0
Output: 2
Constraints
- n ≤ 1000
- Use greedy + sorting approach
Follow-up
What if you must return to the starting point after visiting all restaurants?
added 6 days ago