网址:https://leetcode.com/problems/product-of-array-except-self/

参考:https://leetcode.com/problems/product-of-array-except-self/discuss/65622/Simple-Java-solution-in-O(n)-without-extra-space

class Solution {
public:
vector<int> productExceptSelf(vector<int>& nums) {
vector<int> res(nums.size(),);
int right = ; for(int i=;i<nums.size();i++)
{
res[i] = res[i-] * nums[i-];
} for(int i=nums.size()-;i>=;i--)
{
res[i] *= right;
right *= nums[i];
}
return res;
}
};

238. Product of Array Except Self除自身以外数组的乘积的更多相关文章

  1. 238 Product of Array Except Self 除自身以外数组的乘积

    一个长度为 n 的整形数组nums,其中 n > 1,返回一个数组 output ,其中 output[i] 等于nums中除nums[i]以外所有元素的乘积.不用除法 且在O(n)内解决这个问 ...

  2. Leetcode238. Product of Array Except Self除自身以外数组的乘积

    给定长度为 n 的整数数组 nums,其中 n > 1,返回输出数组 output ,其中 output[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积. 示例: 输入: [1 ...

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

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

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

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

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

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

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

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

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

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

随机推荐

  1. WebService简单搭建和调用

    http://www.cnblogs.com/JiYF/p/6164859.html https://www.cnblogs.com/JiYF/p/6169349.html #region Invok ...

  2. git常用命令--tag

    /// 查看标签 // 打印所有标签 git tag // 打印符合检索条件的标签 git tag -l 1.*.* // 查看对应标签状态 git checkout 1.0.0 /// 创建标签(本 ...

  3. 【Linux】-NO.87.Assembly.1.滴水逆向.1.001-【介绍】-

    1.0.0 Summary Tittle:[Linux]-NO.87.Assembly.1.滴水逆向.1.001-[基础]- Style:Java Series:Log4j Since:2017-04 ...

  4. PHP环境安全加固

    随着使用 PHP 环境的用户越来越多,相关的安全问题也变得越来越重要.PHP 环境提供的安全模式是一个非常重要的内嵌安全机制,PHP 安全模式能有效控制一些 PHP 环境中的函数(例如system() ...

  5. Kaggle初学者五步入门指南,七大诀窍助你享受竞赛

    Kaggle 是一个流行的数据科学竞赛平台,已被谷歌收购,参阅<业界 | 谷歌云官方正式宣布收购数据科学社区 Kaggle>.作为一个竞赛平台,Kaggle 对于初学者来说可能有些难度.毕 ...

  6. linux----------linux的scp命令介绍

    1.scp是有Security的文件copy,基于ssh登录. 命令基本格式: scp [OPTIONS] file_source file_target OPTIONS: -v 和大多数 linux ...

  7. RedHat7.之.图形化切换

    RedHat7.之.图形化切换 从黑窗口(纯指令输入界面)切换到图形化界面,使用root用户执行指令:startx 指令:startx 如有问题,欢迎纠正!!! 如有转载,请标明源处:https:// ...

  8. 网页头部meta标签

    <meta http-equiv="content-Type" content="text/html;charset=UTF-8">    //设置 ...

  9. Kubernetes-Host网络模式应用

    目录贴:Kubernetes学习系列 在实际生产环境中,有些容器内应用(比如编码器)需要用到物理层面的网络资源(比如组播流).这就要求Kubernetes中的该Pod以HOST模式来启动.以下实验了K ...

  10. jQuery 查找元素2

    jQuery 查找元素2 :first <ul> <li>list item 1</li> <li>list item 2</li> < ...