Tyfone's Ozone digital banking experience displays transaction activity that users may narrow by transaction type and minimum amount. Given an array of transaction records, return a new array containing only records that satisfy both criteria, without using Python's built-in filter function or mutating the input.
Preserve the original order of the matching records. Use an explicit loop. Converting allowed_types to a set is permitted and encouraged for efficient membership checks.
Implement filter_transactions(transactions, min_amount, allowed_types).
transactions is a list of dictionaries. Each dictionary contains an id string, a type string, and an amount number.min_amount is a non-negative integer or float.allowed_types is a list of transaction-type strings.amount is greater than or equal to min_amount and whose type appears in allowed_types.Example 1: transactions = [{"id": "t1", "type": "card", "amount": 42}, {"id": "t2", "type": "ach", "amount": 80}], min_amount = 50, allowed_types = ["ach"] returns [{"id": "t2", "type": "ach", "amount": 80}] because only t2 satisfies both conditions.
Example 2: transactions = [{"id": "t1", "type": "card", "amount": 25}, {"id": "t2", "type": "card", "amount": 100}], min_amount = 25, allowed_types = ["card"] returns both records in their original order.
def filter_transactions(transactions, min_amount, allowed_types):