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?