2640. Find the Score of All Prefixes of an Array

2640. Find the Score of All Prefixes of an Array

python 复制代码
class Solution:
    def findPrefixScore(self, nums: List[int]) -> List[int]:
        conver=[nums[0]*2]
        premax=nums[0]
        for i in range(1,len(nums)):
            premax=max(premax,nums[i])
            conver.append(conver[-1]+premax+nums[i])
        return conver
相关推荐
To_OC5 小时前
LC 207 课程表:刚学图论那会儿,我连这是拓扑排序都没看出来
javascript·算法·leetcode
To_OC5 小时前
LC 208 实现 Trie 前缀树:曾被名字劝退,写完发现是送分题
javascript·算法·leetcode
To_OC1 天前
LC 994 腐烂的橘子:人人都说是 BFS 入门题,我却写了三遍才过
javascript·算法·leetcode
To_OC2 天前
LC 200 岛屿数量:经典 DFS 入门题,我第一次写居然连方向都搞错了
javascript·算法·leetcode
To_OC2 天前
LC 128 最长连续序列:别上来就排序,O (n) 解法才是这题的灵魂
javascript·算法·leetcode
To_OC4 天前
LC 49 字母异位词分组:想到哈希表很简单,选对 key 才是精髓
javascript·算法·leetcode
To_OC5 天前
LC 1 两数之和:面试第一道必考题,暴力解法直接被面试官 pass
javascript·算法·leetcode
想吃火锅100512 天前
【leetcode】121.买卖股票的最佳时机js/c++
算法·leetcode·职场和发展
凌波粒12 天前
LeetCode--491.递增子序列(回溯算法)
数据结构·算法·leetcode
退休倒计时12 天前
【每日一题】LeetCode 146. LRU 缓存 TypeScript
算法·leetcode·缓存·typescript