Word Squares

Given a list of words that all have the same length L, return every word square that can be formed.

A word square is an L by L grid where row i read from left to right equals column i read from top to bottom, for every i. Equivalently, the list of rows w0, w1, ..., wL-1 satisfies w[i][j] == w[j][i] for every pair of positions.

Every row must be one of the supplied words. A word may be used in several rows, and the same word square must not be returned twice. If no word square exists, return an empty list.

Examples
Input: ["area","lead","wall","lady","ball"]
Output: [["ball","area","lead","lady"],["wall","area","lead","lady"]]
Hints

Word Squares

Given a list of words that all have the same length `L`, return every word square that can be formed.