Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func productExceptSelf(nums []int) []int {
- res:=make([]int,len(nums))
- prefix:=1
- for i:= range nums {
- res[i] = prefix
- prefix *=nums[i]
- }
- postfix:=1
- for i:=len(nums) -1;i>=0;i-- {
- res[i] *=postfix
- postfix *=nums[i]
- }
- return res
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement