leetcodedaybyday - Beats 100% with C++ and Beats 100% with Python3 and Beats 28.62% with Java
IntuitionWe need to compute the "concatenation value" of an array by pairing numbers from both ends and concatenating them as strings before summing their numer
# Intuition
We need to compute the "concatenation value" of an array by pairing numbers from both ends and concatenating them as strings before summing their numeric values.

# Approach
1. **Two-pointer technique**:  
   - Use two pointers (`left` and `right`), where `left` starts from the beginning and `right` starts from the end of the array.
   - Move towards the center while pairing elements.
  
2. **Concatenation and conversion**:  
   - Convert each pair of elements into strings, concatenate them, and convert back to an integer before adding to the sum.
   - If there's a middle element (odd length array), add it separately.

# Complexity
- **Time Complexity:** $$O(n)$$ (We iterate through the array once)
- **Space Complexity:** $$O(1)$$ (Only a few extra variables are used)

# Code
```cpp []
class Solution {
public:
    long long findTheArrayConcVal(vector<int>& nums) {
        long long total = 0;
        int n = nums.size();
        for(int i = 0, j = n - 1; i <= j; i++, j--){
            if (i == j){
                total += nums[i];
            } else {
                int concat = stoi(to_string(nums[i]) + to_string(nums[j]));
                total += concat;
            }
        }
        return total;
    }
};


```

```java []
class Solution {
    public long findTheArrayConcVal(int[] nums) {
        long total = 0;
        int n = nums.length;
        for(int i = 0, j = n - 1; i <= j; i++, j--){
            if (i == j){
                total += nums[i];
            } else {
                long concat = Long.parseLong(nums[i] + "" + nums[j]);
                total += concat;
            }
        }
        return total;
    }
}


```
```python3 []
class Solution:
    def findTheArrayConcVal(self, nums: List[int]) -> int:
        left, right = 0, len(nums) - 1
        total = 0
        while left < right:
            total += int(str(nums[left]) + str(nums[right]))
            left += 1
            right -= 1
            
        if left == right:
            total += nums[left]
    
        return total



```


['Array', 'Two Pointers', 'Simulation', 'C++', 'Java', 'Python3']