bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 551. Student Attendance Record I

551. Student Attendance Record I

Leetcode Solutions

Approach # Single pass Solution (Without indexOf method)

  1. Initialize absentCount to 0 and consecutiveLate to 0.
  2. Iterate through each character in the string s. a. If the current character is 'A', increment absentCount. b. If absentCount is greater than 1, return false. c. If the current character is 'L', increment consecutiveLate. d. If the current character is not 'L', reset consecutiveLate to 0. e. If consecutiveLate reaches 3, return false.
  3. If the loop completes without returning false, return true.
UML Thumbnail

Approach # Simple Solution

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...