leetCode题解之Product of Array Except Self
1、题目描述

2、题目分析
每个元素对应的积应该是 它 前面的每个元素的积,和后面的每个元素的积
3、代码
vector<int> productExceptSelf(vector<int>& nums) {
vector<int> res( nums.size() );
long p = ;
for( int i = ; i< nums.size() ; i++)
{
res[i] = p;
p *= nums[i];
}
p = ;
for( int i = nums.size() - ; i >= ; i--)
{
res[i] *= p;
p *= nums[i];
}
return res;
}
leetCode题解之Product of Array Except Self的更多相关文章
- LeetCode OJ 238. Product of Array Except Self 解题报告
题目链接:https://leetcode.com/problems/product-of-array-except-self/ 238. Product of Array Except Se ...
- 【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 ...
- 【LeetCode】238. Product of Array Except Self 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 两次遍历 日期 题目地址:https://leetcode.c ...
- 【LeetCode 238】Product of Array Except Self
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equ ...
- LeetCode OJ:Product of Array Except Self(除己之外的元素乘积)
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equ ...
- leetcode 题解:Merge Sorted Array(两个已排序数组归并)
题目: Given two sorted integer arrays A and B, merge B into A as one sorted array. Note:You may assume ...
- LeetCode题解之 Convert Sorted Array to Binary Search Tree
1.题目描述 2.问题分析 使用二分法即可. 3.代码 TreeNode* sortedArrayToBST(vector<int>& nums) { ) return NULL; ...
随机推荐
- 《构建之法》阅读笔记06-项目经理PM
软件团队里除了能写代码.测试代码和画图做设计的成员,还有一类角色,不做上面这些事情但也很重要,我们叫他们项目经理--PM. PM 的M 就是 Manager: P有这几种: Product Manag ...
- PCI配置空间简介
一.PCI配置空间简介 PCI有三个相互独立的物理地址空间:设备存储器地址空间.I/O地址空间和配置空间.配置空间是PCI所特有的一个物理空间.由于PCI支持设备即插即用,所以PCI设备不占用固定的内 ...
- docker容器网络通信原理分析(转)
概述 自从docker容器出现以来,容器的网络通信就一直是大家关注的焦点,也是生产环境的迫切需求.而容器的网络通信又可以分为两大方面:单主机容器上的相互通信和跨主机的容器相互通信.而本文将分别针对这两 ...
- vue-resource使用笔记
基本语法 //基于全局Vue对象使用http Vue.http.get('/someUrl', [options]).then(successCallback, errorCallback); Vue ...
- windows server 2012 如何开启 hyper-v 并创建虚拟机
当我们拿到一台新的windows server 2012 服务器的时候,默认hyper-v是没有开启的,如果我们要在windows server上面创建虚拟机,那么我们也就需要开启hyper-v. 开 ...
- spring整合elasticsearch之环境搭建
推荐一个非常好的博客: 点我 // 测试使用docker下启动的es不管用, 在linux下或者windows下运行的es可用 // 进一步测试docker下启动的es链接时, 开启嗅探也链接不上, ...
- mysql创建用户,并指定用户的权限(grant命令)
参考链接http://blog.csdn.net/leili0806/article/details/8573636,谢谢这位仁兄 1.创建新用户的SQL语句: CREATE USER 'pig'@' ...
- 关于EJB,为什么用EJB?为什么不用EJB?
http://blog.csdn.net/linxi1209163com/article/details/51029890 一:什么是EJB 官方说法,就是企业级是基于语言的服务器框架技术,通过我们可 ...
- Shell如何解决文件流管道的文本拼接失效问题
前言: 近期由于业务的需要,需实现通过监控日志文件的内容并定时将日志的有效内容通过邮件进行告警. 文本内容的格式如下: 1 aaa 2 bbb 4 ccc 7 ddd 希望输出: bbb ccc 版本 ...
- 设计模式学习--装饰者模式(Decorator Pattern)
概念: 装饰者模式(Decorator Pattern): 动态地将功能添加到对象,相比生成子类更灵活,更富有弹性. 解决方案: 装饰者模式的重点是对象的类型,装饰者对象必须有着相同的接口,也也就是有 ...