3452. 好数字之和
题目来源:
LeetCode题目:3452. 好数字之和 - 力扣(LeetCode)
解题思路:
按要求判断求和即可。
解题代码:
#python3
class Solution:def sumOfGoodNumbers(self, nums: List[int], k: int) -> int:res=0length=len(nums)for i in range(length):if (i-k>=0 and nums[i]<=nums[i-k]) or (i+k<length and nums[i]<=nums[i+k]):continueres=res+nums[i]return res
总结:
无官方题解。