Bloomberg Interview Question

Both are tree style problems