【LeetCode】Student Attendance Record I 解题报告
来源:互联网 发布:怎么查看服务端口 编辑:程序博客网 时间:2024/05/16 11:21
【LeetCode】Student Attendance Record I 解题报告
标签(空格分隔): LeetCode
题目地址:https://leetcode.com/problems/student-attendance-record-i/#/description
题目描述:
You are given a string representing an attendance record for a student. The record only contains the following three characters:
‘A’ : Absent.
‘L’ : Late.
‘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: TrueExample 2:Input: "PPALLL"Output: False
Ways
一直错的原因是没看清题,题目说的是不超过一个A或者两个**连续的**L,直接求解有点麻烦,可以用正则表达式。
.*匹配的是任意字符重复0次或者任意次,一行代码搞定。
public class Solution { public boolean checkRecord(String s) { return !s.matches(".*A.*A.*") && !s.matches(".*LLL.*"); }}
Date
2017 年 4 月 21 日
0 0
- 【LeetCode】Student Attendance Record I 解题报告
- [Leetcode] 551. Student Attendance Record I 解题报告
- [Leetcode] 552. Student Attendance Record II 解题报告
- LeetCode 551. Student Attendance Record I
- [LeetCode]551. Student Attendance Record I
- leetcode 551 Student Attendance Record I C++
- LeetCode 551. Student Attendance Record I
- [leetcode]: 551. Student Attendance Record I
- [leetcode: Python]551. Student Attendance Record I
- [leetcode]551. Student Attendance Record I
- Leetcode 551 Student Attendance Record I
- LeetCode-551. Student Attendance Record I (Java)
- leetcode#551. Student Attendance Record I
- leetcode 551. Student Attendance Record I
- leetcode 551. Student Attendance Record I
- LeetCode-551. Student Attendance Record I
- LeetCode 551 Student Attendance Record I
- [LeetCode] 551. Student Attendance Record I
- Visual Studio 2010 使用
- 编译安装PHP,解决问题 Don't know how to define struct flock on this system, set --enable-opcache=no
- 对大数(BigInteger)进行开方运算
- C#之Switch分支语句
- 20153724——2
- 【LeetCode】Student Attendance Record I 解题报告
- 2016东莞市特长生考试 字串距离
- python中的类属性和实例属性
- [51Nod 1048] 整数分解为2的幂 V2
- 神奇的ActivityLifecycleCallbacks,解决Activity管理的后顾之忧
- ListView多条目加载
- c++实验4项目6
- Spark性能优化指南——高级篇
- MySQL的统计函数