Ctrl K

Perfect Attendance Bonus

Easy
An employee's timesheet is a string log where each character describes one working day: - 'P': on time; - 'L': late; - 'A': absent. The attendance bonus is earned when both hold: - there are fewer than two absences ('A') over the whole period; - there are never three or more lates ('L') on consecutive days. Return True if the employee earns the bonus and False otherwise.
Example 1
log='PLPALLP' → True

One absence, and lates come at most two days in a row, so the bonus is earned.

Example 2
log='APPPPA' → False

Two absences are already too many.

Example 3
log='PLLLP' → False

Three lates in a row.

Constraints
  • 1 ≤ log.length ≤ 1000
  • every character of log is 'A', 'L' or 'P'
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasyShared Start of Words EasyBracket Balance EasyWhere the Fragment Starts EasyLength of the Final Word Easy
loading Python…
Input
log='PLPALLP'
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 184 tests on the server, hidden ones included.