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的更多相关文章

  1. 【LeetCode】551. Student Attendance Record I 解题报告(Java & Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 正则表达式 统计 日期 题目地址:https://l ...

  2. 【leetcode】552. Student Attendance Record II

    题目如下: Given a positive integer n, return the number of all possible attendance records with length n ...

  3. 551. Student Attendance Record I【easy】

    551. Student Attendance Record I[easy] You are given a string representing an attendance record for ...

  4. 551. Student Attendance Record I 从字符串判断学生考勤

    [抄题]: You are given a string representing an attendance record for a student. The record only contai ...

  5. 551. Student Attendance Record I + Student Attendance Record II

    ▶ 一个学生的考勤状况是一个字符串,其中各字符的含义是:A 缺勤,L 迟到,P 正常.如果一个学生考勤状况中 A 不超过一个,且没有连续两个 L(L 可以有多个,但是不能连续),则称该学生达标(原文表 ...

  6. [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 ...

  7. LeetCode 551. Student Attendance Record I (C++)

    题目: You are given a string representing an attendance record for a student. The record only contains ...

  8. LeetCode 551. Student Attendance Record I (学生出勤纪录 I)

    You are given a string representing an attendance record for a student. The record only contains the ...

  9. 551. Student Attendance Record I

    static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...

随机推荐

  1. 【反向多源点同时BFS一个强连通图+类最短路题面】Fair-986C-Codeforce

    借鉴博客:https://www.cnblogs.com/zhangjiuding/p/9112273.html 986-A. Fair /* 986-A-Fair,codeforce: 大致题意: ...

  2. ACM-ICPC 2018 沈阳赛区现场赛 E. The Kouga Ninja Scrolls (切比雪夫距离+线段树)

    题目链接: 题意:在二维平面上有 n 个人,每个人有一个位置(xi, yi)和门派 ci,m 个操作:①改变第 k 个人的位置:②改变第 k 个人的门派:③询问区间[l,r]之间不同门派的两个人的最大 ...

  3. Windows服务操作

    资料 https://docs.microsoft.com/zh-cn/dotnet/api/system.serviceprocess.servicecontroller?redirectedfro ...

  4. 浏览器顶部设置margin-top时存在的bug

    浏览器bug<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8 ...

  5. paramiko的使用

    import paramiko import sys user = "root" pwd = " # 上传文件 def sftp_upload_file(server_p ...

  6. 纯 css 控制隔行变色

    使用::nth-child 选择器 tr:nth-child(odd) { background-color: #ccc; } tr:nth-child(even) { background-colo ...

  7. tree/pstree

    tree yum install tree 不指定路径的话直接显示当前目录的结构 加上-L 表示只显示到指定的目录层级 tree -L 2 ./

  8. 牛客小白月赛11 Rinne Loves Edges

    题库链接:https://ac.nowcoder.com/acm/contest/370/F code: #include<bits/stdc++.h> using namespace s ...

  9. Codeforces.520B.Two Buttons(正难则反)

    题目链接 \(Description\) 给定两个数\(n,m\),每次可以使\(n\)减一或使\(n\)乘2.求最少需要多少次可以使\(n\)等于\(m\). \(Solution\) 暴力连边BF ...

  10. Bzoj 1588: [HNOI2002]营业额统计(splay)

    1588: [HNOI2002]营业额统计 Time Limit: 5 Sec Memory Limit: 162 MB Description 营业额统计 Tiger最近被公司升任为营业部经理,他上 ...