Write the program in MIPS that reads a string representing an attendance record
ID: 3590301 • Letter: W
Question
Write the program in MIPS that reads 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' : Presen A student could be rewarded if his attendance record doesn't contain more than one 'A (absent) or more than two consecutive 'L' (late) You need to return (print) whether the student could be rewarded according to his attendance record Example Input: "PPALLP" Output: True Example 2: Input: "PPALLL" Output: FalseExplanation / Answer
Kindly convert this code in MIPS
class Solution {
public:
bool checkRecord(string s) {
multiset<char> ss;
int continuousL = 0;
for(int i = 0; i < s.length(); i++){
if(continuousL == 2){
if(s[i] == 'L'){
return false;
}
}
if(s[i] == 'L'){
continuousL++;
}else{
continuousL = 0;
}
ss.insert(s[i]);
}
return ss.count('A') <= 1;
}
};
class Solution {
public:
bool checkRecord(string s) {
multiset<char> ss;
int continuousL = 0;
for(int i = 0; i < s.length(); i++){
if(continuousL == 2){
if(s[i] == 'L'){
return false;
}
}
if(s[i] == 'L'){
continuousL++;
}else{
continuousL = 0;
}
ss.insert(s[i]);
}
return ss.count('A') <= 1;
}
};
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.