Running sum · ผลรวมสะสม
Running sum
Return a new array where position i holds the sum of all elements up to and including i: [1, 2, 3, 4] → [1, 3, 6, 10]. Keep a running total and fill a fresh int[] of the same length.
Running sum
คืนอาเรย์ใหม่โดยที่ตำแหน่ง i เก็บผลรวมของทุกองค์ประกอบจนถึงและรวมถึง i: [1, 2, 3, 4] → [1, 3, 6, 10]. Keep running total และเติม fresh int[] ที่มีความยาวเท่ากัน
Complete runningSum(int[] nums) so result position i is the sum nums[0] + ... + nums[i]. Example: [1,2,3,4] becomes [1,3,6,10]. · เติม runningSum(int[] nums) ให้ตำแหน่งผลลัพธ์ i เป็นผลบวก nums[0] + ... + nums[i] ตัวอย่าง: [1,2,3,4] จะกลายเป็น [1,3,6,10]
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่