Expedia Group interview question

You are given a string variable that holds "aabbcc". Given the string, how do we output a2b2c2?

Interview Answer

Anonymous

4 Jan 2016

In Java use Map in .NET use Dictionary, get the count of chars in string using char as a key and number of occurrences as a value, then for each KVP call ToString() on each key and value and concat them together into a new string.