See attached file.
First consider the following problem You have some object, say a brick as in this problem. You put this on a table and move it gradually over the side. The object can remain on the table only if the center of mass is still over the table. If you move the object further over the edge then it will fall. The bricks in this problem can be assumed to be of uniform density, so you can take the center of mass to be in the middle of the bricks.
If you have some pile of bricks, then the top brick can be moved over the edge until its center of mass is just at the edge of the brick below it. This means that you can move this brick 15 centimeters over the edge. Then let's move the second brick over the edge and see how far we can move it without it topling over the edge. If you move the second brick, you also move the top brick that is resting on it. You thus have to consider the center of mass of the system comprising of the second and the top brick together. Now, the center of mass of N objects can be computed by replacing the two objects by point masses placed at the center of mass of the N individual objects.
Suppose we move the second brick x ...
The solutions gives a a detailed step-by-step solution in which the relevant physics is explained.