【leetcode_easy】551. Student Attendance Record I
problem
551. Student Attendance Record I
题意:
solution:
class Solution {
public:
bool checkRecord(string s) {
int cntA = ;
int cntL = ;
for(auto ch:s)
{
if('A'==ch)
{
if(++cntA > ) return false;//
cntL = ;//
}
else if('L' == ch)
{
if(++cntL > ) return false;//
}
else cntL = ;//
}
return true;
}
};
理解题意很简单,重要的是其中的逻辑怎么实现。还有一点需要注意自加自减运算,感觉还是有点不熟练。。
参考
1. Leetcode_easy_551. Student Attendance Record I;
2. Grandyang;
完
【leetcode_easy】551. Student Attendance Record I的更多相关文章
- 【LeetCode】551. Student Attendance Record I 解题报告(Java & Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 正则表达式 统计 日期 题目地址:https://l ...
- 【leetcode】552. Student Attendance Record II
题目如下: Given a positive integer n, return the number of all possible attendance records with length n ...
- 551. Student Attendance Record I【easy】
551. Student Attendance Record I[easy] You are given a string representing an attendance record for ...
- 551. Student Attendance Record I 从字符串判断学生考勤
[抄题]: You are given a string representing an attendance record for a student. The record only contai ...
- 551. Student Attendance Record I + Student Attendance Record II
▶ 一个学生的考勤状况是一个字符串,其中各字符的含义是:A 缺勤,L 迟到,P 正常.如果一个学生考勤状况中 A 不超过一个,且没有连续两个 L(L 可以有多个,但是不能连续),则称该学生达标(原文表 ...
- [LeetCode&Python] Problem 551. Student Attendance Record I
You are given a string representing an attendance record for a student. The record only contains the ...
- LeetCode 551. Student Attendance Record I (C++)
题目: You are given a string representing an attendance record for a student. The record only contains ...
- LeetCode 551. Student Attendance Record I (学生出勤纪录 I)
You are given a string representing an attendance record for a student. The record only contains the ...
- 551. Student Attendance Record I
static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...
随机推荐
- Service Broker 消息队列的方式实现数据同步
SQL Server 2008中SQL应用系列--目录索引 导读:本文主要涉及Service Broker的基本概念及建立一个Service Broker应用程序的基本步骤. 一.前言: Servic ...
- Java常用数学类和BigDecimal
笔记: Math类 * java.lang.Math提供了一系列静态方法用于科学计算:其方法的参数和返回值类型一般为double型. * abs 绝对值 * acos,asin,atan,cos,si ...
- Java : 对象不再使用时,为什么要赋值为 null ?
今天遇到一个比较有意思的问题,对象不再使用时,为什么要赋值为 null ? 在这里我看到一篇文章说的不错,下面是网址,有兴趣的IT友可以看看. https://mp.weixin.qq.com/s/Z ...
- WCF Windows基础通信
概述 WCF,Windows Communication Foundation ,Windows通信基础, 面向服务的架构,Service Orientation Architechture=SOP ...
- Python+request 将获取的url和接口响应时间(timeout)写入到Excel中《八》
使用场景: 在工作中,常见某个功能的查询,当查询关联表特别多时,开发写的SQL语句等等问题导致响应时间较慢,那么作为测试需要将每个接口的响应时间进行测试,对同个接口多次执行,并将测试结果写入到exce ...
- mybatis-oracle 新增序列
1.参考 https://blog.csdn.net/qq_29001173/article/details/82106853 2.思考: 2.1获取序列下一个值:seq_car.nextval 2. ...
- 大二小学期C#资产管理大作业小记
说明 这个程序是我大二夏季学期(俗称小学期)用Visual Studio + C#写的<资产管理>大作业.这个项目非常简单,就是用C#写出一个UI界面,并连接数据库进行增删改查.这是我第一 ...
- request.querystring和request.form的区别
1,request.querystring和request.form的区别 request.querystring是用来接收地址里面问号“?”后面的参数的内容, 用get方法读取的 不安全 requ ...
- springBoot maven项目打成jar包
springBoot项目打包springBoot项目打包最常用且最简单的方式是用springBoot的打包plugin <plugin> <groupId>org.spring ...
- Codeforces Educational Codeforces Round 54 题解
题目链接:https://codeforc.es/contest/1076 A. Minimizing the String 题意:给出一个字符串,最多删掉一个字母,输出操作后字典序最小的字符串. 题 ...