551. Student Attendance Record I
来源:互联网 发布:无人机航拍软件 编辑:程序博客网 时间:2024/06/05 19:41
551. Student Attendance Record I
Problem 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' : 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: TrueExample 2:Input: "PPALLL"Output: False
Implementation
class Solution {public: bool checkRecord(string s) { char rec = 0; int s_len = s.size(); for(int idx = 0; idx < s_len; idx++) { if(s[idx] == 'A') { if(rec & 0xf0) { return false; } else { rec = 0x80; } } else if(s[idx] == 'L') { if(rec & 0x02) { return false; } else { rec++; } } else { rec &= 0xf0; } } return true; }};
阅读全文
0 0
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- Student Attendance Record I
- Student Attendance Record I
- Student Attendance Record I
- LeetCode 551. Student Attendance Record I
- [LeetCode]551. Student Attendance Record I
- LeetCode 551. Student Attendance Record I
- FrameLayout布局使用问题(一)
- 使用AngularJS制作一个选项卡
- Python 中glob模块使用笔记
- 用DFS求连通块(油田Oil Deposits,UVa 572)
- HTML_用参数判断轮播-小标签-文字图片轮播-第一挪到最后的无缝滚动轮播
- 551. Student Attendance Record I
- SQL Server 设置默认数据库
- ThreadLocal基本使用和源码分析
- Windows核心编程的官方网站
- BigDecimal除法运算出现java.lang.ArithmeticException: Non-terminating decimal expansion; no exact represent
- tcp系列文章学习总结
- Markdown常用技巧
- skia库的3D变换研究
- Android开发工作中遇到的重点和难点总结