Expedia Group Interview Question

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

Interview Answer

Anonymous

Jan 4, 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.