Leetcode 551. 學生出勤記錄 I
給定一個字串來代表一個學生的出勤記錄,這個記錄僅包含以下三個字元:
- 'A' : Absent,缺勤
- 'L' : Late,遲到
- 'P' : Present,到場
如果一個學生的出勤記錄中不超過一個'A'(缺勤)並且不超過兩個連續的'L'(遲到),那麼這個學生會被獎賞。
你需要根據這個學生的出勤記錄判斷他是否會被獎賞。
示例 1:
輸入: "PPALLP" 輸出: True
示例 2:
輸入: "PPALLL" 輸出: False
這裡又是經典的字串處理,使用Python特別簡潔
class Solution: def checkRecord(self, s): """ :type s: str :rtype: bool """ return s.count("A")<=1 and "LLL" not in s
相關推薦
Leetcode 551. 學生出勤記錄 I
給定一個字串來代表一個學生的出勤記錄,這個記錄僅包含以下三個字元: 'A' : Absent,缺勤 'L' : Late,遲到 'P' : Present,到場 如果一個學生的出勤記錄中不超過一個'A'(缺勤)並且不超過兩個連續的'L'(遲
551.學生出勤記錄 I(簡單)
給定一個字串來代表一個學生的出勤記錄,這個記錄僅包含以下三個字元: 'A' : Absent,缺勤 'L' : Late,遲到 'P' : Present,到場 如果一個學生的出勤記錄中不超過一個'A'(缺勤)並且不超過兩個連續的'L'(遲
551. 學生出勤記錄 I
給定一個字串來代表一個學生的出勤記錄,這個記錄僅包含以下三個字元: 'A' : Absent,缺勤 'L' : Late,遲到 'P' : Present,到場 如果一個學生的出勤記錄中不超過一個'A'(缺勤)並且不超過兩個連續的'L'(遲
C#LeetCode刷題之#551-學生出勤紀錄 I(Student Attendance Record I)
問題 給定一個字串來代表一個學生的出勤紀錄,這個紀錄僅包含以下三個字元: 'A' : Absent,缺勤 'L' : Late,遲到 'P' : Present,到場 如果一個學生的出勤紀錄中不超過一個'A'(缺勤)並且不超過兩個連續的'L'(遲到),那麼這個學生會被獎賞。 你需要根
【LeetCode】551. 學生出勤紀錄 I
題目連結:https://leetcode-cn.com/problems/student-attendance-record-i/description/ 題目描述 給定一個字串來代表一個學生的出勤紀錄,這個紀錄僅包含以下三個字元: ‘A’ : Absent,缺勤
C#LeetCode刷題之#551-學生出勤紀錄 I(Student Attendance Record I)
問題 給定一個字串來代表一個學生的出勤紀錄,這個紀錄僅包含以下三個字元: 'A' : Absent,缺勤 'L' : Late,遲到 'P' : Present,到場 如果一個學生的出勤紀錄中不超過一個'A'(缺勤)並且不超過兩個連續的'L'(遲到),那麼這個學生會被獎賞
LeetCode Student Attendance Record I 學生出勤記錄I
You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A'&n
[LeetCode] Student Attendance Record I 學生出勤記錄之一
You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L'
Leetcode551.Student Attendance Record I學生出勤記錄1
給定一個字串來代表一個學生的出勤紀錄,這個紀錄僅包含以下三個字元: 'A' : Absent,缺勤 'L' : Late,遲到 'P' : Present,到場 如果一個學生的出勤紀錄中不超過一個'A'(缺勤)並且不超過兩個連續的'L'
[LeetCode] Student Attendance Record II 學生出勤記錄之二
Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be v
552. 學生出勤記錄 II
給定一個正整數 n,返回長度為 n 的所有可被視為可獎勵的出勤記錄的數量。 答案可能非常大,你只需返回結果mod 109 + 7的值。 學生出勤記錄是隻包含以下三個字元的字串: 'A' : Absent,缺勤 'L' : Late,遲到
leetCode551. 學生出勤紀錄 I
給定一個字串來代表一個學生的出勤紀錄,這個紀錄僅包含以下三個字元:'A' : Absent,缺勤'L' : Late,遲到'P' : Present,到場如果一個學生的出勤紀錄中不超過一個'A'(缺勤)並且不超過兩個連續的'L'(遲到),那麼這個學生會被獎賞。你需要根據這個學生的出勤紀錄判斷他是否會被獎賞。示
#Leetcode# 551. Student Attendance Record I
tps https eth character highlight more problems ret lan https://leetcode.com/problems/student-attendance-record-i/ You are given a st
LeetCode:學生的出勤記錄|【551】
就是 har 問題 cor 解法 包含 表示 light mat LeetCode:學生的出勤記錄|【551】 題目描述 給定一個字符串來代表一個學生的出勤紀錄,這個紀錄僅包含以下三個字符: ‘A‘ : Absent,缺勤 ‘L‘ : Late,遲到 ‘P‘ : Pres
leetcode-496-Next Greater Element I
rip 原本 理解 這份 where exp plan array iss 題目描述: You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are sub
[LeetCode][Python]刷題記錄 1. 兩數之和
ron 題記 細節 重復 給定 假設 利用 tar 分享圖片 第一次做發現很多小細節以前都沒註意過,感覺還是蠻頭疼的。 題目: 給定一個整數數組和一個目標值,找出數組中和為目標值的兩個數。 你可以假設每個輸入只對應一種答案,且同樣的元素不能被重復利用。 根據題目要求
LeetCode-824 劃水記錄3
示例 小寫 int tex 轉換 大小寫 proc != alt 給定一個由空格分割單詞的句子 S。每個單詞只包含大寫或小寫字母。 我們要將句子轉換為 “Goat Latin”(一種類似於 豬拉丁文 - Pig Latin 的虛構語言)。 山羊拉丁文的規則如下: 如果單詞以
LeetCode-62 劃水記錄 04
%d default 一個 增長 clu case unique 不用 變量 題目一看;感覺可以用回溯法 就是從(0.0)開始 走到下一步 再走下一步 走到盡頭了 向右邊走 到盡頭了回去上一個格子 再從上一個格子換一個方向 走 因為只能走2個方向 如果一個格子2個方向都走
Leetcode __908. 最小差值 I
問題描述 給定一個整數陣列 A,對於每個整數 A[i],我們可以選擇任意 x 滿足 -K <= x <= K,並將 x 加到 A[i] 中。 在此過程之後,我們得到一些陣列 B。 返回 B 的最大值和 B 的最小值之間可能存在的最小差值。 示例 1: 輸入:A = [
學生消費記錄管理系統(C語言 結構體, 連結串列)
自己在寒假練手的小專案 本系統要實現的功能: 1. 消費記錄存在檔案fee.txt中, 每一條記錄包括一個消費的交易日期、入賬日期、交易額、交易後餘額 2. (1)使用者能夠查詢自己