1
votes

I am trying to study contiguous subarray but I am not getting any study material which explains this concept.

But I found one example with says that Given the array [-2,1,-3,4,-1,2,1,-5,4] the contiguous subarray is [4,-1,2,1]

Can anyone explain on what bases they are saying contiguous subarray is [4,-1,2,1]

1

1 Answers

2
votes

It isn't the contiguous subarray, there are many. It's just a subsequence without skipping any elements. E.g. [-2, 1], [-2, 1, -3], [2, 1, -5] are all contiguous subarrays of this array, but [2, 1, 4] isn't.