当前位置:网站首页>Maximum product of three numbers in question 628 of Li Kou
Maximum product of three numbers in question 628 of Li Kou
2022-07-06 22:04:00 【Big chicken legs are best】
628. The maximum product of three numbers
The difficulty is simple 353 Switch to English to receive dynamic feedback
Here's an integer array nums
, Find the largest product of three numbers in the array , And output this product .
Example 1:
Input :nums = [1,2,3] Output :6
Example 2:
Input :nums = [1,2,3,4] Output :24
Example 3:
Input :nums = [-1,-2,-3] Output :-6
/**
* @param {number[]} nums
* @return {number}
*/
var maximumProduct = function(nums) {
nums=nums.sort((a,b)=> {return a-b})
let len=nums.length-1
let l=nums[0]*nums[1]*nums[len]
let p=nums[len-2]*nums[len-1]*nums[len]
let c=Math.max(l,p)
return c
};
边栏推荐
- The golden age of the U.S. technology industry has ended, and there have been constant lamentations about chip sales and 30000 layoffs
- Codeforces Round #274 (Div. 2) –A Expression
- [Digital IC manual tearing code] Verilog automatic beverage machine | topic | principle | design | simulation
- GPS从入门到放弃(十三)、接收机自主完好性监测(RAIM)
- C language char, wchar_ t, char16_ t, char32_ Relationship between T and character set
- C# 如何在dataGridView里设置两个列comboboxcolumn绑定级联事件的一个二级联动效果
- 50 commonly used numpy function explanations, parameters and usage examples
- GPS从入门到放弃(十五)、DCB差分码偏差
- make menuconfig出现recipe for target ‘menuconfig‘ failed错误
- The role of applicationmaster in spark on Yan's cluster mode
猜你喜欢
2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
Wechat red envelope cover applet source code - background independent version - source code with evaluation points function
Numpy download and installation
Adjustable DC power supply based on LM317
C# 如何在dataGridView里设置两个列comboboxcolumn绑定级联事件的一个二级联动效果
GPS from entry to abandonment (XVII), tropospheric delay
Leetcode topic [array] -118 Yang Hui triangle
Powerful domestic API management tool
[Chongqing Guangdong education] Information Literacy of Sichuan Normal University: a new engine for efficiency improvement and lifelong learning reference materials
Shake Sound poussera l'application indépendante de plantation d'herbe "louable", les octets ne peuvent pas oublier le petit livre rouge?
随机推荐
Some problems about the use of char[] array assignment through scanf..
Is it important to build the SEO foundation of the new website
经纪xx系统节点VIP案例介绍和深入分析异常
Michael smashed the minority milk sign
Vit paper details
50 commonly used numpy function explanations, parameters and usage examples
基于LM317的可调直流电源
C how to set two columns comboboxcolumn in DataGridView to bind a secondary linkage effect of cascading events
Univariate cubic equation - relationship between root and coefficient
GPS du début à l'abandon (XIII), surveillance autonome de l'intégrité du récepteur (raim)
GPS从入门到放弃(十九)、精密星历(sp3格式)
LeetCode学习记录(从新手村出发之杀不出新手村)----1
Xiaoman network model & http1-http2 & browser cache
GPS从入门到放弃(十六)、卫星时钟误差和卫星星历误差
在Pi和Jetson nano上运行深度网络,程序被Killed
LeetCode:1189. The maximum number of "balloons" -- simple
hdu 4912 Paths on the tree(lca+馋)
Unity3D学习笔记6——GPU实例化(1)
Problems in the process of opencv300 cmake generating project
数字化转型挂帅复产复工,线上线下全融合重建商业逻辑