Problem is :
Given an integer array nums
, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Below is the C solution:
Its a simple solution:
— take the sum of previous numbers with the current element
— compare it with the current element
— keep the max of those above 2 values
— compare it with global max value and update
Below is the Python solution:
leetcode shows the runtime and memory taken to execute the test cases:
Lots of difference with C solution and Python solution even if the logic is same.