Tesla Interview Question

Optimize js algorithms by binary trees