#C3652. Max Unique Flowers
Max Unique Flowers
Max Unique Flowers
Henry has a garden consisting of several flowering plants arranged in a row. Each plant produces one type of flower. Henry wants to find a contiguous section of his garden such that the number of unique flower types in that section is maximized.
Your task is to compute the maximum number of unique flowers that can be obtained from any contiguous segment of the garden.
Formally, given an integer \(n\) representing the number of plants and an array \(A\) of length \(n\) where \(A[i]\) indicates the type of flower produced by the \(i\)-th plant, find the maximum number of unique values over all contiguous subarrays of \(A\).
It is guaranteed that the list of flower types may be empty when \(n = 0\), in which case the answer is 0.
inputFormat
The first line contains an integer \(n\) (\(0 \leq n \leq 10^5\)) – the number of plants in the garden.
The second line contains \(n\) space-separated integers representing the flower types of each plant.
outputFormat
Output a single integer – the maximum number of unique flowers in any contiguous section of the garden.
## sample7
1 2 1 3 4 2 4
4