当前位置:网站首页>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
};
边栏推荐
- GPS from getting started to giving up (XIII), receiver autonomous integrity monitoring (RAIM)
- OpenCV300 CMake生成project在项目过程中的问题
- GPS从入门到放弃(十七) 、对流层延时
- GPS從入門到放弃(十三)、接收機自主完好性監測(RAIM)
- Tiktok will push the independent grass planting app "praiseworthy". Can't bytes forget the little red book?
- C# 如何在dataGridView里设置两个列comboboxcolumn绑定级联事件的一个二级联动效果
- Earned value management EVM detailed explanation and application, example explanation
- JS method to stop foreach
- npm run dev启动项目报错 document is not defined
- 爬虫实战(五):爬豆瓣top250
猜你喜欢
About the professional ethics of programmers, let's talk about it from the way of craftsmanship and neatness
Broadcast variables and accumulators in spark
GPS从入门到放弃(十七) 、对流层延时
C# 如何在dataGridView里设置两个列comboboxcolumn绑定级联事件的一个二级联动效果
Happy sound 2[sing.2]
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
make menuconfig出现recipe for target ‘menuconfig‘ failed错误
numpy 下载安装
Aggregate function with key in spark
Some problems about the use of char[] array assignment through scanf..
随机推荐
Unity3d Learning Notes 6 - GPU instantiation (1)
Uni app app half screen continuous code scanning
Write a rotation verification code annotation gadget with aardio
爬虫实战(五):爬豆瓣top250
npm run dev启动项目报错 document is not defined
GPS from getting started to giving up (XV), DCB differential code deviation
guava:Collections. The collection created by unmodifiablexxx is not immutable
Leetcode learning records (starting from the novice village, you can't kill out of the novice Village) ---1
搜素专题(DFS )
Univariate cubic equation - relationship between root and coefficient
[Yu Yue education] reference materials for surgical skills teaching in Tongji University
MPLS experiment
MySQL removes duplicates according to two fields
Solution to the problem of UOS boot prompt unlocking login password ring
GPS從入門到放弃(十三)、接收機自主完好性監測(RAIM)
Why rdd/dataset is needed in spark
【sciter】: 基于 sciter 封装通知栏组件
PostgreSQL 安装gis插件 CREATE EXTENSION postgis_topology
Checkpoint of RDD in spark
设置状态栏样式Demo