What is contigous subarray?

SIr, can you please explain me this question?

The problem is saying that you need to sum the lengths of contiguous subarray such that the subarray consists distinct elements. For example in array A = {1, 2, 3 1} possible subarrays with all distinct elements will be
Size 1: {1}, {2}, {3}, {1}
Size 2: {1, 2}, {2, 3}, {3, 1}
Size 3: {1, 2, 3}, {2, 3, 1}
Size 4: null

Hence answer = 4 * 1 + 3 * 2 + 2 * 3 + 0 * 4

A contiguous subarray or simply subarray is an array consisting of all elements in range [L, R] occurring in same sequence for a given array(let its size be n) where 1 ≤ L ≤ R ≤ n.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.