Computer Science, asked by dattaraj96, 7 months ago

Frequent Letters
Description
Given a string, you have to find the first n most frequent characters in it.
You have to print these n letters in alphabetically sorted order.
The input will contain two lines, the first line will contain a string and the second line will contain the letter n.
The output
should be a list of n most frequent letters in alphabetically
sorted order.
Note: If there are two letters with the same frequency, then the alphabetically preceding alphabet should
be picked first. (For example, in "aabbccc", if n=2, then output list would have cand a.)
Sample Input:
ddddaacccb
3
Sample Output:
['a', 'c','d']​

Answers

Answered by tehaminadeem
0

Answer:

itdtsdourgdiyrtdodu4dtix6rsryxitdtsutey

rstd9yt8psi6rd7ts6e8zr7oi6rzsrorus39aoursrsyopgidrsiygdursyifugd

Explanation:

geykhdgeyeyieyjeryuyru64i4yirgjdghcbdefheeryetytukz bherjytykdgdb

egh

egh

egh

eghgrjyyjeh

tw

jey

jye

h

hf

vd

ne

h

myns

b

fan

ye

yn

yen

ht

wfhttjw

eyke

wy

jye

j

eeyj

wth

tehh

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

90

1

2

4

4

4

55

6

6

7

7

8

8

8

9

0

d

d

d

d

d

d

d

d

d

d

d

Similar questions