Determine if a string of symbols contains at least 3 consecutive digits. Example #1. s=“a12b34c”, answer=no. Example #2. s=“a1234cb”, answer=yes.
>Solution :
#include
using namespace std
int main() {
std::string str ;
std::cin >> str;
int count = 0;
for (int i = 0; i < str.length(); i++) {
if (isdigit(str[i])) {
count++;
if (count == 3) {
std::cout << "YES";
return 0;
}
} else {
count = 0;
}
}
std::cout << "NO";
return 0;
}