• leetcode495


    public class Solution {
        public int FindPoisonedDuration(int[] timeSeries, int duration) {
            if (timeSeries == null || timeSeries.Length == 0)
                {
                    return 0;
                }
                else if (timeSeries.Length == 1)
                {
                    return duration;
                }
                else
                {
                    var sum = 0;
                    for (int i = 0; i < timeSeries.Length - 1; i++)
                    {
                        var cur = timeSeries[i];
                        var next = timeSeries[i + 1];
    
                        if (cur + duration <= next)
                        {
                            sum += duration;
                        }
                        else
                        {
                            sum += next - cur;
                        }
                    }
                    sum += duration;
                    return sum;
                }
        }
    }

    https://leetcode.com/problems/teemo-attacking/#/description

  • 相关阅读:
    p1297
    p2023
    p1612
    逆元总结
    p1652
    考试总结10-08
    p1459
    p1821
    p1863
    p1884
  • 原文地址:https://www.cnblogs.com/asenyang/p/6800586.html
Copyright © 2020-2023  润新知