Input: arr[] = {3, 2, 1}, N = 3
Output: 3
Explanation:
The array formed by the concatenation -
{3, 2, 1, 3, 2, 1, 3, 2, 1}
The longest increasing subsequence that can be formed from this array is of length 3 which is {1, 2, 3}
Input: N = 3 arr[] = {3, 1, 4}
Output:
Explanation:
The array formed by concatenation -
{3, 1, 4, 3, 1, 4, 3, 1, 4}
The longest increasing subsequence that can be formed from this array is of length 3 which is {1, 3, 4}
Given Array be – {4, 4, 1}
Creating the map of unique elements: {(4, 2), (1, 1)}
Length of the Map = 2
Hence the required longest subsequence = 2