๐Ÿ“˜ Day 20 โ€“ Teacher's Day Challenge | Translation

TanishiTanishi
2 min read

๐Ÿ—“๏ธ Date: September 04, 2025
๐Ÿงฉ Platform: Codeforces
๐Ÿ”ข Problems Solved Today: 1
๐ŸŽฏ Focus Topic: Strings, Reversal Check


๐Ÿ”— Table of Contents


๐Ÿงฉ Problem 1 โ€“ Translation

๐Ÿ“š Difficulty: Easy
๐Ÿง  Concepts: Strings, Reverse, Comparison


๐Ÿ“„ Problem Statement (Summary):
You are given two words:

  • s โ€“ a Berlandish word

  • t โ€“ 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" if t is exactly the reverse of s.

  • 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 with s.

  • 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

MetricValue
Problems Solved1
Topics CoveredStrings, Reverse
Tools UsedC++
Next FocusMore String Problems
Day20 / 43

๐Ÿท๏ธ Tags:
#codeforces #strings #reverse #cpp #dsa #43DaysChallenge

0
Subscribe to my newsletter

Read articles from Tanishi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tanishi
Tanishi