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的更多相关文章

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

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

  2. 【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 ...

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

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

  4. 【刷题-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 ...

  5. 【LeetCode】238. Product of Array Except Self 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 两次遍历 日期 题目地址:https://leetcode.c ...

  6. 【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 ...

  7. 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 ...

  8. leetcode 题解:Merge Sorted Array(两个已排序数组归并)

    题目: Given two sorted integer arrays A and B, merge B into A as one sorted array. Note:You may assume ...

  9. LeetCode题解之 Convert Sorted Array to Binary Search Tree

    1.题目描述 2.问题分析 使用二分法即可. 3.代码 TreeNode* sortedArrayToBST(vector<int>& nums) { ) return NULL; ...

随机推荐

  1. centos7上安装redis

    关闭防火墙:systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启 ...

  2. Failed to instantiate CLSID_VirtualBox w/ IVirtualBox, but CLSID_VirtualBox w/ IUnknown works.

    我是 win7 64位 解决办法: 1, win+r 快捷键打开 “运行”,输入regedit 打开注册表 2,找到 HKEY_CLASSES_ROOT\CLSID\{00020420-0000-00 ...

  3. android即时通信开源项目信息

    源码提供!Android即时通讯和sns开源项目汇总 http://www.jianshu.com/p/b2ca52337fe5

  4. mysql数据库数据监测

    #!/bin/bash MYSQL="mysql -h10.10.10.10 -P8036 -uusername -ppassword --default-character-set=utf ...

  5. 终极 shell zsh

    在mac上安装zsh,推荐安装. 参见http://macshuo.com/?p=676. 安装成功提示,看着很帅的样子

  6. 发布Framework 4.0到iis时,出现HTTP 错误 403.14 - Forbidden

    新发布MVC到服务器的时候,经常碰到403.14错误,绝大部分的时候都是因为Framework 4.0需要重新注册下,在运行里输入:C:\Windows\Microsoft.NET\Framework ...

  7. 原生JavaScript 导出excel表格(兼容ie和其他主流浏览器)

    因同事的需求是想前端导出excel表格,网上找了一些demo,自己修改了一下,可能以后会用到,记录下来吧,兼容ie和一些主流浏览器,ie可能会报错,原因参考 这里,edge 浏览器还没有办法导出,正在 ...

  8. (技术分享) 解决 Firefox 显示“已阻止载入混合活动内容”的问题

    (摘自http://blog.aizhet.com/Windows/18415.html) 从 Firefox 18 开始,如果 HTTPS 页面中包含非加密的 HTTP 内容,浏览器会在控制台输出警 ...

  9. 牛客网剑指offer java 全部题解

    经过数月的努力,终于更完了牛客网的66道剑指offer,以下的顺序和大家在牛客网的顺序是一样的(排序也花了不少时间),希望对大家找工作/提高算法能力能起到些许帮助. 每天一道剑指offer-二维数组中 ...

  10. Shell脚本编写3---Shell 传递参数

    我们可以在执行 Shell 脚本时,向脚本传递参数,脚本内获取参数的格式为:$n.n 代表一个数字,1 为执行脚本的第一个参数,2 为执行脚本的第二个参数,以此类推…… 执行脚本,查看输出结果: 另外 ...