AttendanceShort
SRM 352 · 2007-06-02 · by Ishan
Problem Statement
The ith student's name is given as the ith element of names and his attendance record as the ith element of attendance. The attendance record corresponding to each student is specified as a string of 'A's, 'P's and 'M's. An 'A' indicates the students was absent for a class, whereas a 'P' means he was present and a 'M' means he was absent but he submitted a doctor's note for that class. If a student was absent for a class but submitted a doctor's note then that class is not counted when calculating his attendance percentage. Return a
Constraints
- names will contain between 0 and 50 elements, inclusive.
- attendance will contain the same number of elements as names.
- Each element of names will contain between 1 and 50 characters, inclusive.
- Each element of attendance will contain between 1 and 50 characters, inclusive.
- Each element of names will contain only letters ('A' - 'Z' and 'a' - 'z').
- Each element of attendance will contain only 'A', 'P' and 'M' characters.
- Each element of attendance will contain at least one 'A' or 'P' character.
{"Justin"}
{"PAAPP"}
Returns: {"Justin" }
Justin has attended 3 of his 5 classes which gives him 3/5 * 100 = 60% attendance. Since this is lower than 75% his name should be returned.
{"Justin","Chris"}
{"PAAPP","PPPPA"}
Returns: {"Justin" }
Chris has attended 4 out of his 5 classes and thus has 80% attendance. Justin has 60% so only Justin's name should be returned.
{"Sunny"}
{"PPPAM"}
Returns: { }
Sunny's attendance is effectively calculated from "PPPA" as classes which have a doctor's note are ignored. This results in a 75% attendance and so his name is not included in the returned list.
{"Mansi", "Arjun", "Nikhil", "Taneja"}
{"PPPPMPPAPP", "AAMAAPP", "PPPPAAP", "PPPAAAMPP"}
Returns: {"Arjun", "Nikhil", "Taneja" }
{}
{}
Returns: { }
Take care of the empty case.
Submissions are judged against all 86 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class AttendanceShort with a public method vector<string> shortList(vector<string> names, vector<string> attendance) · 86 test cases · 2 s / 256 MB per case