File tree Expand file tree Collapse file tree 1 file changed +0
-69
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +0
-69
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import java .util .List ;
4
4
5
- /**
6
- * 422. Valid Word Square
7
- *
8
- * Given a sequence of words, check whether it forms a valid word square.
9
-
10
- A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤ k < max(numRows, numColumns).
11
-
12
- Note:
13
- The number of words given is at least 1 and does not exceed 500.
14
- Word length will be at least 1 and does not exceed 500.
15
- Each word contains only lowercase English alphabet a-z.
16
- Example 1:
17
-
18
- Input:
19
- [
20
- "abcd",
21
- "bnrt",
22
- "crmy",
23
- "dtye"
24
- ]
25
-
26
- Output:
27
- true
28
-
29
- Explanation:
30
- The first row and first column both read "abcd".
31
- The second row and second column both read "bnrt".
32
- The third row and third column both read "crmy".
33
- The fourth row and fourth column both read "dtye".
34
-
35
- Therefore, it is a valid word square.
36
- Example 2:
37
-
38
- Input:
39
- [
40
- "abcd",
41
- "bnrt",
42
- "crm",
43
- "dt"
44
- ]
45
-
46
- Output:
47
- true
48
-
49
- Explanation:
50
- The first row and first column both read "abcd".
51
- The second row and second column both read "bnrt".
52
- The third row and third column both read "crm".
53
- The fourth row and fourth column both read "dt".
54
-
55
- Therefore, it is a valid word square.
56
- Example 3:
57
-
58
- Input:
59
- [
60
- "ball",
61
- "area",
62
- "read",
63
- "lady"
64
- ]
65
-
66
- Output:
67
- false
68
-
69
- Explanation:
70
- The third row reads "read" while the third column reads "lead".
71
-
72
- Therefore, it is NOT a valid word square.
73
- */
74
5
public class _422 {
75
6
76
7
public static class Solution1 {
You can’t perform that action at this time.
0 commit comments