Learn DSADSAContests
coding75 logo
LeetCode POTDPOTDSheets
coding75 Pro
coding75 logo
Dashboard
Learn DSA
Course RoadmapFlow
DSA Topic TreeNew πŸš€
Contest SolutionsPractice
Practice Sheets
MasterclassesLive πŸ‘¨πŸ»β€πŸ’»

coding75 ProPRO

Live Classes & Placement Guidance

coding75 logo

The premier developer platform for mastering Data Structures & Algorithms, exploring contest editorials, building ATS-ready resumes, and accelerating your tech career.

Connect & Community

DSA & Contests

  • Learn DSA
  • Contest Solutions
  • LeetCode POTDDaily
  • Practice Sheets
  • MasterclassesSoon

Interview Prep

  • Portfolio Projects
  • CS Fundamentals
  • System DesignSoon
  • Interview ExperiencesSoon
  • Mock InterviewsSoon

Career & Pro

  • Jobs & Internships
  • Resume BuilderATS
  • coding75 Pro
  • Submit Feedback
Β© 2026coding75β€’crackDSAβ„’β€’Maa Lalita Edtech Private Limited. All Rights Reserved.
Privacy PolicyTerms & ConditionsContact Support
Registered Office: Kanpur 208021β€’Regional Office: Indiranagar, Bangalore, 560008
Maa Lalita Edtech Private Limited
Contests/Codeforces/Codeforces Round 946/B. Symmetric Encoding
PrevNext
CodeforcesCodeforces
Pupil
Codeforces Round 946

B. Symmetric Encoding

SortingGreedyStringHashing
Loading...
Solve on Codeforces

Problem Statement

Official algorithmic problem description and constraints.

Open on Codeforces

Polycarp has a string π‘ , which consists of lowercase Latin letters. He encodes this string using the following algorithm:

  • first, he constructs a new auxiliary string π‘Ÿ, which consists of all distinct letters of the string π‘ , written in alphabetical order;
  • then the encoding happens as follows: each character in the string π‘  is replaced by its symmetric character from the string π‘Ÿ (the first character of the string π‘Ÿ will be replaced by the last, the second by the second from the end, and so on).

For example, encoding the string s="codeforces" happens as follows:

  • the string π‘Ÿ is obtained as "cdefors";
  • the first character π‘ 1='c' is replaced by 's';
  • the second character π‘ 2='o' is replaced by 'e';
  • the third character π‘ 3='d' is replaced by 'r';
  • ...the last character π‘ 10='s' is replaced by 'c'.

The string π‘Ÿ and replacements for π‘ ="codeforces".


Thus, the result of encoding the string π‘ ="codeforces" is the string "serofedsoc".

Write a program that performs decoding β€” that is, restores the original string π‘  from the encoding result.

Solutions & Walkthrough

Detailed video explanations, mathematical intuition, and clean C++ implementation code.

Connecting secure classroom stream...
Back to Codeforces Round 946
Previous ProblemNext Problem