public class Solution { public int PivotIndex(int[] nums) { if (nums.Length == 0) { return -1; } var left = 0; var right = nums.Sum() - nums[0]; if (left == right) { return 0; } for (int i = 1; i < nums.Length; i++) { left += nums[i - 1]; right -= nums[i]; if (left == right) { return i; } } return -1; } }