Jupiter Money Interview Question

cumulative sum sql , with and without cte