标签:tle cal careercup nbsp not ora one -- loop
1 public int PivotIndex(int[] nums) 2 { 3 if (nums == null || nums.Length == 0) 4 { 5 return -1; 6 } 7 int l = nums.Length; 8 int sum = 0; int leftsum = 0; 9 for (int i = 0; i < l; i++) 10 { 11 sum +=nums[i]; 12 } 13 for (int j=0; j< l; j++) 14 { 15 if (sum - nums[j] - leftsum == leftsum) 16 { 17 return j; 18 } 19 else 20 leftsum += nums[j]; 21 } 22 return -1; 23 }
标签:tle cal careercup nbsp not ora one -- loop
原文地址:http://www.cnblogs.com/MiaBlog/p/6056134.html