LeetCode: Maximum SubArray
Question:- https://leetcode.com/problems/maximum-subarray/
Soution:-
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
maxsum = nums[0]
length_list = len(nums)
for index in range(0,length_list):
for nest_index in range(index,length_list):
sel_sum = sum(nums[index:nest_index+1])
if sel_sum>maxsum:
maxsum = sel_sum
return maxsum
This Solution PASSES 200 test case out of 210, need more optimization in terms
of looping that we are using
Comments
Post a Comment