- 4
Code coach Security
Test case 1. 14 Chars input length, should be 3G's in input at position 3,4,10. I counted,and checker it only find 2G's.
2 Respuestas
+ 3
Check out 👇
#include <iostream>
#include <vector>
using namespace std;
int main() {
string lo;
vector<char> c;
cin >> lo;
//push char we care about into a vector
for(int i=0;i<lo.length();i++) {
if(lo[i]=='G' || lo[i]=='#x27; || lo[i]=='T') {
c.push_back(lo[i]);
}
}
for(int i=0;i<c.size();i++) {
//if the theif is somewhere in the middle of the vector he must be surrounded by guards
if(c[i]=='T' && i>0 && i<c.size()-1) {
if(c[i+1]=='G' && c[i-1]=='G') {
cout << "quiet";
return 0;
}
}
//if the theif is at the start of the vector the next char must be a guard
else if(c[i]=='T' && i==0) {
if(c[i+1]=='G') {
cout << "quiet";
return 0;
}
}
//if the theif is at the end there must be a guard before him
else if(c[i]=='T' && i==c.size()-1) {
if(c[i-1]=='G') {
cout << "
+ 1
Hey there Oliver Pasaribu,
Can you please add your code/attempt so that the community can help you more easily? Thanks :)
https://www.sololearn.com/Discuss/333866/?ref=app