LeetCode 551 Student Attendance Record I
来源:互联网 发布:韩子高网络剧有下部吗 编辑:程序博客网 时间:2024/06/05 18:04
题目:
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 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题目链接
题意:
有一个学生出勤表,表中仅有三种情况”A“代表缺席,”L“代表迟到,”P“代表在场,评奖要求缺席次数不超过1次,且不得连续迟到两次以上,否则取消评奖资格,先给一个出勤表,问该学生是否有资格获奖。
利用变量统计次数即可。
代码如下:
class Solution {public: bool checkRecord(string s) { map<char, int> dic; for (char c : s) { dic[c] ++; if (c != 'L') dic['L'] = 0; if (dic['A']>1 || dic['L']>2) return false; } return true; }};
阅读全文
0 0
- leetcode 551 Student Attendance Record I C++
- Leetcode 551 Student Attendance Record I
- LeetCode 551 Student Attendance Record I
- Leetcode 551 Student Attendance Record I
- leetcode 551[easy]-- Student Attendance Record I
- LeetCode 551:Student Attendance Record I (c++)
- LeetCode 551. Student Attendance Record I
- 【LeetCode】Student Attendance Record I 解题报告
- [LeetCode]551. Student Attendance Record I
- LeetCode 551. Student Attendance Record I
- [leetcode]: 551. Student Attendance Record I
- [leetcode: Python]551. Student Attendance Record I
- [leetcode]551. Student Attendance Record I
- LeetCode-551. Student Attendance Record I (Java)
- leetcode#551. Student Attendance Record I
- leetcode 551. Student Attendance Record I
- leetcode 551. Student Attendance Record I
- LeetCode-551. Student Attendance Record I
- 网络爬虫框架设计与实现
- 计算机语言的基本结构
- String类的简要介绍
- No UserDatabase component found under key UserDatabase
- java 监控系统项目分享!
- LeetCode 551 Student Attendance Record I
- python求解非递减排序的数组的一个旋转的最小元素
- POJ-3684 Physics Experiment(弹性碰撞)
- 问题 D: 天神下凡
- Puzzle HDU
- hdu 多校联赛 TrickGCD
- spring+springmvc+hibernate,实现分页功能
- hdu5692(dfs序+线段树 )Snacks
- 设计模式之禅笔记-命令模式