← Back to Lambda Functions
Question 193
Lambda as a Predicate (count_if)
Lambda as a Predicate (count_if)
Use a lambda together with the STL algorithmstd::count_if. Write intcountGreater(const vector<int>& nums, int threshold)that returns how many elements are strictly greater than threshold, using count_if with a lambda that captures threshold. Include<algorithm>. Do NOT write a main function.
Expected Output:
2 4
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Lambda Functions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.