forked from luliyucoordinate/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1333.cpp
20 lines (18 loc) · 743 Bytes
/
1333.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Solution
{
public:
vector<int> filterRestaurants(vector<vector<int>>& restaurants, int veganFriendly, int maxPrice, int maxDistance)
{
restaurants.erase(remove_if(restaurants.begin(), restaurants.end(), [=](auto const s) {
return !(s[2] >= veganFriendly && s[3] <= maxPrice && s[4] <= maxDistance);
}), restaurants.end());
sort(restaurants.begin(), restaurants.end(), [](auto const a, auto const b) {
return a[1] == b[1] ? a[0] > b[0]: a[1] > b[1];
});
vector<int> res(restaurants.size());
transform(restaurants.begin(), restaurants.end(), res.begin(), [](auto const s) {
return s[0];
});
return res;
}
};