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. Android 开发工具类 28_sendGETRequest

    以 GET 方式上传数据,小于 2K,且安全性要求不高的情况下. package com.wangjialin.internet.userInformation.service; import jav ...

  2. 使用subgit进行svn迁移至git(branch,tags)

    前言: 最近公司需要将整体项目从svn迁移至gitlab上,经过几天的研究,现记录一下流程 整体思路是进行一次导入: 先通过subgit将svn整个import至本地,在与git上的项目进行合并. 1 ...

  3. java 使用 pdf.js 在线查看 pdf 文档

    1. 下载对应的 pdf.js 文件: 推荐地址:             https://github.com/mozilla/pdf.js/            http://mozilla.g ...

  4. VF

    VF 描述 Vasya is the beginning mathematician. He decided to make an important contribution to the scie ...

  5. Ionic3 UI组件之 ImageLoader

    ImageLoader:通过后台线程加载图片(异步)并缓存.类似于Glide或者Picasso. 组件特性: 后台线程下载图片,下载速度更快,不使用webview的资源: 缓存图像.图像将在您下次显示 ...

  6. portable-net45+win8

    <PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> <RuntimeFramew ...

  7. Mac下显示和隐藏隐藏文件的命令

    打开终端,输入: 1.defaults write com.apple.finder AppleShowAllFiles -bool true 此命令显示隐藏文件defaults write com. ...

  8. 关于HSQLDB访问已有数据库文件的操作说明

    关于HSQLDB数据库的创建,本文不做过多描述,可以在百度上搜索一下,有许多. 对于访问已存在的库文件,网上找了半天,没有整理的很清楚的参考资料,现将自己的操作过程整理如下,以供参考. 1.先下载一个 ...

  9. ManualResetEvent

    ManualResetEvent是C#中一个比较常用的工具,可用于线程间通信,实现一种类似信号量的功能(不知道我这样描述是否恰当,有可能不是“类似”,而“就是”通过信号量来实现的,因为我也是最近才知道 ...

  10. 统计SQL Server所有表记录数

    SELECT SCHEMA_NAME(t.schema_id) AS [schema] ,t.name AS tableName ,i.rows AS [rowCount] FROM sys.tabl ...