1578. Minimum Time to Make Rope Colorful
1 | class Solution { |
就是把连续颜色的气球消成1个. 把需要时间最多的那个保留下来. 我们用count存连续颜色出现的次数, timeSum存把所有连续颜色气球扎破的时间. max存连续颜色气球中需要时间最多的.
时间复杂度: O(n)
空间复杂度: O(1)
Insist on doing small things, then witness the magic
1 | class Solution { |
就是把连续颜色的气球消成1个. 把需要时间最多的那个保留下来. 我们用count存连续颜色出现的次数, timeSum存把所有连续颜色气球扎破的时间. max存连续颜色气球中需要时间最多的.
时间复杂度: O(n)
空间复杂度: O(1)