forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_551.java
30 lines (27 loc) · 867 Bytes
/
_551.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
27
28
29
30
package com.fishercoder.solutions;
public class _551 {
public static class Solution1 {
public boolean checkRecord(String s) {
int aCount = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == 'A') {
aCount++;
if (aCount > 1) {
return false;
}
} else if (s.charAt(i) == 'L') {
int continuousLCount = 0;
while (i < s.length() && s.charAt(i) == 'L') {
i++;
continuousLCount++;
if (continuousLCount > 2) {
return false;
}
}
i--;
}
}
return true;
}
}
}