Created
October 17, 2020 13:40
-
-
Save gunavaran/cb4cc012c14b657c6b5bbd6f66854fbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdbool.h> | |
bool overflow(int64_t *A, size_t n) { | |
//All elements of A are non-negative | |
A[n] = INT64_MAX; | |
A[n + 1] = 1; //any positive value | |
size_t i = 0; | |
int64_t sum = A[0]; | |
while (sum >= A[i]) { | |
sum += A[++i]; | |
} | |
if (i < n) return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment