My Java Solution


  • 0
    D
        public int[] getModifiedArray(int length, int[][] updates) {
            int[] res = new int[length];
            int len = updates.length;
            for (int i = 0 ; i < len ; i++) {
                int start = updates[i][0];
                int end = updates[i][1];
                int inc = updates[i][2];
                for (int j = start; j<=end; j++) {
                    res[j] += inc;
                }
            }
            return res;
        }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.