2562. Find the Array Concatenation Value
Problem
2562. Find the Array Concatenation Value
Approach
This problem is very similar to quiz 4 — both use two pointers.
I made a mistake when computing the right pointer using a negative index: right = -left + 1. It's tricky to reason about with positive indices, so I switched to right = 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.0
2490. Circular Sentence
LeetCode 2490. Circular Sentence — Check if a sentence is circular by splitting into words and verifying each word's last character matches the next word's first character, wrapping around. For beginners.
2582. Pass the Pillow
LeetCode 2582. Pass the Pillow — Math pattern solution using period (n-1) and full cycles to determine forward/backward position, ideal for coding interview prep.