Microsoft Interview Question

Write a function that performs run-length encoding on a string.