← 返回 optiver 的题目列表Trading Sequence Counting
类型:online_judge
Given a trading sequence, count the number of subsequences that meet a specific condition. Write a function that takes a list of trading sequences and a condition function, and returns the number of subsequences that satisfy the condition.
Input
sequence: A list of integers representing the trading sequence.
condition: A function that takes a list and returns a boolean value to determine if the condition is met.
Output
Return an integer, the number of subsequences satisfying the condition.
Test Example
Example 1
Input: sequence = [1, 2, 3], condition = lambda x: sum(x) > 3
Output: 3
Constraints
The length of sequence is between [1, 100].
Each element is between [0, 100].
Example
Input
3
1 2 3
sum(x) > 3