Maximum Circular Subarray Product

HardArrayDynamic Programming

Description

Given a circular integer array nums, return the maximum possible product of any non-empty contiguous subarray (wrapping allowed).

Examples

Input:nums = [2,3,-2,4]
Output:24
Explanation:

Circular wrap subarray [4,2,3] gives 24.

Input:nums = [-1,-2,-3]
Output:6
Explanation:

Subarray [-2,-3] gives 6.

Input:nums = [5,-3,5]
Output:25
Explanation:

Circular wrap [5,5] gives 25.

Constraints

  • 1 ≤ nums.length ≤ 200
  • -10 ≤ nums[i] ≤ 10

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.