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. 【java规则引擎】《Drools7.0.0.Final规则引擎教程》第4章 4.4 LHS简介&Pattern

    LHS简介 在规则文件组成章节,我们已经了解了LHS的基本使用说明.LHS是规则条件部分的统称,由0个或多个条件元素组成.前面我们已经提到,如果没有条件元素那么默认就是true. 没有条件元素,官方示 ...

  2. 如何查看Eclipse的数字版的版本(转)

    为什么叫数字版的版本,因为Eclipse软件里显示的是文字版的版本,比如我现在的就是Version: Indigo Release.这在下载插件的时候很不方便. 如何查看文字版的版本信息:打开Ecli ...

  3. sql server merge into 与update 批量更新1 百万测试数据的性能比较

    1. 1百万的测试数据的生成 declare @index int;  begin  set @index=0;  while @index<1000000  begin  insert int ...

  4. event store

    Event Store The documentation has now moved to the wiki in this repository. For a quick start, look  ...

  5. nyoj 魔法少女

    魔法少女 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 前些时间虚渊玄的巨献小圆着实火了一把. 在黑长直(小炎)往上爬楼去对抗魔女之夜时,她遇到了一个问题想请你帮忙. 因为 ...

  6. C语言面试题3

    编程题 1.读文件file1.txt的内容(例如): 123456 输出到file2.txt: 563412 #include <stdio.h> #include <stdlib. ...

  7. es6知识点

    扩展运算符(三个点): 将值转换为参数序列. 解构赋值:比如:var [a,b,c]=[1,2,3];

  8. django 获取前端获取render模板渲染后的html

    function GetProxyServerByGroup(ths, action){ var _html = $.ajax({ url: "/nginx/get_proxy_server ...

  9. spark内存模型

    在spark里面,内存管理有两块组成,一部分是JVM的堆内内存(on-heap memory),这部分内存是通过spark dirver参数executor-memory以及spark.executo ...

  10. 查看 linux cpu 、内存、服务器型号和序列号、磁盘、raid 的信息

    yum -y install dmidecode 查看cpu的型号: 查看cpu的颗数:dmidecode -t processor |grep "Version"dmidecod ...