Bloomberg interview question

Hackerrank coding. Not about balancing a binary tree, more technical and useful.