Definition of subarray

arrays

I am unclear about the definition of a sub array. Does it mean a contiguous list of indexes , such as a[i..j] or can it be non contiguous, such as a[0], a[5],a[6]

Best Answer

I think the subarray means the array in which the contiguousness is based on the index . for example lets take an example

2 3 1 3 1 (index are 0,1,2,3,4 respectively )

so subarray is 2,3,1 3 (index 0,1,2,3) But (1,2 1) (index 2,0,4) cannot be a subarray coz the indexes are non-contiguous ..

Hope its helpfull ;)