Dsa
Dynamic Programming
Warm-up
Planting Garden
You are helping a gardener design a flower bed where each flower can grow for a certain number of days before it wilts. For a given sequence of flowers, calculate the maximum number of flowers that can be planted in the bed without having any of them wilt on the same day. Write a program to find out how many flowers can be planted.
Input format:
- The first line contains an integer N (1 ≤ N ≤ 100).
- The second line contains N space-separated integers representing the number of days each flower can last.
Output format:
- A single integer indicating the maximum number of flowers that can be planted.
Example:
Input:
5
5 1 2 3 4
Output:
5
Key concepts
dynamic_programmingsequencesmaximization
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now