#3799
Word Squares II
specialist · 820 · lc medium +31 · 54.8% accepted · 55 likes · top 48%
Description
Given a list words of distinct 4-letter lowercase strings, find all arrangements of four distinct words (top, left, right, bottom) that form a valid word square — satisfying top[0]==left[0], top[3]==right[0], bottom[0]==left[3], and bottom[3]==right[3] — and return them sorted lexicographically by the 4-tuple (top, left, right, bottom).
Code
1
2
3