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,到场 如果一个学生的出勤纪录中不超过一个' ...
随机推荐
- hdu2085-2086
hdu2085 模拟 #include<stdio.h> ][]; void fun(){ a[][]=; a[][]=; ;i<=;i++){ a[i][]=*a[i-][]+*a ...
- MySQL Transaction--事务隔离级别基础
MYSQL 支持的事务隔离级别 REPEATABLE READ READ COMMITTED READ UNCOMMITTED SERIALIZABLE InnoDB 默认使用REPEATABLE R ...
- 用vbs打开文件
set ws=createobject("wscript.shell")ws.run"打开文件所使用的程序+空格+程序路径",x,ture Run方法有三个参数 ...
- socket、WebSocket
WebSocket 协议本质上是一个基于TCP的协议,它由通信协议和编程API组成,WebSocket能够在浏览器和服务器之间建立双向连接,以基于事件的方式,赋予浏览器实时通信能力. socket本质 ...
- POJ1639顶点度限制最小生成树
题目:http://poj.org/problem?id=1639 见汪汀的<最小生成树问题的拓展>. 大体是先忽略与根节点相连的边,做一遍kruscal,得到几个连通块和一个根节点: 然 ...
- jmeter --自动化badboy脚本开发技术
jmeter --自动化badboy脚本开发技术 一般人用badboy都是使用它的录制功能,其它badboy还是一款自动化的工具,它可以实现检查点.参数化.迭代.并发.报告.断点等功能.本文就这些功能 ...
- golang中如何判断文件是否有可执行权限
本文介绍在Go语言如何检查文件的权限.以检查文件可执行权限为例. 在文件系统中,文件的属性使用uint32表示. 例如 -rwxrwxrwx 判断可执行权限,也就是检查文件mode是否有: --x-- ...
- Asp.Net中使用Newtonsoft.Json转换,读取,写入
using Newtonsoft.Json;using Newtonsoft.Json.Converters; //把Json字符串反序列化为对象目标对象 = JsonConvert.Deserial ...
- Spring的IOC原理 通俗解释
1. IoC理论的背景我们都知道,在采用面向对象方法设计的软件系统中,它的底层实现都是由N个对象组成的,所有的对象通过彼此的合作,最终实现系统的业务逻辑. 图1:软件系统中耦合的对象 如果我们打开机械 ...
- 发送邮件(单独文字)的方法(网易邮箱 OR QQ邮箱)
# coding:utf-8import smtplibfrom email.mime.text import MIMEText # 发邮件相关的参数# 网易邮箱用这个# smtpserver=&qu ...