国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

[LeetCode] Student Attendance Record I

RancherLabs / 1154人閱讀

Problem

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: True

Example 2:

Input: "PPALLL"
Output: False

Solution
class Solution {
    public boolean checkRecord(String s) {
        if (s == null || s.length() == 0) return true;
        Map map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (!map.containsKey(ch)) map.put(ch, 1);
            else map.put(ch, map.get(ch)+1);
            if (ch == "A" && map.get(ch) > 1) return false;
            if (i+3 <= s.length() && s.substring(i, i+3).equals("LLL")) {
                return false; 
            }
        }
        return true;
    }
}

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/77140.html

相關文章

  • JavaEE環境配置與示例教程

    摘要:環境配置運行環境安裝配置數據庫下載安裝下載地址牢記安裝過程中設置的用戶的密碼安裝選擇版本的安裝配置數據庫驅動教程前提開發環境參考環境配置文檔基礎知識基本語法協議基礎知識只需了解請求即可基礎的等。 **寒假的時候老師讓寫個簡單的JavaEE教程給學弟or學妹看,于是寫了下面的內容。發表到這個地方以防丟失。。。因為寫的時候用的是word,直接復制過來格式有點亂。。。所以不要在意細節了。。...

    AbnerMing 評論0 收藏0
  • [LeetCode] 763. Partition Labels

    Problem A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers represe...

    iliyaku 評論0 收藏0
  • 【硬核】用C語言來寫學生成績管理系統,讓你的課設不再是難題

    摘要:嗨這里是狐貍大家的期末課設要來了吧,有想法做什么了嘛,有沒有為此熬夜,有沒有為此努力呢,今天,我們來寫一個學生成績管理系統,一方面是讓大家復習一下自己學過的知識,一方面是為了給大家的期末課設提供一點思路。 目錄 序 嗨!這里是狐貍~~ 一、需求分析說明 二、概要設計說明 三、詳細設計說明 1...

    seanHai 評論0 收藏0
  • [LeetCode] Intersection of Two Arrays I & II

    Intersection of Two Arrays I Problem Given two arrays, write a function to compute their intersection. Example Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note Each element in the result m...

    lucas 評論0 收藏0
  • LeetCode——Longest Substring Without Repeating Char

    摘要:原問題我的沙雕解法無重復字母存在重復字母挨打最暴力的無腦解法,耗時。。。 原問題 Given a string, find the length of the?longest substring?without repeating characters. Example 1: Input: abcabcbb Output: 3 Explanation: The answer is a...

    forsigner 評論0 收藏0

發表評論

0條評論

RancherLabs

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<