Official

B - Precondition Editorial by en_translator


For each integer \(i\) with \(2 \leq i \leq |S|\), check if \(S_i\) is an uppercase English letter. If it is, check if \(S_{i - 1}\) is contained in \(T\).

To check the existence in \(T\), one may use a loop, but many languages provide functions that allow us to determine it without explicitly writing a loop.

Sample code

#include <bits/stdc++.h> using namespace std; int main() {	string s, t;	cin >> s >> t;	bool res = true;	int n = ssize(s);	for (int i = 1; i < n; i++) {	if (isupper(s[i])) {	if (t.find(s[i - 1]) == string::npos) res = false;	}	}	cout << (res ? "Yes" : "No") << '\n'; } 

posted:
last update: