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. MySQl 进阶一 基本查询及练习

    知识点及练习 USE myemployees; #.查询表中的单个字段 SELECT last_name FROM employees; #.查询表中多个字段 #.查询全部 SELECT * FROM ...

  2. CSRF(cross-site request forgery )跨站请求攻击

    CSRF(cross-site request forgery )跨站请求伪造,攻击者盗用了你的身份,以你的名义发送恶意请求,对服务器来说这个请求是完全合法的,但是却完成了攻击者所期望的一个操作,通过 ...

  3. jmeter接口测试-使用aes加密算法

    好久没写文章了,一直在忙公司项目的事情!今天抽空写篇关于jmeter加密的教程吧! 随着互联网的发展,越来越多的系统开始提供接口调用! 我们进行接口测试的时候,大多数接口或多或少的都使用了各种加密验证 ...

  4. VS 运行库MT、MD的区别

    https://www.jianshu.com/p/f43afc1d5946 VC项目属性→配置属性→C/C++→代码生成→运行时库 可以采用的方式有:多线程(/MT).多线程调试(/MTd).多线程 ...

  5. SQL分表

    一.为什么要水平分表?简而言之,当单表数据量过大时,无法对其进行有效的维护,以及查询速度严重变慢时,我们就需要对其时行水平分表. 二.什么时候需要水平分表?在数据库结构的设计中,需要充分考虑后期数据的 ...

  6. jQuery.map(arr|obj,callback)

    jQuery.map(arr|obj,callback) 概述 将一个数组中的元素转换到另一个数组中.广州大理石机械构件 作为参数的转换函数会为每个数组元素调用,而且会给这个转换函数传递一个表示被转换 ...

  7. RX232串口发送

    在进行工程调试的时候有时候需要对变量进行观察,SingnaTap II Logic Analyzer 只能对管脚进行观察,所以要观察内部的变量必须把内部的变量进行输出.一种方法是直接把变量定义成管脚通 ...

  8. mac 安装oh-my-zsh的问题

    安装完,如果想切换回mac原来的bash终端,可以: chsh -s /bin/bash 反之,切换回zsh: chsh -s /bin/zsh

  9. linux下设置git代理访问.

    有时候克隆仓库巨慢无比,需要设置代理. 一般情况下 proxychains 可以搞定的. 但是某些情况,如go 安装模块的时候是调用git的.这个时候proxchains就不行了. go 也可以通过设 ...

  10. CSocket创建套接字返回10093

    创建套接字之前未初始化. 即需要添加AfxSocketInit()