讨论/技术交流/1109. 航班预订统计:global name 'num_flights' is not defined, 缺失全局变量/
1109. 航班预订统计:global name 'num_flights' is not defined, 缺失全局变量
  1. 航班预订统计:global name 'num_flights' is not defined, 缺失全局变量!!
    image.png

class Solution {
public int[] corpFlightBookings(int[][] bookings, int n) {
int[] counters = new int[n];
for (int[] booking : bookings) {
counters[booking[0] - 1] += booking[2];
if (booking[1] < n) {
counters[booking[1]] -= booking[2];
}
}
for (int i = 1; i < n; ++i) {
counters[i] += counters[i - 1];
}
return counters;
}
}

共 1 个回复

我也遇到了,很奇怪