首页 > 其他 > 详细

leetcode238

时间:2017-05-09 18:43:48      阅读:313      评论:0      收藏:0      [点我收藏+]
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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!