Product of Array Except Self
来源:互联网 发布:ghost网络克隆软件 编辑:程序博客网 时间:2024/05/17 22:58
public class Solution { public int[] productExceptSelf(int[] nums) { int[] left = new int[nums.length]; left[0] = nums[0]; int[] right = new int[nums.length]; right[nums.length - 1] = nums[nums.length - 1]; for (int i = 1; i < nums.length; i++) { left[i] = left[i - 1]* nums[i]; } for (int i = nums.length - 2; i >= 0; i--) { right[i] = right[i + 1]*nums[i]; } int[] result = new int[nums.length]; result[0] = right[1]; result[nums.length - 1] = left[nums.length - 2]; for (int i = 1; i < nums.length - 1; i++) { result[i] = left[i - 1]*right[i + 1]; } return result; }}j今天写代码没感觉啊,费了好大劲才写完
0 0
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- 类和对象浅谈(3)
- IPython :一个交互式计算和开发环境
- 项目26.4个人所得税计算器switch语句
- 函数式编程——函数笔记
- leetcode笔记:Path Sum II
- Product of Array Except Self
- USACO 2.3.3 Zero Sum
- word里创建自己的行文格式
- Eclipse 中设置JVM 内存
- 【2015/10/2】Linux学习日志_Day4 改变用户权限 文件类型与权限 链接 服务
- opencv多线程读取视频的问题
- ARC指南1 - strong和weak指针
- 在win7下安装python开发环境和numpy,scipy,matplotlib模块的问题
- ARC指南2 - ARC的开启和禁止