First, O(n^2) solution.
(nums []int)
| 27 | |
| 28 | // First, O(n^2) solution. |
| 29 | func maxProduct0(nums []int) int { |
| 30 | max := math.MinInt32 |
| 31 | for i := 0; i < len(nums); i++ { |
| 32 | product := nums[i] |
| 33 | max = int(math.Max(float64(max), float64(product))) |
| 34 | for j := i + 1; j < len(nums); j++ { |
| 35 | product *= nums[j] |
| 36 | max = int(math.Max(float64(max), float64(product))) |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | return max |
| 41 | } |
nothing calls this directly
no outgoing calls
no test coverage detected