區域和檢索 - 數組不可變

注意需要多次調用sumRange方法,所以不能簡單的進行區間遍歷求和,動態規劃一下,記錄一下 每個區間的和,然後根據索引直接求出結果。 class NumArray { private int[] sums; public NumArray(int[] nums) { final int length = nums.length; if (l
相關文章
相關標籤/搜索