$ ./guess_the_languageProblem Solving — fill the blank
Problem Solving — fill the blank · hard · #334

What goes in the blank?

# recursive segment tree over n leaves (root = 1,
# children 2k and 2k+1): a safe array size
tree = [0] * (____ * n)

Answer: 4 (also accepted: 4)

For n that is not a power of two the tree is deeper than log2(n), and indexes can exceed 2n; 4n always fits.
Play Problem Solving ▸