学生出勤记录问题
问题描述:给定一些字符串表示学生的出勤记录。
例如:PPALLP
其中 A 表示Absent;L表示 Late;P表示 Present。
学生获得表彰的条件是出勤记录中不能存在A,或者两个以上(不含两个)的L。
请写一个算法,分析给定的出勤记录,判断学生是否能够获得表彰。
算法设计:
package com.bean.basic;
public class StudentAttendanceRecordDemo2 {
/*
* You are given a string representing an attendance record for a student.
* The record only contains the following three characters:
* 1.'A' : Absent.
* 2.'L' : Late.
* 3.'P' : Present.
* A student could be rewarded if his attendance record doesn't contain more than one 'A' (absent)
* or more than two continuous 'L' (late).
* You need to return whether the student could be rewarded according to his attendance record.
*
* Example 1:
* Input: "PPALLP"
* Output: True
*
* Example 2:
* Input: "PPALLL"
* Output: False
*
* */
/*
* Solution 1(解法 1)
* */
// public static boolean checkRecord(String s) {
// int a = 0, l = 0;