Filter a JSON Array of Orders

Medium ⏱ 12 min 63% acceptance ★★★★★ 4.8
Write big_orders(raw, threshold) that parses a JSON array of order objects (each with id and amount) and returns the list of ids whose amount is at least the threshold, preserving order.

Examples

Example 1
Input
big_orders('[{"id": 1, "amount": 50}, {"id": 2, "amount": 500}]', 100)
Output
[2]
Explanation

Only order 2 clears 100.

Constraints

  • Parse first, then filter.
  • Return ids, not whole objects.

Topics

JSONarray processing

Companies

AmazonFlipkartShopify

Hints

Hint 1

loads gives a list of dicts.

Hint 2

A comprehension with o['amount'] >= threshold.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.