Tap here to switch tabs
Problem
Submissions

Problem: Word Squares II

Try to solve the Word Squares II problem.

Statement

Given an array of strings words where each word has a length of 44, find all valid word squares that can be formed using four words: top, left, right, and bottom.

A word square is valid if it satisfies the following corner constraints:

  • top[0] == left[0] (top left corner)

  • top[3] == right[0] (top right corner)

  • bottom[0] == left[3] (bottom left corner)

  • bottom[3] == right[3] (bottom right corner)

Return all valid word squares as a list of lists of strings, where each square is represented in the order [top, left, right, bottom]. The results may be returned in any order.

Constraints:

  • 4≤4 \leq words.length ≤15\leq 15

  • words[i].length ==4== 4

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

  • All words[i] are distinct.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Word Squares II

Try to solve the Word Squares II problem.

Statement

Given an array of strings words where each word has a length of 44, find all valid word squares that can be formed using four words: top, left, right, and bottom.

A word square is valid if it satisfies the following corner constraints:

  • top[0] == left[0] (top left corner)

  • top[3] == right[0] (top right corner)

  • bottom[0] == left[3] (bottom left corner)

  • bottom[3] == right[3] (bottom right corner)

Return all valid word squares as a list of lists of strings, where each square is represented in the order [top, left, right, bottom]. The results may be returned in any order.

Constraints:

  • 4≤4 \leq words.length ≤15\leq 15

  • words[i].length ==4== 4

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

  • All words[i] are distinct.