当前位置: 首页 > news >正文

海外网站入口wordpress默认摘要

海外网站入口,wordpress默认摘要,房地产新闻时事热点,机械加工网报价文章目录1. 题目2. 解题1. 题目 你需要设计一个包含验证码的验证系统。 每一次验证中#xff0c;用户会收到一个新的验证码#xff0c;这个验证码在 currentTime 时刻之后 timeToLive 秒过期。 如果验证码被更新了#xff0c;那么它会在 currentTime #xff08;可能与之前… 文章目录1. 题目2. 解题1. 题目 你需要设计一个包含验证码的验证系统。 每一次验证中用户会收到一个新的验证码这个验证码在 currentTime 时刻之后 timeToLive 秒过期。 如果验证码被更新了那么它会在 currentTime 可能与之前的 currentTime 不同时刻延长 timeToLive 秒。 请你实现 AuthenticationManager 类 AuthenticationManager(int timeToLive) 构造 AuthenticationManager 并设置 timeToLive 参数。generate(string tokenId, int currentTime) 给定 tokenId 在当前时间 currentTime 生成一个新的验证码。renew(string tokenId, int currentTime) 将给定 tokenId 且 未过期 的验证码在 currentTime 时刻更新。如果给定 tokenId 对应的验证码不存在或已过期请你忽略该操作不会有任何更新操作发生。countUnexpiredTokens(int currentTime) 请返回在给定 currentTime 时刻未过期 的验证码数目。 如果一个验证码在时刻 t 过期且另一个操作恰好在时刻 t 发生renew 或者 countUnexpiredTokens 操作过期事件 优先于 其他操作。 示例 1 输入 [AuthenticationManager, renew, generate, countUnexpiredTokens, generate, renew, renew, countUnexpiredTokens] [[5], [aaa, 1], [aaa, 2], [6], [bbb, 7], [aaa, 8], [bbb, 10], [15]] 输出 [null, null, null, 1, null, null, null, 0]解释 AuthenticationManager authenticationManager new AuthenticationManager(5); // 构造 AuthenticationManager 设置 timeToLive 5 秒。 authenticationManager.renew(aaa, 1); // 时刻 1 时没有验证码的 tokenId 为 aaa 没有验证码被更新。 authenticationManager.generate(aaa, 2); // 时刻 2 时生成一个 tokenId 为 aaa 的新验证码。 authenticationManager.countUnexpiredTokens(6); // 时刻 6 时只有 tokenId 为 aaa 的验证码未过期所以返回 1 。 authenticationManager.generate(bbb, 7); // 时刻 7 时生成一个 tokenId 为 bbb 的新验证码。 authenticationManager.renew(aaa, 8); // tokenId 为 aaa 的验证码在时刻 7 过期且 8 7 所以时刻 8 的renew 操作被忽略没有验证码被更新。 authenticationManager.renew(bbb, 10); // tokenId 为 bbb 的验证码在时刻 10 没有过期所以 renew 操作会执行该 token 将在时刻 15 过期。 authenticationManager.countUnexpiredTokens(15); // tokenId 为 bbb 的验证码在时刻 15 过期tokenId 为 aaa 的验证码在时刻 7 过期所有验证码均已过期所以返回 0 。提示 1 timeToLive 108 1 currentTime 108 1 tokenId.length 5 tokenId 只包含小写英文字母。 所有 generate 函数的调用都会包含独一无二的 tokenId 值。 所有函数调用中currentTime 的值 严格递增 。 所有函数的调用次数总共不超过 2000 次。https://leetcode-cn.com/problems/design-authentication-manager/ 2. 解题 使用 双向 map 记录 token 和 time题目说了都是独一无二的 key class AuthenticationManager {int livetime;mapint,string t_str;unordered_mapstring, int str_t; public:AuthenticationManager(int timeToLive) {livetime timeToLive;}void generate(string tokenId, int currentTime) {t_str[currentTime] tokenId;str_t[tokenId] currentTime;}void renew(string tokenId, int currentTime) {if(!str_t.count(tokenId)) return;int t str_t[tokenId];if(currentTime-t livetime) {t_str.erase(t);t_str[currentTime] tokenId;str_t[tokenId] currentTime;}}int countUnexpiredTokens(int currentTime) {for(auto it t_str.begin(); it ! t_str.end(); ) {int t it-first;string token it-second;if(currentTime-t livetime){ // 删除过期的t_str.erase(it);str_t.erase(token);}else // map key 有序没过期停止删除break;}return str_t.size();} };我的CSDN博客地址 https://michael.blog.csdn.net/ 长按或扫码关注我的公众号Michael阿明一起加油、一起学习进步
http://www.pierceye.com/news/158246/

相关文章:

  • 宁波网站建设公司怎么报价网页打开速度慢的解决方法
  • 有趣的网站有哪些推荐关键词没有排名的网站怎么做
  • 昆山网站制作哪家强海淀区企业网络公司
  • 北京网站制建设公司永兴县网站建设服务商
  • 嘉兴做网站优化公司江阴网站优化公司
  • dz可以做旅游网站吗wordpress 4.1.1 漏洞
  • 谷歌网站地图生成福州便民网免费发布信息
  • 最新军事战争新闻超级优化大师
  • 好的网站建设公司排名网站建设 交易保障
  • 怎么查看网站外链效果代理注册公司有什么风险
  • 西安网站漏洞免费自动生成小程序
  • 怎么修改网站信息同ip网站做301
  • 松江品划网络做网站logo设计网页
  • 重庆博达建设集团股份有限公司网站徐州建设企业网站
  • 有没有专门做老年婚介的网站东营会计信息网官网
  • 鞍山怎么做平台软件汕头网站时优化
  • 邹城建网站深圳装修公司排行榜
  • 泊头网站优化WordPress如何添加cnzz
  • dz论坛网站创建页面wap网站建设方案 pdf
  • 网站建设项目报告总结报告seo关于网站搜索排名关键词的标准评定
  • 东莞电商网站建设wordpress注册验证邮箱
  • 网站建设名中国建设劳动学会是假网站吗
  • 一个优秀的个人网站百度极速版免费下载安装
  • 咋做211校徽加网站wordpress免费教程视频教程
  • 网站建设制作网络营销公司蛋糕店网站模板
  • a站网址东莞市网络seo推广价格
  • 莱州市双语网站seo白帽优化
  • 不忘初心网站建设深圳公租房官网
  • 网站点击率原因深圳做自适应网站制作
  • 上海个人建站小程序注册完成后如何制作