0

How can I count frequencies of characters in string!!!!??

I am reading from an input file and want to read all letters and symbols. I am looking to create something bigger from this like encode it eventually - but I cannot seem to move from this block of trying to read in characters and use its frequency in a vector which I would sport in a heap. For context, how can I get something like this: "I am soo stuck." --> i:1 a:1 m:1 s:2 o:2 t: 1 u:1 c: 1 k:1 :3 (represents spacing) -- and how can i order them from least to greatest frequencies? please help!

19th Nov 2022, 2:34 PM
Serety
Serety - avatar
6 Respostas
+ 3
Could you please tag the relevant programming language?
19th Nov 2022, 2:54 PM
Lisa
Lisa - avatar
+ 2
Lisa Did you notice something strange in the forum? I see another post exactly like this one, just below it in the post list, it has a blank profile picture and empty user name. But if I enter the post and refresh it by sliding down, the user name becomes this OP's name, and the profile picture also changes accordingly.
19th Nov 2022, 4:31 PM
Ipang
+ 2
Guessing that this must be in C++ from the mention of map, heap, and vector in the tags. Serety this article might address for you how to sort the frequencies in a map: https://www.geeksforgeeks.org/sorting-a-map-by-value-in-c-stl/
19th Nov 2022, 4:43 PM
Brian
Brian - avatar
+ 2
Ipang Yes, this issue that you describe was observed several times over last few days. 🤔 We passed it along to sololearn; they will investigate it.
19th Nov 2022, 4:54 PM
Lisa
Lisa - avatar
+ 1
Ipang Yes that is some weird issue we are already talking about that. We also tested this by posting questions even it is also happening with our own old questions just check your profile.
19th Nov 2022, 7:09 PM
A͢J
A͢J - avatar
0
Thanks Lisa
19th Nov 2022, 4:55 PM
Ipang