You are viewing a single comment's thread. Return to all 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
Seems like cookies are disabled on this browser, please enable them to open this website
Cube Summation
You are viewing a single comment's thread. Return to all comments →