CJCoding With Joseph
15free / daySign inCreate account

Lambda as a Predicate (count_if)

Use a lambda together with the STL algorithm std::count_if. Write int countGreater(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
Topics:
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.