博客
关于我
Leetcode 5727. 找出游戏的获胜者(DAY 82) ---- 周赛题目
阅读量:193 次
发布时间:2019-02-28

本文共 539 字,大约阅读时间需要 1 分钟。

原题题目

在这里插入图片描述


代码实现(首刷自解)

class Solution {   public:    int findTheWinner(int n, int k) {           vector
dp; for(int i=1;i<=n;++i) dp.push_back(i); auto pos = dp.begin(); while(dp.size()-1) { int count = 1; while(count != k) { pos++; ++count; if(pos == dp.end()) pos = dp.begin(); } pos = dp.erase(pos); if(pos == dp.end()) pos = dp.begin(); } return dp.front(); }};

转载地址:http://vbni.baihongyu.com/

你可能感兴趣的文章
mysql中having的用法
查看>>
MySQL中interactive_timeout和wait_timeout的区别
查看>>
mysql中int、bigint、smallint 和 tinyint的区别、char和varchar的区别详细介绍
查看>>
mysql中json_extract的使用方法
查看>>
mysql中json_extract的使用方法
查看>>
mysql中null和空字符串的区别与问题!
查看>>
MySQL中ON DUPLICATE KEY UPDATE的介绍与使用、批量更新、存在即更新不存在则插入
查看>>
MYSQL中TINYINT的取值范围
查看>>
Mysql中varchar类型数字排序不对踩坑记录
查看>>
mysql中出现update-alternatives: 错误: 候选项路径 /etc/mysql/mysql.cnf 不存在 dpkg: 处理软件包 mysql-server-8.0的解决方法(全)
查看>>
MySQL中地理位置数据扩展geometry的使用心得
查看>>
Mysql中存储引擎简介、修改、查询、选择
查看>>
mysql中实现rownum,对结果进行排序
查看>>
mysql中对于数据库的基本操作
查看>>
mysql中的 +号 和 CONCAT(str1,str2,...)
查看>>
MySql中的concat()相关函数
查看>>
mysql中的concat函数,concat_ws函数,concat_group函数之间的区别
查看>>
MySQL中的count函数
查看>>
MySQL中的DB、DBMS、SQL
查看>>
MySQL中的DECIMAL类型:MYSQL_TYPE_DECIMAL与MYSQL_TYPE_NEWDECIMAL详解
查看>>