mycode   99.47%

class Solution(object):
def productExceptSelf(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
temp =
res = list()
res.append()
#nums的第一个数和最后一个数是最特殊的,因为别人都是左右可以包围的,即product=该数前面所有数的乘积*该数后面所有数的乘积
#所以res[]放1,代表nums[]前面的数(其实没有)的product
for i in range(len(nums)-):
#当i为len(nums)-2时,计算出来的乘积就是nums最后一个元素的product结果
temp *= nums[i]
res.append(temp) #res[]放的时nums[]前面的数的product
#i==len(nums)-2时,res[len(nums)-]放的就是nums[-]前面的数的product,而nums[-]后面是没有数的,所有逆向遍历的时候只需要从nums[len(nums)-]开始计算它后面的乘积
temp =
for i in range(len(nums)-,-,-):
temp *= nums[i+]
res[i] = res[i]*temp
return res

leetcode-hard-array-238. Product of Array Except Self-NO的更多相关文章

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

  3. 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 用双指针向中间滑动,较小的高度就作为当前情 ...

  4. 238. Product of Array Except Self(对O(n)和递归又有了新的理解)

    238. Product of Array Except Self     Total Accepted: 41565 Total Submissions: 97898 Difficulty: Med ...

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

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

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

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

  8. [LeetCode] 238. Product of Array Except Self 除本身之外的数组之积

    Given an array nums of n integers where n > 1,  return an array output such that output[i] is equ ...

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

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

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

随机推荐

  1. Oracle层次查询start with connect by

    博客参考:https://www.cnblogs.com/jerryxing/articles/2339352.html start with connect by 层次查询(Hierarchical ...

  2. 开源you-get项目爬虫,以及基于python+selenium的自动测试利器

    写在前面 爬虫和自动测试,对于python来说是最合适不过也是最擅长的. 开源的项目也很多,例如you-get项目https://github.com/soimort/you-get.盗链和爬虫神器. ...

  3. BLE 5协议栈-通用访问规范层(GAP)

    文章转载自:http://www.sunyouqun.com/2017/04/ 通用访问规范GAP(Generic Access Profile)是BLE设备内部功能对外的接口层,它规定了三个方面:G ...

  4. Linux基础命令02

    常用的一些命令选项 向网络发送icmp检测主机是否在线 ping 指定发送包数量 ping -c windows系统中是ping -t不间断刷包 比如ping百度,ping不同,一直卡在这里,加了-w ...

  5. H265码流格式

    一.H265码流格式 VPS:视频参数集,用于传输视频分级信息,有利于兼容标准在可分级视频编码或多视点视频的扩展. NALU header定义: NALU header(){ Descriptor f ...

  6. 将本地代码使用Git上传更新至Github

    注册.配置git 1. 首先注册git image 2.然后下载.配置git 百度“git下载”,然后默认安装,注意的是最后要添加环境变量,最后安装结果如下: image 配置如下: 1.设置本地的s ...

  7. anaconda应答文件

    一.anaconda和isolinux anaconda是linux安装程序的安装想到,在我们的系统安装光盘内有一个isolinux的目录,这个目录是用来启动光盘镜像的,下面我们说一下这个目录下的文件 ...

  8. idea操作mysql数据库添加汉字时出现乱码解决方案

    首先 然后 最后 在连接数据库后面加一个指定编码格式 编码格式: characterEncoding=UTF-8

  9. C# 数据类型转化为byte数组

    short数据与byte数组互转 public byte[] ShortToByte(short value) { return BitConverter.GetBytes(value); } pub ...

  10. python中的list,tuple,dict,set简介---陈雨童

    变量和对象 变量把对象和自己连接起来(指针连接对象空间),引用建立了变量和对象之间的映射关系,这就是引用.引用完成,就实现了赋值.变量通过对象的内存地址指向对象,类似于软链接 将变量a赋值给变量b,其 ...