博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LeetCode - 551. Student Attendance Record I
阅读量:7222 次
发布时间:2019-06-29

本文共 981 字,大约阅读时间需要 3 分钟。

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

 

  1. 'A' : Absent.
  2. 'L' : Late.
  3. 'P' : Present.

 

A student could be rewarded if his attendance record doesn't contain more than one 'A' (absent) or more than two continuous 'L' (late).

You need to return whether the student could be rewarded according to his attendance record.

Example 1:

Input: "PPALLP"Output: True

 

Example 2:

Input: "PPALLL"Output: False
class Solution {    public boolean checkRecord(String s) {        if (s == null)            return true;        int a = 0, l = 1;        for (int i=0; i
1) return false; if (ch == 'L') { while (i < s.length()-1 && s.charAt(++i) == 'L') l ++; if (l > 2) return false; l = 1; if (i < s.length()-1) i--; } i ++; } return true; }}

 

转载于:https://www.cnblogs.com/wxisme/p/7691198.html

你可能感兴趣的文章
大谷无人机将追求“才貌双全”
查看>>
量子世界的十个事实
查看>>
U-Boot启动过程完全分析
查看>>
Web性能优化工具WebPageTest(二)——性能数据
查看>>
Lucene 6.0中BooleanQuery
查看>>
数据库反规范设计
查看>>
Oracle数据库在线备份原理
查看>>
云栖科技评论第28期:高通宣布芯片内置亚马逊Alexa
查看>>
扫描二维码自动识别手机APP下载地址
查看>>
分享Ubuntu下一些很棒的软件(一)
查看>>
bootstrap-内联文本元素-改变大小写
查看>>
阿里云MaxCompute香港开服 将引入更多人工智能服务
查看>>
你的指纹还安全吗? - BlackHat 2015 黑帽大会总结 day 2
查看>>
2、SRX笔记及基础配置
查看>>
RH134 UNIT7
查看>>
硬纪元AI峰会实录|图森未来陈默:人工智能技术的商业化起点在B端
查看>>
centos下scp命令安装和使用
查看>>
类的继承、类的属性总结、类的方法总结
查看>>
linux ftp
查看>>
Linux LVM添加物理盘学习笔记1
查看>>