You are given an array A consisting of the integers −1, 0 and 1. A slice of that array is any pair of integers (P, Q) such that 0 ≤ P ≤ Q < N. Your task is to find the longest slice of A whose elements yield a non-negative sum.
Write a function:
int solution(vector<int> &A);
that, given an array A of length N, consisting only of the values −1, 0, 1, returns the length of the longest slice of A that yields a non-negative sum. If there's no such slice, your function should return 0.
For example, given A = [−1, −1, 1, −1, 1, 0, 1, −1, −1], your function should return 7, as the slice starting at the second position and ending at the eighth is the longest slice with a non-negative sum.
For another example, given A = [1, 1, −1, −1, −1, −1, −1, 1, 1] your function should return 4: both the first four elements and the last four elements of array A are longest valid slices.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [2..100,000];
- each element of array A is an integer within the range [−1..1].
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
}
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B
}
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for ()
}
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{}
}
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) -
}
}
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B()
}
}
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B(it - 1);
if ((it - ()))
}
}
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B(it - 1);
if ( (it - (it-1) > max))
}
}
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B(it - 1);
if ( (it - (it-1)) > max )
max = (it - (it - 1))
}
}
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B(it - 1);
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B(it - 1);
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
func.cpp: In function 'int solution(std::vector<int>&)': func.cpp:28:43: error: no match for call to '(std::vector<int>) (int)' partial = B.at(it2) - B(it - 1); ^
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B.at(it - 1);
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B.at(it - 1);
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B.at(it - 1);
if (partial >= 0)
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) > 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B.at(it - 1);
if (partial >= 0)
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) >= 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B.at(it - 1);
if (partial >= 0)
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) >= 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B.at(it - 1);
if (partial >= 0)
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) >= 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B.at(it - 1);
if (partial >= 0)
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
[-1, 0, -1]
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) >= 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B.at(it - 1);
if (partial >= 0)
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
[-1, 0, -1]
[-1, 0, 0, -1]
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) >= 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B.at(it - 1);
if (partial >= 0)
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) >= 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
//std::cout << "it " << it <<std::endl;
//std::cout << "it2 " << it2 <<std::endl;
partial = B.at(it2) - B.at(it - 1);
if (partial >= 0)
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) >= 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
std::cout << "it " << it <<std::endl;
std::cout << "it2 " << it2 <<std::endl;
partial = B.at(it2) - B.at(it - 1);
if (partial >= 0)
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) >= 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
std::cout << "it " << it <<std::endl;
std::cout << "it2 " << it2 <<std::endl;
partial = B.at(it2) - B.at(it - 1);
std::cout << "partial " << partial <<std::endl;
std::cout << "max " << max <<std::endl;
if (partial >= 0)
if ( (it - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
[-1, 0, -1]
[-1, 0, 0, -1]
it 1 it2 1 partial -1 max 7 it 1 it2 2 partial 0 max 7 it 1 it2 3 partial -1 max 7 it 1 it2 4 partial 0 max 7 it 1 it2 5 partial 0 max 7 it 1 it2 6 partial 1 max 7 it 1 it2 7 partial 0 max 7 it 1 it2 8 partial -1 max 7 it 2 it2 2 partial 1 max 7 it 2 it2 3 partial 0 max 7 it 2 it2 4 partial 1 max 7 it 2 it2 5 partial 1 max 7 it 2 it2 6 partial 2 max 7 it 2 it2 7 partial 1 max 7 it 2 it2 8 partial 0 max 7 it 3 it2 3 partial -1 max 7 it 3 it2 4 partial 0 max 7 it 3 it2 5 partial 0 max 7 it 3 it2 6 partial 1 max 7 it 3 it2 7 partial 0 max 7 it 3 it2 8 partial -1 max 7 it 4 it2 4 partial 1 max 7 it 4 it2 5 partial 1 max 7 it 4 it2 6 partial 2 max 7 it 4 it2 7 partial 1 max 7 it 4 it2 8 partial 0 max 7 it 5 it2 5 partial 0 max 7 it 5 it2 6 partial 1 max 7 it 5 it2 7 partial 0 max 7 it 5 it2 8 partial -1 max 7 it 6 it2 6 partial 1 max 7 it 6 it2 7 partial 0 max 7 it 6 it2 8 partial -1 max 7 it 7 it2 7 partial -1 max 7 it 7 it2 8 partial -2 max 7 it 8 it2 8 partial -1 max 7
it 1 it2 1 partial 1 max 4 it 1 it2 2 partial 0 max 4 it 1 it2 3 partial -1 max 4 it 1 it2 4 partial -2 max 4 it 1 it2 5 partial -3 max 4 it 1 it2 6 partial -4 max 4 it 1 it2 7 partial -3 max 4 it 1 it2 8 partial -2 max 4 it 2 it2 2 partial -1 max 4 it 2 it2 3 partial -2 max 4 it 2 it2 4 partial -3 max 4 it 2 it2 5 partial -4 max 4 it 2 it2 6 partial -5 max 4 it 2 it2 7 partial -4 max 4 it 2 it2 8 partial -3 max 4 it 3 it2 3 partial -1 max 4 it 3 it2 4 partial -2 max 4 it 3 it2 5 partial -3 max 4 it 3 it2 6 partial -4 max 4 it 3 it2 7 partial -3 max 4 it 3 it2 8 partial -2 max 4 it 4 it2 4 partial -1 max 4 it 4 it2 5 partial -2 max 4 it 4 it2 6 partial -3 max 4 it 4 it2 7 partial -2 max 4 it 4 it2 8 partial -1 max 4 it 5 it2 5 partial -1 max 4 it 5 it2 6 partial -2 max 4 it 5 it2 7 partial -1 max 4 it 5 it2 8 partial 0 max 4 it 6 it2 6 partial -1 max 4 it 6 it2 7 partial 0 max 4 it 6 it2 8 partial 1 max 4 it 7 it2 7 partial 1 max 4 it 7 it2 8 partial 2 max 4 it 8 it2 8 partial 1 max 4
function result: 1
it 1 it2 1 partial 0 max 0 it 1 it2 2 partial -1 max 1 it 2 it2 2 partial -1 max 1
function result: 1
it 1 it2 1 partial 0 max 0 it 1 it2 2 partial 0 max 1 it 1 it2 3 partial -1 max 1 it 2 it2 2 partial 0 max 1 it 2 it2 3 partial -1 max 1 it 3 it2 3 partial -1 max 1
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) >= 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
std::cout << "it " << it <<std::endl;
std::cout << "it2 " << it2 <<std::endl;
partial = B.at(it2) - B.at(it - 1);
std::cout << "partial " << partial <<std::endl;
std::cout << "max " << max <<std::endl;
if (partial >= 0)
if ( (it2 - (it-1)) > max )
max = (it - (it - 1));
}
}
return max;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) >= 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B.at(it - 1);
if (partial >= 0)
if ( (it2 - (it-1)) > max )
max = (it2 - (it - 1));
}
}
return max;
}
[-1, 0, -1]
[-1, 0, 0, -1]
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) >= 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B.at(it - 1);
if (partial >= 0)
if ( (it2 - (it-1)) > max )
max = (it2 - (it - 1));
}
}
return max;
}
[-1, 0, -1]
[-1, 0, 0, -1]
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
#include <vector>
int solution(vector<int> &A) {
std::vector <int> B;
int len = A.size();
int it;
int max = 0;
int partial = 0;
B = A;
for (it = 0 ; it < len; ++it)
{
if (it != 0)
B.at(it) = B.at(it) + B.at(it-1);
if (B.at(it) >= 0)
max = it + 1;
}//end for
for (it = 1; it < len; ++it)
{
for (int it2 = it; it2 < len; ++it2)
{
partial = B.at(it2) - B.at(it - 1);
if (partial >= 0)
if ( (it2 - (it-1)) > max )
max = (it2 - (it - 1));
}
}
return max;
}
The following issues have been detected: timeout errors.
large array with all prefixes positive
running time: 1.57 sec., time limit: 0.10 sec.
random array N = 100000
running time: >6.00 sec., time limit: 0.10 sec.
array of fibonacci words N = 100000
running time: 4.86 sec., time limit: 0.10 sec.