网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  LeetCode "Teemo Attacking"

LeetCode "Teemo Attacking"

分类: IT文章 • 2023-11-13 09:40:25

Isn't it 'Easy'?

class Solution {
public:
    int findPoisonedDuration(vector<int>& ts, int d) 
    {
        int ret = 0, s = 0, e = 0;
        for(auto t : ts)
        {
            if(t > e) 
            {
                ret += e - s;
                s = t;
            }
            
            e = t + d;
        }
        ret += e - s;
        
        return ret;
    }
};

相关推荐

  • leetcode无重复字符最长子串
  • leetcode 31. Next Permutation(字典序的下一个)
  • leetcode 60. Permutation Sequence(康托展开)
  • leetCode书房之链表(LC实现链表)
  • LeetCode 278 First Bad Version
  • LeetCode 231 Power of Two
  • LeetCode 136 Single Number
  • LeetCode 202 Happy Number
  • LeetCode 28 Implement strStr()
  • LeetCode 20 Valid Parentheses
  • nginx能访问html静态文件但无法访问php文件
  • opencv学习之houghlinesp include include
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号