sTec

  www.stec-inc.com
  www.stec-inc.com

Interview Question

Senior Firmware Engineer Interview Santa Ana, CA

Given a cube made of NxN sub cubes, find the number of

  cubes that are no exposed to the outside.
Answer

Interview Answer

4 Answers

0

6N**2 - 12N + 4

Interview Candidate on Nov 8, 2010
1

Let N^2 = n^3
Hence total number of sub-cubes : n^3

Number of cubes on one face : n^2
Total # of cubes/face = 6n^2 - Common cubes
Common cubes = common on the edge + common on the corner
Common on the edge = (n-2) * Number of edges (=12) = 12n - 24
Common on the corner = counted 3 times for neighboring faces. Will need to take into account the 2 extra = 2*number of corners = 2*8

Hence the total number of visible cubes = 6n^2 - 12n + 8
Total number of not visible cubes = n^3 - (visible cubes)

replacing n by N

Soln: N^2 - 6N^(4/3) + 12N^(2/3) - 8

sum1 on Jan 9, 2011
0

Its simply :
No. of small cubes in Outer Cube - No. of small cubes in inner cube
n^3 - (n-2)^3 = 6n^2 - 12n + 8 for n >=2

Gaurav on Jun 16, 2011
1

The question is for cubes "no exposed to the outside". So the answer is just the count of inner cubes which is
(n-2)^3 for n>=2

But more precisely the question should be "Given a cube made of N^3 sub cubes".

Simon on Oct 12, 2011

Add Answers or Comments

To comment on this, Sign In or Sign Up.