网址:https://leetcode.com/problems/product-of-array-except-self/

参考:https://leetcode.com/problems/product-of-array-except-self/discuss/65622/Simple-Java-solution-in-O(n)-without-extra-space

class Solution {
public:
vector<int> productExceptSelf(vector<int>& nums) {
vector<int> res(nums.size(),);
int right = ; for(int i=;i<nums.size();i++)
{
res[i] = res[i-] * nums[i-];
} for(int i=nums.size()-;i>=;i--)
{
res[i] *= right;
right *= nums[i];
}
return res;
}
};

238. Product of Array Except Self除自身以外数组的乘积的更多相关文章

  1. 238 Product of Array Except Self 除自身以外数组的乘积

    一个长度为 n 的整形数组nums,其中 n > 1,返回一个数组 output ,其中 output[i] 等于nums中除nums[i]以外所有元素的乘积.不用除法 且在O(n)内解决这个问 ...

  2. Leetcode238. Product of Array Except Self除自身以外数组的乘积

    给定长度为 n 的整数数组 nums,其中 n > 1,返回输出数组 output ,其中 output[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积. 示例: 输入: [1 ...

  3. LeetCode OJ 238. Product of Array Except Self 解题报告

        题目链接:https://leetcode.com/problems/product-of-array-except-self/ 238. Product of Array Except Se ...

  4. 238. Product of Array Except Self(对O(n)和递归又有了新的理解)

    238. Product of Array Except Self     Total Accepted: 41565 Total Submissions: 97898 Difficulty: Med ...

  5. LN : leetcode 238 Product of Array Except Self

    lc 238 Product of Array Except Self 238 Product of Array Except Self Given an array of n integers wh ...

  6. leetcode 11. Container With Most Water 、42. Trapping Rain Water 、238. Product of Array Except Self 、407. Trapping Rain Water II

    11. Container With Most Water https://www.cnblogs.com/grandyang/p/4455109.html 用双指针向中间滑动,较小的高度就作为当前情 ...

  7. 【LeetCode】238. Product of Array Except Self

    Product of Array Except Self Given an array of n integers where n > 1, nums, return an array outp ...

  8. leetcode:238. Product of Array Except Self(Java)解答

    转载请注明出处:z_zhaojun的博客 原文地址 题目地址 Product of Array Except Self Given an array of n integers where n > ...

  9. 【刷题-LeetCode】238. Product of Array Except Self

    Product of Array Except Self Given an array nums of n integers where n > 1, return an array outpu ...

随机推荐

  1. 解决win10无法访问共享

    一台win10共享的文件夹,有的电脑是可以访问的,我的win10 访问不了,说什么 遇到未知错误,用以下方法得以解决 ----------------------------------------- ...

  2. IDEA eclipse转maven

    在pom.xml 文件上右键 Add as Maven Project

  3. ubuntu常用软件命令

    解压zip软件 unzip  xxx.zip -d解压到指定目录 清理磁盘空间 sudo apt-get autoremove sudo apt-get clean sudo dpkg --list ...

  4. 发布自己的npm包、开源项目

    背景:由于最近在做项目之余想做一些其他的事,所以东找找西找找的,最后决定写一个封装一些常用原型方法的NPM包,但不仅限于此.话不多说,说一下实践过程. 一.注册NPM及如何上传NPM包参考连接:htt ...

  5. python str find & index 联系

    [1]相同点 (1)功能:检测字符串中是否包含子字符串str (2)语法: [1] str.find(str, beg = 0, end = len(string)) [2] str.index(st ...

  6. GoldenGate抽取Informix数据库安装及配置

    GoldenGate抽取Informix数据库安装及配置 本次测试架构 l  在中间机上安装informix csdk4.10版本,并编译配置unixODBC; l  在中间机上安装ogg for I ...

  7. Ipan笔记-2

    其实二级联动下拉选择框很简单的, 参考: https://www.cnblogs.com/zhangmiaomiao/p/6013533.html ============== 关于$.each和 $ ...

  8. python from entry to abandon2

    学习Linux已经有大致两周了,依然感觉到自己仍然在运维的大门外徘徊.于是我想要找到一个在Linux之外的业余方向,可以以作为枯燥基础学习的调节.没过多久我就发现了Python可以说是钦定的选择,它作 ...

  9. MySQL安装指南(转)

    MySQL安装指南   安装MySQL sudo apt-get install mysql-server 这个应该很简单了,而且我觉得大家在安装方面也没什么太大问题,所以也就不多说了,下面我们来讲讲 ...

  10. 浅谈JS数据遍历的几种方式

    遍历对象(数组)是我们日常撸码的必不可少的部分,如何从性能上优化代码,提高运行效率?下文为你揭开真像: 第一种:普通的for循环 for(j = 0; j < arr.length; j++) ...