You are viewing a single comment's thread. Return to all comments →
Python 3 solution
def cubeSum(n, operations): d = {} s = set() ans = [] for o in operations: o_split = o.split(" ") if o_split[0] == "UPDATE": x, y, z, W = map(int, o_split[1:]) d[(x,y,z)] = W s.add((x,y,z)) elif o_split[0] == "QUERY": x1,y1,z1,x2,y2,z2 = map(int, o_split[1:]) ans.append(0) for e in s: if e[0] in range(x1, x2+1) and e[1] in range(y1, y2+1) and e[2] in range(z1, z2+1): ans[-1] += d[e] return ans
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 →
Python 3 solution