avatar
Siz Long

My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • Resume
  • Archives
  • Categories
  • Photos
  • Music



{{ date }}

{{ time }}

avatar
Siz Long

My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • 主页
  • Resume
  • Archives
  • Categories
  • Photos
  • Music

2562.Find the series of the array

  2024-01-01        
字数统计: 100字   |   阅读时长: 1min

topic:

screenshot2023-10-12 afternoon11.08.18.png
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:

1
2
3
4
5
6
7
8
9
10
11
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
  • Python
  • answer
  • Array
  • Double pointer
  • simulation

扫一扫,分享到微信

微信分享二维码
2490Return ring sentence
2582.Pillow
目录
  1. 1. topic:
  2. 2. Thought:
  3. 3. Code:

150 篇 | 131.7k
次 | 人
这里自动载入天数这里自动载入时分秒
2022-2025 loong loong | 新南威尔士龙龙号