|
1 | | -## 题目地址 |
| 1 | +## 题目地址(238. 除自身以外数组的乘积) |
2 | 2 |
|
3 | 3 | https://leetcode.com/problems/product-of-array-except-self/description/ |
4 | 4 |
|
5 | 5 | ## 题目描述 |
6 | 6 |
|
7 | 7 | ``` |
8 | | -Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. |
| 8 | +给你一个长度为 n 的整数数组 nums,其中 n > 1,返回输出数组 output ,其中 output[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积。 |
9 | 9 |
|
10 | | -Example: |
| 10 | + |
11 | 11 |
|
12 | | -Input: [1,2,3,4] |
13 | | -Output: [24,12,8,6] |
14 | | -Note: Please solve it without division and in O(n). |
| 12 | +示例: |
15 | 13 |
|
16 | | -Follow up: |
17 | | -Could you solve it with constant space complexity? (The output array does not count as extra space for the purpose of space complexity analysis.) |
| 14 | +输入: [1,2,3,4] |
| 15 | +输出: [24,12,8,6] |
| 16 | + |
| 17 | +
|
| 18 | +提示:题目数据保证数组之中任意元素的全部前缀元素和后缀(甚至是整个数组)的乘积都在 32 位整数范围内。 |
| 19 | +
|
| 20 | +说明: 请不要使用除法,且在 O(n) 时间复杂度内完成此题。 |
| 21 | +
|
| 22 | +进阶: |
| 23 | +你可以在常数空间复杂度内完成这个题目吗?( 出于对空间复杂度分析的目的,输出数组不被视为额外空间。) |
18 | 24 |
|
19 | 25 |
|
20 | 26 | ``` |
@@ -42,38 +48,6 @@ Could you solve it with constant space complexity? (The output array does not co |
42 | 48 | ## 代码 |
43 | 49 |
|
44 | 50 | ```js |
45 | | - |
46 | | -/* |
47 | | - * @lc app=leetcode id=238 lang=javascript |
48 | | - * |
49 | | - * [238] Product of Array Except Self |
50 | | - * |
51 | | - * https://leetcode.com/problems/product-of-array-except-self/description/ |
52 | | - * |
53 | | - * algorithms |
54 | | - * Medium (53.97%) |
55 | | - * Total Accepted: 246.5K |
56 | | - * Total Submissions: 451.4K |
57 | | - * Testcase Example: '[1,2,3,4]' |
58 | | - * |
59 | | - * Given an array nums of n integers where n > 1, return an array output such |
60 | | - * that output[i] is equal to the product of all the elements of nums except |
61 | | - * nums[i]. |
62 | | - * |
63 | | - * Example: |
64 | | - * |
65 | | - * |
66 | | - * Input: [1,2,3,4] |
67 | | - * Output: [24,12,8,6] |
68 | | - * |
69 | | - * |
70 | | - * Note: Please solve it without division and in O(n). |
71 | | - * |
72 | | - * Follow up: |
73 | | - * Could you solve it with constant space complexity? (The output array does |
74 | | - * not count as extra space for the purpose of space complexity analysis.) |
75 | | - * |
76 | | - */ |
77 | 51 | /** |
78 | 52 | * @param {number[]} nums |
79 | 53 | * @return {number[]} |
|
0 commit comments