当前位置:网站首页>1010. song backtracking with total duration divisible by 60
1010. song backtracking with total duration divisible by 60
2022-06-26 07:37:00 【wx60d4764eb475e】
In the song list , The first i The duration of a song is time[i] second .
Return its total duration ( In seconds ) Can be 60 The number of divided song pairs . Formally , We want subscript numbers i and j Satisfy i < j And there are (time[i] + time[j]) % 60 == 0.
Example 1:
Input :time = [30,20,150,100,40]
Output :3
explain : The total duration of these three pairs can be 60 to be divisible by :
(time[0] = 30, time[2] = 150): Total duration 180
(time[1] = 20, time[3] = 100): Total duration 120
(time[1] = 20, time[4] = 40): Total duration 60
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
Example 2:
Input :time = [60,60,60]
Output :3
explain : The total duration of all three pairs is 120, Can be 60 to be divisible by .
- 1.
- 2.
- 3.
Tips :
-
1 <= time.length <= 6 * 104 -
1 <= time[i] <= 500
/**
* @param {number[]} time
* @return {number}
*/
// solution 1 to flash back
// var numPairsDivisibleBy60 = function(time) {
// //2 Permutation
// let count = 0;
// let backTrack = (start, path, time) => {
// if (path.length === 2) {
// if ((path[0] + path[1]) % 60 === 0) {
// count++
// }
// return;
// }
// for(let i = start; i < time.length; i++) {
// path.push(time[i])
// backTrack(i+1, path, time);
// path.pop()
// }
// }
// backTrack(0, [],time)
// return count
// };
var numPairsDivisibleBy60 = function(time) {
let count = 0;
for(let i = 0; i < time.length; i++) {
for(let j = i+1; j<time.length; j++) {
if ((time[i] + time[j]) % 60 === 0) {
count ++
}
}
}
return count
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
边栏推荐
- 个人用指南针软件买股票安全吗?怎么炒股买股票呢
- Introduction to mapping in ES
- Tetradecanoxy tetraphenylporphyrin methacrylate mm-tpp-14c; Cetanoxy tetraphenyl porphyrin methacrylate mm-tpp-16c; Purple solid; Qiyue supply
- Niuniu looks at the cloud (greedy, hash, push formula) - the first session of Niuke winter vacation training camp
- Web technology sharing | webrtc recording video stream
- Crosslinked porphyrin based polyimide ppbpi-2, ppbpi-1-cr and ppbpi-2-cr; Porous porphyrin based hyperbranched polyimide (ppbpi-1, ppbpi-2) supplied by Qiyue
- How to convert Unicode into Chinese characters in Excel
- Summary of domestic database examination data (continuously updated)
- 异地北京办理居住证详细材料
- SQL
猜你喜欢

Porphyrin based polyimide (ppbpis); Synthesis of crosslinked porphyrin based polyimides (ppbpi CRS) porphyrin products supplied by Qiyue biology
![[NLP] vector retrieval model landing: Bottleneck and solution!](/img/c4/784534e5504dfee1c989d19255c31b.jpg)
[NLP] vector retrieval model landing: Bottleneck and solution!

Ppbpi-h-cr, ppbpimn Cr, ppbpi Fe Cr alkynyl crosslinked porphyrin based polyimide material Qiyue porphyrin reagent

C#/. Net phase VI 01C Foundation_ 02:vs2019 basic operations, excluding code files, smart tips, data types, differences between float and double, and differences between string and string

Kalman filter_ Recursive Processing

快速找到优质对象的5种渠道,赶紧收藏少走弯路

Jmeter压力测试-Web代理本地接口测试【教学篇】

MXNet对NIN网络中的网络的实现

Redis (4) -- Talking about integer set
![5,10,15,20-tetra (4-methoxycarbonylphenyl) porphyrin tcmpp purple crystal; Meso-5,10,15,20-tetra (4-methoxyphenyl) porphyrin tmopp|zn[t (4-mop) p] and co[t (4-mop) p] complexes](/img/51/136eda75986fc01282558e626b2faf.jpg)
5,10,15,20-tetra (4-methoxycarbonylphenyl) porphyrin tcmpp purple crystal; Meso-5,10,15,20-tetra (4-methoxyphenyl) porphyrin tmopp|zn[t (4-mop) p] and co[t (4-mop) p] complexes
随机推荐
Liujinhai, chief architect of zhongang Mining: according to the analysis of fluorite supply and demand, it is estimated that the fluorine coating market has great potential
Blue Bridge Cup embedded learning summary (new version)
Redis series - redis startup, client day1-2
手机开户哪个证券公司佣金最低?网上开户是否安全么?
Jmeter压力测试-Web代理本地接口测试【教学篇】
MySQL'replace into'has a self incrementing ID of the pit. There is a problem with the backup opportunity
What is Wi Fi 6 (802.11ax)? Why is Wi Fi 6 important?
Jemter stress test - basic requirements - [teaching]
What is the difference between bone conduction earphones and ordinary earphones? Advantages of bone conduction earphones
[UVM foundation] UVM_ Driver member variable req definition
Is it safe for individuals to buy stocks with compass software? How to buy stocks
Multisensor fusion sensing
The performance of iron and steel enterprises was expected to be good in January this year. Since February, the prices of products of iron and steel enterprises have increased significantly. A mighty
多传感器融合感知
Liquid crystal texture diagram of purple solid mm-tpp-10c methacrylic acid decanoxy tetraphenyl porphyrin and mm-tpp-12c methacrylic acid dodecanoxy tetraphenyl porphyrin - Qi Yue display
Sanic based services use celery to complete dynamic modification timing tasks
Teach you how to use the harmonyos local simulator
[UVM practice] Chapter 2: a simple UVM verification platform (5) build test cases
Encapsulating ranging and surface class based on leaflet
Systemctl PHP configuration file