2698. Find the Array Concatenation Value
My accepted Python solution to LeetCode problem 2698, Find the Array Concatenation Value, running in 2ms.
- Difficulty: Easy
- Python
- Runtime 2ms
- Memory 17.3MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 2ms, memory 17.3MB, accepted 2026-01-01.
class Solution:
def findTheArrayConcVal(self, nums: List[int]) -> int:
result = 0
left, right = 0, len(nums) - 1
while left < right:
# Concatenate first and last elements
concat = int(str(nums[left]) + str(nums[right]))
result += concat
left += 1
right -= 1
# If there's a middle element left
if left == right:
result += nums[left]
return result