From 444a764d7d81b2c542f9c6d18d4746722767f323 Mon Sep 17 00:00:00 2001 From: Pranavimmaneni <44798404+Pranavimmaneni@users.noreply.github.com> Date: Wed, 30 Oct 2019 22:53:30 +0530 Subject: [PATCH] Create prob5.py --- Problems/Problem_5/prob5.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Problems/Problem_5/prob5.py diff --git a/Problems/Problem_5/prob5.py b/Problems/Problem_5/prob5.py new file mode 100644 index 0000000..6d78c65 --- /dev/null +++ b/Problems/Problem_5/prob5.py @@ -0,0 +1,23 @@ +def max_sum(a): + + tempMax = 0 + max = 0 + + for i in range(0, len(a)): + max = max + a[i] + if max < 0: + max = 0 + + elif (tempMax < max): + tempMax = max + + return tempMax + +lenArray = int(input("Enter size of array : ")) +x = [] + +for i in range(0,lenArray): + n = int(input("Enter the value : ")) + x.append(n) + +print (max_sum(x))