内卷地狱

2562.Find the series of the array

Edit Me

topic:

2562.Find the series of the array.md

Thought:

This question andquiz4very similar,都是Double pointer。 I made a mistake when I did this question,When calculating the right pointer, the negative index is calculatedright = -left + 1,It is difficult to calculate the relationship between positive indexes,So replacedright = len(nums) - 1 - left

Code:

class Solution:
    def findTheArrayConcVal(self, nums: List[int]) -> int:
        sums = 0
        for left in range(len(nums)):
            right = len(nums) - 1 - left
            if left == right:
                sums += nums[left]
                break
            elif left < right:
                sums += int(str(nums[left]) + str(nums[right]))
        return sums

贡献者


这篇文章有帮助吗?

最近更新

Involution Hell© 2026 byCommunityunderCC BY-NC-SA 4.0CCBYNCSA