Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0527f0a

Browse files
String: 551. Student Attendance Record I
1 parent 9d861c7 commit 0527f0a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// https://leetcode.com/problems/student-attendance-record-i/description/
2+
/**
3+
* 551. Student Attendance Record I
4+
* @param {string} s
5+
* @return {boolean}
6+
*/
7+
var checkRecord = function(s) {
8+
s = s.replace('A', 'B');
9+
if (s.indexOf('A') > -1) return false;
10+
let last2 = s[0];
11+
let last1 = s[1];
12+
for (let i = 2; i < s.length; i++) {
13+
if (s[i] === 'L' && last1 === 'L' && last2 === 'L') {
14+
return false;
15+
}
16+
last2 = last1;
17+
last1 = s[i];
18+
}
19+
return true;
20+
};
21+
var checkRecord = function(s) {
22+
if (s.indexOf('LLL') > -1) return false;
23+
s = s.replace('A', '');
24+
if (s.indexOf('A') > -1) return false;
25+
return true;
26+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /