Resource Library

Below you can find all of the different resources in the Guide: practice problems, former Google interview questions, online courses, videos, and more.

Back to all resources
  • Former interview question: word squares

    Pit yourself against this problem that asks you to write a program that can identify word sequences defined as word squares, and then return all word square sequences within a given list of words.

    Mark as complete Save for later
  • A “word square” is an ordered sequence of K different words of length K that, when written one word per line, reads the same horizontally and vertically. For example:

    BALLAREALEADLADY    

    In this exercise you're going to create a way to find word squares.

    First, design a way to return true if a given sequence of words is a word square.

    Second, given an arbitrary list of words, return all the possible word squares it contains. Reordering is allowed.

    For example, the input list

    [AREA, BALL, DEAR, LADY, LEAD, YARD]

    should output

    [(BALL, AREA, LEAD, LADY), (LADY, AREA, DEAR, YARD)]

    Finishing the first task should help you accomplish the second task.

    Learning objectives

    This problem gives practice with algorithms, recursion, arrays, progressively optimizing from an initial solution, and testing.