leetcode551
public class Solution
{
public bool CheckRecord(string s)
{
var Absent = ;
var MaxLate = ;
var ContiLate = ;
var preChar = '\0';
for (int i = ; i < s.Length; i++)
{
var c = s[i];
if (c == 'A')
{
Absent++;
preChar = c;
if (MaxLate < ContiLate)
{
MaxLate = ContiLate;
}
ContiLate = ;
}
else if (c == 'L')
{
if (ContiLate == )
{
ContiLate = ;
preChar = c;
}
else
{
if (preChar == c)
{
ContiLate++;
preChar = c;
}
else
{
ContiLate = ;
preChar = c;
}
}
}
else
{
if (MaxLate < ContiLate)
{
MaxLate = ContiLate;
}
ContiLate = ;
}
} if (MaxLate < ContiLate)
{
MaxLate = ContiLate;
} if (Absent > || MaxLate > )
{
return false;
}
else
{
return true;
}
}
}
https://leetcode.com/problems/student-attendance-record-i/#/description
leetcode551的更多相关文章
- [Swift]LeetCode551. 学生出勤纪录 I | Student Attendance Record I
You are given a string representing an attendance record for a student. The record only contains the ...
- Leetcode551.Student Attendance Record I学生出勤记录1
给定一个字符串来代表一个学生的出勤纪录,这个纪录仅包含以下三个字符: 'A' : Absent,缺勤 'L' : Late,迟到 'P' : Present,到场 如果一个学生的出勤纪录中不超过一个' ...
随机推荐
- test20180919 选择客栈
题意 分析 不难发现把增加人数看成减少人数,上限是w 看成总数是w,问题就变成了询问有多少个子区间没有0. 考虑这个问题困难在哪里,就是区间加减法让我们不好判断0 的位置. 因为题目保证每个位置的值非 ...
- 【转】python mysql数据库 'latin-1' codec can't encode character错误问题解决
UnicodeEncodeError: 'latin-1' codec can't encode character "UnicodeEncodeError:'latin-1' code ...
- nyoj 最小公倍数
最小公倍数 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 为什么1小时有60分钟,而不是100分钟呢?这是历史上的习惯导致. 但也并非纯粹的偶然:60是个优秀的数字 ...
- MQ的不足
调用方实时依赖执行结果的业务场景,请使用调用,而不是MQ.MQ是互联网分层架构中的解耦利器,那所有通讯都使用MQ岂不是很好?这是一个严重的误区,调用与被调用的关系,是无法被MQ取代的.比如用户登录场景 ...
- saltops 安装及相关环境安装
本次布署测试环境 阿里云 Centos 7.3 1.安装nginx,这里采用yum 安装方式 A.yum install nginx B.创建开机启动 systemctl enable nginx.s ...
- RabbitMQ-官方指南-RabbitMQ配置
原文:http://www.rabbitmq.com/configure.html RabbitMQ 提供了三种方式来定制服务器: 环境变量 定义端口,文件位置和名称(接受shell输入,或者在环境配 ...
- 注意字符串的strlen与sizeof的差别
unsigned char AT_RESET[]="r\r\n"; printf("strlen=%d sizeof=%d\n",strlen(AT_RESET ...
- bzoj 4556 [Tjoi2016&Heoi2016]字符串——后缀数组+主席树
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4556 本来只要查 ht[ ] 数组上的前驱和后继就行,但有长度的限制.可以二分答案解决!然后 ...
- UOJ 188 【UR #13】Sanrd——min_25筛
题目:http://uoj.ac/problem/188 令 \( s(n,j)=\sum\limits_{i=1}^{n}[min_i>=p_j]f(j) \) ,其中 \( min_i \) ...
- cc2530 AES加密
快速配置 Z-stack对Zigbee2006提供了全面的支持,功能之强大,性能稳定.安全性高,说到安全性是我们今天的主题.CC2430硬件支持128bit的AES加密算法,在协议栈中为了避开相同设备 ...