1013. Pairs of Songs With Total Durations Divisible by 60总持续时间可被 60 整除的歌曲
网址:https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/submissions/
参考:https://blog.csdn.net/Sea_muxixi/article/details/88649191
- 直接双层for循环必定tle
- 在一轮遍历中将t取余存入map中
- 之后只需要遍历一个大小为60的map即可解决问题
class Solution {
public:
int numPairsDivisibleBy60(vector<int>& time) {
map<int,int> m;
int nums = ;
for(int t:time)
m[t%]++;
if(m[])
nums = m[] * (m[]-) / ;
cout << nums << endl;
for(int i=;i<;i++)
{
nums += m[i] * m[-i];
}
if(m[])
nums += m[] * (m[]-) / ;
return nums;
}
};

1013. Pairs of Songs With Total Durations Divisible by 60总持续时间可被 60 整除的歌曲的更多相关文章
- 【leetcode】1013. Pairs of Songs With Total Durations Divisible by 60
题目如下: In a list of songs, the i-th song has a duration of time[i] seconds. Return the number of pair ...
- 【LeetCode】1013. Pairs of Songs With Total Durations Divisible by 60 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...
- [Swift]LeetCode1010. 总持续时间可被 60 整除的歌曲 | Pairs of Songs With Total Durations Divisible by 60
In a list of songs, the i-th song has a duration of time[i] seconds. Return the number of pairs of s ...
- Pairs of Songs With Total Durations Divisible by 60 LT1010
In a list of songs, the i-th song has a duration of time[i] seconds. Return the number of pairs of s ...
- 128th LeetCode Weekly Contest Pairs of Songs With Total Durations Divisible by 60
In a list of songs, the i-th song has a duration of time[i] seconds. Return the number of pairs of s ...
- Leetcode 1013. 总持续时间可被 60 整除的歌曲
1013. 总持续时间可被 60 整除的歌曲 显示英文描述 我的提交返回竞赛 用户通过次数450 用户尝试次数595 通过次数456 提交次数1236 题目难度Easy 在歌曲列表中,第 i 首 ...
- 如何使用Total Recorder录制网上的音乐,如何下载只能试听的歌曲
1 在网上找到了对应的网站.其中正在播放的歌曲正是我们想要的 2 在地址栏输入上面音乐网站的网址,并点击捕获广播.(URL直接给出了音乐的完整地址,比如http://www.someserver.co ...
- Weekly Contest 128
1012. Complement of Base 10 Integer Every non-negative integer N has a binary representation. For e ...
- Swift LeetCode 目录 | Catalog
请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift 说明:题目中含有$符号则为付费题目. 如 ...
随机推荐
- CAS 单点登录4.24版本 登录调用其它系统并且返回客户端用其它的用户信息改造
1.登录调用其它系统.修改deployerConfigContext.xml <?xml version="1.0" encoding="UTF-8"?& ...
- python学习之re库
正则表达式库re是非常重要的一个库. 首先正则表达式有两种表示类型,一种是raw string类型(原生字符串类型),也就是我们经常看到的r' '的写法,另一种是不带r的写法,称为string类型. ...
- JSON平铺功能的实现(JS操作JSON数据)
一.什么是JSON平铺 JSON平铺分成两种: 平铺的json转树结构的json 例如: { a: 'value', b: 'b1.value' } // 转换成=> { a: 'value', ...
- C#端加载数据库,Combobox与Node控件绑定数据源demo示例
最近一直在做网页.用的js比较多,最近需要做一个C#相关的demo,一开始还有点不适应,写了几句有点感觉了 本篇博客的主要内容是C#怎么读取数据库文件里的数据以及相关控件如何绑定数据源,所做的Demo ...
- go helloworld
// Sample program to show how a bytes.Buffer can also be used // with the io.Copy function. package ...
- Java生成指定长度的随机数
char[] str = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', ' ...
- LaTeX 交叉引用系统简介
目录 摘要 1. 简介 2. 指定标签或标记符 3. 标签的位置 4. 引用的生成和更新 5. 引用相关的警告信息 6. 扩展引用功能的宏包 6.1 varioref宏包 6.2 cleveref宏包 ...
- include
1. 自己写的文件都用:include "....." 2. 如果A类include了B,那么在主函数中,只用include A类,就可以使用B类了,但是此时不能再include ...
- Python全栈开发-Day4-Python基础4
本节内容 匿名函数 装饰器 列表生成式.迭代器&生成器 内置函数 Json & pickle 数据序列化 1. 匿名函数 匿名函数就是不需要显式的指定函数 1 2 3 4 5 6 7 ...
- stm32复位引脚NRST
STM32F的NRST是异步复位脚. 当NRST输入低电平的时候,MCU处于复位状态,重设所有的内部寄存器,及片内几十KB的SRAM. 当NRST从低电平变高时,PC指针从0开始. 但是复位的时候不会 ...