You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attendance record doesn't contain more than o…
给定一个字符串来代表一个学生的出勤纪录,这个纪录仅包含以下三个字符: 'A' : Absent,缺勤 'L' : Late,迟到 'P' : Present,到场 如果一个学生的出勤纪录中不超过一个'A'(缺勤)并且不超过两个连续的'L'(迟到),那么这个学生会被奖赏. 你需要根据这个学生的出勤纪录判断他是否会被奖赏. 示例 1: 输入: "PPALLP" 输出: True 示例 2: 输入: "PPALLL" 输出: False class Solution {…
给定一个正整数 n,返回长度为 n 的所有可被视为可奖励的出勤记录的数量. 答案可能非常大,你只需返回结果mod 109 + 7的值.学生出勤记录是只包含以下三个字符的字符串:    1.'A' : Absent,缺勤    2.'L' : Late,迟到    3.'P' : Present,到场如果记录不包含多于一个'A'(缺勤)或超过两个连续的'L'(迟到),则该记录被视为可奖励的.示例:输入: n = 2输出: 8 解释:有8个长度为2的记录将被视为可奖励:"PP" , &qu…
You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attendance record doesn't contain more than o…
给定一个字符串来代表一个学生的出勤纪录,这个纪录仅包含以下三个字符:    'A' : Absent,缺勤    'L' : Late,迟到    'P' : Present,到场如果一个学生的出勤纪录中不超过一个'A'(缺勤)并且不超过两个连续的'L'(迟到),那么这个学生会被奖赏.你需要根据这个学生的出勤纪录判断他是否会被奖赏.示例 1:输入: "PPALLP"输出: True 示例 2:输入: "PPALLL"输出: False详见:https://leetc…
552. 学生出勤记录 II 给定一个正整数 n,返回长度为 n 的所有可被视为可奖励的出勤记录的数量. 答案可能非常大,你只需返回结果mod 109 + 7的值. 学生出勤记录是只包含以下三个字符的字符串: 'A' : Absent,缺勤 'L' : Late,迟到 'P' : Present,到场 如果记录不包含多于一个'A'(缺勤)或超过两个连续的'L'(迟到),则该记录被视为可奖励的. 示例 1: 输入: n = 2 输出: 8 解释: 有8个长度为2的记录将被视为可奖励: "PP&qu…
学生出勤记录II 给定一个正整数 n,返回长度为 n 的所有可被视为可奖励的出勤记录的数量. 答案可能非常大,你只需返回结果mod 109 + 7的值. 学生出勤记录是只包含以下三个字符的字符串: 'A' : Absent,缺勤 'L' : Late,迟到 'P' : Present,到场 如果记录不包含多于一个'A'(缺勤)或超过两个连续的'L'(迟到),则该记录被视为可奖励的. 示例 1: 输入: n = 2 输出: 8 解释: 有8个长度为2的记录将被视为可奖励: "PP" ,…
Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after mod 109 + 7. A student attendance record is a string that only contain…
Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after mod 109 + 7. A student attendance record is a string that only contain…
Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after mod 109 + 7. A student attendance record is a string that only contain…
题目如下: Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after mod 109 + 7. A student attendance record is a string that only c…
Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after mod 109 + 7. A student attendance record is a string that only contain…
[抄题]: You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attendance record doesn't contain more…
这是悦乐书的第258次更新,第271篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第125题(顺位题号是551).您将获得一个表示学生出勤记录的字符串. 该记录仅包含以下三个字符: 'A':缺席. 'L':迟到. 'P':在场. 如果学生的出勤记录不超过一个"A"(缺席)或超过两个连续的"L"(迟到),则可以奖励学生.您需要返回学生是否可以根据他的出勤记录获得奖励.例如: 输入:"PPALLP" 输出:true 输入…
/* * @lc app=leetcode.cn id=551 lang=java * * [551] 学生出勤记录 I * * https://leetcode-cn.com/problems/student-attendance-record-i/description/ * * algorithms * Easy (46.31%) * Total Accepted: 3.5K * Total Submissions: 7.6K * Testcase Example: '"PPALLP&qu…
551. Student Attendance Record I[easy] You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attend…
problem 551. Student Attendance Record I 题意: solution: class Solution { public: bool checkRecord(string s) { ; ; for(auto ch:s) { if('A'==ch) { ) return false;// cntL = ;// } else if('L' == ch) { ) return false;// } ;// } return true; } }; 理解题意很简单,重要…
551. 学生出勤记录 I 给定一个字符串来代表一个学生的出勤记录,这个记录仅包含以下三个字符: 'A' : Absent,缺勤 'L' : Late,迟到 'P' : Present,到场 如果一个学生的出勤记录中不超过一个'A'(缺勤)并且不超过两个连续的'L'(迟到),那么这个学生会被奖赏. 你需要根据这个学生的出勤记录判断他是否会被奖赏. 示例 1: 输入: "PPALLP" 输出: True 示例 2: 输入: "PPALLL" 输出: False cla…
You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attendance record doesn't contain more than o…
▶ 一个学生的考勤状况是一个字符串,其中各字符的含义是:A 缺勤,L 迟到,P 正常.如果一个学生考勤状况中 A 不超过一个,且没有连续两个 L(L 可以有多个,但是不能连续),则称该学生达标(原文表述:A student could be rewarded if his attendance record doesn't contain more than one 'A' (absent) or more than two continuous 'L' (late). ) ▶ 551. 给定一…
问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3953 访问. 给定一个字符串来代表一个学生的出勤纪录,这个纪录仅包含以下三个字符: 'A' : Absent,缺勤 'L' : Late,迟到 'P' : Present,到场 如果一个学生的出勤纪录中不超过一个'A'(缺勤)并且不超过两个连续的'L'(迟到),那么这个学生会被奖赏. 你需要根据这个学生的出勤纪录判断他是否会被奖赏. 输入: "PPALLP&qu…
描述 You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attendance record doesn't contain more tha…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 正则表达式 统计 日期 题目地址:https://leetcode.com/problems/student-attendance-record-i/#/description 题目描述 You are given a string representing an attendance record for a student. The record…
You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attendance record doesn't contain more than o…
题目: You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attendance record doesn't contain more th…
1.题目描述 You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attendance record doesn't contain more…
原题链接在这里:https://leetcode.com/problems/student-attendance-record-i/description/ 题目: You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Presen…
给定一个字符串来代表一个学生的出勤记录,这个记录仅包含以下三个字符: 'A' : Absent,缺勤 'L' : Late,迟到 'P' : Present,到场 如果一个学生的出勤记录中不超过一个'A'(缺勤)并且不超过两个连续的'L'(迟到),那么这个学生会被奖赏. 你需要根据这个学生的出勤记录判断他是否会被奖赏. 示例 1: 输入: "PPALLP" 输出: True 示例 2: 输入: "PPALLL" 输出: False 做法比较清晰,当A的次数大于1时,…
string类中有很多好用的函数,这里介绍在string类字符串中查找字符串的函数. string类字符串中查找字符串一般可以用: 1.s.find(s1)函数,从前往后查找与目标字符串匹配的第一个位置: 2.s.rfind(s1)函数,从后往前查找与目标字符串匹配的最后一个位置: 3.s.find_first_of(s1),查找在s1中任意一个字符在s中第一次出现的位置 4.s.find_last_of(s1)       查找在s1中任意一个字符在s中最后一次出现的位置 下面给出一道例题:…
static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { public: bool checkRecord(string s) { ; int len=s.length(); ;i<len;i++) { if(s[i]=='A') countA++; if(s[i]=='L') { <len&&s[i+]==]=='L') return fals…