Math, asked by tbhargavasrinivas, 2 days ago

DESCRIPTION © SUBMISSIONS Swap Most Frequent Letter with Least Given a sentence, swap the occurrences of the most frequent letter with the least frequent letter and vice-versa. Note: 5 • Consider upper and lower case letters as different. 6 • If there are multiple letters with the same frequency, choose the lower case letter that comes earliest in dictionary order. 7 o If letters like X X and and B have same frequency consider 8 х 9 10 o If letters like X and b have same frequency consider b. 11 Input The first line of input is a string. Output The output should be a single line containing the sentence by swapping the most frequent letter with the least frequent letter and vice-versa

Answers

Answered by dreamrob
0

For the above question problem the code is given below:

s = input()

ss = set()

d = dict()

mx = s.count(s[0])

mn = s.count(s[0])

mnc = s[0]

mxc = s[0]

for i in s:

ss.add(i)

for i in ss:

f = {i: s.count(i)}

mx = max(mx, s.count(i))

mn = min(mn, s.count(i))

d.update(f)

for i in d:

if d[i] == mn:

mnc = i

break

for i in d:

if d[i] == mx:

mxc = i

break

  • After successfully write this code and when you finally get that code and going to compile and run it. You get the value of the following questions.

Hence, it's the perfect code that execute the following problem.

#SPJ3

Similar questions