We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
auto count_fruits = []
(vector<int>& fruits, int s, int t) -> int
{
return std::accumulate(
fruits.begin(), fruits.end(), 0,
[&] (int v, int f)
{
return v + (s <= f && f <= t ? 1 : 0);
});
};
std::cout
<< count_fruits(apples, s - a, t - a)
<< std::endl
<< count_fruits(oranges, s - b, t - b);
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Apple and Orange
You are viewing a single comment's thread. Return to all comments →
C++ way
}