Given an array restaurants where restaurants[i] = [idi, ratingi, veganFriendlyi, pricei, distancei]. You need to filter the restaurants using three filters:
The veganFriendly filter will be either true (meaning you should only include restaurants with veganFriendlyi set to true) or false (meaning you can include any restaurant).
In addition, you have the filters maxPrice and maxDistance which are the maximum values for price and distance of restaurants you should consider respectively.
Return the array of restaurant IDs after filtering, ordered by rating from highest to lowest. For restaurants with the same rating, order them by id from highest to lowest.
For simplicity, veganFriendlyi and veganFriendly take value 1 when true, and 0 when false.
Input & Output
Constraints
- 1 ≤ restaurants.length ≤ 104
- restaurants[i].length == 5
- 1 ≤ idi, ratingi, pricei, distancei ≤ 105
- 1 ≤ maxPrice, maxDistance ≤ 105
- veganFriendlyi and veganFriendly are 0 or 1