#K15161. Longest Unique Subarray Lengths

    ID: 24296 Type: Default 1000ms 256MiB

Longest Unique Subarray Lengths

Longest Unique Subarray Lengths

You are given an array \(A\) of \(N\) integers. For every index \(i\) (0-indexed), your task is to compute the length of the longest contiguous subarray ending at index \(i\) that contains all unique elements. Formally, if we denote the starting index of such subarray by \(start\), then the length at index \(i\) is given by \(L_i = i - start + 1\). You need to determine \(L_i\) for every \(i\) from 0 to N-1.

Note: A contiguous subarray is a sequence of consecutive elements in the array.

inputFormat

The first line contains an integer \(N\) denoting the number of elements in the array. The second line contains \(N\) space-separated integers representing the array \(A\).

outputFormat

Output a single line containing \(N\) space-separated integers, where the \(i\)-th integer represents the length of the longest contiguous subarray ending at index \(i\) with all unique elements.

## sample
5
1 2 1 3 2
1 2 2 3 3