From 95328c10aa2b75107eb2eca2a452a53d054c5354 Mon Sep 17 00:00:00 2001 From: shirali saraf <109896594+shirali-saraf@users.noreply.github.com> Date: Fri, 6 Oct 2023 20:51:17 +0530 Subject: [PATCH] Create c++ code for maximum subarray sum #444 --- c++ code for maximum subarray sum | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 c++ code for maximum subarray sum diff --git a/c++ code for maximum subarray sum b/c++ code for maximum subarray sum new file mode 100644 index 00000000..032870cc --- /dev/null +++ b/c++ code for maximum subarray sum @@ -0,0 +1,18 @@ +int maxSubArray(vector& nums) { + int l=nums.size(); + int max=INT_MIN; + int sum=0; + + for(int i=0;imax){ + max=sum; + } + if(sum<0){ + sum=0; + } + + } + return max; + }