551. 学生出勤记录 I

题目链接:https://leetcode-cn.com/problems/student-attendance-record-i/

执行用时:4 ms, 在所有 Swift 提交中击败了100.00% 的用户
内存消耗:13.9 MB, 在所有 Swift 提交中击败了100.00% 的用户

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Solution {
func checkRecord(_ s: String) -> Bool {
var A = 0, L = 0
for i in s {
switch i {
case "A":
A += 1
L = 0
case "L":
L += 1
default:
L = 0
}
if A > 1 || L > 2 {
return false
}
}
return true
}
}



551. 学生出勤记录 I
https://pisces34.github.io/2021/08/18/leetcode/student/
发布于
2021年8月18日
许可协议