Two Pointer ✅ | Array 🦾 | Easy 😉 | Python3 | 🥳
IntuitionThe problem requires performing pairwise concatenation from both ends of the array until it's empty. A two-pointer approach came to mind: one pointer s
# Intuition
The problem requires performing pairwise concatenation from both ends of the array until it's empty. A two-pointer approach came to mind: one pointer starts at the beginning (i), and one at the end (j). We concatenate the values at these pointers as strings, convert the result back to an integer, and add to the total. If i == j, we only add the middle element once.

# Approach
We initialize two pointers i and j at the start and end of the array, respectively. A variable sums holds the final concatenation value. We use a while loop to iterate as long as i <= j:

- If i == j, there’s only one element left, so we add it directly to sums.

- Otherwise, we concatenate nums[i] and nums[j] as strings, convert the result to an integer, and add it to sums.

- Increment i and decrement j to continue processing the inner elements.

We return sums once the loop ends.

# Complexity
- Time complexity: **O(n)**
We visit each element at most once, performing constant-time operations per iteration.

- Space complexity: **O(1)**
We only use a few variables for tracking indices and the total sum. The temporary string concatenation and conversion are done in constant space per iteration.

# Code
```python3 []
class Solution:
    def findTheArrayConcVal(self, nums: List[int]) -> int:
        i , j = 0, len(nums)-1
        sums = 0
        while i <= j:
            if i == j:
                sums += int(str(nums[i]))
            else:
                sums += int(str(nums[i]) + str(nums[j]))
            i += 1
            j -= 1
        return sums

        
```



---

# If you find it useful
![478xve.jpg](https://assets.leetcode.com/users/images/e0d8028e-4d5c-4d03-8fa2-a9e676d9dea2_1744136974.575695.jpeg)

- Thank You  ☺️
- Hope your day Goes well 😉

['Array', 'Two Pointers', 'Python3']