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 ...
随机推荐
- Linux 安装python3.7.0
我这里使用的时centos7-mini,centos系统本身默认安装有python2.x,版本x根据不同版本系统有所不同,可通过 python --V 或 python --version 查看系统自 ...
- ignore_user_abort(true); set_time_limit(0);程序在本地测试可以一直运行,上传服务器只能运行10-15分钟
当PHP运行在安全模式下时此函数无效.除了关闭安全模式或者在php.ini程序中修改最大运行时间没有其他办法让此函数运行. php.ini 中缺省的最长执行时间是 30 秒,这是由 php.ini 中 ...
- react 中的return 什么时候用小括号,什么时候用大括号啊
return( <div>....</div> ) return( <Component/> ) return{...} 1:html 2:react 组件 3:j ...
- Eclipse安装fatjar(不用自己下载fatjar包)
.安装Eclipse-jee-luna-SR2-win32-x86_64版本的插件支持 方法如下: Help -> Install New Software... -> Work with ...
- windows程序设计 获取系统文件路径
获取系统文件路径,打印到txt文件中. #include <windows.h> int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hP ...
- Unable to construct api.Node object for kubelet: can't get ip address of node master.example.com: lookup master.example.com on : no such host
openshift首页进不去 启动openshift时报的错,大意是: 无法为kubelet构造api.Node对象:无法获取节点master.example.com的IP地址: 所以就联想到新装的c ...
- Java内存模型学习笔记
Java内存模型(JMM):描述了java程序中各种变量(线程共享变量)的范根规则,以及在JVM中将变量存储到内存和从内存中读取出变量这样的底层细节.共享变量就是指一个线程中的变量在其他线程中也是可见 ...
- proc:基本数据库操作
导师布置了一作业: 主要目的是学习数据库最基本的操作:创建用户.创建库表,和用程序访问数据库的相关技能(编码.编译等) 1,交易流水表(包含但不限于以下字段):交易日期.交易流水(用sequence实 ...
- CentOS 6.5优化开机启动服务
使用chkconfig命令列举出所有服务,配合管道筛选出开机默认启动的服务,再去掉level0(关机).level4(无意义)和level6(重启)的显示,使结果更直观. chkconfig | gr ...
- python__面向对象,继承,命名空间
http://www.cnblogs.com/Eva-J/articles/7293890.html 阅读目录 楔子 面向过程vs面向对象 初识面向对象 类的相关知识 对象的相关知识 对象之间的交互 ...