Here's your approach:
Create a
Write an
The class structure makes this clean. You're not juggling three separate sums. You have one vector object that handles all three dimensions together. Each step should be clear and testable. Before coding, trace through with a small example to verify the logic. Think about edge cases: empty input, single element, maximum values. Make sure your algorithm handles them correctly.