Tap here to switch tabs
Problem
Submissions

Problem: Valid Word Square

med
30 min
Try to solve the Valid Word Square problem.

Statement

Given an array of strings words, return true if it forms a valid word square, or false otherwise.

A sequence of strings forms a valid word square if the kthk^{th} row and kthk^{th} column read the exact same string for every valid index kk. Specifically, the string formed by reading the characters of the kthk^{th} column from top to bottom must be identical to the kthk^{th} string in words.

Constraints:

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

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Valid Word Square

med
30 min
Try to solve the Valid Word Square problem.

Statement

Given an array of strings words, return true if it forms a valid word square, or false otherwise.

A sequence of strings forms a valid word square if the kthk^{th} row and kthk^{th} column read the exact same string for every valid index kk. Specifically, the string formed by reading the characters of the kthk^{th} column from top to bottom must be identical to the kthk^{th} string in words.

Constraints:

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

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

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