Max inversion distance linear implementation
Binary search tree lowest common ancestor