Subject: PHP

Find Subarray with Maximum Sum (Kadane’s Algorithm)

Write a PHP function to find the subarray with the maximum sum in a given array.

Example:
Input: [-2, -3, 4, -1, -2, 1, 5, -3]
Output: 7 (subarray: [4, -1, -2, 1, 5])

Select file or drag and drop

PNG, JPG, SVG

Preview