# Cubic array

Posted by Job-Interview
Given a cubic array made up of NxNxN smaller cubes: the cubic array is N cubes wide, N cubes deep and N cubes high.

Question: How many cubes are on the surface of the array.

There are N

Thus, the answer is

Bonus question:

Calculate number of 4D hypercubes on the surface of NxNxNxN hypercubic array

Question: How many cubes are on the surface of the array.

__Answer__:There are N

^{3}cubes total. If you can calculate how many cubes are hidden you can answer this questions. The number of hidden cubes is simply a number of cubes with sides (N-2)x(N-2)x(N-2). ie. (N-2)^{3}.Thus, the answer is

N

N

^{3}- (N-2)^{3}.Bonus question:

Calculate number of 4D hypercubes on the surface of NxNxNxN hypercubic array