当前位置:网站首页>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 (19), precise ephemeris (SP3 format)
- Kohana 数据库
- Sql: stored procedures and triggers - Notes
- Sparkshuffle process and Mr shuffle process
- 用aardio写一个旋转验证码标注小工具
- zabbix 代理服务器 与 zabbix-snmp 监控
- UNI-Admin基础框架怎么关闭创建超级管理员入口?
- Kohana database
- HDU 4912 paths on the tree (lca+)
- GPS从入门到放弃(二十)、天线偏移
猜你喜欢

数字化转型挂帅复产复工,线上线下全融合重建商业逻辑

ViT论文详解

2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks

GPS从入门到放弃(十九)、精密星历(sp3格式)

make menuconfig出现recipe for target ‘menuconfig‘ failed错误

50 commonly used numpy function explanations, parameters and usage examples

JPEG2000-Matlab源码实现

Shell product written examination related

AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing

GPS从入门到放弃(十三)、接收机自主完好性监测(RAIM)
随机推荐
uni-app App端半屏连续扫码
What is the difference between animators and animators- What is the difference between an Animator and an Animation?
GPS from getting started to giving up (XV), DCB differential code deviation
hdu 4912 Paths on the tree(lca+馋)
强化学习-学习笔记5 | AlphaGo
Earned value management EVM detailed explanation and application, example explanation
What is the RDD operator in spark
Why rdd/dataset is needed in spark
设置状态栏样式Demo
HDU 2008 digital statistics
GPS from getting started to giving up (XVIII), multipath effect
1D convolution detail
string的底层实现
【sciter】: 基于 sciter 封装通知栏组件
GPS from getting started to giving up (XX), antenna offset
GPS从入门到放弃(十六)、卫星时钟误差和卫星星历误差
Sparkshuffle process and Mr shuffle process
PostgreSQL modifies the password of the database user
GPS从入门到放弃(十四)、电离层延时
Uni app app half screen continuous code scanning