I have understood the algorithm in case of rectangles but I am confused with the boxes with x, y, z and height as value given. The conditions for not overlapping are 1) Box
if(xMin1 <= xMax2 || xMax1 >= xMin2)
if(yMin1 <= yMax2 || yMax1 >= yMin2)
if(zMin1 <= zMax2 || zMax1 >= zMin2)
All of these conditions have to be true for the boxes to not be overlapped.
Also I assumed that the box edges could lay on the same x,y,z co-ordinates.
If not, just take the equal signs outs.
if(xMin1 < xMax2 || xMax1 > xMin2)
if(yMin1 < yMax2 || yMax1 > yMin2)
if(zMin1 < zMax2 || zMax1 > zMin2)