码迷,mamicode.com
首页 > 其他好文 > 详细

leetcode238

时间:2017-05-09 18:57:49      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:problems   ref   array   cep   desc   rod   com   rip   public   

public class Solution {
    public int[] ProductExceptSelf(int[] nums) {
        int[] result = new int[nums.Length];
            for (int i = 0, tmp = 1; i < nums.Length; i++)
            {
                result[i] = tmp;
                tmp *= nums[i];
            }
            for (int i = nums.Length - 1, tmp = 1; i >= 0; i--)
            {
                result[i] *= tmp;
                tmp *= nums[i];
            }
            return result;
    }
}

https://leetcode.com/problems/product-of-array-except-self/#/description

leetcode238

标签:problems   ref   array   cep   desc   rod   com   rip   public   

原文地址:http://www.cnblogs.com/asenyang/p/6832048.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!