当前位置:网站首页>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
};
边栏推荐
- Guava: three ways to create immutablexxx objects
- AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
- GPS from getting started to giving up (XX), antenna offset
- What about the spectrogram
- 强化学习-学习笔记5 | AlphaGo
- [Chongqing Guangdong education] Information Literacy of Sichuan Normal University: a new engine for efficiency improvement and lifelong learning reference materials
- zabbix 代理服务器 与 zabbix-snmp 监控
- GPS从入门到放弃(十二)、 多普勒定速
- Huawei has launched attacks in many industries at the same time, and its frightening technology has made European and American enterprises tremble
- Checkpoint of RDD in spark
猜你喜欢
GPS從入門到放弃(十三)、接收機自主完好性監測(RAIM)
numpy 下载安装
PostgreSQL 修改数据库用户的密码
【10点公开课】:视频质量评价基础与实践
PostgreSQL 安装gis插件 CREATE EXTENSION postgis_topology
Some problems about the use of char[] array assignment through scanf..
Microsoft technology empowerment position - February course Preview
GPS从入门到放弃(十五)、DCB差分码偏差
50 commonly used numpy function explanations, parameters and usage examples
数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
随机推荐
GPS from getting started to giving up (XVIII), multipath effect
About the professional ethics of programmers, let's talk about it from the way of craftsmanship and neatness
基于LM317的可调直流电源
Run the deep network on PI and Jetson nano, and the program is killed
[MySQL] online DDL details
Method return value considerations
Problems in the process of opencv300 cmake generating project
MySQL removes duplicates according to two fields
GPS from getting started to giving up (16), satellite clock error and satellite ephemeris error
在Pi和Jetson nano上运行深度网络,程序被Killed
Realization of epoll reactor model
LeetCode:1189. The maximum number of "balloons" -- simple
Vit paper details
数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
VIP case introduction and in-depth analysis of brokerage XX system node exceptions
Aggregate function with key in spark
记一次清理挖矿病毒的过程
GPS从入门到放弃(十二)、 多普勒定速
Reptile practice (V): climbing watercress top250
JS method to stop foreach