Tap here to switch tabs
Problem
Submissions

Problem: Word Squares

Try to solve the Word Squares problem.

Statement

Given an array of unique strings words, return all valid word squares that can be constructed from words. You may return the result in any order.

A sequence of words forms a valid word square if the kextthk^{ ext{th}} row and kextthk^{ ext{th}} column read the exact same string for every valid index kk.

Note: The same word may be used multiple times when constructing a word square.

Constraints:

  • 1≤1 \leq words.length ≤1000\leq 1000

  • 1≤1 \leq words[i].length ≤4\leq 4

  • All words[i] have the same length.

  • words[i] consists of only lowercase English letters.

  • All strings in words are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Word Squares

Try to solve the Word Squares problem.

Statement

Given an array of unique strings words, return all valid word squares that can be constructed from words. You may return the result in any order.

A sequence of words forms a valid word square if the kextthk^{ ext{th}} row and kextthk^{ ext{th}} column read the exact same string for every valid index kk.

Note: The same word may be used multiple times when constructing a word square.

Constraints:

  • 1≤1 \leq words.length ≤1000\leq 1000

  • 1≤1 \leq words[i].length ≤4\leq 4

  • All words[i] have the same length.

  • words[i] consists of only lowercase English letters.

  • All strings in words are unique.