Leetcode Problem 422. Valid Word Square

422. Valid Word Square

Leetcode Solutions

Iterate on the Matrix

  1. Loop over each word in the list with index wordNum.
  2. For each word, loop over each character in the word with index charPos.
  3. Check if charPos is within the bounds of the other words in the list.
  4. If charPos is out of bounds or the characters at (wordNum, charPos) and (charPos, wordNum) do not match, return false.
  5. If all characters match for all words, return true after the loops complete.
UML Thumbnail

Storing New Words

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...