Uber interview question

stack + 3D dp question based on the stable cuboid alignment