From 62b45eb05bc2d94268ff14616d9567718cfb8fd3 Mon Sep 17 00:00:00 2001 From: manvika-10 <84900650+manvika-10@users.noreply.github.com> Date: Wed, 26 Oct 2022 00:58:37 +0530 Subject: [PATCH] Added code for "Maximum Subarray Sum" --- MaxSubarraySum.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 MaxSubarraySum.cpp diff --git a/MaxSubarraySum.cpp b/MaxSubarraySum.cpp new file mode 100644 index 00000000..556ea67c --- /dev/null +++ b/MaxSubarraySum.cpp @@ -0,0 +1,34 @@ +//Time Complexity : O(N) +//Space Complexity : O(1) + +#include +using namespace std; + +int maxSubArraySum(int arr[], int size) +{ + int max_sum = INT_MIN, ending_index = 0; + + for(int i=0; i