Merkle root
Your task
Compute the Merkle root of a list of integer leaves. Use the deterministic hash combine(a, b) = (a * 31 + b * 17 + 1) % 1000000007 for an internal node from its left child a and right child b; a leaf's hash is its own value taken mod 1000000007. Build the tree level by level: pair up adjacent nodes left to right; if a level has an odd number of nodes, the last (unpaired) node is promoted unchanged to the next level. Repeat until one node remains, that is the root. For an empty leaf list, return 0. Return the root as an integer.
Examples
merkle_root(leaves: list[int]) -> intExample 1
Input
merkle_root([1, 2])Output
66