I am trying to convert some C code into Go.
for i := l + 1; i < r; ++i {
ans = max(ans, nums[l]*nums[i]*nums[r]+maxCoin(dp, l, i, nums)+maxCoin(dp, i, r, nums))
}
Go doesn't have prefix operator, how can I convert this loop to use postfix?
I am trying to convert some C code into Go.
for i := l + 1; i < r; ++i {
ans = max(ans, nums[l]*nums[i]*nums[r]+maxCoin(dp, l, i, nums)+maxCoin(dp, i, r, nums))
}
Go doesn't have prefix operator, how can I convert this loop to use postfix?
Use a postfix increment statement, it doesn't make any difference in this case:
The difference only matters when you're using the result of the expression formed by the increment / decrement operator, but since in Go they're not even operators but statements, it doesn't matter. For reasoning, see FAQ: Why are ++ and -- statements and not expressions? And why postfix, not prefix?