网址: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. Python四线程爬取西刺代理

    import requests from bs4 import BeautifulSoup import lxml import telnetlib #验证代理的可用性 import pymysql. ...

  2. 【LeetCode每天一题】Jump Game(跳跃游戏)

    Given an array of non-negative integers, you are initially positioned at the first index of the arra ...

  3. js 执行机制

    浏览器中每个一个窗口都是一个单独的进程.这就需要分析浏览器与Javascript解释引擎之间的关系.先给出结论,浏览器本身是多线程的,Javascript解释引擎是单线程的. 先说说浏览器有哪些线程, ...

  4. 编译器将"+"转换成了StringBuilder类

    MapReduce map100% Reduce 66% 卡死 如果你碰到map100%,reduce 66% 然后程序就貌似停止在这里了,可能是由于在Reduce类里使用了String造成的 根据一 ...

  5. Spring框架的第三天

    ## Spring框架的第三天 ## ---------- **课程回顾:Spring框架第二天** 1. IOC的注解方式 * @Value * @Resource(name="" ...

  6. windows程序设计 基础

    API全名(Application Program Interface) Windows窗口主函数 int WINAPI WinMain( HINSTANCE hInstance,//应用程序本次运行 ...

  7. 转载一篇较为详细的caffe-ssd编译环境的搭建

    这篇搭建的文章写得还是比较全面的,亲测有效:https://blog.csdn.net/lukaslong/article/details/81390276

  8. C++对象赋值问题

  9. 213. House Robber II(动态规划)

    You are a professional robber planning to rob houses along a street. Each house has a certain amount ...

  10. lua语言三目运算符

    [1]lua语言中完整的三目运算符 完整三目运算符形式:(a and {b} or {c})[1] [2]分析原因 大部分C或C++程序员经常会用到三目运算符(三元运算符),形如 a ? b : c; ...