forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_422.java
26 lines (23 loc) · 755 Bytes
/
_422.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.fishercoder.solutions;
import java.util.List;
public class _422 {
public static class Solution1 {
public boolean validWordSquare(List<String> words) {
for (int i = 0; i < words.size(); i++) {
String word = words.get(i);
for (int j = 0; j < word.length(); j++) {
if (j >= words.size()) {
return false;
}
if (i >= words.get(j).length()) {
return false;
}
if (word.charAt(j) != words.get(j).charAt(i)) {
return false;
}
}
}
return true;
}
}
}