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的更多相关文章

  1. [Swift]LeetCode551. 学生出勤纪录 I | Student Attendance Record I

    You are given a string representing an attendance record for a student. The record only contains the ...

  2. Leetcode551.Student Attendance Record I学生出勤记录1

    给定一个字符串来代表一个学生的出勤纪录,这个纪录仅包含以下三个字符: 'A' : Absent,缺勤 'L' : Late,迟到 'P' : Present,到场 如果一个学生的出勤纪录中不超过一个' ...

随机推荐

  1. LG3804 【模板】后缀自动机

    题意 给定一个只包含小写字母的字符串\(S\), 请你求出 \(S\) 的所有出现次数不为 \(1\) 的子串的出现次数乘上该子串长度的最大值. 对于\(100\%\) 的数据,\(|S| \leq ...

  2. 转 Apache Kafka:下一代分布式消息系统

    简介 Apache Kafka是分布式发布-订阅消息系统.它最初由LinkedIn公司开发,之后成为Apache项目的一部分.Kafka是一种快速.可扩展的.设计内在就是分布式的,分区的和可复制的提交 ...

  3. RabbitMQ之监控

    RabbitMQ作为一个工业级的消息中间件,肯定是缺少不了监控的,RabbitMQ提供了WEB版的页面监控(访问地址:http://xxx.xxx.xxx.xxx:15672/,默认端口号是15672 ...

  4. opencv mat flags含义

    f:\opencv\opencv\sources\modules\core\src\matrix.cpp:  flags = (_type & CV_MAT_TYPE_MASK) | MAGI ...

  5. 小米盒子 作为nas服务器

    1. webdav缺点:慢优点:方便,不许额外软件 http://blog.csdn.net/laoyiin/article/details/9283023 sw webdav 2. smb缺点:不可 ...

  6. windows python3 安装gittle

    1 从github clone gittle项目, git clone https://github.com/FriendCode/gittle.git 2 进行到下载的项目,执行安装 python ...

  7. bzoj 3674 可持久化并查集加强版——可持久化并查集

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3674 用主席树维护 fa[ ]  和 siz[ ] .改 fa[ ] 和改 siz[ ] 都 ...

  8. 转jmeter --JDBC请求

    做JDBC请求,首先要了解这个JDBC对象是什么,然后寻找响应的数据库连接URL和数据库驱动. 数据库URL:jdbc:sqlserver://200.99.197.190:1433;database ...

  9. oracle常用数据类型说明

    类型 含义 存储描述 备注 CHAR 固定长度字符串 最大长度2000bytes VARCHAR2 可变长度的字符串, 最大长度4000bytes 可做索引的最大长度749 NCHAR 根据字符集而定 ...

  10. CentOS Linux解决Device eth0 does not seem to be present 但是没有发现eth1

    http://www.linuxidc.com/Linux/2012-12/76248.htm 此标题已经是有人写过的了.但是为什么拿来重写? 我复制完,没有发现有eth1这个网卡 为什么呢?需要选中 ...