You are given an array consisting of n integer numbers \(a_1,a_2..a_n\). Two subarrays \([l_1
\space r_1]\) (\(1\le l_1\le r_1\le n\)) and \([l_2 \space r_2]\) (\(1\le l_2\le r_2\le n\)) are considered the same if they have the same "special set" of numbers. Output the number of distinct subarrays.
Note: A "special set" of numbers is a set of unique numbers sorted in increasing order.For example,the "special set" corresponding to the numbers [\(5,2,7,2,5,9\)] is [\(2,5,7,9\)].
Input Format
First line contains n denoting the number of array elements.
Second line contains n integers denoting \(a_1,a_2..a_n\)
Output Format
Output the required answer.
Constraints
\(1\le n\le 1000\)
\(1\le a_i\le 1000 \)
Special Set of numbers in subarray [1 1]: {1}
Special Set of numbers in subarray [2 2]: {1}
Special Set of numbers in subarray [3 3]: {2}
Special Set of numbers in subarray [1 2]: {1}
Special Set of numbers in subarray [1 3]: {1,2}
Special Set of numbers in subarray [2 3]: {1,2}
Thus the number of distinct subarrays are 3.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor