System Testing
81 / 81
AC
81/81 test cases passed
Submission #28
| Problem | AppleWord |
|---|---|
| Handle | Nur Ahmad Khatim |
| Submitted | 2026-07-28 02:47:54 |
Source Code
#include <string>
using namespace std;
class AppleWord {
public:
int minRep(string word) {
int n = word.length();
if (n < 5) {
return -1;
}
int count = 0;
count += word[0] == 'a' || word[0] == 'A' ? 0 : 1;
count += word[n - 1] == 'e' || word[n - 1] == 'E' ? 0 : 1;
count += word[n - 2] == 'l' || word[n - 2] == 'L' ? 0 : 1;
for (int i = 1; i < n - 2; i++) {
count += word[i] == 'p' || word[i] == 'P' ? 0 : 1;
}
return count;
}
};