Simple Java Solution 0ms | beats 100% | two pointer approach and No conversion to String needed
Intuition\nUse the two pointer approach to iterate through the array from both ends and conactenate the correspinding numbers till start<end.\n\nNote: please ma
# Intuition\nUse the two pointer approach to iterate through the array from both ends and conactenate the correspinding numbers till start<end.\n\n**Note: please make sure to use \'long\' variable while adding otherwise theoutput will overflow.**\n\n# Approach\n1. Place two pointers and both left and right end of the array and itarate through moving them towards each other.\n2. If start<end, concatenate the numbers and add them to the output variable. You may not need to convert the number to String to concatenate. Simple arithematic operation will also do it in O(1) due to input contraints. Please refer the code for this.\n3. If start==end, simply add the number to the result and return it.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\n    public long findTheArrayConcVal(int[] nums) {\n        \n        long result=0;\n        int start=0, end=nums.length-1;\n\n        while(start<end) {\n            result = result + concat((long)nums[start], (long)nums[end]);\n            start++;\n            end--;\n        }\n\n        if(start==end) {\n            result = result+nums[start];\n        }\n\n        return result;\n    }\n\n    public long concat(long a, long b) {\n        \n        if (b < 10) {\n            return a * 10 + b;\n        } else if (b < 100) {\n            return a * 100 + b;\n        } else if (b < 1000) {\n            return a * 1000 + b;\n        } else if (b < 10000) {\n            return a * 10000 + b;\n        }\n\n        return a * 100000 + b;\n    }\n}\n```
['Java']