Problem in concept of contiguous subarrays

As an example if :
Input = [1 5 5 4 3 2 1 1]
Then contiguous subarrays will be :
{1},{2},{3},{4},{5}
{1,5},{5,4},{4,3},{3,2},{2,1}
{5,4,3},{4,3,2},{3,2,1}
{5,4,3,2},{4,3,2,1}
{5,4,3,2,1}
which totals up to 37. Is this correct interpretation?

{1} {1} {1} would be there ie 3 times(different indices)
similarly for others as well.

1 Like

And rest others are correct ???

I mean this ones:
{1,5},{5,4},{4,3},{3,2},{2,1}
{5,4,3},{4,3,2},{3,2,1}
{5,4,3,2},{4,3,2,1}
{5,4,3,2,1}

If input is 1 5 6 5
then the subset {5,6} and {6,5} will be identical??

Reply 1: Yes they are correct.
Reply 2: No, they aren’t identical. Look , we need to get all subarrays that have distinct elements and not distinct sets of elements. subarray with index [2,4] is different to subarray with index [4,6].

1 Like