Maximum cake orders

Write codeMedium14 min

Your task

A bakery takes custom cake orders for tomorrow. Every cake takes exactly one hour, work starts at hour 0, and only one cake is in the oven at a time. deadlines[i] is the hour by which order i must be finished, a deadline of 3 means it must be done at or before hour 3. Orders may be declined. Return the maximum number of orders the bakery can fulfill. Example: deadlines [2, 1, 2] gives 2.

Examples

max_orders(deadlines: list[int]) -> int
Example 1
Inputmax_orders([2, 1, 2])
Output2