Skip to content

Instantly share code, notes, and snippets.

@codyhan94
Created January 6, 2014 04:59
Show Gist options
  • Save codyhan94/8278493 to your computer and use it in GitHub Desktop.
Save codyhan94/8278493 to your computer and use it in GitHub Desktop.
int array[];
int prev2 = array[0];
int prev1 = array[1];
int sum_prev = prev1 + prev2;
bool seg_good = true;
for (int i = 2; i < n; ++i)
{
int cur = array[i];
if (cur == sum_prev)
{
longest_seg++;
}
else
{
longest_seg = 2;
}
prev2 = prev1;
prev1 = cur;
sum_prev = prev1 + prev2;
}
cout << longest_seg << endl;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment