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. 使用webpack打包js文件(隔行变色案例)

    使用webpack打包js文件(隔行变色案例) 1.webpack安装的两种方式 运行npm i webpack -g全局安装webpack,这样就能在全局使用webpack的命令 在项目根目录中运行 ...

  2. winrar 命令行 解压文件

    1,最简单的压缩命令:winrar a asdf.txt.rar asdf.txt a的意思是进行压缩动作,后面第一个参数是被压缩后的文件名,后缀当然是rar了,最后面 的参数就是要被压缩的文件名 2 ...

  3. 【数组】Jump Game

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

  4. Android_ActionBar

    ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true);//在activity title栏的左 ...

  5. linux安装tmux

    由于tmux依赖于libevent和ncurses-devel,所以应首先有这两个库,和相关的头文件. 1.对于ncurses-devel,可用yum安装. yum install ncurses-d ...

  6. MySQL Optimization 优化原理

    MySQL Optimization 优化原理 MySQL逻辑架构 如果能在头脑中构建一幅MySQL各组件之间如何协同工作的架构图,有助于深入理解MySQL服务器.下图展示了MySQL的逻辑架构图. ...

  7. 反转ListBox的ListBoxItem(控件级别,不是数据的反转)

    在默认的排序下,当将ListBoxItem往下移动时,ListBoxItem是从其他ListBoxItem的底部移动的如下图:   但当往上移动时,情况则不是如此,     所以需要尝试对ListBo ...

  8. C语言求数组的第二大数

    nt second(int value[],int n) { ]; ]; ; ;i < n;i++) { if(value[i] > first) { second = first; fi ...

  9. Java中的数据验证

    原文链接:https://www.cuba-platform.com/blog/2018-10-09/945 翻译:CUBA China CUBA-Platform 官网 : https://www. ...

  10. input属性type为file打开文件资源管理器时,如何限制多次选取或只能一次选取的行为

    1.input标签没有设置multiple属性,文件资源管理器默认一次选取 <!doctype html> <html lang="en"> <hea ...