bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
HardTriesLC 425

Word Squares

Given an array of unique strings words, return all the word squares you can build from_ words. The same word from words can be used multiple times. You can return the answer in any order. A sequence of strings forms a valid word square if the kth row and column read the same string, where 0 <= k < max(numRows, numColumns). For example, the word sequence [ "ball ", "area ", "lead ", "lady "] forms a word square because each word reads the same both horizontally and vertically.

Asked at 2 companies
GoogleOracle
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode