๐ Day 20 โ Teacher's Day Challenge | Translation


๐๏ธ Date: September 04, 2025
๐งฉ Platform: Codeforces
๐ข Problems Solved Today: 1
๐ฏ Focus Topic: Strings, Reversal Check
๐ Table of Contents
Daily Summary
๐งฉ Problem 1 โ Translation
๐ Difficulty: Easy
๐ง Concepts: Strings, Reverse, Comparison
๐ Problem Statement (Summary):
You are given two words:
s
โ a Berlandish wordt
โ Vasya's translation into Birlandish
The languages differ such that a valid translation means word t
should be the reverse of s
.
Your task is to check if Vasya translated correctly.
๐ข Input Format:
First line: string
s
(Berlandish word)Second line: string
t
(Vasya's translation)
๐งพ Output Format:
Print
"YES"
ift
is exactly the reverse ofs
.Otherwise, print
"NO"
.
๐ Example 1:
Input:
code
edoc
Output:
YES
๐ Example 2:
Input:
abb
aba
Output:
NO
๐ Example 3:
Input:
code
code
Output:
NO
๐ก Approach:
Reverse string
t
.Compare reversed
t
withs
.If they are equal โ print
"YES"
.Otherwise โ print
"NO"
.
๐งช Code (C++):
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
string s, s1, s2 = "";
cin >> s;
cin >> s1;
for (int i = 0; i < s1.length(); i++)
{
s2 = s1[i] + s2; // building reverse
}
if (s2 == s)
{
cout << "YES";
}
else
{
cout << "NO";
}
return 0;
}
๐ธ Submission Screenshot:
โ Key Takeaways:
Simple string reversal problems can be solved using
reverse()
or by manually reversing.Always check equality after reversal for correctness.
Good practice for string manipulation basics.
๐ Daily Summary
Metric | Value |
Problems Solved | 1 |
Topics Covered | Strings, Reverse |
Tools Used | C++ |
Next Focus | More String Problems |
Day | 20 / 43 |
๐ท๏ธ Tags:#codeforces #strings #reverse #cpp #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
