✅C++ beats 100% of submissions ✅
Intuition\n Describe your first thoughts on how to solve this problem. \n- Just by looking at the word "concatenation", I had got the string approach in my mind
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- Just by looking at the word "concatenation", I had got the string approach in my mind along with its predefined functions.. stoi(used for the conversion of string to integer) and to_string(converts integer value to string).\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Iterating over the first half of the nums vector and concatenating the values at each index with the corresponding value at the opposite end of the vector (i.e. if the index is i, the concatenated value is the string representation of nums[i] concatenated with the string representation of nums[n-i-1]). This concatenated value is then converted to an integer and added to a running sum.\n- If n is odd, the value of nums[n/2] is added to sum.\n- Finally, sum is returned as the result of the function.\n\n# Complexity\nTime complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n- The time complexity of this function is O(n), where n is the number of elements in the nums vector. This is because the function performs a single loop over the first half of the vector, and each iteration of the loop takes constant time.\n\nSpace complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n- The space complexity of this function is O(1), as the function uses a constant amount of memory regardless of the size of the input. The only variables used in the function are an integer n to store the size of the input vector, two long long variables sum and n1 to store intermediate results, and one string variable res to store the concatenated value before converting it to an integer. All of these variables use a constant amount of memory, so the overall space complexity is constant.\n\n# Code\n```\nclass Solution {\npublic:\n    typedef long long ll;\n    long long findTheArrayConcVal(vector<int>& nums) \n    {\n        int n = nums.size();\n        ll sum = 0;\n        ll n1;\n        ll n2;\n        for (int i = 0; i < n / 2; i++) \n        {\n            n1 = nums[i];\n            n2 = nums[n - i - 1];\n            string res = to_string(n1) + to_string(n2);\n            sum += stoi(res);\n    }\n        \n    if (n % 2)\n        sum += nums[n / 2];\n        \n    return sum;\n    }\n};\n```
['C++']