当前位置:网站首页>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
};
边栏推荐
- 嵌入式常用计算神器EXCEL,欢迎各位推荐技巧,以保持文档持续更新,为其他人提供便利
- Michael smashed the minority milk sign
- The relationship between root and coefficient of quadratic equation with one variable
- What is the difference between animators and animators- What is the difference between an Animator and an Animation?
- 基于InsightFace的高精度人脸识别,可直接对标虹软
- How does the uni admin basic framework close the creation of super administrator entries?
- HDU 4912 paths on the tree (lca+)
- GPS from getting started to giving up (19), precise ephemeris (SP3 format)
- MariaDB database management system learning (I) installation diagram
- Guava: use of multiset
猜你喜欢
![[Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference](/img/61/976c7d86ab3b2df5f5af3beefbf547.png)
[Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference

What can one line of code do?
![[Chongqing Guangdong education] Information Literacy of Sichuan Normal University: a new engine for efficiency improvement and lifelong learning reference materials](/img/a5/94bdea3a871db5305ef54e3b304beb.jpg)
[Chongqing Guangdong education] Information Literacy of Sichuan Normal University: a new engine for efficiency improvement and lifelong learning reference materials

Embedded common computing artifact excel, welcome to recommend skills to keep the document constantly updated and provide convenience for others

MPLS experiment

搜素专题(DFS )

【10点公开课】:视频质量评价基础与实践

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

1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros

GPS从入门到放弃(十四)、电离层延时
随机推荐
What a new company needs to practice and pay attention to
GPS from entry to abandonment (XVII), tropospheric delay
功能强大的国产Api管理工具
Yyds dry goods inventory C language recursive implementation of Hanoi Tower
GPS从入门到放弃(十六)、卫星时钟误差和卫星星历误差
Reptile practice (V): climbing watercress top250
hdu 4912 Paths on the tree(lca+馋)
嵌入式常用计算神器EXCEL,欢迎各位推荐技巧,以保持文档持续更新,为其他人提供便利
美国科技行业结束黄金时代,芯片求售、裁员3万等哀声不断
Kohana 数据库
guava:Collections. The collection created by unmodifiablexxx is not immutable
1292_FreeROS中vTaskResume()以及xTaskResumeFromISR()的实现分析
GPS从入门到放弃(二十)、天线偏移
[Digital IC manual tearing code] Verilog automatic beverage machine | topic | principle | design | simulation
GNN, please deepen your network layer~
[Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference
MongoDB(三)——CRUD
Efficiency tool +wps check box shows the solution to the sun problem
C language char, wchar_ t, char16_ t, char32_ Relationship between T and character set
语谱图怎么看