Skip to main content

A- Yes or Yes (Problem 1703A) Codeforces Round 120 (Div. 4) (C++ Code and Explanation)

  A - Yes or Yes? (Problem 1703A) - Codeforces Round 806 (Div.4)


Problem-
 https://codeforces.com/contest/1703/problem/A

Approach-

Since we have to check just three letters, so we can just match them individually. Check whether the first letter is 'Y' or 'y' similarly to 'E' and 'e' and also for 'S' and 's'. It is already given that the length of the string is 3 so we do not have to worry about any further cases.
Below is the detailed code in C++ exactly matching the explanation above.

Code-

string s; cin>>s; if((s[0]=='y'||s[0]=='Y')&&(s[1]=='e'||s[1]=='E')&&(s[2]=='s'||s[2]=='S')) cout<<"YES"<<endl; else cout<<"NO"<<endl;

Disclaimer- Everything is published after the actual contest gets over.

Comments