xAI interview question

Dynamic programming-based sum of integers in an array.