Yahoo Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
2
of 2 vote

for 3d - (n^3 - (n-2)^3)
for kd - (n^k - (n-2)^k)

- dp September 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nice solution!

- Anonymous March 12, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Like

- gsn July 21, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Very nice!

- Delon August 14, 2011 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Nice solution, but what's the rationale here? I tabulated for k=3 and n from 1 to 5 and got:

n | cubes | hidden cubes
1        1                0
2        8                0
3       27               1
4       64               8
5      125              27

You can clearly 'see' the relationship (n-2). But how one can arrive to this in a more smart way?

- still code March 03, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@still_code: You consider the "inner" cube of side (n-2). Now subtract the inner cubes from the total to give you the number of 1x1x1 cubes on the surface.

- Loler March 03, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

2(n^2) + 4(n-2) + 4((n-2)^2)

which can be simplied to : 2(n^2) + 4(n-1)*(n-2)

for n=3 it comes out as 26
for n=4 it is 56.
is this the correct solution..?

- Anonymous September 15, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

lets have n=1;
this is trivial 1 surface exposed;
n=2 here we have all 8 cubes exposed;
n=3 here we have one cube innermost cube jiddedn and rest all exposed;

so we have by symmetry following relations

n*n*n - (n-2)*(n-2)*(n-2)... cubes on surfacce as all the rest would be innermost ones. ,,

however what on earth does k dimension mean here..

- Amit Priyadarshi September 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

1D: Object=line segment, surface=2 ends.
n small line segments, n-2 inner ones.
n - (n-2) = 2 mini-segments exposed.

2D: Object = (filled) square, surface = square outline.
n^2 small squares, (n-2)^2 inner squares.
n^2 - (n-2)^2 mini-squares exposed.

3D: Object = cube
n^3 - (n-2)^3

kD: n^k - (n-2)^k

Simple :-)

- czpete October 13, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

brilliant k-D extension :-)

- Prince December 15, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

great answer

- siva.sai.2020 February 08, 2011 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More