How to approach?

I cannot figure out how to approach this problem.

at every position, consider two cases, One is that you treat the current number individually. Second is that you combine it with previos element if possible.
You can take the parameters position,last, check.
check contains weather last element was treated individually or not.
Hope you are able to get it, Try now!
Goodluck!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.