【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 ...
随机推荐
- es相关
1.es在数据量很大的情况下(数十亿级别)如何提高查询性能啊? 2.es生产集群的部署架构是什么?每个索引的数据量大概有多少?每个索引大概有多少个分片? 3.es的分布式架构原理能说一下么(es是如何 ...
- postgresql backup
#!/bin/sh # Database backup script # Backup use postgres pg_dump command: # pg_dump -U <user> ...
- easyui-filebox上传文件或图片时选择相同文件无法触发change事件的问题
其实很简单,当选择完一个文件之后,会将文件名存放在input中的value值中,当下一次onChange之后,比对玩发现,value值没有发生变化,所以不能触发. 所以,只需要下次将value值清空就 ...
- 表达式* ptr ++和++ * ptr是否相同?
两种表达都不同.让我们看一个示例代码来理解两个表达式之间的区别. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include <stdio.h> int m ...
- python MySQL安装依赖报错的坑
0X01 问题 MySQL-python是python调用MySQL的常用库 通常安装时会遇到某些坑. EnvironmentError: mysql_config not found yum -y ...
- Charles破解注册
Charles破解注册English 本页面会持续更新Charles最新版破解注册方法,建议加入收藏 Charles 4.1.2 下载Charles v4.1.2 并安装 云盘下载: Windows ...
- 参数类型 (@Test层)常用参数
long lNum = 1234L; float fNum = 1.23f; double dNum = 1.23d;
- 快速幂 x
快速幂! 模板如下: #include<iostream> #include<cmath> #include<cstdio> #define LL long lon ...
- CMake学习- 使用批处理设置编译环境
批处理-.bat cd /d "%~dp0" mkdir build mkdir install cd build ..\cmake37\bin\cmake.exe -D WIN3 ...
- CF1153E Serval and Snake【构造】
题目链接:洛谷 这道题是很久以前NTF跟我说的,现在想起来把它做了... 我们发现,如果蛇的两头都在矩形里或矩形外,则询问为偶数,否则为奇数. 所以我们询问每一行和每一列,就能知道蛇的两头的横纵坐标了 ...