๐ Day 15 โ Teacher's Day Challenge | Boy or Girl


๐๏ธ Date: August 08, 2025
๐งฉ Platform: Codeforces
๐ข Problems Solved Today: 1
๐ฏ Focus Topic: String Manipulation, Sets
๐ Table of Contents
Daily Summary
๐งฉ Problem 1 โ Boy or Girl
๐ Difficulty: Easy-Medium
๐ง Concepts: String Manipulation, Unique Characters
๐ Problem Statement (Summary):
Given a username string consisting of lowercase English letters, determine the "gender" based on the count of distinct characters:
If the count is odd โ Male โ print
"IGNORE HIM!"
If the count is even โ Female โ print
"CHAT WITH HER!"
๐ข Input Format:
A single string containing only lowercase English letters (length โค 100).
๐งพ Output Format:
One of the following strings:
"CHAT WITH HER!"
(female)"IGNORE HIM!"
(male)
๐ Example 1:
Input:wjmzbmr
Output:CHAT WITH HER!
๐ Example 2:
Input:xiaodao
Output:IGNORE HIM!
๐ Example 3:
Input:sevenkplus
Output:CHAT WITH HER!
๐ก Approach:
Sort the string to group identical letters.
Remove duplicates to find the count of distinct characters.
Check if count is odd or even.
Output result accordingly.
๐งช Code (C++):
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string str;
cin >> str;
int i = 0, j;
sort(str.begin(), str.end());
for (j = 1; j < str.length(); j++)
{
if (str[i] == str[j])
{
str.erase(j, 1);
j--;
i--;
}
i++;
}
if (str.length() & 1)
cout << "IGNORE HIM!";
else
cout << "CHAT WITH HER!";
return 0;
}
๐ธ Submission Screenshot:
โ Key Takeaways:
Sorting helps in grouping duplicates for easy removal.
Distinct character counting is a common string problem.
Simple logic with
% 2
can determine parity-based decisions.
๐ Daily Summary
Metric | Value |
Problems Solved | 1 |
Topics Covered | String Manipulation, Unique Characters |
Tools Used | C++ |
Next Focus | Continue String & Set-based Problems |
Day | 15 / 43 |
๐ท๏ธ Tags:#codeforces #strings #cpp #beginner #dsa #43DaysChallenge
Subscribe to my newsletter
Read articles from Tanishi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
