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 说明:题目中含有$符号则为付费题目. 如 ...
随机推荐
- AtomicReference实现单例模式
CAS是项乐观锁技术,当多个线程尝试使用CAS同时更新同一个变量时,只有其中一个线程能更新变量的值,而其它线程都失败,失败的线程并不会被挂起,而是被告知这次竞争中失败,并可以再次尝试. 乐观锁的一种实 ...
- 说明Heap与stack的差别。
Heap 是堆,Stack 是栈. 栈与堆都是Java用来在Ram中存放数据的地方,与C++不同,Java会自动管理栈与堆,程序员不能直接设置栈与堆. Java的堆是一个运行时的数据区,类的对象从中分 ...
- ngnix简介以及如何实现负载均衡原理
1 负载均衡 先来简单了解一下什么是负载均衡,单从字面上的意思来理解就可以解释N台服务器平均分担负载,不会因为某台服务器负载高宕机而某台服务器闲置的情况.那么负载均衡的前提就是要有多台服务器才能实现, ...
- Echarts 设置地图大小
项目中要添加地图,默认地图太小,折腾半天终于找到解决方案. series: [ { //name: '香港18区人口密度', type: 'map', mapType: 'jiangsu', // 自 ...
- 【Python】图形界面
# [[图形界面]]'''Python支持多种图形界面的第三方库,包括TkwxWidgetsQtGTK但是Python自带的库是支持Tk的Tkinter,无需安装任何包,可直接使用.''' #[Tki ...
- Spring中JdbcTemplate使用RowMapper
package com.cxl.demo.dao; import java.sql.ResultSet; import java.sql.SQLException; import java.util. ...
- springboot 启动报错 java.lang.IllegalStateException: Failed to introspect annotated methods on class org
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ...
- sklearn中的train_test_split (随机划分训练集和测试集)
官方文档:http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html ...
- c++ cmakelist 详解
基本元素 首先cmaklist必须包括以下几个部分: #工程名 project(study_case) #cmake最低版本需求 cmake_minimum_required(VERSION 2.8. ...
- prometheus的agent 二次开发代码参考
import com.codahale.metrics.MetricRegistry;import io.prometheus.client.CollectorRegistry;import io.p ...