DEV Community

loading...

Discussion on: Daily Challenge #306 - Largest Possible Product

Collapse
mrwebuzb profile image
Asliddinbek Azizovich

Golang solution

func adjacentProduct(nums []int) int {
    curr, max := nums[0], 0
    for i := 1; i < len(nums); i++ {
        curr = curr * nums[i]
        if max < curr {
            max = curr
        }
        curr = nums[i]
    }
    return max
}
Enter fullscreen mode Exit fullscreen mode