From 88591c99ffcae4cc4971ca3772c0ac14c2b18348 Mon Sep 17 00:00:00 2001 From: Kratika Gupta <54476432+kratikagupta2002@users.noreply.github.com> Date: Sat, 23 Oct 2021 13:33:09 +0530 Subject: [PATCH 1/2] added GCD.cpp --- gcd.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 gcd.cpp diff --git a/gcd.cpp b/gcd.cpp new file mode 100644 index 0000000..8041ba1 --- /dev/null +++ b/gcd.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; + +int gcd(int a, int b) +{ + if (b == 0) + return a; + return gcd(b, a % b); +} + + + +int main() +{ int a,b; + cin>>a>>b; + int result=gcd(a, b); + cout< Date: Sat, 23 Oct 2021 15:00:45 +0530 Subject: [PATCH 2/2] added Kadane's Algorithm --- Kadane's algorithm.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Kadane's algorithm.cpp diff --git a/Kadane's algorithm.cpp b/Kadane's algorithm.cpp new file mode 100644 index 0000000..c69daf8 --- /dev/null +++ b/Kadane's algorithm.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; + +int kadanes(int array[],int length) { + int highestMax = 0; + int currentElementMax = 0; + for(int i = 0; i < length; i++){ + currentElementMax =max(array[i],currentElementMax + array[i]) ; + highestMax = max(highestMax,currentElementMax); + } + return highestMax; +} +int main() { + cout << "Enter the array length: "; + int l; + cin >> l; + int arr[l]; + cout << "Enter the elements of array: "; + for (int i = 0; i < l; i++) { + cin >> arr[i]; + } + cout << "The Maximum Sum is: "<