代码面试集锦 1 - Uber

本文探讨了如何在不使用除法的情况下,给定一个整数数组,返回一个新数组,其中每个元素是原始数组中除当前位置外所有元素的乘积。例如,输入[1,2,3,4,5],输出应为[120,60,40,30,24]。文章提供了理解和解决这一复杂问题的方法。

Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.

For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].

Follow-up: what if you can't use division?

转载于:https://www.cnblogs.com/Wonner/p/10360787.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值