#include <iostream>
int main() {
int data[] = {2, 1, 3, 2, 5, 1, 1, 2, 3};
int size = sizeof(data)/sizeof(data[0]);
int max = 0;
int len = 0;
int sum = 0;
int start = 0;
for(int i = 0; i<size; i++)
{
sum+=data[i];
len++;
while( sum > 10)
{
sum -= data[start];
start++;
len--;
}
if(max < len)
{
max = len;
}
}
printf("%d" , max);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: