Lintcode50 Product of Array Exclude Itself solution 题解
来源:互联网 发布:mac 搜狗五笔偏好设置 编辑:程序博客网 时间:2024/06/06 16:57
【题目描述】
Given an integers array A.Define B[i] = A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1], calculate B WITHOUT divide operation.
给定一个整数数组A。定义B[i] = A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1], 计算B的时候请不要使用除法。
【题目链接】
http://www.lintcode.com/en/problem/product-of-array-exclude-itself/
【题目解析】
有点动态规划的思想。
首先从后往前遍历数组,用f[i]保存i到end所有元素的乘积。
然后从前往后遍历数组,对于当前位i,其值的计算公式为start~i-1的元素的乘积 * f[i]。start~i-1的乘积在i-1位置时已经可以得到。
【参考答案】
http://www.jiuzhang.com/solutions/product-of-array-exclude-itself/
0 0
- Lintcode50 Product of Array Exclude Itself solution 题解
- Product of Array Exclude Itself
- Product of Array Exclude Itself
- Product of Array Exclude Itself
- Lintcode - Product of Array Exclude Itself
- lintcode:Product of Array Exclude Itself
- [Lintcode]Product of Array Exclude Itself
- #50 Product of Array Exclude Itself
- 【LintCode】Product of Array Exclude Itself 数组剔除元素后的乘积
- 50.Product of Array Exclude Itself-数组剔除元素后的乘积(容易题)
- 238.[LeetCode]Product of Array Except itself
- 238.[LeetCode]Product of Array Except itself
- LeetCode题解:Product of Array Except Self
- Product of Array Except Self 题解
- LeetCode238 Product of Array Except Self(java and python solution)
- LeetCode 题解(146): Product of Array Except Self
- Leetcode题解 238. Product of Array Except Self
- LeetCode 238. Product of Array Except Self 题解(C++)
- Android触摸事件分发机制完全解析《一》
- 腾讯云搭建git服务器--和踩过的坑
- 12 qt的反射机制应用
- Mariadb数据库配置及管理
- C语言中局部变量与全局变量在内存中的存放位置
- Lintcode50 Product of Array Exclude Itself solution 题解
- 安卓中的Flux架构
- 手指上的代码,手心里的作品
- 【C++学习笔记】如何输入含有未知变量的数组?
- SpringMVC 拦截器
- 【阿里云服务器】外网无法访问tomcat下部署的项目
- 4-数据类型及相关的操作
- Java配置文档
- C# 获取本机CPU序列号,MAC地址,硬盘ID,本机IP地址,计算机名,物理内存,PC类型