Subarray with distinct element

what would be the output for arr={1,2,1} ?according to this question

3 one size subarrays + 2 two size subarrays + 0 three sized subarray

asn = 3 * 1 + 2 * 2 + 0 = 7

1 Like