Ad

made it fit on one line :)

Code
Diff
  • max_sequence = lambda arr :max([sum(arr)] + [sum(arr[j:j+i]) for i in range(len(arr)) for j in range(len(arr) - i + 1)])
    • def max_sequence(arr):
    • # Code to find maximum sum of subarray
    • return max(
    • [sum(arr)] +
    • [sum(arr[j:j+i]) for i in range(len(arr)) for j in range(len(arr) - i + 1)]
    • )
    • max_sequence = lambda arr :max([sum(arr)] + [sum(arr[j:j+i]) for i in range(len(arr)) for j in range(len(arr) - i + 1)])