java.lang.Object
g0501_0600.s0551_student_attendance_record_i.Solution

public class Solution extends Object
551 - Student Attendance Record I.<p>Easy</p> <p>You are given a string <code>s</code> representing an attendance record for a student where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters:</p> <ul> <li><code>'A'</code>: Absent.</li> <li><code>'L'</code>: Late.</li> <li><code>'P'</code>: Present.</li> </ul> <p>The student is eligible for an attendance award if they meet <strong>both</strong> of the following criteria:</p> <ul> <li>The student was absent (<code>'A'</code>) for <strong>strictly</strong> fewer than 2 days <strong>total</strong>.</li> <li>The student was <strong>never</strong> late (<code>'L'</code>) for 3 or more <strong>consecutive</strong> days.</li> </ul> <p>Return <code>true</code> <em>if the student is eligible for an attendance award, or</em> <code>false</code> <em>otherwise</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;PPALLP&rdquo;</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> The student has fewer than 2 absences and was never late 3 or more consecutive days.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;PPALLL&rdquo;</p> <p><strong>Output:</strong> false</p> <p><strong>Explanation:</strong> The student was late 3 consecutive days in the last 3 days, so is not eligible for the award.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 1000</code></li> <li><code>s[i]</code> is either <code>'A'</code>, <code>'L'</code>, or <code>'P'</code>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • checkRecord

      public boolean checkRecord(String s)