238 Product of Array Except Self
2015-07-20 15:37
274 查看
网上的
public class Solution { public int[] productExceptSelf(int[] nums) { int[] res = new int[nums.length]; res[res.length-1] = 1; for(int i=nums.length-2; i>=0; i--) { res[i] = res[i+1] * nums[i+1]; } int left = 1; for(int i=0; i<nums.length; i++) { res[i] *= left; left *= nums[i]; } return res; } }
相关文章推荐
- poj 3280 区间dp
- C#字典的遍历方法
- 解决SQL server2005数据库死锁的经验心得
- Zend Studio 上 安装使用Aptana插件
- 初试FitNesse
- 2025 查找最大元素
- HDU 4979 A simple math problem.
- java 堆和栈
- C#索引器的使用
- 使用URLDecoder和URLEncoder对中文进行处理
- bestcoder48 第二题
- 2894 Txx考试
- POJ2964日历问题
- Multithreaded simple data type access and atomic variables
- 【C++】利用Visual Studio 2008编写C++,Visual Studio 2008的基本使用
- 清除Windows Server Backup 备份副本
- GRE写作必备句型
- jstring 和string char*之间的转换
- 你的程序支持复杂的时间调度嘛?
- 给还在上学的你们