238. Product of Array Except Self除自身以外数组的乘积
网址: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除自身以外数组的乘积的更多相关文章
- 238 Product of Array Except Self 除自身以外数组的乘积
一个长度为 n 的整形数组nums,其中 n > 1,返回一个数组 output ,其中 output[i] 等于nums中除nums[i]以外所有元素的乘积.不用除法 且在O(n)内解决这个问 ...
- Leetcode238. Product of Array Except Self除自身以外数组的乘积
给定长度为 n 的整数数组 nums,其中 n > 1,返回输出数组 output ,其中 output[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积. 示例: 输入: [1 ...
- LeetCode OJ 238. Product of Array Except Self 解题报告
题目链接:https://leetcode.com/problems/product-of-array-except-self/ 238. Product of Array Except Se ...
- 238. Product of Array Except Self(对O(n)和递归又有了新的理解)
238. Product of Array Except Self Total Accepted: 41565 Total Submissions: 97898 Difficulty: Med ...
- 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 ...
- 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 用双指针向中间滑动,较小的高度就作为当前情 ...
- 【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 ...
- leetcode:238. Product of Array Except Self(Java)解答
转载请注明出处:z_zhaojun的博客 原文地址 题目地址 Product of Array Except Self Given an array of n integers where n > ...
- 【刷题-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 ...
随机推荐
- 如何知道网页浏览器cookie是什么?
一直有网友问网页cookie如何获取,其实想知道自己访问网页时的cookie没那么难,用Chrome内核浏览器的debug功能就能看到,怎么查看呢?随ytkah一起来看看吧! 打开网页,按F12键,选 ...
- GreenDao开源ORM框架浅析
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u011133213/article/details/37738943 Android程序开发中,避免 ...
- Java-idea-安装配置优化等
1.属性配置 使用版本,winzip解压版,开发工具安装目录下idea.properties文件,自定义配置路径 # idea.config.path=${user.home}/.IntelliJId ...
- abap 断言
1: Assert equal http://www.saptechnical.com/Tutorials/OOPS/ABAPUnit/Index.htm
- ionic3 在ios9.0 系统下 会出现ReferenceError:Can't find variable:Intl 错误提示
ionic3 框架开发app 在ios 9.0版本中 ReferenceError:Can't find variable:Intl 错误提示: 在index.html 文件中添加 <scri ...
- webpack 常用命令
1 初始化package.json npm init -y 2 全局安装webpack npm install webpack -g 3 安装webpack依赖 npm install webpack ...
- linux之tree命令
linux下tree命令的用法解释 2018年03月22日 ⁄ RakSmart教程 ⁄ 共 583字 ⁄ 字号 小 中 大 ⁄ linux下tree命令的用法解释已关闭评论 tree命令,主要功能是 ...
- Python之包管理
1.setup.py from distutils.core import setup setup(name='Distutils', version='1.0', description='Pyth ...
- C#对象序列化成XML,以及自定义标签名
C#对象序列化操作: public class XMLHelper { /// <summary> /// 对象序列化成 XML String /// </summary> p ...
- 改变FileUpload文件上传控件的显示方式,确认后上传
一.Aspx页面: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="File ...