From ec7a3848f5d945808f4eb0a43ccfeb6a65508fef Mon Sep 17 00:00:00 2001
From: Rudranil Ghosh <134212273+rudra1ghosh@users.noreply.github.com>
Date: Tue, 31 Oct 2023 22:20:05 +0530
Subject: [PATCH 1/2] Update CONTRIBUTORS.md
---
CONTRIBUTORS.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 21f269aa..33e7722a 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -33,5 +33,6 @@ United Kingdom - https://github.com/cu-sanjay/HacktoberFest2023/assets/96792511/
|[Naveen Kumar .v](https://github.com/NK-dev-24) |
| I'm a Student. |
|[Chandan Arya](https://github.com/alpha2lucifer) |
| I am a passionate developer with a keen interest in blockchain technology and decentralized applications. My focus lies in creating efficient and secure solutions, and I enjoy exploring various programming languages and frameworks to build innovative applications.|
|[Tushar khatri](https://github.com/tusharkhatri434) |
| I'm a Frontend developer (ReactJs) |
+|[Rudranil Ghosh](https://github.com/rudra1ghosh) |
| I'm a programmer, learning one step at a time. |
From 4267b45239b76d57b74bbdabc2f19801543bde16 Mon Sep 17 00:00:00 2001
From: Rudranil Ghosh <134212273+rudra1ghosh@users.noreply.github.com>
Date: Tue, 31 Oct 2023 22:20:30 +0530
Subject: [PATCH 2/2] Add files via upload
---
Algorithms/MaxSubarraySum.cpp | 37 +++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 Algorithms/MaxSubarraySum.cpp
diff --git a/Algorithms/MaxSubarraySum.cpp b/Algorithms/MaxSubarraySum.cpp
new file mode 100644
index 00000000..0413b764
--- /dev/null
+++ b/Algorithms/MaxSubarraySum.cpp
@@ -0,0 +1,37 @@
+#include
+using namespace std;
+
+long long maxSubarraySum(int arr[], int n) {
+ long long maxi = LONG_MIN; // maximum sum
+ long long sum = 0;
+
+ for (int i = 0; i < n; i++) {
+
+ sum += arr[i];
+
+ if (sum > maxi) {
+ maxi = sum;
+ }
+
+ // If sum < 0: discard the sum calculated
+ if (sum < 0) {
+ sum = 0;
+ }
+ }
+
+ // To consider the sum of the empty subarray
+ // uncomment the following check:
+
+ //if (maxi < 0) maxi = 0;
+
+ return maxi;
+}
+
+int main()
+{
+ int arr[] = { -2, 1, -3, 4, -1, 2, 1, -5, 4};
+ int n = sizeof(arr) / sizeof(arr[0]);
+ long long maxSum = maxSubarraySum(arr, n);
+ cout << "The maximum subarray sum is: " << maxSum << endl;
+ return 0;
+}
\ No newline at end of file