Datadog Interview Question

probem solving problem 1 : accumulative sum