Google | Phone | Spell word with wooden blocks
Anonymous User
1820

I applied to Google via internal referral.

Passed my first phone screen. I got this question on the second phone screen.

You have a word n letters long. You can spell the word out using n 6-sided wooden spelling blocks. A block can only be used once to spell the word.

Example given (more or less, I don't remember the exact example):

Spell the word GOOGLE using these blocks:

1: [G , B , A, C, D , E]
2: [Q , L , M, O, B, C]
3: [M, O, X, Q, Z, A]
4: [G, M, T, L, N, E]
5: [F, N, B, R, E, V]
6: [C, D, E , F, G, H]

In this example, you can spell the word by arranging the blocks in this order [1, 2, 3, 6, 4, 5]

The return value is an array of size n, containing the order in which you would arrange the blocks to spell the word. There may be multiple solutions, just return one of them.

The interviewer said my approach was going in the right direction (backtracking), but I couldn't quite solve it in time. I spent too much time initially on a brute force approach that wouldn't work.

Comments (6)