Professional Documents
Culture Documents
Code 1
Code 1
int jump = 1;
int start = 0;
int end = 0;
for (int i=0; i<a.length; i=i+jump){
jump = 1;
start = i;
int kx = a[i];
int no_of_words = 1;
if (kx<=k){
if (no_of_words>max_no_of_words){
max_no_of_words = no_of_words;
}
}
else if (kx>k){
continue;
}
for (int j=i+1; j<a.length; j++){
kx = kx + a[j];
no_of_words = no_of_words+1;
if (kx<=k){
if (no_of_words>max_no_of_words){
max_no_of_words = no_of_words;
}
}
else if (kx > k){