solution for level traverse and max height