• + 0 comments
    def cubeSum(n, operations):
        s = {}
        res=[]
        for op in operations:
            op = op.rstrip().split()
            if op[0] == 'UPDATE':
                x, y, z, w = map(int, op[1:])
                s[(x, y, z)] = w
            else:
                x1, y1, z1, x2, y2, z2 = map(int, op[1:])
                csum = sum(s[(x, y, z)] for x, y, z in s if x1 <= x <= x2 and y1 <= y <= y2 and z1 <= z <= z2)
                res.append(csum)
        return res