1
// comparator class for sorting restaurants by their rating4
bool operator()(vector<int> a, vector<int> b) {5
// same rating then sort by ids6
if (a[1] == b[1]) return a[0] > b[0];12
vector<int> filterRestaurants(vector<vector<int>> &restaurants, int veganFriendly, int maxPrice,13
int maxDistance) { // sort restaurants by their rating14
sort(restaurants.begin(), restaurants.end(), comp());16
for (int i = 0; i < restaurants.size(); i++) {19
// store ids who satisfy the constraints20
if (restaurants[i][2] == veganFriendly and restaurants[i][3] <= maxPrice and21
restaurants[i][4] <= maxDistance) {22
ans.push_back(restaurants[i][0]);27
// store ids who satisfy the constraints28
if (restaurants[i][3] <= maxPrice and restaurants[i][4] <= maxDistance) {29
ans.push_back(restaurants[i][0]);