GFRIEND - EDITORIAL

Contest

Setter: debrc

Tester: dustu_947 , mishra_roshan

Editorialist: debrc

Cakewalk

PREREQUISITES:

Basic observations.

PROBLEM:

Given a Username S ending with F for Female and M for Male, you have to determine whether that string belongs to Male Username or Female Username. Print ‘Yes’ if its a Female Username or else ‘No’.

EXPLANATION

You only have to check the last character of a Username. If it’s F print ‘Yes’ as it’s a Female User.
If it’s M print ‘No’ as it’s a Male User.

TIME COMPLEXITY

Time complexity is O(1) to check the last character of a string.

SOLUTIONS:

Setter's Solution
C++
``````#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--){
string s;
cin>>s;
if(s[s.size()-1]=='F')
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}
return 0;
}
``````
Python
``````for _ in range(int(input())):
s = input()
if s[len(s) - 1] == 'F':
print('Yes')
else:
print('No')
``````
Tester's Solution
``````#include <iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

int main() {
int T;
std::cin >> T;
while(T--)
{
int l;
char Uname[1000000];
scanf("%s",Uname);
l=strlen(Uname);
if(Uname[l-1]=='F')
std::cout << "Yes" << std::endl;
else
std::cout << "No" << std::endl;
}
return 0;
}

``````

Feel free to Share your approach.
Suggestions are welcomed as always had been