leetcode[Student Attendance Record I]//待整理多种解法
来源:互联网 发布:centos 6.2 编辑:程序博客网 时间:2024/04/29 12:13
解法一:
public class Solution {//A student could be rewarded if his attendance record doesn't contain more than one 'A' (absent)//or more than two [continuous] 'L' (late). 对L的要求是[连续]超过2次 public boolean checkRecord(String s) { int countA = 0; int countL = 0;//这个代表最大的countL int curCountL = 0;//这个代表当前连续的curCountL for(int i = 0; i < s.length(); i++){ if(s.charAt(i) == 'A'){ countA++; } if(s.charAt(i) == 'L'){ curCountL++; countL = Math.max(countL, curCountL); } else{ curCountL = 0; } //System.out.println("countA:" + countA + " countL:" + countL + " curCountL:" + curCountL); } if(countA > 1 || countL > 2){ return false; } else{ return true; } }}
阅读全文
1 0
- leetcode[Student Attendance Record I]//待整理多种解法
- Student Attendance Record I问题及解法
- LeetCode 551. Student Attendance Record I
- 【LeetCode】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
- 【CodeForces】622D
- git同步上传的几个命令
- pipeline, dataflow, workflow 简述
- 字符串问题---去掉字符串中连续出现k个0的子串
- effect java 学习摘要(8)
- leetcode[Student Attendance Record I]//待整理多种解法
- 一文读懂机器学习
- Spring Boot 定时任务之@Schedule
- 开发中遇到的几个问题小记
- 手把手教你搭建PHP版Elasticsearch开发环境
- 进程调度--CFS
- AngularCLI基本使用
- HDU
- android环境搭建之Android studio环境搭建