I am on an interview ride here. One more interview question I had difficulties with.
“A rose is a rose is a rose” Write an algorithm that prints the number of times a character/word occurs. E.g. A – 3 Rose – 3 Is – 2
Also ensure that when you are printing the results, they are in order of what was present in the original sentence. All this in order n.
I did get solution to count number of occurrences of each word in sentence in the order as present in the original sentence. I used Dictionary<string,int>
to do it. However I did not understand what is meant by order of n. That is something I need an explanation from you guys.