java.lang.Object
g0501_0600.s0552_student_attendance_record_ii.Solution

public class Solution extends Object
552 - Student Attendance Record II.<p>Hard</p> <p>An attendance record for a student can be represented as a string 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>Any 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>Given an integer <code>n</code>, return <em>the <strong>number</strong> of possible attendance records of length</em> <code>n</code> <em>that make a student eligible for an attendance award. The answer may be very large, so return it <strong>modulo</strong></em> <code>10<sup>9</sup> + 7</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> n = 2</p> <p><strong>Output:</strong> 8</p> <p><strong>Explanation:</strong></p> <pre><code> There are 8 records with length 2 that are eligible for an award: &quot;PP&quot;, &quot;AP&quot;, &quot;PA&quot;, &quot;LP&quot;, &quot;PL&quot;, &quot;AL&quot;, &quot;LA&quot;, &quot;LL&quot; Only &quot;AA&quot; is not eligible because there are 2 absences (there need to be fewer than 2). </code></pre> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 1</p> <p><strong>Output:</strong> 3</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> n = 10101</p> <p><strong>Output:</strong> 183236316</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= n <= 10<sup>5</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • checkRecord

      public int checkRecord(int n)