How to place an object precisely on a surface?

I mean like put a cube on a table and there is no interval between them. Note that I don’t know the height of the table.

Something like:

  1. Get the renderer bounds of the table. GetComponent<Renderer>().bounds.

  2. Get the renderer bounds of the cube.

  3. Calculate the difference between the renderer bounds of the cube and cube.transform.position.

  4. Set y component of cube.transform.position to tableBounds.max.y + offsetFrom3