网址:https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/submissions/

参考:https://blog.csdn.net/Sea_muxixi/article/details/88649191

  1. 直接双层for循环必定tle
  2. 在一轮遍历中将t取余存入map中
  3. 之后只需要遍历一个大小为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 整除的歌曲的更多相关文章

  1. 【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 ...

  2. 【LeetCode】1013. Pairs of Songs With Total Durations Divisible by 60 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  3. [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 ...

  4. 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 ...

  5. 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 ...

  6. Leetcode 1013. 总持续时间可被 60 整除的歌曲

    1013. 总持续时间可被 60 整除的歌曲  显示英文描述 我的提交返回竞赛   用户通过次数450 用户尝试次数595 通过次数456 提交次数1236 题目难度Easy 在歌曲列表中,第 i 首 ...

  7. 如何使用Total Recorder录制网上的音乐,如何下载只能试听的歌曲

    1 在网上找到了对应的网站.其中正在播放的歌曲正是我们想要的 2 在地址栏输入上面音乐网站的网址,并点击捕获广播.(URL直接给出了音乐的完整地址,比如http://www.someserver.co ...

  8. Weekly Contest 128

    1012. Complement of Base 10 Integer Every non-negative integer N has a binary representation.  For e ...

  9. Swift LeetCode 目录 | Catalog

    请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift    说明:题目中含有$符号则为付费题目. 如 ...

随机推荐

  1. Docker 开发概述

    This page lists resources for application developers using Docker. Develop new apps on Docker If you ...

  2. Java中泛型Class<T>、T与Class<?>、 Object类和Class类、 object.getClass()和Object.class

    一.区别 单独的T 代表一个类型(表现形式是一个类名而已) ,而 Class<T>代表这个类型所对应的类(又可以称做类实例.类类型.字节码文件), Class<?>表示类型不确 ...

  3. eclipse中建geoserver源码

    概述:本文讲述的是在eclipse中如何构建geoserver源码工程,其中涉及到了jdk,github,marven等. 1.安装git 从(http://git-scm.com/download/ ...

  4. Oracle AMERICAN改成简体中文

    64位Oracle连接32位PLSQL_Developer时,在PLSQL_Developer安装的目录中新建了一个TXT文件,之后更名为start.bat,内容如下: @echo off set p ...

  5. QT移植无法启动 This application failed to start because it could not find or load the QT platform

    QT配置好在自己机器上可以运行,但在别人机器上一直弹出 "This application failed to start because it could not find or load ...

  6. 【Django】【三】模型

    [基本数据访问] 1. models.py写模型 2. 数据库迁移 guest> python manage.py makemigrations sign guest> python ma ...

  7. RN 数据持久化存储服务API

    一些数据信息需要存储在手机内存中,比如用户的登录名密码 token啥的,所以这就需要了来存这些信息 在RN中 采用了AsyncStorage是一个简单的.异步的.持久化的Key-Value存储系统,它 ...

  8. pymongo.errors.OperationFailure: Authentication failed.

    mongoDB有不同的认证机制,3.0版本以后采用的是'MONGODB-CR', 之前的版本采用的是'MONGODB-CR'. 所以,以我的版本情况,显然应该用'SCRAM-SHA-1' from p ...

  9. memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

    1.在http://libevent.org/   下载libevent-2.0.22-stable.tar.gz 2.tar -zxvf libevent-2.0.22-stable.tar.gz ...

  10. Django中ORM系统多表数据操作

    一,多表操作之增删改查 1.在seting.py文件中配置数据库连接信息 2.创建数据库关联关系models.py from django.db import models # Create your ...