HYLAND ONLINE ASSESSMENT QUESTION

Revision en2, by wronganswer.5, 2023-04-08 09:30:10

You are given a string s. You are allowed to do following operation any number of times: choose two characters in s say c1 and c2, replace all the occurences of c1 with c2 and all the occurences of c2 with c1. You want to make it lexographically smallest.

eg: s="bbcacad" ans: "aabbccd"

step1: choose a and b, we get -> aacbcbd step2: choose b and, we get -> aabcbcd

eg2: s="bdea" ans: "abde"

How to solve this question?

Tags online assessment, string

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English wronganswer.5 2023-04-08 09:30:10 1
en1 English wronganswer.5 2023-04-08 08:50:09 471 Initial revision (published)