Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is contiguous subarray

Tags:

arrays

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]

like image 309
Sushil Shinde Avatar asked Feb 20 '26 10:02

Sushil Shinde


1 Answers

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.

like image 90
Alexey Romanov Avatar answered Feb 23 '26 07:02

Alexey Romanov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!