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,到场 如果一个学生的出勤纪录中不超过一个' ...
随机推荐
- Cassandra 数据库, python cqlsh命令
★ cql操作数据库(cqlsh.bat: python cqlsh命令操作<优缺点:https://blog.csdn.net/vbirdbest/article/details/77662 ...
- LG4197 Peaks
题意 题目描述 在Bytemountains有N座山峰,每座山峰有他的高度hih_ihi.有些山峰之间有双向道路相连,共MMM条路径,每条路径有一个困难值,这个值越大表示越难走,现在有QQQ组询问, ...
- silverlight 进行本地串口调用的一种可行的解决方法
silverlight 是一个很不错的开发平台,我们可以设计出很绚丽的界面,用户可以拥有很好的体验,但是就目前来说,进行本地串口的直接调用时不行的,因为安全的原因,有没有相对简单的调用方式呢? 答案是 ...
- php取两个整数的最大公约数算法大全
php计算两个整数的最大公约数常用算法 <?php//计时,返回秒function microtime_float (){ list( $usec , $sec ) = explode ( &q ...
- Oracle根据表的大小排序SQL语句
--按照数据行数排序select table_name,blocks,num_rows from dba_tables where owner not like '%SYS%' and table_n ...
- visual studio 2010 c++ fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或
解决方案: 1,在项目 上 选择 “视图”- “属性页” 2,选择 “配置属性” - “清单工具” - “输入输出”,将 “嵌入清单”的值设置为 “否”
- linux raid10管理维护
http://www.linuxidc.com/Linux/2015-10/124391.htm 制作raid10 http://www.linuxidc.com/Linux/2015-09/1 ...
- Sql Server Report Service 的部署问题
近期在研究SSRS部署问题,因为以前也用到过SSRS报表,但当时开发的报表是有专门的集成系统的,不需要我自己去部署,所以对这一块的部署也不熟悉,我记得当时我是直接开发出一个SSRS 报表,然后会通过自 ...
- Android中measure过程、WRAP_CONTENT详解以及 xml布局文件解析流程浅析
转自:http://www.uml.org.cn/mobiledev/201211221.asp 今天,我着重讲解下如下三个内容: measure过程 WRAP_CONTENT.MATCH_PAREN ...
- 一款easyUI写的界面例子,小记
后台是用strut2的: 前台界面风格easyUI,感觉挺好用的: <!DOCTYPE html> <html> <head> <meta charset=& ...