Skip to content

Commit 75890d5

Browse files
committed
Add solution #551
1 parent b57247f commit 75890d5

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
451|[Sort Characters By Frequency](./0451-sort-characters-by-frequency.js)|Medium|
8383
459|[Repeated Substring Pattern](./0459-repeated-substring-pattern.js)|Easy|
8484
541|[Reverse String II](./0541-reverse-string-ii.js)|Easy|
85+
551|[Student Attendance Record I](./0551-student-attendance-record-i.js)|Easy|
8586
565|[Array Nesting](./0565-array-nesting.js)|Medium|
8687
566|[Reshape the Matrix](./0566-reshape-the-matrix.js)|Easy|
8788
606|[Construct String from Binary Tree](./0606-construct-string-from-binary-tree.js)|Easy|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* 551. Student Attendance Record I
3+
* https://leetcode.com/problems/student-attendance-record-i/
4+
* Difficulty: Easy
5+
*
6+
* You are given a string s representing an attendance record for a student
7+
* where each character signifies whether the student was absent, late, or
8+
* present on that day. The record only contains the following three characters:
9+
* - 'A': Absent.
10+
* - 'L': Late.
11+
* - 'P': Present.
12+
*
13+
* The student is eligible for an attendance award if they meet both of the following criteria:
14+
* - The student was absent ('A') for strictly fewer than 2 days total.
15+
* - The student was never late ('L') for 3 or more consecutive days.
16+
*
17+
* Return true if the student is eligible for an attendance award, or false otherwise.
18+
*/
19+
20+
/**
21+
* @param {string} s
22+
* @return {boolean}
23+
*/
24+
var checkRecord = function(s) {
25+
return !s.includes('LLL') && (s.indexOf('A') === s.lastIndexOf('A'));
26+
};

0 commit comments

Comments
 (0)