Given an array of integers, we sum neighbouring elements like pascal's triangle until only two integers remain and take those to be the output. During the process, if the sum of two elements is greater than or equal to 10, we only take the digit place to the next level. Sorry if the description isn't clear enough, I included a picture to demonstrate the idea.
I used a queue and pushed the sums into it until only two numbers were left (popping out numbers as needed during the process), which is O(n^2) I believe. Passed 8/15 test cases and TLE on the rest of them. Better solutions?