Imagine a cubic array made up of an $n\times n\times n$ arrangement of unit cubes: the cubic array is n cubes wide, n cubes high and n cubes deep. A special case is a $3\times3\times3$ Rubik’s cube, which you may be familiar with. How many unit cubes are there on the surface of the $n\times n\times n$ cubic array?
As far as I can see there are 27 unit cubes in a $n\times n\times n$ rubik cube. But the answer says something different. There are total $6n^2$ squares are present in $n\times n\times n$ cube. But after that I cant proceed.
Please help :)
So, i think that thing you're missing is that you're counting the number of squares on the surface; not the number of cubes. For example, a corner piece of a Rubix cube is one cube but contributes three squares.
In a $n\times n\times n$ cube, you have the outer layer of cubes counting, and the ones on the inside not counting. The easiest way to see this is recursive: for a $n\times n\times n$ cube, you have an $(n-2)\times (n-2)\times (n-2)$ cube on the inside that is coated by a number of cubes that form the cubes on the outside. Subtracting $$n^3-(n-2)^3=6n^2-12n+8$$ gives the final answer.
This generalizes immediately to higher dimensions... In dimension $k$ the answer is $$n^k-(n-2)^k$$